Merge branch 'master' of /home/noisy2/OpenFOAM/OpenFOAM-dev/

This commit is contained in:
mattijs
2008-05-13 11:53:42 +01:00
55 changed files with 212 additions and 49305 deletions

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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 mean and maximum Courant Numbers.
\*---------------------------------------------------------------------------*/
scalar CoNum = 0.0;
scalar meanCoNum = 0.0;
scalar acousticCoNum = 0.0;
if (mesh.nInternalFaces())
{
surfaceScalarField SfUfbyDelta =
mesh.surfaceInterpolation::deltaCoeffs()*mag(phiv);
CoNum = max(SfUfbyDelta/mesh.magSf())
.value()*runTime.deltaT().value();
meanCoNum = (sum(SfUfbyDelta)/sum(mesh.magSf()))
.value()*runTime.deltaT().value();
acousticCoNum = max
(
mesh.surfaceInterpolation::deltaCoeffs()/sqrt(fvc::interpolate(psi))
).value()*runTime.deltaT().value();
}
Info<< "phiv Courant Number mean: " << meanCoNum
<< " max: " << CoNum
<< " acoustic max: " << acousticCoNum
<< endl;
// ************************************************************************* //

View File

@ -1,3 +0,0 @@
cavitatingFoam.C
EXE = $(FOAM_APPBIN)/cavitatingFoam

View File

@ -1,7 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lbarotropicCompressibilityModel

View File

@ -1,16 +0,0 @@
surfaceScalarField gammaf = fvc::interpolate(gamma);
surfaceScalarField muf("muf", gammaf*muv + (1.0 - gammaf)*mul);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(muf, U)
//- (fvc::grad(U) & fvc::grad(muf))
- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)
{
solve(UEqn == -fvc::grad(p));
}

View File

@ -1,90 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
cavitatingFoam
Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "barotropicCompressibilityModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readThermodynamicProperties.H"
# include "readTransportProperties.H"
# include "readControls.H"
# include "createFields.H"
# include "initContinuityErrs.H"
# include "compressibleCourantNo.H"
# include "setInitialDeltaT.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
# include "readControls.H"
# include "CourantNo.H"
# include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
for (int outerCorr=0; outerCorr<nOuterCorr; outerCorr++)
{
# include "rhoEqn.H"
# include "gammaPsi.H"
# include "UEqn.H"
for (int corr=0; corr<nCorr; corr++)
{
# include "pEqn.H"
}
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "\n end \n";
return(0);
}
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
{
volScalarField thermoRho = psi*p + (1.0 - gamma)*rhol0;
dimensionedScalar totalMass = fvc::domainIntegrate(rho);
scalar sumLocalContErr =
(
fvc::domainIntegrate(mag(rho - thermoRho))/totalMass
).value();
scalar globalContErr =
(
fvc::domainIntegrate(rho - thermoRho)/totalMass
).value();
cumulativeContErr += globalContErr;
Info<< "time step continuity errors : sum local = " << sumLocalContErr
<< ", global = " << globalContErr
<< ", cumulative = " << cumulativeContErr
<< endl;
}

View File

@ -1,75 +0,0 @@
Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
volScalarField gamma
(
IOobject
(
"gamma",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0))
);
gamma.oldTime();
Info<< "Creating barotropicompressibilityModel\n" << endl;
autoPtr<barotropicCompressibilityModel> psiModel =
barotropicCompressibilityModel::New
(
thermodynamicProperties,
gamma
);
const volScalarField& psi = psiModel->psi();
rho == max
(
psi*p
+ (1.0 - gamma)*rhol0
+ ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat,
rhoMin
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhiv.H"
# include "compressibleCreatePhi.H"

View File

@ -1,10 +0,0 @@
{
gamma = max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));
Info<< "max-min gamma: " << max(gamma).value()
<< " " << min(gamma).value() << endl;
psiModel->correct();
//Info<< "min a: " << 1.0/sqrt(max(psi)).value() << endl;
}

View File

