Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
commit
3c5afbfcac
@ -55,8 +55,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< nl << "Starting time loop" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -48,8 +48,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nCalculating temperature distribution\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -50,8 +50,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
# include "CourantNo.H"
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -63,7 +63,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info << "\nStarting time loop\n" << endl;
|
||||
|
||||
while(runTime.run())
|
||||
while (runTime.run())
|
||||
{
|
||||
# include "readPISOControls.H"
|
||||
# include "compressibleCourantNo.H"
|
||||
|
@ -51,8 +51,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -49,8 +49,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
#include "readSIMPLEControls.H"
|
||||
|
@ -47,8 +47,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
surfaceScalarField phiv
|
||||
|
@ -53,8 +53,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.value() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -52,8 +52,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
autoPtr<Foam::motionSolver> motionPtr = motionSolver::New(mesh);
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
#include "readPISOControls.H"
|
||||
|
@ -49,8 +49,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
#include "readPISOControls.H"
|
||||
|
@ -50,8 +50,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -47,8 +47,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting iteration loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Iteration = " << runTime.timeName() << nl << endl;
|
||||
|
||||
solve
|
||||
|
@ -71,8 +71,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< nl << "Starting time loop" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
# include "readPISOControls.H"
|
||||
# include "readBPISOControls.H"
|
||||
|
||||
|
@ -55,8 +55,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Starting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
delta == fvc::grad(V)().component(Foam::vector::X);
|
||||
|
||||
solve
|
||||
|
@ -1,3 +0,0 @@
|
||||
buoyantBoussinesqFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/buoyantBoussinesqFoam
|
@ -0,0 +1,3 @@
|
||||
buoyantBoussinesqPisoFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/buoyantBoussinesqPisoFoam
|
@ -23,10 +23,10 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
buoyantBoussinesqSimpleFoam
|
||||
buoyantBoussinesqPisoFoam
|
||||
|
||||
Description
|
||||
Steady-state solver for buoyant, turbulent flow of incompressible fluids
|
||||
Transient solver for buoyant, turbulent flow of incompressible fluids
|
||||
|
||||
Uses the Boussinesq approximation:
|
||||
\f[
|
||||
@ -69,8 +69,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readTimeControls.H"
|
@ -66,8 +66,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -1,3 +0,0 @@
|
||||
buoyantFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/buoyantFoam
|
@ -0,0 +1,3 @@
|
||||
buoyantPisoFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/buoyantPisoFoam
|
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
buoyantFoam
|
||||
buoyantPisoFoam
|
||||
|
||||
Description
|
||||
Transient Solver for buoyant, turbulent flow of compressible fluids for
|
@ -51,8 +51,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -54,8 +54,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
||||
# include "setInitialDeltaT.H"
|
||||
}
|
||||
|
||||
while(runTime.run())
|
||||
while (runTime.run())
|
||||
{
|
||||
# include "readTimeControls.H"
|
||||
|
||||
|
@ -58,8 +58,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
fvVectorMatrix divR = turbulence->divDevReff(U);
|
||||
|
@ -51,8 +51,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for(runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
#include "readPISOControls.H"
|
||||
|
@ -48,8 +48,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -49,8 +49,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -52,8 +52,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Global
|
||||
CourantNo
|
||||
|
||||
Description
|
||||
Calculates and outputs the maximum Courant Number.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
scalar CoNum = 0.0;
|
||||
scalar meanCoNum = 0.0;
|
||||
scalar waveCoNum = 0.0;
|
||||
|
||||
if (mesh.nInternalFaces())
|
||||
{
|
||||
surfaceScalarField SfUfbyDelta =
|
||||
mesh.surfaceInterpolation::deltaCoeffs()
|
||||
*mag(phi)/fvc::interpolate(h);
|
||||
|
||||
CoNum = max(SfUfbyDelta/mesh.magSf())
|
||||
.value()*runTime.deltaT().value();
|
||||
|
||||
meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf()))
|
||||
.value()*runTime.deltaT().value();
|
||||
|
||||
// Gravity wave Courant number
|
||||
waveCoNum =
|
||||
0.5*max
|
||||
(
|
||||
mesh.surfaceInterpolation::deltaCoeffs()
|
||||
*sqrt(fvc::interpolate(h))
|
||||
).value()*sqrt(magg).value()*runTime.deltaT().value();
|
||||
}
|
||||
|
||||
Info<< "Courant number mean: " << meanCoNum
|
||||
<< " max: " << CoNum << endl;
|
||||
|
||||
Info<< "Gravity wave Courant number max: " << waveCoNum
|
||||
<< endl;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,3 @@
|
||||
shallowWaterFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/shallowWaterFoam
|
@ -0,0 +1,74 @@
|
||||
Info<< "Reading field h\n" << endl;
|
||||
volScalarField h
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"h",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "Reading field h0 if present\n" << endl;
|
||||
volScalarField h0
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"h0",
|
||||
runTime.findInstance("polyMesh", "points"),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("h0", dimLength, 0.0)
|
||||
);
|
||||
|
||||
Info<< "Reading field U\n" << endl;
|
||||
volVectorField U
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "Creating field hU\n" << endl;
|
||||
volVectorField hU
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"hU",
|
||||
runTime.timeName(),
|
||||
mesh
|
||||
),
|
||||
h*U,
|
||||
U.boundaryField().types()
|
||||
);
|
||||
|
||||
Info<< "Creating field hTotal for post processing\n" << endl;
|
||||
volScalarField hTotal
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"hTotal",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
h+h0
|
||||
);
|
||||
hTotal.write();
|
||||
|
||||
# include "createPhi.H"
|
||||
|
||||
Info<< "Creating Coriolis Force" << endl;
|
||||
const dimensionedVector F("F", ((2.0*Omega) & gHat)*gHat);
|
@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Global
|
||||
createPhi
|
||||
|
||||
Description
|
||||
Creates and initialises the face-flux field phi.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef createPhi_H
|
||||
#define createPhi_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "Reading/calculating face flux field phi\n" << endl;
|
||||
|
||||
surfaceScalarField phi
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"phi",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
linearInterpolate(hU) & mesh.Sf()
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,21 @@
|
||||
Info<< "\nReading environmentalProperties" << endl;
|
||||
|
||||
IOdictionary environmentalProperties
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"environmentalProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
const dimensionedVector g(environmentalProperties.lookup("g"));
|
||||
const Switch rotating(environmentalProperties.lookup("rotating"));
|
||||
const dimensionedVector Omega =
|
||||
rotating ? environmentalProperties.lookup("Omega")
|
||||
: dimensionedVector("Omega", -dimTime, vector(0,0,0));
|
||||
const dimensionedScalar magg = mag(g);
|
||||
const dimensionedVector gHat = g/magg;
|
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
shallowWaterFoam
|
||||
|
||||
Description
|
||||
Transient solver for inviscid shallow-water equations with rotation.
|
||||
If the geometry is 3D then it is assumed to be one layers of cells and the
|
||||
component of the velocity normal to gravity is removed.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "readEnvironmentalProperties.H"
|
||||
#include "createFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (runTime.loop())
|
||||
{
|
||||
Info<< "\n Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
#include "readPISOControls.H"
|
||||
#include "CourantNo.H"
|
||||
|
||||
for (int ucorr=0; ucorr<nOuterCorr; ucorr++)
|
||||
{
|
||||
surfaceScalarField phiv("phiv", phi/fvc::interpolate(h));
|
||||
|
||||
fvVectorMatrix hUEqn
|
||||
(
|
||||
fvm::ddt(hU)
|
||||
+ fvm::div(phiv, hU)
|
||||
);
|
||||
|
||||
hUEqn.relax();
|
||||
|
||||
if (momentumPredictor)
|
||||
{
|
||||
if (rotating)
|
||||
{
|
||||
solve(hUEqn + (F ^ hU) == -magg*h*fvc::grad(h + h0));
|
||||
}
|
||||
else
|
||||
{
|
||||
solve(hUEqn == -magg*h*fvc::grad(h + h0));
|
||||
}
|
||||
|
||||
// Constrain the momentum to be in the geometry if 3D geometry
|
||||
if (mesh.nGeometricD() == 3)
|
||||
{
|
||||
hU -= (gHat & hU)*gHat;
|
||||
hU.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
|
||||
// --- PISO loop
|
||||
for (int corr=0; corr<nCorr; corr++)
|
||||
{
|
||||
surfaceScalarField hf = fvc::interpolate(h);
|
||||
volScalarField rUA = 1.0/hUEqn.A();
|
||||
surfaceScalarField ghrUAf = magg*fvc::interpolate(h*rUA);
|
||||
|
||||
surfaceScalarField phih0 = ghrUAf*mesh.magSf()*fvc::snGrad(h0);
|
||||
|
||||
if (rotating)
|
||||
{
|
||||
hU = rUA*(hUEqn.H() - (F ^ hU));
|
||||
}
|
||||
else
|
||||
{
|
||||
hU = rUA*hUEqn.H();
|
||||
}
|
||||
|
||||
phi = (fvc::interpolate(hU) & mesh.Sf())
|
||||
+ fvc::ddtPhiCorr(rUA, h, hU, phi)
|
||||
- phih0;
|
||||
|
||||
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
|
||||
{
|
||||
fvScalarMatrix hEqn
|
||||
(
|
||||
fvm::ddt(h)
|
||||
+ fvc::div(phi)
|
||||
- fvm::laplacian(ghrUAf, h)
|
||||
);
|
||||
|
||||
if (ucorr < nOuterCorr-1 || corr < nCorr-1)
|
||||
{
|
||||
hEqn.solve();
|
||||
}
|
||||
else
|
||||
{
|
||||
hEqn.solve(mesh.solver(h.name() + "Final"));
|
||||
}
|
||||
|
||||
if (nonOrth == nNonOrthCorr)
|
||||
{
|
||||
phi += hEqn.flux();
|
||||
}
|
||||
}
|
||||
|
||||
hU -= rUA*h*magg*fvc::grad(h + h0);
|
||||
|
||||
// Constrain the momentum to be in the geometry if 3D geometry
|
||||
if (mesh.nGeometricD() == 3)
|
||||
{
|
||||
hU -= (gHat & hU)*gHat;
|
||||
}
|
||||
|
||||
hU.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
|
||||
U == hU/h;
|
||||
hTotal == h + h0;
|
||||
|
||||
runTime.write();
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -49,8 +49,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readSIMPLEControls.H"
|
||||
|
@ -53,8 +53,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readBubbleFoamControls.H"
|
||||
|
@ -57,8 +57,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -52,8 +52,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -57,8 +57,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nCalculating displacement field\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Iteration: " << runTime.value() << nl << endl;
|
||||
|
||||
# include "readSolidDisplacementFoamControls.H"
|
||||
|
@ -55,8 +55,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nCalculating displacement field\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Iteration: " << runTime.value() << nl << endl;
|
||||
|
||||
# include "readSteadyStressFoamControls.H"
|
||||
|
@ -53,8 +53,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
|
@ -120,8 +120,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
|
||||
|
@ -46,8 +46,9 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
# include "createDynamicFvMesh.H"
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.update();
|
||||
|
@ -47,8 +47,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.theta() << " CA-deg\n" << endl;
|
||||
|
||||
mesh.move();
|
||||
|
@ -46,8 +46,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
autoPtr<Foam::motionSolver> motionPtr = motionSolver::New(mesh);
|
||||
|
||||
for (runTime++; !runTime.end(); runTime++)
|
||||
while (runTime.run())
|
||||
{
|
||||
runTime++;
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
mesh.movePoints(motionPtr->newPoints());
|
||||
|
@ -74,7 +74,7 @@ namespace Foam
|
||||
}
|
||||
else
|
||||
{
|
||||
functionObjectList fol(runTime, runTime.controlDict());
|
||||
functionObjectList fol(runTime);
|
||||
fol.start();
|
||||
fol.execute();
|
||||
}
|
||||
|
@ -144,11 +144,14 @@ $(regIOobject)/regIOobjectWrite.C
|
||||
|
||||
db/IOobjectList/IOobjectList.C
|
||||
db/objectRegistry/objectRegistry.C
|
||||
db/functionObject/functionObject.C
|
||||
db/functionObjectList/functionObjectList.C
|
||||
db/CallbackRegistry/CallbackRegistryName.C
|
||||
db/dlLibraryTable/dlLibraryTable.C
|
||||
|
||||
db/functionObjects/functionObject/functionObject.C
|
||||
db/functionObjects/functionObjectList/functionObjectList.C
|
||||
db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C
|
||||
|
||||
|
||||
Time = db/Time
|
||||
$(Time)/TimePaths.C
|
||||
$(Time)/TimeState.C
|
||||
|
@ -352,25 +352,27 @@ Foam::Time::Time
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Time::~Time()
|
||||
{}
|
||||
{
|
||||
// destroy function objects first
|
||||
functionObjects_.clear();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::Time::timeName(const scalar t)
|
||||
{
|
||||
std::ostringstream osBuffer;
|
||||
osBuffer.setf(ios_base::fmtflags(format_), ios_base::floatfield);
|
||||
osBuffer.precision(precision_);
|
||||
osBuffer << t;
|
||||
return osBuffer.str();
|
||||
std::ostringstream buf;
|
||||
buf.setf(ios_base::fmtflags(format_), ios_base::floatfield);
|
||||
buf.precision(precision_);
|
||||
buf << t;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::Time::timeName() const
|
||||
{
|
||||
return dimensionedScalar::name();
|
||||
//return timeName(timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
@ -432,7 +434,7 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
|
||||
return times[nearestIndex];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
// This should work too,
|
||||
// if we don't worry about checking "constant" explicitly
|
||||
//
|
||||
@ -490,9 +492,28 @@ bool Foam::Time::run() const
|
||||
{
|
||||
bool running = value() < (endTime_ - 0.5*deltaT_);
|
||||
|
||||
if (!subCycling_ && !running && timeIndex_ != startTimeIndex_)
|
||||
if (!subCycling_)
|
||||
{
|
||||
const_cast<functionObjectList&>(functionObjects_).execute();
|
||||
// only execute when the condition is no longer true
|
||||
// ie, when exiting the control loop
|
||||
if (!running && timeIndex_ != startTimeIndex_)
|
||||
{
|
||||
// Note, end() also calls an indirect start() as required
|
||||
functionObjects_.end();
|
||||
}
|
||||
}
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::Time::loop()
|
||||
{
|
||||
bool running = run();
|
||||
|
||||
if (running)
|
||||
{
|
||||
operator++();
|
||||
}
|
||||
|
||||
return running;
|
||||
@ -501,7 +522,7 @@ bool Foam::Time::run() const
|
||||
|
||||
bool Foam::Time::end() const
|
||||
{
|
||||
return (value() > (endTime_ + 0.5*deltaT_));
|
||||
return value() > (endTime_ + 0.5*deltaT_);
|
||||
}
|
||||
|
||||
|
||||
@ -611,9 +632,7 @@ Foam::Time& Foam::Time::operator+=(const dimensionedScalar& deltaT)
|
||||
Foam::Time& Foam::Time::operator+=(const scalar deltaT)
|
||||
{
|
||||
setDeltaT(deltaT);
|
||||
operator++();
|
||||
|
||||
return *this;
|
||||
return operator++();
|
||||
}
|
||||
|
||||
|
||||
@ -643,22 +662,22 @@ Foam::Time& Foam::Time::operator++()
|
||||
setTime(0.0, timeIndex_);
|
||||
}
|
||||
|
||||
switch(writeControl_)
|
||||
switch (writeControl_)
|
||||
{
|
||||
case wcTimeStep:
|
||||
outputTime_ = !(timeIndex_%label(writeInterval_));
|
||||
outputTime_ = !(timeIndex_ % label(writeInterval_));
|
||||
break;
|
||||
|
||||
case wcRunTime:
|
||||
case wcAdjustableRunTime:
|
||||
{
|
||||
label outputTimeIndex =
|
||||
label outputIndex =
|
||||
label(((value() - startTime_) + 0.5*deltaT_)/writeInterval_);
|
||||
|
||||
if (outputTimeIndex > outputTimeIndex_)
|
||||
if (outputIndex > outputTimeIndex_)
|
||||
{
|
||||
outputTime_ = true;
|
||||
outputTimeIndex_ = outputTimeIndex;
|
||||
outputTimeIndex_ = outputIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -669,13 +688,11 @@ Foam::Time& Foam::Time::operator++()
|
||||
|
||||
case wcCpuTime:
|
||||
{
|
||||
label outputTimeIndex =
|
||||
label(elapsedCpuTime()/writeInterval_);
|
||||
|
||||
if (outputTimeIndex > outputTimeIndex_)
|
||||
label outputIndex = label(elapsedCpuTime()/writeInterval_);
|
||||
if (outputIndex > outputTimeIndex_)
|
||||
{
|
||||
outputTime_ = true;
|
||||
outputTimeIndex_ = outputTimeIndex;
|
||||
outputTimeIndex_ = outputIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -686,11 +703,11 @@ Foam::Time& Foam::Time::operator++()
|
||||
|
||||
case wcClockTime:
|
||||
{
|
||||
label outputTimeIndex = label(elapsedClockTime()/writeInterval_);
|
||||
if (outputTimeIndex > outputTimeIndex_)
|
||||
label outputIndex = label(elapsedClockTime()/writeInterval_);
|
||||
if (outputIndex > outputTimeIndex_)
|
||||
{
|
||||
outputTime_ = true;
|
||||
outputTimeIndex_ = outputTimeIndex;
|
||||
outputTimeIndex_ = outputIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -698,8 +715,9 @@ Foam::Time& Foam::Time::operator++()
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
// see if endTime needs adjustment to stop at the next run()/end() check
|
||||
if (!end())
|
||||
{
|
||||
if (stopAt_ == saNoWriteNow)
|
||||
|
@ -26,7 +26,7 @@ Class
|
||||
Foam::Time
|
||||
|
||||
Description
|
||||
Class to control time during FOAM simulations which is also the
|
||||
Class to control time during OpenFOAM simulations that is also the
|
||||
top-level objectRegistry.
|
||||
|
||||
SourceFiles
|
||||
@ -109,7 +109,7 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
label startTimeIndex_;
|
||||
label startTimeIndex_;
|
||||
scalar startTime_;
|
||||
scalar endTime_;
|
||||
|
||||
@ -121,10 +121,10 @@ protected:
|
||||
|
||||
scalar writeInterval_;
|
||||
|
||||
label purgeWrite_;
|
||||
label purgeWrite_;
|
||||
mutable FIFOStack<word> previousOutputTimes_;
|
||||
|
||||
//- Is the time currently being sub-cycled
|
||||
//- Is the time currently being sub-cycled?
|
||||
bool subCycling_;
|
||||
|
||||
//- Time directory name format
|
||||
@ -157,21 +157,21 @@ private:
|
||||
//- Default graph format
|
||||
word graphFormat_;
|
||||
|
||||
//- Is runtim modification of dictionaries allowed
|
||||
//- Is runtime modification of dictionaries allowed?
|
||||
Switch runTimeModifiable_;
|
||||
|
||||
//- Instantiate a dummy class to cause the reading of dynamic libraries
|
||||
dlLibraryTable::readDlLibrary readLibs_;
|
||||
|
||||
//- Function objects executed at start and on ++, +=
|
||||
functionObjectList functionObjects_;
|
||||
mutable functionObjectList functionObjects_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
TypeName("time");
|
||||
|
||||
//- The default control dictionary name
|
||||
//- The default control dictionary name (normally "controlDict")
|
||||
static word controlDictName;
|
||||
|
||||
|
||||
@ -282,8 +282,8 @@ public:
|
||||
void readModifiedObjects();
|
||||
|
||||
//- Return the location of "dir" containing the file "name".
|
||||
// (Used in reading mesh data)
|
||||
// If name is null search for the directory "dir" only
|
||||
// (eg, used in reading mesh data)
|
||||
// If name is null, search for the directory "dir" only
|
||||
word findInstance
|
||||
(
|
||||
const fileName& dir,
|
||||
@ -291,7 +291,7 @@ public:
|
||||
const IOobject::readOption rOpt = IOobject::MUST_READ
|
||||
) const;
|
||||
|
||||
//- Search tha case for valid time directories
|
||||
//- Search the case for valid time directories
|
||||
instantList times() const;
|
||||
|
||||
//- Search the case for the time directory path
|
||||
@ -307,9 +307,9 @@ public:
|
||||
//- Write using given format, version and compression
|
||||
virtual bool writeObject
|
||||
(
|
||||
IOstream::streamFormat fmt,
|
||||
IOstream::versionNumber ver,
|
||||
IOstream::compressionType cmp
|
||||
IOstream::streamFormat,
|
||||
IOstream::versionNumber,
|
||||
IOstream::compressionType
|
||||
) const;
|
||||
|
||||
//- Write the objects now and continue the run
|
||||
@ -348,10 +348,43 @@ public:
|
||||
|
||||
// Check
|
||||
|
||||
//- Return true if run should continue
|
||||
//- Return true if run should continue,
|
||||
// also invokes the functionObjectList::end() method
|
||||
// when the time goes out of range
|
||||
// @note
|
||||
// For correct behaviour, the following style of time-loop
|
||||
// is recommended:
|
||||
// @code
|
||||
// while (runTime.run())
|
||||
// {
|
||||
// runTime++;
|
||||
// solve;
|
||||
// runTime.write();
|
||||
// }
|
||||
// @endcode
|
||||
virtual bool run() const;
|
||||
|
||||
//- Return true if end of run
|
||||
//- Return true if run should continue and if so increment time
|
||||
// also invokes the functionObjectList::end() method
|
||||
// when the time goes out of range
|
||||
// @note
|
||||
// For correct behaviour, the following style of time-loop
|
||||
// is recommended:
|
||||
// @code
|
||||
// while (runTime.loop())
|
||||
// {
|
||||
// solve;
|
||||
// runTime.write();
|
||||
// }
|
||||
// @endcode
|
||||
virtual bool loop();
|
||||
|
||||
//- Return true if end of run,
|
||||
// does not invoke any functionObject methods
|
||||
// @note
|
||||
// The rounding heuristics near endTime mean that
|
||||
// @code run() @endcode and @code !end() @endcode may
|
||||
// not yield the same result
|
||||
virtual bool end() const;
|
||||
|
||||
|
||||
@ -400,16 +433,18 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Set deltaT to that specified and increment time
|
||||
//- Set deltaT to that specified and increment time via operator++()
|
||||
virtual Time& operator+=(const dimensionedScalar&);
|
||||
|
||||
//- Set deltaT to that specified and increment time
|
||||
//- Set deltaT to that specified and increment time via operator++()
|
||||
virtual Time& operator+=(const scalar);
|
||||
|
||||
//- Prefix increment
|
||||
//- Prefix increment,
|
||||
// also invokes the functionObjectList::start() or
|
||||
// functionObjectList::execute() method, depending on the time-index
|
||||
virtual Time& operator++();
|
||||
|
||||
//- Postfix increment
|
||||
//- Postfix increment, this is identical to the prefix increment
|
||||
virtual Time& operator++(int);
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ void Foam::Time::readDict()
|
||||
|
||||
if (oldWriteInterval != writeInterval_)
|
||||
{
|
||||
switch(writeControl_)
|
||||
switch (writeControl_)
|
||||
{
|
||||
case wcRunTime:
|
||||
case wcAdjustableRunTime:
|
||||
@ -180,11 +180,7 @@ void Foam::Time::readDict()
|
||||
}
|
||||
|
||||
controlDict_.readIfPresent("graphFormat", graphFormat_);
|
||||
|
||||
if (controlDict_.found("runTimeModifiable"))
|
||||
{
|
||||
runTimeModifiable_ = Switch(controlDict_.lookup("runTimeModifiable"));
|
||||
}
|
||||
controlDict_.readIfPresent("runTimeModifiable", runTimeModifiable_);
|
||||
}
|
||||
|
||||
|
||||
@ -268,25 +264,14 @@ bool Foam::Time::writeObject
|
||||
timeDict.add("deltaT", deltaT_);
|
||||
timeDict.add("deltaT0", deltaT0_);
|
||||
|
||||
timeDict.regIOobject::writeObject
|
||||
(
|
||||
fmt,
|
||||
ver,
|
||||
cmp
|
||||
);
|
||||
|
||||
bool writeOK = objectRegistry::writeObject
|
||||
(
|
||||
fmt,
|
||||
ver,
|
||||
cmp
|
||||
);
|
||||
timeDict.regIOobject::writeObject(fmt, ver, cmp);
|
||||
bool writeOK = objectRegistry::writeObject(fmt, ver, cmp);
|
||||
|
||||
if (writeOK && purgeWrite_)
|
||||
{
|
||||
previousOutputTimes_.push(timeName());
|
||||
|
||||
while(previousOutputTimes_.size() > purgeWrite_)
|
||||
while (previousOutputTimes_.size() > purgeWrite_)
|
||||
{
|
||||
rmDir(objectRegistry::path(previousOutputTimes_.pop()));
|
||||
}
|
||||
@ -310,7 +295,7 @@ bool Foam::Time::writeNow()
|
||||
|
||||
bool Foam::Time::writeAndEnd()
|
||||
{
|
||||
stopAt_ = saWriteNow;
|
||||
stopAt_ = saWriteNow;
|
||||
endTime_ = value();
|
||||
|
||||
return writeNow();
|
||||
|
@ -44,7 +44,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class subCycleTimeTime Declaration
|
||||
Class subCycleTime Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class subCycleTime
|
||||
@ -62,7 +62,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from original time and number of sub-cycles
|
||||
subCycleTime(Time& t, const label nSubCycles);
|
||||
subCycleTime(Time&, const label nSubCycles);
|
||||
|
||||
|
||||
// Destructor
|
||||
@ -72,6 +72,7 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return true if the number of sub-cycles has been reached
|
||||
bool end() const;
|
||||
|
||||
//- End the sub-cycling and reset the time-state
|
||||
|
@ -65,6 +65,20 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::on()
|
||||
{
|
||||
enabled_ = true;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::off()
|
||||
{
|
||||
enabled_ = false;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
|
||||
{
|
||||
@ -120,16 +134,19 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::execute()
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::on()
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
|
||||
{
|
||||
enabled_ = true;
|
||||
}
|
||||
if (enabled_)
|
||||
{
|
||||
ptr_->end();
|
||||
|
||||
if (enabled_ && outputControl_.output())
|
||||
{
|
||||
ptr_->write();
|
||||
}
|
||||
}
|
||||
|
||||
template<class OutputFilter>
|
||||
void Foam::OutputFilterFunctionObject<OutputFilter>::off()
|
||||
{
|
||||
enabled_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OutputFilterFunctionObject Declaration
|
||||
Class OutputFilterFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class OutputFilter>
|
||||
@ -69,7 +69,7 @@ class OutputFilterFunctionObject
|
||||
word regionName_;
|
||||
word dictName_;
|
||||
|
||||
//- Switch for the execution of the functionObjects
|
||||
//- Switch for the execution of the functionObject
|
||||
bool enabled_;
|
||||
|
||||
outputFilterOutputControl outputControl_;
|
||||
@ -114,20 +114,25 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- start is called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- execute is called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Switch the function object on
|
||||
virtual void on();
|
||||
|
||||
//- Switch the function object off
|
||||
virtual void off();
|
||||
|
||||
//- Read and set the function object if its data has changed
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- Called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
virtual bool end();
|
||||
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
@ -30,11 +30,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineRunTimeSelectionTable(functionObject, dictionary);
|
||||
int functionObject::debug(::Foam::debug::debugSwitch("functionObject", 0));
|
||||
}
|
||||
defineRunTimeSelectionTable(Foam::functionObject, dictionary);
|
||||
int Foam::functionObject::debug(Foam::debug::debugSwitch("functionObject", 0));
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -71,10 +68,10 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
|
||||
FatalErrorIn
|
||||
(
|
||||
"functionObject::New"
|
||||
"(const word& functionType, const Time&, const dictionary&)"
|
||||
"(const word& name, const Time&, const dictionary&)"
|
||||
) << "Unknown function type "
|
||||
<< functionType << endl << endl
|
||||
<< "Table of functionObjects is empty"
|
||||
<< functionType << nl << nl
|
||||
<< "Table of functionObjects is empty" << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -86,11 +83,11 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
|
||||
FatalErrorIn
|
||||
(
|
||||
"functionObject::New"
|
||||
"(const word& functionType, const Time&, const dictionary&)"
|
||||
"(const word& name, const Time&, const dictionary&)"
|
||||
) << "Unknown function type "
|
||||
<< functionType << endl << endl
|
||||
<< "Valid functions are : " << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< functionType << nl << nl
|
||||
<< "Valid functions are : " << nl
|
||||
<< dictionaryConstructorTablePtr_->toc() << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -106,6 +103,12 @@ Foam::functionObject::~functionObject()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObject::end()
|
||||
{
|
||||
return execute();
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
|
||||
(
|
||||
const word& name,
|
@ -121,7 +121,7 @@ public:
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Select from Time and Istream
|
||||
//- Select from dictionary, based on its "type" entry
|
||||
static autoPtr<functionObject> New
|
||||
(
|
||||
const word& name,
|
||||
@ -137,14 +137,18 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- start is called at the start of the time-loop
|
||||
//- Called at the start of the time-loop
|
||||
virtual bool start() = 0;
|
||||
|
||||
//- execute is called at each ++ or += of the time-loop
|
||||
//- Called at each ++ or += of the time-loop
|
||||
virtual bool execute() = 0;
|
||||
|
||||
//- Read and set the function object if its data has changed
|
||||
virtual bool read(const dictionary& dict) = 0;
|
||||
//- Called when Time::run() determines that the time-loop exits.
|
||||
// By default it simply calls execute().
|
||||
virtual bool end();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&) = 0;
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObject* Foam::functionObjectList::remove(const word& key)
|
||||
Foam::functionObject*
|
||||
Foam::functionObjectList::remove(const word& key, label& oldIndex)
|
||||
{
|
||||
functionObject* ptr = 0;
|
||||
|
||||
@ -38,10 +39,16 @@ Foam::functionObject* Foam::functionObjectList::remove(const word& key)
|
||||
|
||||
if (fnd != indices_.end())
|
||||
{
|
||||
// remove the pointer from the old list
|
||||
ptr = functions_.set(fnd(), 0).ptr();
|
||||
oldIndex = fnd();
|
||||
|
||||
// retrieve the pointer and remove it from the old list
|
||||
ptr = this->set(oldIndex, 0).ptr();
|
||||
indices_.erase(fnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldIndex = -1;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@ -55,7 +62,8 @@ Foam::functionObjectList::functionObjectList
|
||||
const bool execution
|
||||
)
|
||||
:
|
||||
functions_(),
|
||||
PtrList<functionObject>(),
|
||||
digests_(),
|
||||
indices_(),
|
||||
time_(t),
|
||||
parentDict_(t.controlDict()),
|
||||
@ -71,7 +79,8 @@ Foam::functionObjectList::functionObjectList
|
||||
const bool execution
|
||||
)
|
||||
:
|
||||
functions_(),
|
||||
PtrList<functionObject>(),
|
||||
digests_(),
|
||||
indices_(),
|
||||
time_(t),
|
||||
parentDict_(parentDict),
|
||||
@ -88,6 +97,34 @@ Foam::functionObjectList::~functionObjectList()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjectList::clear()
|
||||
{
|
||||
PtrList<functionObject>::clear();
|
||||
digests_.clear();
|
||||
indices_.clear();
|
||||
updated_ = false;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::on()
|
||||
{
|
||||
execution_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::off()
|
||||
{
|
||||
// for safety, also force a read() when execution is turned back on
|
||||
updated_ = execution_ = false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::status() const
|
||||
{
|
||||
return execution_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::start()
|
||||
{
|
||||
return read();
|
||||
@ -105,7 +142,12 @@ bool Foam::functionObjectList::execute()
|
||||
read();
|
||||
}
|
||||
|
||||
forAllIter(PtrList<functionObject>, functions_, iter)
|
||||
forAllIter
|
||||
(
|
||||
PtrList<functionObject>,
|
||||
static_cast<PtrList<functionObject>&>(*this),
|
||||
iter
|
||||
)
|
||||
{
|
||||
ok = iter().execute() && ok;
|
||||
}
|
||||
@ -115,15 +157,29 @@ bool Foam::functionObjectList::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::on()
|
||||
bool Foam::functionObjectList::end()
|
||||
{
|
||||
execution_ = true;
|
||||
}
|
||||
bool ok = true;
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
if (!updated_)
|
||||
{
|
||||
read();
|
||||
}
|
||||
|
||||
void Foam::functionObjectList::off()
|
||||
{
|
||||
execution_ = false;
|
||||
forAllIter
|
||||
(
|
||||
PtrList<functionObject>,
|
||||
static_cast<PtrList<functionObject>&>(*this),
|
||||
iter
|
||||
)
|
||||
{
|
||||
ok = iter().end() && ok;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@ -143,6 +199,7 @@ bool Foam::functionObjectList::read()
|
||||
if (entryPtr)
|
||||
{
|
||||
PtrList<functionObject> newPtrs;
|
||||
List<SHA1Digest> newDigs;
|
||||
HashTable<label> newIndices;
|
||||
|
||||
label nFunc = 0;
|
||||
@ -151,7 +208,9 @@ bool Foam::functionObjectList::read()
|
||||
{
|
||||
// a dictionary of functionObjects
|
||||
const dictionary& functionDicts = entryPtr->dict();
|
||||
|
||||
newPtrs.setSize(functionDicts.size());
|
||||
newDigs.setSize(functionDicts.size());
|
||||
|
||||
forAllConstIter(dictionary, functionDicts, iter)
|
||||
{
|
||||
@ -163,11 +222,17 @@ bool Foam::functionObjectList::read()
|
||||
const word& key = iter().keyword();
|
||||
const dictionary& dict = iter().dict();
|
||||
|
||||
functionObject* objPtr = remove(key);
|
||||
newDigs[nFunc] = dict.digest();
|
||||
|
||||
label oldIndex;
|
||||
functionObject* objPtr = remove(key, oldIndex);
|
||||
if (objPtr)
|
||||
{
|
||||
// existing functionObject
|
||||
ok = objPtr->read(dict) && ok;
|
||||
// an existing functionObject, and dictionary changed
|
||||
if (newDigs[nFunc] != digests_[oldIndex])
|
||||
{
|
||||
ok = objPtr->read(dict) && ok;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -185,7 +250,9 @@ bool Foam::functionObjectList::read()
|
||||
{
|
||||
// a list of functionObjects
|
||||
PtrList<entry> functionDicts(entryPtr->stream());
|
||||
|
||||
newPtrs.setSize(functionDicts.size());
|
||||
newDigs.setSize(functionDicts.size());
|
||||
|
||||
forAllIter(PtrList<entry>, functionDicts, iter)
|
||||
{
|
||||
@ -197,11 +264,17 @@ bool Foam::functionObjectList::read()
|
||||
const word& key = iter().keyword();
|
||||
const dictionary& dict = iter().dict();
|
||||
|
||||
functionObject* objPtr = remove(key);
|
||||
newDigs[nFunc] = dict.digest();
|
||||
|
||||
label oldIndex;
|
||||
functionObject* objPtr = remove(key, oldIndex);
|
||||
if (objPtr)
|
||||
{
|
||||
// existing functionObject
|
||||
ok = objPtr->read(dict) && ok;
|
||||
// an existing functionObject, and dictionary changed
|
||||
if (newDigs[nFunc] != digests_[oldIndex])
|
||||
{
|
||||
ok = objPtr->read(dict) && ok;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -218,15 +291,18 @@ bool Foam::functionObjectList::read()
|
||||
|
||||
// safety:
|
||||
newPtrs.setSize(nFunc);
|
||||
newDigs.setSize(nFunc);
|
||||
|
||||
// update PtrList of functionObjects
|
||||
// also deletes existing, unused functionObjects
|
||||
functions_.transfer(newPtrs);
|
||||
// updating the PtrList of functionObjects also deletes any existing,
|
||||
// but unused functionObjects
|
||||
PtrList<functionObject>::transfer(newPtrs);
|
||||
digests_.transfer(newDigs);
|
||||
indices_.transfer(newIndices);
|
||||
}
|
||||
else
|
||||
{
|
||||
functions_.clear();
|
||||
PtrList<functionObject>::clear();
|
||||
digests_.clear();
|
||||
indices_.clear();
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ Class
|
||||
Foam::functionObjectList
|
||||
|
||||
Description
|
||||
List of function objects with execute() function that is called for each
|
||||
object.
|
||||
List of function objects with start(), execute() and end() functions
|
||||
that is called for each object.
|
||||
|
||||
See Also
|
||||
Foam::functionObject and Foam::OutputFilterFunctionObject
|
||||
@ -40,9 +40,10 @@ SourceFiles
|
||||
#ifndef functionObjectList_H
|
||||
#define functionObjectList_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "HashTable.H"
|
||||
#include "PtrList.H"
|
||||
#include "functionObject.H"
|
||||
#include "SHA1Digest.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,20 +55,20 @@ namespace Foam
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class functionObjectList
|
||||
:
|
||||
private PtrList<functionObject>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- A list of function objects
|
||||
// Avoid 'is-a' relationship for protection
|
||||
PtrList<functionObject> functions_;
|
||||
//- A list of SHA1 digests for the function object dictionaries
|
||||
List<SHA1Digest> digests_;
|
||||
|
||||
//- Quick lookup of the index into the PtrList<functionObject>
|
||||
// Currently only used to manage rereading/deletion
|
||||
HashTable<label> indices_;
|
||||
//- Quick lookup of the index into functions/digests
|
||||
HashTable<label> indices_;
|
||||
|
||||
const Time& time_;
|
||||
|
||||
//- Dictionary containing the "functions" entry
|
||||
//- The parent dictionary containing a "functions" entry
|
||||
// This entry can either be a list or a dictionary of
|
||||
// functionObject specifications.
|
||||
const dictionary& parentDict_;
|
||||
@ -75,15 +76,16 @@ class functionObjectList
|
||||
//- Switch for the execution of the functionObjects
|
||||
bool execution_;
|
||||
|
||||
//- Tracks if read() was called while execution was turned off
|
||||
//- Tracks if read() was called while execution is on
|
||||
bool updated_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Remove and return the function object pointer by name.
|
||||
// Return NULL if it didn't exist.
|
||||
functionObject* remove(const word&);
|
||||
//- Remove and return the function object pointer by name,
|
||||
// and returns the old index via the parameter.
|
||||
// Returns a NULL pointer (and index -1) if it didn't exist.
|
||||
functionObject* remove(const word&, label& oldIndex);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectList(const functionObjectList&);
|
||||
@ -105,8 +107,11 @@ public:
|
||||
);
|
||||
|
||||
|
||||
//- Construct from Time, dictionary with "functions" entry
|
||||
// and the execution setting
|
||||
//- Construct from Time, a dictionary with "functions" entry
|
||||
// and the execution setting.
|
||||
// @param[in] parentDict - the parent dictionary containing
|
||||
// a "functions" entry, which can either be a list or a dictionary
|
||||
// of functionObject specifications.
|
||||
functionObjectList
|
||||
(
|
||||
const Time&,
|
||||
@ -122,11 +127,15 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Start is called at the start of the time-loop
|
||||
virtual bool start();
|
||||
//- Return the number of elements in the List.
|
||||
using PtrList<functionObject>::size;
|
||||
|
||||
//- Return true if the List is empty (ie, size() is zero).
|
||||
using PtrList<functionObject>::empty;
|
||||
|
||||
//- Clear the list of function objects
|
||||
virtual void clear();
|
||||
|
||||
//- Execute is called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Switch the function objects on
|
||||
virtual void on();
|
||||
@ -134,8 +143,22 @@ public:
|
||||
//- Switch the function objects off
|
||||
virtual void off();
|
||||
|
||||
//- Return the execution status (on/off) of the function objects
|
||||
virtual bool status() const;
|
||||
|
||||
|
||||
//- Called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- Called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
virtual bool end();
|
||||
|
||||
//- Read and set the function objects if their data have changed
|
||||
virtual bool read();
|
||||
|
||||
};
|
||||
|
||||
|
@ -47,11 +47,11 @@ const Foam::NamedEnum<Foam::outputFilterOutputControl::outputControls, 2>
|
||||
|
||||
Foam::outputFilterOutputControl::outputFilterOutputControl
|
||||
(
|
||||
const Time& time,
|
||||
const Time& t,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
time_(time),
|
||||
time_(t),
|
||||
outputControl_(ocTimeStep),
|
||||
outputInterval_(0)
|
||||
{
|
||||
@ -93,8 +93,8 @@ bool Foam::outputFilterOutputControl::output() const
|
||||
{
|
||||
return
|
||||
(
|
||||
!(time_.timeIndex() % outputInterval_)
|
||||
|| (outputInterval_ <= 1)
|
||||
(outputInterval_ <= 1)
|
||||
|| !(time_.timeIndex() % outputInterval_)
|
||||
);
|
||||
break;
|
||||
}
|
@ -88,22 +88,18 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary and Time object
|
||||
outputFilterOutputControl
|
||||
(
|
||||
const Time& time,
|
||||
const dictionary& dict
|
||||
);
|
||||
//- Construct from Time object and dictionary
|
||||
outputFilterOutputControl(const Time&, const dictionary&);
|
||||
|
||||
|
||||
// Destructor
|
||||
~outputFilterOutputControl();
|
||||
~outputFilterOutputControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read from dictionary
|
||||
void read(const dictionary& dict);
|
||||
void read(const dictionary&);
|
||||
|
||||
//- Return const access to the Time object
|
||||
const Time& time() const
|
@ -29,10 +29,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(objectRegistry, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::objectRegistry, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -86,9 +83,9 @@ Foam::objectRegistry::~objectRegistry()
|
||||
{
|
||||
if (iter()->ownedByRegistry())
|
||||
{
|
||||
regIOobject* elemPtr = iter();
|
||||
regIOobject* object = iter();
|
||||
erase(iter);
|
||||
delete elemPtr;
|
||||
delete object;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,18 +203,15 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
|
||||
bool Foam::objectRegistry::modified() const
|
||||
{
|
||||
bool anyModified = false;
|
||||
|
||||
for (const_iterator iter = begin(); iter != end(); ++iter)
|
||||
{
|
||||
if (iter()->modified())
|
||||
{
|
||||
anyModified = true;
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return anyModified;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,25 +31,20 @@ Description
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(regIOobject, 0);
|
||||
defineTypeNameAndDebug(Foam::regIOobject, 0);
|
||||
|
||||
int regIOobject::fileModificationSkew
|
||||
int Foam::regIOobject::fileModificationSkew
|
||||
(
|
||||
debug::optimisationSwitch("fileModificationSkew", 30)
|
||||
Foam::debug::optimisationSwitch("fileModificationSkew", 30)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from IOobject
|
||||
regIOobject::regIOobject(const IOobject& io)
|
||||
Foam::regIOobject::regIOobject(const IOobject& io)
|
||||
:
|
||||
IOobject(io),
|
||||
registered_(false),
|
||||
@ -66,7 +61,7 @@ regIOobject::regIOobject(const IOobject& io)
|
||||
|
||||
|
||||
// Construct as copy
|
||||
regIOobject::regIOobject(const regIOobject& rio)
|
||||
Foam::regIOobject::regIOobject(const regIOobject& rio)
|
||||
:
|
||||
IOobject(rio),
|
||||
registered_(false),
|
||||
@ -80,7 +75,7 @@ regIOobject::regIOobject(const regIOobject& rio)
|
||||
|
||||
// Construct as copy, and transfering objectRegistry registration to copy
|
||||
// if registerCopy is true
|
||||
regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
:
|
||||
IOobject(rio),
|
||||
registered_(false),
|
||||
@ -99,7 +94,7 @@ regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
// Delete read stream, checkout from objectRegistry and destroy
|
||||
regIOobject::~regIOobject()
|
||||
Foam::regIOobject::~regIOobject()
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
@ -125,7 +120,7 @@ regIOobject::~regIOobject()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void regIOobject::checkIn()
|
||||
void Foam::regIOobject::checkIn()
|
||||
{
|
||||
if (!registered_)
|
||||
{
|
||||
@ -153,7 +148,7 @@ void regIOobject::checkIn()
|
||||
}
|
||||
|
||||
|
||||
void regIOobject::checkOut()
|
||||
void Foam::regIOobject::checkOut()
|
||||
{
|
||||
if (registered_)
|
||||
{
|
||||
@ -164,7 +159,7 @@ void regIOobject::checkOut()
|
||||
|
||||
|
||||
// Rename object and re-register with objectRegistry under new name
|
||||
void regIOobject::rename(const word& newName)
|
||||
void Foam::regIOobject::rename(const word& newName)
|
||||
{
|
||||
// Check out of objectRegistry
|
||||
checkOut();
|
||||
@ -177,7 +172,7 @@ void regIOobject::rename(const word& newName)
|
||||
|
||||
|
||||
// Assign to IOobject
|
||||
void regIOobject::operator=(const IOobject& io)
|
||||
void Foam::regIOobject::operator=(const IOobject& io)
|
||||
{
|
||||
if (isPtr_)
|
||||
{
|
||||
@ -195,8 +190,4 @@ void regIOobject::operator=(const IOobject& io)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -5,6 +5,6 @@ set -x
|
||||
wmake libo postCalc
|
||||
wmake libso foamCalcFunctions
|
||||
|
||||
(cd functionObjects && ./Allwmake)
|
||||
functionObjects/Allwmake
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
|
@ -26,19 +26,13 @@ License
|
||||
|
||||
#include "fieldAverage.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#include "fieldAverageItem.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(fieldAverage, 0);
|
||||
}
|
||||
defineTypeNameAndDebug(Foam::fieldAverage, 0);
|
||||
|
||||
const Foam::word Foam::fieldAverage::EXT_MEAN = "Mean";
|
||||
const Foam::word Foam::fieldAverage::EXT_PRIME2MEAN = "Prime2Mean";
|
||||
@ -46,100 +40,81 @@ const Foam::word Foam::fieldAverage::EXT_PRIME2MEAN = "Prime2Mean";
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldAverage::checkoutFields(const wordList& fieldNames) const
|
||||
void Foam::fieldAverage::resetFields(wordList& names)
|
||||
{
|
||||
forAll(fieldNames, i)
|
||||
forAll(names, fieldI)
|
||||
{
|
||||
if (fieldNames[i] != word::null)
|
||||
if (names[fieldI].size())
|
||||
{
|
||||
obr_.checkOut(*obr_[fieldNames[i]]);
|
||||
obr_.checkOut(*obr_[names[fieldI]]);
|
||||
}
|
||||
}
|
||||
|
||||
names.clear();
|
||||
names.setSize(faItems_.size());
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::resetLists(const label nItems)
|
||||
void Foam::fieldAverage::initialize()
|
||||
{
|
||||
checkoutFields(meanScalarFields_);
|
||||
meanScalarFields_.clear();
|
||||
meanScalarFields_.setSize(nItems);
|
||||
resetFields(meanScalarFields_);
|
||||
resetFields(meanVectorFields_);
|
||||
resetFields(meanSphericalTensorFields_);
|
||||
resetFields(meanSymmTensorFields_);
|
||||
resetFields(meanTensorFields_);
|
||||
|
||||
checkoutFields(meanVectorFields_);
|
||||
meanVectorFields_.clear();
|
||||
meanVectorFields_.setSize(nItems);
|
||||
|
||||
checkoutFields(meanSphericalTensorFields_);
|
||||
meanSphericalTensorFields_.clear();
|
||||
meanSphericalTensorFields_.setSize(nItems);
|
||||
|
||||
checkoutFields(meanSymmTensorFields_);
|
||||
meanSymmTensorFields_.clear();
|
||||
meanSymmTensorFields_.setSize(nItems);
|
||||
|
||||
checkoutFields(meanTensorFields_);
|
||||
meanTensorFields_.clear();
|
||||
meanTensorFields_.setSize(nItems);
|
||||
|
||||
checkoutFields(prime2MeanScalarFields_);
|
||||
prime2MeanScalarFields_.clear();
|
||||
prime2MeanScalarFields_.setSize(nItems);
|
||||
|
||||
checkoutFields(prime2MeanSymmTensorFields_);
|
||||
prime2MeanSymmTensorFields_.clear();
|
||||
prime2MeanSymmTensorFields_.setSize(nItems);
|
||||
resetFields(prime2MeanScalarFields_);
|
||||
resetFields(prime2MeanSymmTensorFields_);
|
||||
|
||||
totalIter_.clear();
|
||||
totalIter_.setSize(nItems, 1);
|
||||
totalIter_.setSize(faItems_.size(), 1);
|
||||
|
||||
totalTime_.clear();
|
||||
totalTime_.setSize(nItems, obr_.time().deltaT().value());
|
||||
}
|
||||
totalTime_.setSize(faItems_.size(), obr_.time().deltaT().value());
|
||||
|
||||
|
||||
void Foam::fieldAverage::initialise()
|
||||
{
|
||||
// Add mean fields to the field lists
|
||||
forAll(faItems_, i)
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
if (obr_.foundObject<volScalarField>(fieldName))
|
||||
{
|
||||
addMeanField<scalar>(i, meanScalarFields_);
|
||||
addMeanField<scalar>(fieldI, meanScalarFields_);
|
||||
}
|
||||
else if (obr_.foundObject<volVectorField>(fieldName))
|
||||
{
|
||||
addMeanField<vector>(i, meanVectorFields_);
|
||||
addMeanField<vector>(fieldI, meanVectorFields_);
|
||||
}
|
||||
else if (obr_.foundObject<volSphericalTensorField>(fieldName))
|
||||
{
|
||||
addMeanField<sphericalTensor>(i, meanSphericalTensorFields_);
|
||||
addMeanField<sphericalTensor>(fieldI, meanSphericalTensorFields_);
|
||||
}
|
||||
else if (obr_.foundObject<volSymmTensorField>(fieldName))
|
||||
{
|
||||
addMeanField<symmTensor>(i, meanSymmTensorFields_);
|
||||
addMeanField<symmTensor>(fieldI, meanSymmTensorFields_);
|
||||
}
|
||||
else if (obr_.foundObject<volTensorField>(fieldName))
|
||||
{
|
||||
addMeanField<tensor>(i, meanTensorFields_);
|
||||
addMeanField<tensor>(fieldI, meanTensorFields_);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("Foam::fieldAverage::initialise()")
|
||||
<< "Requested field " << faItems_[i].fieldName()
|
||||
FatalErrorIn("Foam::fieldAverage::initialize()")
|
||||
<< "Requested field " << faItems_[fieldI].fieldName()
|
||||
<< " does not exist in the database" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// Add prime-squared mean fields to the field lists
|
||||
forAll(faItems_, i)
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
if (faItems_[i].prime2Mean())
|
||||
if (faItems_[fieldI].prime2Mean())
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
if (!faItems_[i].mean())
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
if (!faItems_[fieldI].mean())
|
||||
{
|
||||
FatalErrorIn("Foam::fieldAverage::initialise()")
|
||||
FatalErrorIn("Foam::fieldAverage::initialize()")
|
||||
<< "To calculate the prime-squared average, the "
|
||||
<< "mean average must also be selected for field "
|
||||
<< fieldName << nl << exit(FatalError);
|
||||
@ -149,7 +124,7 @@ void Foam::fieldAverage::initialise()
|
||||
{
|
||||
addPrime2MeanField<scalar, scalar>
|
||||
(
|
||||
i,
|
||||
fieldI,
|
||||
meanScalarFields_,
|
||||
prime2MeanScalarFields_
|
||||
);
|
||||
@ -158,14 +133,14 @@ void Foam::fieldAverage::initialise()
|
||||
{
|
||||
addPrime2MeanField<vector, symmTensor>
|
||||
(
|
||||
i,
|
||||
fieldI,
|
||||
meanVectorFields_,
|
||||
prime2MeanSymmTensorFields_
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("Foam::fieldAverage::initialise()")
|
||||
FatalErrorIn("Foam::fieldAverage::initialize()")
|
||||
<< "prime2Mean average can only be applied to "
|
||||
<< "volScalarFields and volVectorFields"
|
||||
<< nl << " Field: " << fieldName << nl
|
||||
@ -176,102 +151,26 @@ void Foam::fieldAverage::initialise()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldAverage::fieldAverage
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
cleanRestart_(dict.lookupOrDefault<Switch>("cleanRestart", false)),
|
||||
faItems_(dict.lookup("fields")),
|
||||
meanScalarFields_(faItems_.size()),
|
||||
meanVectorFields_(faItems_.size()),
|
||||
meanSphericalTensorFields_(faItems_.size()),
|
||||
meanSymmTensorFields_(faItems_.size()),
|
||||
meanTensorFields_(faItems_.size()),
|
||||
prime2MeanScalarFields_(faItems_.size()),
|
||||
prime2MeanSymmTensorFields_(faItems_.size()),
|
||||
totalIter_(faItems_.size(), 1),
|
||||
totalTime_(faItems_.size(), obr_.time().deltaT().value())
|
||||
{
|
||||
// Check if the available mesh is an fvMesh otherise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"fieldAverage::fieldAverage\n"
|
||||
"(\n"
|
||||
"const word&,\n"
|
||||
"const objectRegistry&,\n"
|
||||
"const dictionary&,\n"
|
||||
"const bool\n"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating."
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldAverage::~fieldAverage()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldAverage::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
faItems_.clear();
|
||||
faItems_ = List<fieldAverageItem>(dict.lookup("fields"));
|
||||
|
||||
resetLists(faItems_.size());
|
||||
|
||||
initialise();
|
||||
|
||||
readAveragingProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
calcAverages();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
writeAverages();
|
||||
writeAveragingProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::calcAverages()
|
||||
{
|
||||
Info<< "Calculating averages" << nl << endl;
|
||||
forAll(faItems_, i)
|
||||
const label currentTimeIndex =
|
||||
static_cast<const fvMesh&>(obr_).time().timeIndex();
|
||||
|
||||
if (prevTimeIndex_ == currentTimeIndex)
|
||||
{
|
||||
totalIter_[i]++;
|
||||
totalTime_[i] += obr_.time().deltaT().value();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
prevTimeIndex_ = currentTimeIndex;
|
||||
}
|
||||
|
||||
|
||||
Info<< "Calculating averages" << nl << endl;
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
totalIter_[fieldI]++;
|
||||
totalTime_[fieldI] += obr_.time().deltaT().value();
|
||||
}
|
||||
|
||||
addMeanSqrToPrime2Mean<scalar, scalar>
|
||||
@ -333,12 +232,12 @@ void Foam::fieldAverage::writeAveragingProperties() const
|
||||
)
|
||||
);
|
||||
|
||||
forAll(faItems_, i)
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
propsDict.add(fieldName, dictionary());
|
||||
propsDict.subDict(fieldName).add("totalIter", totalIter_[i]);
|
||||
propsDict.subDict(fieldName).add("totalTime", totalTime_[i]);
|
||||
propsDict.subDict(fieldName).add("totalIter", totalIter_[fieldI]);
|
||||
propsDict.subDict(fieldName).add("totalTime", totalTime_[fieldI]);
|
||||
}
|
||||
|
||||
propsDict.regIOobject::write();
|
||||
@ -354,34 +253,39 @@ void Foam::fieldAverage::readAveragingProperties()
|
||||
}
|
||||
else
|
||||
{
|
||||
IFstream propsFile
|
||||
IOobject propsDictHeader
|
||||
(
|
||||
obr_.time().path()/obr_.time().timeName()
|
||||
/"uniform"/"fieldAveragingProperties"
|
||||
"fieldAveragingProperties",
|
||||
obr_.time().timeName(),
|
||||
"uniform",
|
||||
obr_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (!propsFile.good())
|
||||
if (!propsDictHeader.headerOk())
|
||||
{
|
||||
Info<< "fieldAverage: starting averaging at time "
|
||||
<< obr_.time().timeName() << nl << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
dictionary propsDict(dictionary::null, propsFile);
|
||||
IOdictionary propsDict(propsDictHeader);
|
||||
|
||||
Info<< "fieldAverage: restarting averaging for fields:" << endl;
|
||||
forAll(faItems_, i)
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
if (propsDict.found(fieldName))
|
||||
{
|
||||
dictionary fieldDict(propsDict.subDict(fieldName));
|
||||
|
||||
totalIter_[i] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[i] = readScalar(fieldDict.lookup("totalTime"));
|
||||
totalIter_[fieldI] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[fieldI] = readScalar(fieldDict.lookup("totalTime"));
|
||||
Info<< " " << fieldName
|
||||
<< " iters = " << totalIter_[i]
|
||||
<< " time = " << totalTime_[i] << endl;
|
||||
<< " iters = " << totalIter_[fieldI]
|
||||
<< " time = " << totalTime_[fieldI] << endl;
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
@ -389,6 +293,104 @@ void Foam::fieldAverage::readAveragingProperties()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldAverage::fieldAverage
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
prevTimeIndex_(-1),
|
||||
cleanRestart_(false),
|
||||
faItems_(),
|
||||
meanScalarFields_(),
|
||||
meanVectorFields_(),
|
||||
meanSphericalTensorFields_(),
|
||||
meanSymmTensorFields_(),
|
||||
meanTensorFields_(),
|
||||
prime2MeanScalarFields_(),
|
||||
prime2MeanSymmTensorFields_(),
|
||||
totalIter_(),
|
||||
totalTime_()
|
||||
{
|
||||
// Only active if a fvMesh is available
|
||||
if (isA<fvMesh>(obr_))
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"fieldAverage::fieldAverage\n"
|
||||
"(\n"
|
||||
"const word&,\n"
|
||||
"const objectRegistry&,\n"
|
||||
"const dictionary&,\n"
|
||||
"const bool\n"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating."
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldAverage::~fieldAverage()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldAverage::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
dict.readIfPresent("cleanRestart", cleanRestart_);
|
||||
dict.lookup("fields") >> faItems_;
|
||||
|
||||
initialize();
|
||||
readAveragingProperties();
|
||||
|
||||
// ensure first averaging works unconditionally
|
||||
prevTimeIndex_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
calcAverages();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::end()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
calcAverages();
|
||||
writeAverages();
|
||||
writeAveragingProperties();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::updateMesh(const mapPolyMesh&)
|
||||
{
|
||||
// Do nothing
|
||||
|
@ -41,7 +41,7 @@ Description
|
||||
// averaging info if available
|
||||
cleanRestart true;
|
||||
|
||||
// Fields to be probed. runTime modifiable!
|
||||
// Fields to be averaged. runTime modifiable!
|
||||
fields
|
||||
(
|
||||
U
|
||||
@ -107,6 +107,14 @@ class fieldAverage
|
||||
{
|
||||
protected:
|
||||
|
||||
// File and field name extensions
|
||||
|
||||
//- Mean average
|
||||
static const word EXT_MEAN;
|
||||
|
||||
//- Prime-squared average
|
||||
static const word EXT_PRIME2MEAN;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Name of this set of field averages.
|
||||
@ -118,6 +126,9 @@ protected:
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Time at last call, prevents repeated averaging
|
||||
label prevTimeIndex_;
|
||||
|
||||
//- Clean restart flag
|
||||
Switch cleanRestart_;
|
||||
|
||||
@ -125,15 +136,6 @@ protected:
|
||||
// calculated and output
|
||||
List<fieldAverageItem> faItems_;
|
||||
|
||||
// File and field name extensions
|
||||
|
||||
//- Mean average
|
||||
static const word EXT_MEAN;
|
||||
|
||||
//- Prime-squared average
|
||||
static const word EXT_PRIME2MEAN;
|
||||
|
||||
|
||||
// Lists of averages
|
||||
|
||||
// Arithmetic mean fields
|
||||
@ -143,7 +145,8 @@ protected:
|
||||
wordList meanSymmTensorFields_;
|
||||
wordList meanTensorFields_;
|
||||
|
||||
// Prime-squared fields - applicable to volVectorFields only
|
||||
// Prime-squared fields
|
||||
// Only applicable to volScalarFields / volVectorFields
|
||||
wordList prime2MeanScalarFields_;
|
||||
wordList prime2MeanSymmTensorFields_;
|
||||
|
||||
@ -162,20 +165,18 @@ protected:
|
||||
// Initialisation routines
|
||||
|
||||
//- Checkout fields (causes deletion) from the database
|
||||
void checkoutFields(const wordList&) const;
|
||||
// and reset lists
|
||||
void resetFields(wordList&);
|
||||
|
||||
//- Reset size of lists (clear existing values)
|
||||
void resetLists(const label nItems);
|
||||
//- Reset lists (clear existing values) and initialize averaging.
|
||||
// Check requested field averages are valid, populate field lists
|
||||
void initialize();
|
||||
|
||||
//- Intitialise averaging. Check requested field averages are
|
||||
// valid, and populate field lists
|
||||
void initialise();
|
||||
|
||||
//- Add mean average field to PtrList
|
||||
//- Add mean average field to list
|
||||
template<class Type>
|
||||
void addMeanField(const label, wordList&) const;
|
||||
|
||||
//- Add prime-squared average field to PtrList
|
||||
//- Add prime-squared average field to list
|
||||
template<class Type1, class Type2>
|
||||
void addPrime2MeanField
|
||||
(
|
||||
@ -211,7 +212,7 @@ protected:
|
||||
) const;
|
||||
|
||||
|
||||
// I-O
|
||||
// IO
|
||||
|
||||
//- Write averages
|
||||
virtual void writeAverages() const;
|
||||
@ -281,6 +282,9 @@ public:
|
||||
//- Execute the averaging
|
||||
virtual void execute();
|
||||
|
||||
//- Execute the averaging at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Calculate the field average data and write
|
||||
virtual void write();
|
||||
};
|
||||
|
@ -33,15 +33,15 @@ License
|
||||
template<class Type>
|
||||
void Foam::fieldAverage::addMeanField
|
||||
(
|
||||
const label fieldi,
|
||||
const label fieldI,
|
||||
wordList& meanFieldList
|
||||
) const
|
||||
{
|
||||
if (faItems_[fieldi].mean())
|
||||
if (faItems_[fieldI].mean())
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
|
||||
const word meanFieldName = fieldName + EXT_MEAN;
|
||||
|
||||
@ -49,14 +49,14 @@ void Foam::fieldAverage::addMeanField
|
||||
|
||||
if (obr_.foundObject<fieldType>(meanFieldName))
|
||||
{
|
||||
meanFieldList[fieldi] = meanFieldName;
|
||||
meanFieldList[fieldI] = meanFieldName;
|
||||
}
|
||||
else if (obr_.found(meanFieldName))
|
||||
{
|
||||
Info<< "Cannot allocate average field " << meanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging." << nl << endl;
|
||||
meanFieldList[fieldi] = word::null;
|
||||
meanFieldList[fieldI] = word::null;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -79,7 +79,7 @@ void Foam::fieldAverage::addMeanField
|
||||
// Store on registry
|
||||
fPtr->store();
|
||||
|
||||
meanFieldList[fieldi] = meanFieldName;
|
||||
meanFieldList[fieldI] = meanFieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,38 +88,38 @@ void Foam::fieldAverage::addMeanField
|
||||
template<class Type1, class Type2>
|
||||
void Foam::fieldAverage::addPrime2MeanField
|
||||
(
|
||||
const label fieldi,
|
||||
const label fieldI,
|
||||
const wordList& meanFieldList,
|
||||
wordList& prime2MeanFieldList
|
||||
) const
|
||||
{
|
||||
if (faItems_[fieldi].mean() && meanFieldList[fieldi] != word::null)
|
||||
if (faItems_[fieldI].mean() && meanFieldList[fieldI].size())
|
||||
{
|
||||
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
|
||||
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
|
||||
|
||||
const word& fieldName = faItems_[fieldi].fieldName();
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
|
||||
const word meanFieldName = fieldName + EXT_PRIME2MEAN;
|
||||
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
|
||||
|
||||
if (obr_.foundObject<fieldType2>(meanFieldName))
|
||||
{
|
||||
prime2MeanFieldList[fieldi] = meanFieldName;
|
||||
prime2MeanFieldList[fieldI] = meanFieldName;
|
||||
}
|
||||
else if (obr_.found(meanFieldName))
|
||||
{
|
||||
Info<< "Cannot allocate average field " << meanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging." << nl << endl;
|
||||
prime2MeanFieldList[fieldi] = word::null;
|
||||
prime2MeanFieldList[fieldI] = word::null;
|
||||
}
|
||||
else
|
||||
{
|
||||
const fieldType1& baseField =
|
||||
obr_.lookupObject<fieldType1>(fieldName);
|
||||
const fieldType1& meanField =
|
||||
obr_.lookupObject<fieldType1>(meanFieldList[fieldi]);
|
||||
obr_.lookupObject<fieldType1>(meanFieldList[fieldI]);
|
||||
|
||||
fieldType2* fPtr = new fieldType2
|
||||
(
|
||||
@ -137,7 +137,7 @@ void Foam::fieldAverage::addPrime2MeanField
|
||||
// Store on registry
|
||||
fPtr->store();
|
||||
|
||||
prime2MeanFieldList[fieldi] = meanFieldName;
|
||||
prime2MeanFieldList[fieldI] = meanFieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ const
|
||||
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
if (faItems_[i].mean() && meanFieldList[i] != word::null)
|
||||
if (faItems_[i].mean() && meanFieldList[i].size())
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
const fieldType& baseField =
|
||||
@ -199,8 +199,8 @@ void Foam::fieldAverage::calculatePrime2MeanFields
|
||||
if
|
||||
(
|
||||
faItems_[i].prime2Mean()
|
||||
&& meanFieldList[i] != word::null
|
||||
&& prime2MeanFieldList[i] != word::null
|
||||
&& meanFieldList[i].size()
|
||||
&& prime2MeanFieldList[i].size()
|
||||
)
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
@ -250,8 +250,8 @@ void Foam::fieldAverage::addMeanSqrToPrime2Mean
|
||||
if
|
||||
(
|
||||
faItems_[i].prime2Mean()
|
||||
&& meanFieldList[i] != word::null
|
||||
&& prime2MeanFieldList[i] != word::null
|
||||
&& meanFieldList[i].size()
|
||||
&& prime2MeanFieldList[i].size()
|
||||
)
|
||||
{
|
||||
const fieldType1& meanField =
|
||||
@ -274,7 +274,7 @@ void Foam::fieldAverage::writeFieldList(const wordList& fieldList) const
|
||||
|
||||
forAll(fieldList, i)
|
||||
{
|
||||
if (fieldList[i] != word::null)
|
||||
if (fieldList[i].size())
|
||||
{
|
||||
const fieldType& f = obr_.lookupObject<fieldType>(fieldList[i]);
|
||||
f.write();
|
||||
|
@ -76,14 +76,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
|
||||
"(Foam::Ostream&, const Foam::fieldAverageItem&)"
|
||||
);
|
||||
|
||||
os<< faItem.fieldName_ << nl;
|
||||
os<< token::BEGIN_BLOCK << nl;
|
||||
os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl;
|
||||
os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("prime2Mean") << faItem.mean_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_]
|
||||
<< token::END_STATEMENT << nl;
|
||||
os<< token::END_BLOCK << nl;
|
||||
<< token::END_STATEMENT << nl << token::END_BLOCK << nl;
|
||||
|
||||
os.check
|
||||
(
|
||||
|
@ -163,6 +163,13 @@ void Foam::fieldMinMax::execute()
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldMinMax::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldMinMax::write()
|
||||
{
|
||||
if (active_)
|
||||
|
@ -80,8 +80,8 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of forces,
|
||||
// Also used as the name of the probes directory.
|
||||
//- Name of this set of field min/max.
|
||||
// Also used as the name of the output directory.
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
@ -108,7 +108,7 @@ protected:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- If the forces file has not been created create it
|
||||
//- If the output file has not been created create it
|
||||
void makeFile();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -147,18 +147,21 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of forces
|
||||
//- Return name of the set of field min/max
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the forces data
|
||||
//- Read the field min/max data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Calculate the field min/max
|
||||
template<class Type>
|
||||
void calcMinMaxFields(const word& fieldName);
|
||||
|
@ -104,6 +104,12 @@ void Foam::forceCoeffs::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::write()
|
||||
{
|
||||
if (active_)
|
||||
|
@ -126,9 +126,12 @@ public:
|
||||
//- Read the forces data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Write the forces
|
||||
virtual void write();
|
||||
};
|
||||
|
@ -273,6 +273,13 @@ void Foam::forces::execute()
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::forces::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::forces::write()
|
||||
{
|
||||
if (active_)
|
||||
|
@ -200,9 +200,12 @@ public:
|
||||
//- Read the forces data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Write the forces
|
||||
virtual void write();
|
||||
|
||||
|
@ -41,15 +41,14 @@ namespace Foam
|
||||
Foam::systemCall::systemCall
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const objectRegistry&,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
const bool
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
executeCalls_(),
|
||||
endCalls_(),
|
||||
writeCalls_()
|
||||
{
|
||||
read(dict);
|
||||
@ -66,8 +65,16 @@ Foam::systemCall::~systemCall()
|
||||
|
||||
void Foam::systemCall::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("executeCalls") >> executeCalls_;
|
||||
dict.lookup("writeCalls") >> writeCalls_;
|
||||
dict.readIfPresent("executeCalls", executeCalls_);
|
||||
dict.readIfPresent("endCalls", endCalls_);
|
||||
dict.readIfPresent("writeCalls", writeCalls_);
|
||||
|
||||
if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
|
||||
{
|
||||
WarningIn("Foam::system::read(const dictionary&)")
|
||||
<< "no executeCalls, endCalls or writeCalls defined."
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +86,16 @@ void Foam::systemCall::execute()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::systemCall::end()
|
||||
{
|
||||
forAll(endCalls_, callI)
|
||||
{
|
||||
::system(endCalls_[callI].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::systemCall::write()
|
||||
{
|
||||
forAll(writeCalls_, callI)
|
||||
|
@ -63,14 +63,12 @@ protected:
|
||||
//- Name of this set of system calls
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- List of calls to execute - every step
|
||||
stringList executeCalls_;
|
||||
|
||||
//- List of calls to execute when exiting the time-loop
|
||||
stringList endCalls_;
|
||||
|
||||
//- List of calls to execute - write steps
|
||||
stringList writeCalls_;
|
||||
|
||||
@ -97,9 +95,9 @@ public:
|
||||
systemCall
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const objectRegistry& unused,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
const bool loadFromFilesUnused = false
|
||||
);
|
||||
|
||||
|
||||
@ -119,10 +117,13 @@ public:
|
||||
//- Read the system calls
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
//- Execute the "executeCalls" at each time-step
|
||||
virtual void execute();
|
||||
|
||||
//- Write
|
||||
//- Execute the "endCalls" at the final time-loop
|
||||
virtual void end();
|
||||
|
||||
//- Write, execute the "writeCalls"
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
|
@ -58,7 +58,7 @@ Foam::dynamicPressure::dynamicPressure
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
pName_(dict.lookup("p")),
|
||||
pName_(dict.lookupOrDefault<word>("p", "p")),
|
||||
rho_(readScalar(dict.lookup("rho")))
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
@ -68,7 +68,7 @@ Foam::dynamicPressure::dynamicPressure
|
||||
WarningIn
|
||||
(
|
||||
"dynamicPressure::dynamicPressure"
|
||||
"(const objectRegistry& obr, const dictionary& dict)"
|
||||
"(const objectRegistry&, const dictionary&)"
|
||||
) << "No fvMesh available, deactivating." << nl
|
||||
<< endl;
|
||||
}
|
||||
@ -81,7 +81,7 @@ Foam::dynamicPressure::dynamicPressure
|
||||
WarningIn
|
||||
(
|
||||
"dynamicPressure::dynamicPressure"
|
||||
"(const objectRegistry& obr, const dictionary& dict)"
|
||||
"(const objectRegistry&, const dictionary&)"
|
||||
) << "Pressure is not kinematic pressure, deactivating." << nl
|
||||
<< endl;
|
||||
}
|
||||
@ -103,7 +103,7 @@ void Foam::dynamicPressure::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
dict.lookup("p") >> pName_;
|
||||
dict.readIfPresent("p", pName_);
|
||||
dict.lookup("rho") >> rho_;
|
||||
}
|
||||
}
|
||||
@ -115,6 +115,12 @@ void Foam::dynamicPressure::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::dynamicPressure::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::dynamicPressure::write()
|
||||
{
|
||||
if (active_)
|
||||
|
@ -66,10 +66,10 @@ class dynamicPressure
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of pressure field
|
||||
//- Name of pressure field, default is "p"
|
||||
word pName_;
|
||||
|
||||
//- Density
|
||||
//- Density value
|
||||
scalar rho_;
|
||||
|
||||
|
||||
@ -120,9 +120,12 @@ public:
|
||||
//- Read the dynamicPressure data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Calculate the dynamicPressure and write
|
||||
virtual void write();
|
||||
|
||||
|
@ -48,8 +48,6 @@ graphField/writePatchGraph.C
|
||||
graphField/writeCellGraph.C
|
||||
graphField/makeGraph.C
|
||||
|
||||
outputFilters/outputFilterOutputControl/outputFilterOutputControl.C
|
||||
|
||||
meshToMesh = meshToMeshInterpolation/meshToMesh
|
||||
$(meshToMesh)/meshToMesh.C
|
||||
$(meshToMesh)/calculateMeshToMeshAddressing.C
|
||||
|
@ -304,6 +304,12 @@ void Foam::probes::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::probes::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::probes::write()
|
||||
{
|
||||
if (probeLocations_.size() && checkFieldTypes())
|
||||
|
@ -194,15 +194,18 @@ public:
|
||||
return cellList_;
|
||||
}
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Sample and write
|
||||
virtual void write();
|
||||
|
||||
//- Read the probes
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute
|
||||
virtual void execute();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
@ -275,6 +275,12 @@ void Foam::sampledSets::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSets::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSets::write()
|
||||
{
|
||||
if (size() && checkFieldTypes())
|
||||
|
@ -270,9 +270,12 @@ public:
|
||||
//- set verbosity level
|
||||
void verbose(const bool verbosity = true);
|
||||
|
||||
//- Execute
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Sample and write
|
||||
virtual void write();
|
||||
|
||||
|
@ -335,7 +335,7 @@ bool Foam::sampledIsoSurface::updateGeometry() const
|
||||
|
||||
subMeshPtr_.reset
|
||||
(
|
||||
new fvMeshSubset(static_cast<const fvMesh&>(mesh()))
|
||||
new fvMeshSubset(fvm)
|
||||
);
|
||||
subMeshPtr_().setLargeCellSubset
|
||||
(
|
||||
|
@ -87,7 +87,7 @@ class sampledIsoSurface
|
||||
|
||||
// Recreated for every isoSurface
|
||||
|
||||
//- Time at last call, also track it surface needs an update
|
||||
//- Time at last call, also track if surface needs an update
|
||||
mutable label prevTimeIndex_;
|
||||
|
||||
//- Cached volfield
|
||||
|
@ -203,7 +203,6 @@ Foam::sampledSurfaces::~sampledSurfaces()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::verbose(const bool verbosity)
|
||||
{
|
||||
verbose_ = verbosity;
|
||||
@ -216,6 +215,12 @@ void Foam::sampledSurfaces::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::write()
|
||||
{
|
||||
if (size() && checkFieldTypes())
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user