@ -1,80 +0,0 @@
{
if (nOuterCorr == 1)
{
p =
(
rho
- (1.0 - gamma)*rhol0
- ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat
)/psi;
}
surfaceScalarField rhof = fvc::interpolate(rho, "rhof");
volScalarField rUA = 1.0/UEqn.A();
surfaceScalarField rUAf("rUAf", rhof*fvc::interpolate(rUA));
volVectorField HbyA = rUA*UEqn.H();
phiv = (fvc::interpolate(HbyA) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, rho, U, phiv);
p.boundaryField().updateCoeffs();
surfaceScalarField phiGradp = rUAf*mesh.magSf()*fvc::snGrad(p);
phiv -= phiGradp/rhof;
# include "resetPhivPatches.H"
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::ddt(psi, p)
- (rhol0 + (psil - psiv)*pSat)*fvc::ddt(gamma) - pSat*fvc::ddt(psi)
+ fvc::div(phiv, rho)
+ fvc::div(phiGradp)
- fvm::laplacian(rUAf, p)
);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phiv += (phiGradp + pEqn.flux())/rhof;
}
}
Info<< "max-min p: " << max(p).value()
<< " " << min(p).value() << endl;
U = HbyA - rUA*fvc::grad(p);
// Remove the swirl component of velocity for "wedge" cases
if (piso.found("removeSwirl"))
{
label swirlCmpt(readLabel(piso.lookup("removeSwirl")));
Info<< "Removing swirl component-" << swirlCmpt << " of U" << endl;
U.field().replace(swirlCmpt, 0.0);
}
U.correctBoundaryConditions();
Info<< "max(U) " << max(mag(U)).value() << endl;
rho == max
(
psi*p
+ (1.0 - gamma)*rhol0
+ ((gamma*psiv + (1.0 - gamma)*psil) - psi)*pSat,
rhoMin
);
Info<< "max-min rho: " << max(rho).value()
<< " " << min(rho).value() << endl;
# include "gammaPsi.H"
}

View File

@ -1,9 +0,0 @@
#include "readTimeControls.H"
scalar maxAcousticCo
(
readScalar(runTime.controlDict().lookup("maxAcousticCo"))
);
#include "readPISOControls.H"

View File

@ -1,27 +0,0 @@
Info<< "Reading thermodynamicProperties\n" << endl;
IOdictionary thermodynamicProperties
(
IOobject
(
"thermodynamicProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar psil(thermodynamicProperties.lookup("psil"));
dimensionedScalar rholSat(thermodynamicProperties.lookup("rholSat"));
dimensionedScalar psiv(thermodynamicProperties.lookup("psiv"));
dimensionedScalar pSat(thermodynamicProperties.lookup("pSat"));
dimensionedScalar rhovSat("rhovSat", psiv*pSat);
dimensionedScalar rhol0("rhol0", rholSat - pSat*psil);
dimensionedScalar rhoMin(thermodynamicProperties.lookup("rhoMin"));

View File

@ -1,23 +0,0 @@
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar mul
(
transportProperties.lookup("mul")
);
dimensionedScalar muv
(
transportProperties.lookup("muv")
);

View File

@ -1,15 +0,0 @@
fvsPatchScalarFieldField& phiPatches = phi.boundaryField();
const fvPatchScalarFieldField& rhoPatches = rho.boundaryField();
const fvPatchVectorFieldField& Upatches = U.boundaryField();
const fvsPatchVectorFieldField& SfPatches = mesh.Sf().boundaryField();
forAll(phiPatches, patchI)
{
if (phi.boundaryField().types()[patchI] == "calculated")
{
calculatedFvsPatchScalarField& phiPatch =
refCast<calculatedFvsPatchScalarField>(phiPatches[patchI]);
phiPatch == ((rhoPatches[patchI]*Upatches[patchI]) & SfPatches[patchI]);
}
}

View File

@ -1,14 +0,0 @@
surfaceScalarField::GeometricBoundaryField& phivPatches = phiv.boundaryField();
const volVectorField::GeometricBoundaryField& Upatches = U.boundaryField();
const surfaceVectorField::GeometricBoundaryField& SfPatches = mesh.Sf().boundaryField();
forAll(phivPatches, patchI)
{
if (phiv.boundaryField().types()[patchI] == "calculated")
{
calculatedFvsPatchScalarField& phivPatch =
refCast<calculatedFvsPatchScalarField>(phivPatches[patchI]);
phivPatch == (Upatches[patchI] & SfPatches[patchI]);
}
}

View File

@ -1,16 +0,0 @@
{
fvScalarMatrix rhoEqn
(
fvm::ddt(rho)
+ fvm::div(phiv, rho)
);
rhoEqn.solve();
phi = rhoEqn.flux();
Info<< "max-min rho: " << max(rho).value()
<< " " << min(rho).value() << endl;
rho == max(rho, rhoMin);
}

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
setDeltaT
Description
Reset the timestep to maintain a constant maximum courant Number.
Reduction of time-step is imediate but increase is damped to avoid
unstable oscillations.
\*---------------------------------------------------------------------------*/
if (adjustTimeStep)
{
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT
(
min
(
deltaTFact*runTime.deltaT().value(),
maxDeltaT
)
);
Info<< "deltaT = " << runTime.deltaT().value() << endl;
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
setInitialDeltaT
Description
Set the initial timestep corresponding to the timestep adjustment
algorithm in setDeltaT
\*---------------------------------------------------------------------------*/
if (adjustTimeStep)
{
# include "CourantNo.H"
if (CoNum > SMALL)
{
scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
runTime.setDeltaT
(
min
(
maxDeltaTFact*runTime.deltaT().value(),
maxDeltaT
)
);
}
}
// ************************************************************************* //

View File

@ -1,18 +1,17 @@
surfaceScalarField gammaf = fvc::interpolate(gamma);
surfaceScalarField muf
(
"muf",
gammaf*muv + (1.0 - gammaf)*mul
+ fvc::interpolate(rho*turbulence->nuSgs())
);
surfaceScalarField muEff
(
"muEff",
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs())
);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(muf, U)
- fvm::laplacian(muEff, U)
//- (fvc::grad(U) & fvc::grad(muf))
- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)

View File

@ -1,12 +0,0 @@
Info << "Calculating averages" << endl;
scalar alpha =
(runTime.value() - timeToStartAveraging - runTime.deltaT().value())
/(runTime.value() - timeToStartAveraging);
scalar onemAlpha = 1.0 - alpha;
Umean == alpha*Umean + onemAlpha*U;
rhoMean == alpha*rhoMean + onemAlpha*rho;
pMean == alpha*pMean + onemAlpha*p;
gammaMean == alpha*gammaMean + onemAlpha*gamma;

View File

@ -1,53 +0,0 @@
scalar timeToStartAveraging = runTime.value();
volVectorField Umean
(
IOobject
(
"Umean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U
);
volScalarField rhoMean
(
IOobject
(
"rhoMean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
rho
);
volScalarField pMean
(
IOobject
(
"pMean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p
);
volScalarField gammaMean
(
IOobject
(
"gammaMean",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
gamma
);

View File

@ -44,10 +44,8 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createMesh.H"
# include "readThermodynamicProperties.H"
# include "readTransportProperties.H"
# include "readControls.H"
# include "createFields.H"
# include "createAverages.H"
# include "initContinuityErrs.H"
# include "compressibleCourantNo.H"
# include "setInitialDeltaT.H"
@ -79,8 +77,6 @@ int main(int argc, char *argv[])
}
}
# include "calculateAverages.H"
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"

View File

@ -1,23 +0,0 @@
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar mul
(
transportProperties.lookup("mul")
);
dimensionedScalar muv
(
transportProperties.lookup("muv")
);

View File

@ -1,14 +1,17 @@
surfaceScalarField muf =
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs());
surfaceScalarField muEff
(
"muEff",
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nuSgs())
);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(rhoPhi, U)
- fvm::laplacian(muf, U)
- (fvc::grad(U) & fvc::grad(muf))
//- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
- fvm::laplacian(muEff, U)
- (fvc::grad(U) & fvc::grad(muEff))
//- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)

View File

@ -1,18 +1,17 @@
surfaceScalarField gammaf = fvc::interpolate(gamma);
surfaceScalarField muf
(
"muf",
gammaf*muv + (1.0 - gammaf)*mul
+ fvc::interpolate(rho*turbulence->nuEff())
);
surfaceScalarField muEff
(
"muEff",
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nut())
);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(phi, U)
- fvm::laplacian(muf, U)
- fvm::laplacian(muEff, U)
//- (fvc::grad(U) & fvc::grad(muf))
- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)

View File

@ -44,7 +44,6 @@ int main(int argc, char *argv[])
# include "createTime.H"
# include "createMesh.H"
# include "readThermodynamicProperties.H"
# include "readTransportProperties.H"
# include "readControls.H"
# include "createFields.H"
# include "initContinuityErrs.H"

View File

@ -1,23 +0,0 @@
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar mul
(
transportProperties.lookup("mul")
);
dimensionedScalar muv
(
transportProperties.lookup("muv")
);

View File

@ -1,14 +1,17 @@
surfaceScalarField muf =
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nut());
surfaceScalarField muEff
(
"muEff",
twoPhaseProperties.muf()
+ fvc::interpolate(rho*turbulence->nut())
);
fvVectorMatrix UEqn
(
fvm::ddt(rho, U)
+ fvm::div(rhoPhi, U)
- fvm::laplacian(muf, U)
- (fvc::grad(U) & fvc::grad(muf))
//- fvc::div(muf*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
- fvm::laplacian(muEff, U)
- (fvc::grad(U) & fvc::grad(muEff))
//- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf()))
);
if (momentumPredictor)

View File

@ -1,6 +0,0 @@
fieldAverage/fieldAverage.C
fieldAverageItem/fieldAverageItem.C
fieldAverageItem/fieldAverageItemIO.C
fieldAverageFunctionObject/fieldAverageFunctionObject.C
LIB = $(FOAM_LIBBIN)/libfieldAverage

View File

@ -1,9 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/OpenFOAM/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lOpenFOAM \
-lsampling

View File

@ -1,84 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application oodles;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 0.1;
deltaT 1e-05;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
functions
(
fieldAverage1
{
// Type of functionObject
type fieldAverage;
// Where to load it from (if not already in solver)
functionObjectLibs ("libfieldAverage.so");
// Fields to be probed. runTime modifiable!
fields
(
U
{
mean on;
prime2Mean on;
base time;
}
p
{
mean on;
prime2Mean on;
base time;
}
);
}
);
// ************************************************************************* //

View File

@ -1,50 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
Typedef
IOfieldAverage
Description
Instance of the generic IOOutputFilter for fieldAverage.
\*---------------------------------------------------------------------------*/
#ifndef IOfieldAverage_H
#define IOfieldAverage_H
#include "fieldAverage.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<fieldAverage> IOFieldAverage;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,339 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
\*---------------------------------------------------------------------------*/
#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);
}
const Foam::word Foam::fieldAverage::EXT_MEAN = "Mean";
const Foam::word Foam::fieldAverage::EXT_PRIME2MEAN = "Prime2Mean";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldAverage::resetLists(const label nItems)
{
meanScalarFields_.clear();
meanScalarFields_.setSize(nItems);
meanVectorFields_.clear();
meanVectorFields_.setSize(nItems);
meanSymmTensorFields_.clear();
meanSymmTensorFields_.setSize(nItems);
meanSphericalTensorFields_.clear();
meanSphericalTensorFields_.setSize(nItems);
prime2MeanScalarFields_.clear();
prime2MeanScalarFields_.setSize(nItems);
prime2MeanSymmTensorFields_.clear();
prime2MeanSymmTensorFields_.setSize(nItems);
nSteps_.clear();
nSteps_.setSize(nItems, 1);
totalTime_.clear();
totalTime_.setSize(nItems, obr_.time().deltaT().value());
}
void Foam::fieldAverage::initialise()
{
// Add mean fields to the field lists
forAll(faItems_, i)
{
const word fieldName = faItems_[i].fieldName();
if (obr_.foundObject<volScalarField>(fieldName))
{
addMeanFields<scalar>(i, meanScalarFields_);
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
addMeanFields<vector>(i, meanVectorFields_);
}
else if (obr_.foundObject<volSymmTensorField>(fieldName))
{
addMeanFields<symmTensor>(i, meanSymmTensorFields_);
}
else if (obr_.foundObject<volSphericalTensorField>(fieldName))
{
addMeanFields<sphericalTensor>(i, meanSphericalTensorFields_);
}
else
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "Requested field " << faItems_[i].fieldName()
<< " does not exist in the database" << nl
<< exit(FatalError);
}
}
// Add prime-squared mean fields to the field lists
forAll(faItems_, i)
{
if (faItems_[i].prime2Mean())
{
const word fieldName = faItems_[i].fieldName();
if (obr_.foundObject<volScalarField>(fieldName))
{
if (!faItems_[i].mean())
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "To calculate the prime-squared average, the "
<< "mean average must also be selected for field "
<< fieldName << nl << exit(FatalError);
}
addPrime2MeanFields<scalar>(i, prime2MeanScalarFields_);
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
if (!faItems_[i].mean())
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "To calculate the prime-squared average, the "
<< "mean average must also be selected for field "
<< fieldName << nl << exit(FatalError);
}
addPrime2MeanFields<vector>
(
i,
prime2MeanSymmTensorFields_
);
}
else
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "prime2Mean average can only be applied to "
<< "volScalarFields and volVectorFields"
<< nl << " Field: " << fieldName << nl
<< exit(FatalError);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverage::fieldAverage
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
active_(true),
faItems_(dict.lookup("fields")),
meanScalarFields_(faItems_.size()),
meanVectorFields_(faItems_.size()),
meanSymmTensorFields_(faItems_.size()),
meanSphericalTensorFields_(faItems_.size()),
prime2MeanScalarFields_(faItems_.size()),
prime2MeanSymmTensorFields_(faItems_.size()),
nSteps_(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"
"("
"const word&,"
"const objectRegistry&,"
"const dictionary&,"
"const bool"
")"
) << "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::write()
{
if (active_)
{
calcAverages();
if (obr_.time().outputTime())
{
writeAverages();
writeAveragingProperties();
}
}
}
void Foam::fieldAverage::calcAverages()
{
Info<< "Calculating averages" << nl << endl;
forAll(faItems_, i)
{
nSteps_[i]++;
totalTime_[i] += obr_.time().deltaT().value();
}
addMeanSqrToPrime2Mean<scalar>(prime2MeanScalarFields_);
addMeanSqrToPrime2Mean<vector>(prime2MeanSymmTensorFields_);
calculateMeanFields<scalar>(meanScalarFields_);
calculateMeanFields<vector>(meanVectorFields_);
calculateMeanFields<symmTensor>(meanSymmTensorFields_);
calculateMeanFields<sphericalTensor>(meanSphericalTensorFields_);
calculatePrime2MeanFields<scalar>(prime2MeanScalarFields_);
calculatePrime2MeanFields<vector>(prime2MeanSymmTensorFields_);
}
void Foam::fieldAverage::writeAverages() const
{
writeFieldList<scalar>(meanScalarFields_);
writeFieldList<vector>(meanVectorFields_);
writeFieldList<symmTensor>(meanSymmTensorFields_);
writeFieldList<sphericalTensor>(meanSphericalTensorFields_);
writeFieldList<scalar>(prime2MeanScalarFields_);
writeFieldList<symmTensor>(prime2MeanSymmTensorFields_);
}
void Foam::fieldAverage::writeAveragingProperties() const
{
IOdictionary propsDict
(
IOobject
(
"fieldAveragingProperties",
obr_.time().timeName(),
"uniform",
obr_,
IOobject::NO_READ,
IOobject::NO_WRITE
)
);
forAll(faItems_, i)
{
const word fieldName = faItems_[i].fieldName();
propsDict.add(fieldName, dictionary());
propsDict.subDict(fieldName).add("nSteps", nSteps_[i]);
propsDict.subDict(fieldName).add("totalTime", totalTime_[i]);
}
propsDict.regIOobject::write();
}
void Foam::fieldAverage::readAveragingProperties()
{
IFstream propsFile
(
obr_.time().path()/obr_.time().timeName()
/"uniform"/"fieldAveragingProperties"
);
if (!propsFile.good())
{
return;
}
dictionary propsDict(dictionary::null, propsFile);
forAll(faItems_, i)
{
const word& fieldName = faItems_[i].fieldName();
if (propsDict.found(fieldName))
{
dictionary fieldDict(propsDict.subDict(fieldName));
nSteps_[i] = readLabel(fieldDict.lookup("nSteps"));
totalTime_[i] = readScalar(fieldDict.lookup("totalTime"));
}
}
}
void Foam::fieldAverage::updateMesh(const mapPolyMesh&)
{
// Do nothing
}
void Foam::fieldAverage::movePoints(const pointField&)
{
// Do nothing
}
// ************************************************************************* //

View File

@ -1,293 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
Class
Foam::fieldAverage
Description
Calculates the field averages given list of fieldAverageItems, e.g.
@verbatim
fields
(
U
{
mean on;
prime2Mean on;
base time; // ensemble
}
p
{
mean on;
prime2Mean on;
base time; // ensemble
}
);
@endverbatim
Member function calcAverages() calculates the averages.
Member function fieldAverage::write() calls calcAverages(). Average
field names are constructed by concatenating the base field with the
averaging type, e.g.
- base field, U
- arithmetic mean field, UMean
- prime-squared field, UPrime2Mean
Information regarding the number of averaging steps, and total averaging
time are written on a (base) per-field basis to the
fieldAveragingProperties dictionary, located in <time>/uniform
SourceFiles
fieldAverage.C
fieldAverageTemplates.C
IOfieldAverage.H
\*---------------------------------------------------------------------------*/
#ifndef fieldAverage_H
#define fieldAverage_H
#include "volFieldsFwd.H"
#include "pointFieldFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class fieldAverageItem;
class OFstream;
template<class Type>
class List;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class fieldAverage Declaration
\*---------------------------------------------------------------------------*/
class fieldAverage
{
protected:
// Private data
//- Name of this set of field averages.
word name_;
//- Database this class is registered to
const objectRegistry& obr_;
//- On/off switch
bool active_;
//- List of field average items, describing waht averages to be
// 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
PtrList<volScalarField> meanScalarFields_;
PtrList<volVectorField> meanVectorFields_;
PtrList<volSymmTensorField> meanSymmTensorFields_;
PtrList<volSphericalTensorField> meanSphericalTensorFields_;
// Prime-squared fields - applicable to volVectorFields only
PtrList<volScalarField> prime2MeanScalarFields_;
PtrList<volSymmTensorField> prime2MeanSymmTensorFields_;
// Counters
//- Integration steps counter
List<label> nSteps_;
//- Total time counter
List<scalar> totalTime_;
// Private Member Functions
// Initialisation routines
//- Reset size of lists (clear existing values)
void resetLists(const label nItems);
//- Intitialise averaging. Check requested field averages are
// valid, and populate field lists
void initialise();
//- Add mean average fields to PtrLists
template<class Type>
void addMeanFields
(
const label fieldi,
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
);
//- Add prime-squared average fields to PtrLists
template<class Type1, class Type2>
void addPrime2MeanFields
(
const label fieldi,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
fieldList
);
// Calculation functions
//- Main calculation routine
virtual void calcAverages();
//- Calculate mean average fields
template<class Type>
void calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
);
//- Add mean-squared field value to prime-squared mean field
template<class Type1, class Type2>
void addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
fieldList
);
//- Calculate prime-squared average fields
template<class Type1, class Type2>
void calculatePrime2MeanFields
(
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
fieldList
);
// I-O
//- Write averages
virtual void writeAverages() const;
//- Write fields
template<class Type>
void writeFieldList
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
) const;
//- Write averaging properties - steps and time
void writeAveragingProperties() const;
//- Read averaging properties - steps and time
void readAveragingProperties();
// Functions to be over-ridden from IOoutputFilter class
//- Update mesh
virtual void updateMesh(const mapPolyMesh&);
//- Move points
virtual void movePoints(const Field<point>&);
//- Disallow default bitwise copy construct
fieldAverage(const fieldAverage&);
//- Disallow default bitwise assignment
void operator=(const fieldAverage&);
public:
//- Runtime type information
TypeName("fieldAverage");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
fieldAverage
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldAverage();
// Member Functions
//- Return name of the set of field averages
virtual const word& name() const
{
return name_;
}
//- Read the field average data
virtual void read(const dictionary&);
//- Calculate the field average data and write
virtual void write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fieldAverageTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,243 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2005 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
\*---------------------------------------------------------------------------*/
#include "fieldAverageItem.H"
#include "volFields.H"
#include "OFstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::fieldAverage::addMeanFields
(
const label fieldi,
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
)
{
if (faItems_[fieldi].mean())
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType& baseField = mesh.lookupObject<fieldType>(fieldName);
const word meanFieldName = fieldName + EXT_MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
fieldList.set
(
fieldi,
new fieldType
(
IOobject
(
meanFieldName,
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
baseField
)
);
}
}
template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanFields
(
const label fieldi,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& fieldList
)
{
if (faItems_[fieldi].mean())
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType1& baseField = mesh.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField =
mesh.lookupObject<fieldType1>(fieldName + EXT_MEAN);
const word meanFieldName = fieldName + EXT_PRIME2MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
fieldList.set
(
fieldi,
new fieldType2
(
IOobject
(
meanFieldName,
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
sqr(baseField) - sqr(meanField)
)
);
}
}
template<class Type>
void Foam::fieldAverage::calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const scalar dt = obr_.time().deltaT().value();
forAll(faItems_, i)
{
if (fieldList.set(i))
{
if (faItems_[i].mean())
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[i].fieldName();
const fieldType& baseField =
mesh.lookupObject<fieldType>(fieldName);
fieldType& meanField = fieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(nSteps_[i] - 1)/scalar(nSteps_[i]);
beta = 1.0/scalar(nSteps_[i]);
}
meanField = alpha*meanField + beta*baseField;
}
}
}
}
template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFields
(
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& fieldList
)
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
const scalar dt = obr_.time().deltaT().value();
forAll(faItems_, i)
{
if (fieldList.set(i))
{
if (faItems_[i].prime2Mean())
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[i].fieldName();
const fieldType1& baseField =
mesh.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField =
mesh.lookupObject<fieldType1>(fieldName + EXT_MEAN);
fieldType2& prime2MeanField = fieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(nSteps_[i] - 1)/scalar(nSteps_[i]);
beta = 1.0/scalar(nSteps_[i]);
}
prime2MeanField =
alpha*prime2MeanField
+ beta*sqr(baseField)
- sqr(meanField);
}
}
}
}
template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& fieldList
)
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
forAll(faItems_, i)
{
if (fieldList.set(i))
{
if (faItems_[i].prime2Mean())
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const word& fieldName = faItems_[i].fieldName();
const fieldType1& meanField =
mesh.lookupObject<fieldType1>(fieldName + EXT_MEAN);
fieldType2& prime2MeanField = fieldList[i];
prime2MeanField += sqr(meanField);
}
}
}
}
template<class Type>
void Foam::fieldAverage::writeFieldList
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
) const
{
forAll(fieldList, i)
{
if (fieldList.set(i))
{
fieldList[i].write();
}
}
}
// ************************************************************************* //

View File

@ -1,43 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
\*---------------------------------------------------------------------------*/
#include "fieldAverageFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(fieldAverageFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
fieldAverageFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
Typedef
fieldAverageFunctionObject
Description
FunctionObject wrapper around fieldAverage to allow them to be created
via the functions list within controlDict.
SourceFiles
fieldAverageFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef fieldAverageFunctionObject_H
#define fieldAverageFunctionObject_H
#include "fieldAverage.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<fieldAverage>
fieldAverageFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,90 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
\*---------------------------------------------------------------------------*/
#include "fieldAverageItem.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* Foam::NamedEnum<Foam::fieldAverageItem::baseType, 2>::names[] =
{
"ensemble",
"time"
};
const Foam::NamedEnum<Foam::fieldAverageItem::baseType, 2>
Foam::fieldAverageItem::baseTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverageItem::fieldAverageItem()
:
fieldName_("unknown"),
mean_(0),
prime2Mean_(0),
base_(ENSEMBLE)
{}
Foam::fieldAverageItem::fieldAverageItem(const fieldAverageItem& faItem)
:
fieldName_(faItem.fieldName_),
mean_(faItem.mean_),
prime2Mean_(faItem.prime2Mean_),
base_(faItem.base_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldAverageItem::~fieldAverageItem()
{}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::fieldAverageItem::operator=(const fieldAverageItem& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"Foam::fieldAverageItem::operator=(const Foam::fieldAverageItem&)"
) << "Attempted assignment to self" << nl
<< abort(FatalError);
}
// Set updated values
fieldName_ = rhs.fieldName_;
mean_ = rhs.mean_;
prime2Mean_ = rhs.prime2Mean_;
base_ = rhs.base_;
}
// ************************************************************************* //

View File

@ -1,194 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
Class
Foam::fieldAverageItem
Description
Helper class to describe what form of averaging to apply. A set will be
applied to each base field in Foam::fieldAverage, of the form:
@verbatim
{
mean on;
prime2Mean on;
base time; // ensemble
}
@endverbatim
SourceFiles
fieldAverageItem.C
fieldAverageItemIO.C
\*---------------------------------------------------------------------------*/
#ifndef fieldAverageItem_H
#define fieldAverageItem_H
#include "NamedEnum.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class fieldAverageItem;
Istream& operator>>(Istream&, fieldAverageItem&);
Ostream& operator<<(Ostream&, const fieldAverageItem&);
/*---------------------------------------------------------------------------*\
Class fieldAverageItem Declaration
\*---------------------------------------------------------------------------*/
class fieldAverageItem
{
public:
// Public data
//- Enumeration defining the averaging base type
enum baseType
{
ENSEMBLE,
TIME
};
private:
// Private data
//- Field name
word fieldName_;
//- Compute mean flag
Switch mean_;
//- Compute prime-squared mean flag
Switch prime2Mean_;
//- Averaging base type names
static const NamedEnum<baseType, 2> baseTypeNames_;
//- Averaging base type
baseType base_;
// Private Member Functions
//- Disallow default bitwise copy construct
// fieldAverageItem(const fieldAverageItem&);
//- Disallow default bitwise assignment
// void operator=(const fieldAverageItem&);
public:
// Constructors
//- Construct null
fieldAverageItem();
//- Construct from Istream
fieldAverageItem(Istream&);
//- Construct as copy
fieldAverageItem(const fieldAverageItem&);
// Destructor
~fieldAverageItem();
// Member Functions
// Access
//- Return const access to the field name
const word& fieldName() const
{
return fieldName_;
}
//- Return const access to the mean flag
const Switch& mean() const
{
return mean_;
}
//- Return const access to the prime-squared mean flag
const Switch& prime2Mean() const
{
return prime2Mean_;
}
//- Return averaging base type name
const word base() const
{
return baseTypeNames_[base_];
}
//- Return true if base is ensemble
Switch ensembleBase() const
{
return base_ == ENSEMBLE;
}
//- Return true if base is time
Switch timeBase() const
{
return base_ == TIME;
}
// Member Operators
void operator=(const fieldAverageItem&);
// IOstream Operators
friend Istream& operator>>(Istream&, fieldAverageItem&);
friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,98 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 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
\*---------------------------------------------------------------------------*/
#include "fieldAverageItem.H"
#include "IOstreams.H"
#include "dictionaryEntry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverageItem::fieldAverageItem(Istream& is)
:
fieldName_("unknown"),
mean_(0),
prime2Mean_(0)
{
is.check("Foam::fieldAverageItem::fieldAverageItem(Foam::Istream&)");
const dictionaryEntry entry(dictionary::null, is);
fieldName_ = entry.keyword();
entry.lookup("mean") >> mean_;
entry.lookup("prime2Mean") >> prime2Mean_;
base_ = baseTypeNames_[entry.lookup("base")];
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem)
{
is.check
(
"Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::fieldAverageItem&)"
);
const dictionaryEntry entry(dictionary::null, is);
faItem.fieldName_ = entry.keyword();
entry.lookup("mean") >> faItem.mean_;
entry.lookup("prime2Mean") >> faItem.prime2Mean_;
faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
{
os.check
(
"Foam::Ostream& Foam::operator<<"
"(Foam::Ostream&, const Foam::fieldAverageItem&)"
);
os<< faItem.fieldName_ << nl;
os<< 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;
os.check
(
"Foam::Ostream& Foam::operator<<"
"(Foam::Ostream&, const Foam::fieldAverageItem&)"
);
return os;
}
// ************************************************************************* //