Merge branch 'master' of /home/noisy2/OpenFOAM/OpenFOAM-dev/
This commit is contained in:
commit
eab4682444
@ -41,17 +41,13 @@ Description
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
# include "readTransportProperties.H"
|
||||
# include "createFields.H"
|
||||
# include "createAverages.H"
|
||||
# include "initContinuityErrs.H"
|
||||
# include "createGradP.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "readTransportProperties.H"
|
||||
#include "createFields.H"
|
||||
#include "initContinuityErrs.H"
|
||||
#include "createGradP.H"
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
@ -59,9 +55,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
#include "readPISOControls.H"
|
||||
|
||||
# include "CourantNo.H"
|
||||
#include "CourantNo.H"
|
||||
|
||||
sgsModel->correct();
|
||||
|
||||
@ -116,7 +112,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
# include "continuityErrs.H"
|
||||
#include "continuityErrs.H"
|
||||
|
||||
U -= rUA*fvc::grad(p);
|
||||
U.correctBoundaryConditions();
|
||||
@ -126,12 +122,12 @@ int main(int argc, char *argv[])
|
||||
// Correct driving force for a constant mass flow rate
|
||||
|
||||
// Extract the velocity in the flow direction
|
||||
dimensionedScalar magUbarStar =
|
||||
dimensionedScalar magUbarStar =
|
||||
(flowDirection & U)().weightedAverage(mesh.V());
|
||||
|
||||
// Calculate the pressure gradient increment needed to
|
||||
// Calculate the pressure gradient increment needed to
|
||||
// adjust the average flow-rate to the correct value
|
||||
dimensionedScalar gragPplus =
|
||||
dimensionedScalar gragPplus =
|
||||
(magUbar - magUbarStar)/rUA.weightedAverage(mesh.V());
|
||||
|
||||
U += flowDirection*rUA*gragPplus;
|
||||
@ -141,14 +137,9 @@ int main(int argc, char *argv[])
|
||||
Info<< "Uncorrected Ubar = " << magUbarStar.value() << tab
|
||||
<< "pressure gradient = " << gradP.value() << endl;
|
||||
|
||||
|
||||
# include "calculateAverages.H"
|
||||
|
||||
runTime.write();
|
||||
|
||||
# include "writeNaveragingSteps.H"
|
||||
|
||||
# include "writeGradP.H"
|
||||
#include "writeGradP.H"
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
|
@ -26,6 +26,7 @@ Application
|
||||
coodles
|
||||
|
||||
Description
|
||||
Compressible LES solver.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -39,15 +40,12 @@ Description
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
# include "setRootCase.H"
|
||||
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
# include "createFields.H"
|
||||
# include "initContinuityErrs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "createFields.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
@ -55,17 +53,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
# include "compressibleCourantNo.H"
|
||||
#include "readPISOControls.H"
|
||||
#include "compressibleCourantNo.H"
|
||||
|
||||
# include "rhoEqn.H"
|
||||
# include "UEqn.H"
|
||||
#include "rhoEqn.H"
|
||||
#include "UEqn.H"
|
||||
|
||||
// --- PISO loop
|
||||
for (int corr=1; corr<=nCorr; corr++)
|
||||
{
|
||||
# include "hEqn.H"
|
||||
# include "pEqn.H"
|
||||
#include "hEqn.H"
|
||||
#include "pEqn.H"
|
||||
}
|
||||
|
||||
turbulence->correct();
|
||||
|
@ -1,14 +0,0 @@
|
||||
nAveragingSteps++;
|
||||
|
||||
scalar nm1Coeff = scalar(nAveragingSteps - 1)/nAveragingSteps;
|
||||
scalar nCoeff = 1.0/nAveragingSteps;
|
||||
|
||||
R += sqr(Umean);
|
||||
Umean = nm1Coeff*Umean + nCoeff*U;
|
||||
R = nm1Coeff*R + nCoeff*sqr(U) - sqr(Umean);
|
||||
Bmean = nm1Coeff*Bmean + nCoeff*sgsModel->B();
|
||||
epsilonMean = nm1Coeff*epsilonMean + nCoeff*sgsModel->epsilon();
|
||||
|
||||
pPrime2Mean += sqr(pMean);
|
||||
pMean = nm1Coeff*pMean + nCoeff*p;
|
||||
pPrime2Mean = nm1Coeff*pPrime2Mean + nCoeff*sqr(p) - sqr(pMean);
|
@ -1,234 +0,0 @@
|
||||
label nAveragingSteps = 1;
|
||||
|
||||
IFstream nAveragingStepsFile
|
||||
(
|
||||
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
|
||||
);
|
||||
|
||||
|
||||
autoPtr<volVectorField> UmeanPtr;
|
||||
autoPtr<volSymmTensorField> RPtr;
|
||||
autoPtr<volSymmTensorField> BmeanPtr;
|
||||
autoPtr<volScalarField> epsilonMeanPtr;
|
||||
|
||||
autoPtr<volScalarField> pMeanPtr;
|
||||
autoPtr<volScalarField> pPrime2MeanPtr;
|
||||
|
||||
if (nAveragingStepsFile.good())
|
||||
{
|
||||
nAveragingStepsFile >> nAveragingSteps;
|
||||
|
||||
Info<< "Reading field Umean\n" << endl;
|
||||
UmeanPtr.reset
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Umean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "\nReading field R\n" << endl;
|
||||
RPtr.reset
|
||||
(
|
||||
new volSymmTensorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"R",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "\nReading field Bmean\n" << endl;
|
||||
BmeanPtr.reset
|
||||
(
|
||||
new volSymmTensorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Bmean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "\nReading field epsilonMean\n" << endl;
|
||||
epsilonMeanPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"epsilonMean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Reading field pMean\n" << endl;
|
||||
pMeanPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pMean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Reading field pPrime2Mean\n" << endl;
|
||||
pPrime2MeanPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pPrime2Mean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Creating field Umean\n" << endl;
|
||||
UmeanPtr.reset
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Umean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
U
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Creating field R\n" << endl;
|
||||
RPtr.reset
|
||||
(
|
||||
new volSymmTensorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"R",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sqr(U) - sqr(UmeanPtr())
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Creating field Bmean\n" << endl;
|
||||
BmeanPtr.reset
|
||||
(
|
||||
new volSymmTensorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Bmean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sgsModel->B()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Creating field epsilonMean\n" << endl;
|
||||
epsilonMeanPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"epsilonMean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sgsModel->epsilon()
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Creating field pMean\n" << endl;
|
||||
pMeanPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pMean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
p
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "Creating field pPrime2Mean\n" << endl;
|
||||
pPrime2MeanPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pPrime2Mean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sqr(p) - sqr(pMeanPtr())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
volVectorField& Umean = UmeanPtr();
|
||||
volSymmTensorField& R = RPtr();
|
||||
volSymmTensorField& Bmean = BmeanPtr();
|
||||
volScalarField& epsilonMean = epsilonMeanPtr();
|
||||
|
||||
volScalarField& pMean = pMeanPtr();
|
||||
volScalarField& pPrime2Mean = pPrime2MeanPtr();
|
@ -42,16 +42,11 @@ Description
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMeshNoClear.H"
|
||||
# include "createFields.H"
|
||||
# include "createAverages.H"
|
||||
# include "initContinuityErrs.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
#include "createMeshNoClear.H"
|
||||
#include "createFields.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
@ -59,8 +54,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "readPISOControls.H"
|
||||
# include "CourantNo.H"
|
||||
#include "readPISOControls.H"
|
||||
#include "CourantNo.H"
|
||||
|
||||
sgsModel->correct();
|
||||
|
||||
@ -76,9 +71,7 @@ int main(int argc, char *argv[])
|
||||
solve(UEqn == -fvc::grad(p));
|
||||
}
|
||||
|
||||
|
||||
// --- PISO loop
|
||||
|
||||
for (int corr=0; corr<nCorr; corr++)
|
||||
{
|
||||
volScalarField rUA = 1.0/UEqn.A();
|
||||
@ -113,19 +106,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
# include "continuityErrs.H"
|
||||
#include "continuityErrs.H"
|
||||
|
||||
U -= rUA*fvc::grad(p);
|
||||
U.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
# include "calculateAverages.H"
|
||||
|
||||
runTime.write();
|
||||
|
||||
# include "writeNaveragingSteps.H"
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
@ -1,18 +0,0 @@
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
OFstream nAveragingStepsFile
|
||||
(
|
||||
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
|
||||
);
|
||||
|
||||
if (nAveragingStepsFile.good())
|
||||
{
|
||||
nAveragingStepsFile << nAveragingSteps << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open file " << nAveragingStepsFile.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
@ -60,24 +60,19 @@ Description
|
||||
|
||||
#define divDevRhoReff divDevRhoBeff
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
# include "setRootCase.H"
|
||||
|
||||
# include "createTime.H"
|
||||
# include "createMeshNoClear.H"
|
||||
# include "readEnvironmentalProperties.H"
|
||||
# include "createFields.H"
|
||||
# include "readPISOControls.H"
|
||||
# include "readCombustionProperties.H"
|
||||
# include "createAverages.H"
|
||||
# include "initContinuityErrs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#include "createTime.H"
|
||||
#include "createMeshNoClear.H"
|
||||
#include "readEnvironmentalProperties.H"
|
||||
#include "createFields.H"
|
||||
#include "readPISOControls.H"
|
||||
#include "readCombustionProperties.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
@ -85,36 +80,32 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
# include "compressibleCourantNo.H"
|
||||
#include "compressibleCourantNo.H"
|
||||
|
||||
# include "rhoEqn.H"
|
||||
#include "rhoEqn.H"
|
||||
|
||||
turbulence->correct();
|
||||
|
||||
# include "UEqn.H"
|
||||
#include "UEqn.H"
|
||||
|
||||
// --- PISO loop
|
||||
for (int corr=1; corr<=nCorr; corr++)
|
||||
{
|
||||
# include "ftEqn.H"
|
||||
# include "bEqn.H"
|
||||
# include "huEqn.H"
|
||||
# include "hEqn.H"
|
||||
#include "ftEqn.H"
|
||||
#include "bEqn.H"
|
||||
#include "huEqn.H"
|
||||
#include "hEqn.H"
|
||||
|
||||
if (!ign.ignited())
|
||||
{
|
||||
hu == h;
|
||||
}
|
||||
|
||||
# include "pEqn.H"
|
||||
#include "pEqn.H"
|
||||
}
|
||||
|
||||
# include "calculateAverages.H"
|
||||
|
||||
runTime.write();
|
||||
|
||||
# include "writeNaveragingSteps.H"
|
||||
|
||||
rho = thermo->rho();
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
|
@ -1,16 +0,0 @@
|
||||
nAveragingSteps++;
|
||||
|
||||
scalar nm1Coeff = scalar(nAveragingSteps - 1)/nAveragingSteps;
|
||||
scalar nCoeff = 1.0/nAveragingSteps;
|
||||
|
||||
R += sqr(Umean);
|
||||
Umean = nm1Coeff*Umean + nCoeff*U;
|
||||
R = nm1Coeff*R + nCoeff*sqr(U) - sqr(Umean);
|
||||
|
||||
pPrime2Mean += sqr(pMean);
|
||||
pMean = nm1Coeff*pMean + nCoeff*p;
|
||||
pPrime2Mean = nm1Coeff*pPrime2Mean + nCoeff*sqr(p) - sqr(pMean);
|
||||
|
||||
Tmean = nm1Coeff*Tmean + nCoeff*T;
|
||||
bmean = nm1Coeff*bmean + nCoeff*b;
|
||||
Ximean = nm1Coeff*Ximean + nCoeff*Xi;
|
@ -1,229 +0,0 @@
|
||||
label nAveragingSteps = 1;
|
||||
|
||||
IFstream nAveragingStepsFile
|
||||
(
|
||||
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
|
||||
);
|
||||
|
||||
volVectorField* UmeanPtr;
|
||||
volSymmTensorField* RPtr;
|
||||
|
||||
volScalarField* pMeanPtr;
|
||||
volScalarField* pPrime2MeanPtr;
|
||||
|
||||
volScalarField* TmeanPtr;
|
||||
volScalarField* bmeanPtr;
|
||||
volScalarField* XimeanPtr;
|
||||
|
||||
if (nAveragingStepsFile.good())
|
||||
{
|
||||
nAveragingStepsFile >> nAveragingSteps;
|
||||
|
||||
Info << "Reading field Umean\n" << endl;
|
||||
UmeanPtr = new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Umean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "\nReading field R\n" << endl;
|
||||
RPtr = new volSymmTensorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"R",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "Reading field pMean\n" << endl;
|
||||
pMeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pMean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "Reading field pPrime2Mean\n" << endl;
|
||||
pPrime2MeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pPrime2Mean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info << "Reading field Tmean\n" << endl;
|
||||
TmeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Tmean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info << "Reading field bmean\n" << endl;
|
||||
bmeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"bmean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info << "Reading field Ximean\n" << endl;
|
||||
XimeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Ximean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info << "Creating field Umean\n" << endl;
|
||||
UmeanPtr = new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Umean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
U
|
||||
);
|
||||
|
||||
Info<< "Creating field R\n" << endl;
|
||||
RPtr = new volSymmTensorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"R",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sqr(U) - sqr(*UmeanPtr)
|
||||
);
|
||||
|
||||
Info<< "Creating field pMean\n" << endl;
|
||||
pMeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pMean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
p
|
||||
);
|
||||
|
||||
Info<< "Creating field pPrime2Mean\n" << endl;
|
||||
pPrime2MeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pPrime2Mean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
sqr(p) - sqr(*pMeanPtr)
|
||||
);
|
||||
|
||||
Info << "Creating field Tmean\n" << endl;
|
||||
TmeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Tmean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
T
|
||||
);
|
||||
|
||||
Info << "Creating field bmean\n" << endl;
|
||||
bmeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"bmean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
b
|
||||
);
|
||||
|
||||
Info << "Creating field Ximean\n" << endl;
|
||||
XimeanPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Ximean",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
Xi
|
||||
);
|
||||
}
|
||||
|
||||
volVectorField& Umean = *UmeanPtr;
|
||||
volSymmTensorField& R = *RPtr;
|
||||
|
||||
volScalarField& pMean = *pMeanPtr;
|
||||
volScalarField& pPrime2Mean = *pPrime2MeanPtr;
|
||||
|
||||
volScalarField& Tmean = *TmeanPtr;
|
||||
volScalarField& bmean = *bmeanPtr;
|
||||
volScalarField& Ximean = *XimeanPtr;
|
@ -1,18 +0,0 @@
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
OFstream nAveragingStepsFile
|
||||
(
|
||||
runTime.path()/runTime.timeName()/"uniform"/"nAveragingSteps.raw"
|
||||
);
|
||||
|
||||
if (nAveragingStepsFile.good())
|
||||
{
|
||||
nAveragingStepsFile << nAveragingSteps << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open file " << nAveragingStepsFile.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
@ -1,8 +1,3 @@
|
||||
cavitatingFoam.C
|
||||
compressibilityModels/compressibilityModel/compressibilityModel.C
|
||||
compressibilityModels/compressibilityModel/newCompressibilityModel.C
|
||||
compressibilityModels/linear/linear.C
|
||||
compressibilityModels/Wallis/Wallis.C
|
||||
compressibilityModels/Chung/Chung.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/cavitatingFoam
|
||||
|
@ -1,6 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-IcompressibilityModels/compressibilityModel
|
||||
-I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume
|
||||
-lfiniteVolume \
|
||||
-lbarotropicCompressibilityModel
|
||||
|
@ -30,7 +30,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "compressibilityModel.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
@ -39,12 +39,13 @@
|
||||
);
|
||||
gamma.oldTime();
|
||||
|
||||
Info<< "Creating compressibilityModel\n" << endl;
|
||||
autoPtr<compressibilityModel> psiModel = compressibilityModel::New
|
||||
(
|
||||
thermodynamicProperties,
|
||||
gamma
|
||||
);
|
||||
Info<< "Creating barotropicompressibilityModel\n" << endl;
|
||||
autoPtr<barotropicCompressibilityModel> psiModel =
|
||||
barotropicCompressibilityModel::New
|
||||
(
|
||||
thermodynamicProperties,
|
||||
gamma
|
||||
);
|
||||
|
||||
const volScalarField& psi = psiModel->psi();
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,5 @@
|
||||
lesCavitatingFoam.C
|
||||
|
||||
devOneEqEddy/devOneEqEddy.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/lesCavitatingFoam
|
@ -0,0 +1,16 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
|
||||
-I$(LIB_SRC)/LESmodels \
|
||||
-I$(LIB_SRC)/LESmodels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/LESmodels/LESdeltas/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lincompressibleTransportModels \
|
||||
-lincompressibleLESmodels \
|
||||
-lfiniteVolume \
|
||||
-lbarotropicCompressibilityModel
|
||||
|
21
applications/solvers/multiphase/lesCavitatingFoam/UEqn.H
Normal file
21
applications/solvers/multiphase/lesCavitatingFoam/UEqn.H
Normal file
@ -0,0 +1,21 @@
|
||||
surfaceScalarField gammaf = fvc::interpolate(gamma);
|
||||
surfaceScalarField muf
|
||||
(
|
||||
"muf",
|
||||
gammaf*muv + (1.0 - gammaf)*mul
|
||||
+ fvc::interpolate(rho*turbulence->nuSgs())
|
||||
);
|
||||
|
||||
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));
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
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;
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
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;
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
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
|
||||
);
|
@ -0,0 +1,85 @@
|
||||
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 compressibilityModel\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"
|
||||
|
||||
Info<< "Reading transportProperties\n" << endl;
|
||||
|
||||
twoPhaseMixture twoPhaseProperties(U, phiv, "gamma");
|
||||
|
||||
// Create LES model
|
||||
autoPtr<LESmodel> turbulence
|
||||
(
|
||||
LESmodel::New(U, phiv, twoPhaseProperties)
|
||||
);
|
@ -0,0 +1,118 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "devOneEqEddy.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace LESmodels
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(devOneEqEddy, 0);
|
||||
addToRunTimeSelectionTable(LESmodel, devOneEqEddy, dictionary);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
devOneEqEddy::devOneEqEddy
|
||||
(
|
||||
const volVectorField& U,
|
||||
const surfaceScalarField& phi,
|
||||
transportModel& transport
|
||||
)
|
||||
:
|
||||
LESmodel(typeName, U, phi, transport),
|
||||
GenEddyVisc(U, phi, transport),
|
||||
|
||||
k_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"k",
|
||||
runTime_.timeName(),
|
||||
mesh_,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_
|
||||
),
|
||||
|
||||
ck_(LESmodelProperties().lookup("ck"))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void devOneEqEddy::correct(const tmp<volTensorField>& gradU)
|
||||
{
|
||||
GenEddyVisc::correct(gradU);
|
||||
|
||||
//volScalarField G = 2*nuSgs_*magSqr(symm(gradU));
|
||||
volScalarField G = 2*nuSgs_*(gradU() && dev(symm(gradU())));
|
||||
|
||||
solve
|
||||
(
|
||||
fvm::ddt(k_)
|
||||
+ fvm::div(phi(), k_)
|
||||
- fvm::Sp(fvc::div(phi()), k_)
|
||||
- fvm::laplacian(DkEff(), k_)
|
||||
==
|
||||
G
|
||||
- fvm::Sp(ce_*sqrt(k_)/delta(), k_)
|
||||
);
|
||||
|
||||
bound(k_, k0());
|
||||
|
||||
nuSgs_ = ck_*sqrt(k_)*delta();
|
||||
nuSgs_.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
bool devOneEqEddy::read()
|
||||
{
|
||||
if (GenEddyVisc::read())
|
||||
{
|
||||
LESmodelProperties().lookup("ck") >> ck_;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace LESmodels
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,145 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
devOneEqEddy
|
||||
|
||||
Description
|
||||
<pre>
|
||||
One Equation Eddy Viscosity Model
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Eddy viscosity SGS model using a modeled balance equation to simulate the
|
||||
behaviour of k, hence,
|
||||
|
||||
d/dt(k) + div(U*k) - div(nuEff*grad(k))
|
||||
=
|
||||
-B*L - ce*k^3/2/delta
|
||||
|
||||
and
|
||||
|
||||
B = 2/3*k*I - 2*nuEff*dev(D)
|
||||
|
||||
where
|
||||
|
||||
D = symm(grad(U));
|
||||
nuSgs = ck*sqrt(k)*delta
|
||||
nuEff = nuSgs + nu
|
||||
</pre>
|
||||
|
||||
SourceFiles
|
||||
devOneEqEddy.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef devOneEqEddy_H
|
||||
#define devOneEqEddy_H
|
||||
|
||||
#include "GenEddyVisc.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace LESmodels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class devOneEqEddy Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class devOneEqEddy
|
||||
:
|
||||
public GenEddyVisc
|
||||
{
|
||||
// Private data
|
||||
|
||||
volScalarField k_;
|
||||
|
||||
dimensionedScalar ck_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
// Disallow default bitwise copy construct and assignment
|
||||
devOneEqEddy(const devOneEqEddy&);
|
||||
devOneEqEddy& operator=(const devOneEqEddy&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("devOneEqEddy");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Constructor from components
|
||||
devOneEqEddy
|
||||
(
|
||||
const volVectorField& U,
|
||||
const surfaceScalarField& phi,
|
||||
transportModel& transport
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~devOneEqEddy()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return SGS kinetic energy
|
||||
tmp<volScalarField> k() const
|
||||
{
|
||||
return k_;
|
||||
}
|
||||
|
||||
//- Return the effective diffusivity for k
|
||||
tmp<volScalarField> DkEff() const
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
(
|
||||
new volScalarField("DkEff", nuSgs_ + nu())
|
||||
);
|
||||
}
|
||||
|
||||
//- Correct Eddy-Viscosity and related properties
|
||||
void correct(const tmp<volTensorField>& gradU);
|
||||
|
||||
//- Read turbulenceProperties dictionary
|
||||
bool read();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace LESmodels
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
10
applications/solvers/multiphase/lesCavitatingFoam/gammaPsi.H
Normal file
10
applications/solvers/multiphase/lesCavitatingFoam/gammaPsi.H
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
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;
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
rasCavitatingFoam
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
#include "twoPhaseMixture.H"
|
||||
#include "incompressible/LESmodel/LESmodel.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 "createAverages.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;
|
||||
|
||||
turbulence->correct();
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
# include "calculateAverages.H"
|
||||
|
||||
runTime.write();
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
Info<< "\n end \n";
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
80
applications/solvers/multiphase/lesCavitatingFoam/pEqn.H
Normal file
80
applications/solvers/multiphase/lesCavitatingFoam/pEqn.H
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
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"
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#include "readTimeControls.H"
|
||||
|
||||
scalar maxAcousticCo
|
||||
(
|
||||
readScalar(runTime.controlDict().lookup("maxAcousticCo"))
|
||||
);
|
||||
|
||||
|
||||
#include "readPISOControls.H"
|
@ -0,0 +1,27 @@
|
||||
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"));
|
@ -0,0 +1,23 @@
|
||||
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")
|
||||
);
|
@ -0,0 +1,15 @@
|
||||
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]);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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]);
|
||||
}
|
||||
}
|
16
applications/solvers/multiphase/lesCavitatingFoam/rhoEqn.H
Normal file
16
applications/solvers/multiphase/lesCavitatingFoam/rhoEqn.H
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
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);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,3 @@
|
||||
rasCavitatingFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/rasCavitatingFoam
|
@ -0,0 +1,14 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/thermophysicalModels/barotropicCompressibilityModel/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lincompressibleTransportModels \
|
||||
-lincompressibleTurbulenceModels \
|
||||
-lfiniteVolume \
|
||||
-lbarotropicCompressibilityModel
|
||||
|
21
applications/solvers/multiphase/rasCavitatingFoam/UEqn.H
Normal file
21
applications/solvers/multiphase/rasCavitatingFoam/UEqn.H
Normal file
@ -0,0 +1,21 @@
|
||||
surfaceScalarField gammaf = fvc::interpolate(gamma);
|
||||
surfaceScalarField muf
|
||||
(
|
||||
"muf",
|
||||
gammaf*muv + (1.0 - gammaf)*mul
|
||||
+ fvc::interpolate(rho*turbulence->nuEff())
|
||||
);
|
||||
|
||||
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));
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
{
|
||||
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;
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
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 compressibilityModel\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"
|
||||
|
||||
Info<< "Reading transportProperties\n" << endl;
|
||||
|
||||
twoPhaseMixture twoPhaseProperties(U, phiv, "gamma");
|
||||
|
||||
// Create RAS turbulence model
|
||||
autoPtr<turbulenceModel> turbulence
|
||||
(
|
||||
turbulenceModel::New(U, phiv, twoPhaseProperties)
|
||||
);
|
10
applications/solvers/multiphase/rasCavitatingFoam/gammaPsi.H
Normal file
10
applications/solvers/multiphase/rasCavitatingFoam/gammaPsi.H
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
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;
|
||||
}
|
80
applications/solvers/multiphase/rasCavitatingFoam/pEqn.H
Normal file
80
applications/solvers/multiphase/rasCavitatingFoam/pEqn.H
Normal file
@ -0,0 +1,80 @@
|
||||
{
|
||||
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"
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
rasCavitatingFoam
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
#include "twoPhaseMixture.H"
|
||||
#include "incompressible/turbulenceModel/turbulenceModel.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"
|
||||
}
|
||||
}
|
||||
|
||||
turbulence->correct();
|
||||
|
||||
runTime.write();
|
||||
|
||||
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
Info<< "\n end \n";
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,9 @@
|
||||
#include "readTimeControls.H"
|
||||
|
||||
scalar maxAcousticCo
|
||||
(
|
||||
readScalar(runTime.controlDict().lookup("maxAcousticCo"))
|
||||
);
|
||||
|
||||
|
||||
#include "readPISOControls.H"
|
@ -0,0 +1,27 @@
|
||||
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"));
|
@ -0,0 +1,23 @@
|
||||
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")
|
||||
);
|
@ -0,0 +1,15 @@
|
||||
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]);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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]);
|
||||
}
|
||||
}
|
16
applications/solvers/multiphase/rasCavitatingFoam/rhoEqn.H
Normal file
16
applications/solvers/multiphase/rasCavitatingFoam/rhoEqn.H
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
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);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,6 @@
|
||||
fieldAverage/fieldAverage.C
|
||||
fieldAverageItem/fieldAverageItem.C
|
||||
fieldAverageItem/fieldAverageItemIO.C
|
||||
fieldAverageFunctionObject/fieldAverageFunctionObject.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfieldAverage
|
@ -0,0 +1,9 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/OpenFOAM/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lOpenFOAM \
|
||||
-lsampling
|
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / 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;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,339 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,293 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,243 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,194 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -211,6 +211,34 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
}
|
||||
|
||||
|
||||
Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recusive
|
||||
)
|
||||
{
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
|
||||
|
||||
if (iter == hashedEntries_.end())
|
||||
{
|
||||
if (recusive && &parent_ != &dictionary::null)
|
||||
{
|
||||
return const_cast<dictionary&>(parent_).lookupEntryPtr
|
||||
(
|
||||
keyword,
|
||||
recusive
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return iter();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry& Foam::dictionary::lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
@ -293,6 +321,28 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
|
||||
{
|
||||
if (entry* entryPtr = lookupEntryPtr(keyword))
|
||||
{
|
||||
return entryPtr->dict();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If keyword not found print error message ...
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"dictionary::subDict(const word& keyword) const",
|
||||
*this
|
||||
) << " keyword " << keyword << " is undefined in dictionary "
|
||||
<< name()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return entryPtr->dict();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::dictionary::toc() const
|
||||
{
|
||||
wordList keywords(size());
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
//- Read dictionary from Istream
|
||||
bool read(Istream&);
|
||||
|
||||
//- Substitute the given keyword prepended by '$' with the
|
||||
//- Substitute the given keyword prepended by '$' with the
|
||||
// corresponding sub-dictionary entries
|
||||
bool substituteKeyword(const word& keyword);
|
||||
|
||||
@ -179,6 +179,11 @@ public:
|
||||
// If recusive search parent dictionaries
|
||||
const entry* lookupEntryPtr(const word&, bool recusive=false) const;
|
||||
|
||||
//- Find and return an entry data stream pointer for manipulation
|
||||
// if present otherwise return NULL.
|
||||
// If recusive search parent dictionaries
|
||||
entry* lookupEntryPtr(const word&, bool recusive=false);
|
||||
|
||||
//- Find and return an entry data stream if present otherwise error.
|
||||
// If recusive search parent dictionaries
|
||||
const entry& lookupEntry(const word&, bool recusive=false) const;
|
||||
@ -202,6 +207,9 @@ public:
|
||||
//- Find and return a sub-dictionary
|
||||
const dictionary& subDict(const word&) const;
|
||||
|
||||
//- Find and return a sub-dictionary for manipulation
|
||||
dictionary& subDict(const word&);
|
||||
|
||||
//- Return the table of contents
|
||||
wordList toc() const;
|
||||
|
||||
@ -262,7 +270,7 @@ public:
|
||||
void clear();
|
||||
|
||||
|
||||
// Write
|
||||
// Write
|
||||
|
||||
void write(Ostream& os, bool subDict = true) const;
|
||||
|
||||
@ -303,7 +311,7 @@ public:
|
||||
// those from dict2.
|
||||
// Warn, but do not overwrite the entries from dict1.
|
||||
dictionary operator+(const dictionary& dict1, const dictionary& dict2);
|
||||
|
||||
|
||||
// Combine dictionaries starting from the entries in dict one and then including
|
||||
// those from dict2.
|
||||
// Do not overwrite the entries from dict1.
|
||||
|
@ -14,4 +14,5 @@ wmake libso laminarFlameSpeed
|
||||
wmake libso chemistryModel
|
||||
wmake libso pdfs
|
||||
wmake libso radiation
|
||||
wmake libso barotropicCompressibilityModel
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace compressibilityModels
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(Chung, 0);
|
||||
addToRunTimeSelectionTable(compressibilityModel, Chung, dictionary);
|
||||
addToRunTimeSelectionTable(barotropicCompressibilityModel, Chung, dictionary);
|
||||
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ Foam::compressibilityModels::Chung::Chung
|
||||
const volScalarField& gamma
|
||||
)
|
||||
:
|
||||
compressibilityModel(compressibilityProperties, gamma),
|
||||
barotropicCompressibilityModel(compressibilityProperties, gamma),
|
||||
psiv_(compressibilityProperties_.lookup("psiv")),
|
||||
psil_(compressibilityProperties_.lookup("psil")),
|
||||
rhovSat_(compressibilityProperties_.lookup("rhovSat")),
|
||||
@ -81,7 +81,7 @@ bool Foam::compressibilityModels::Chung::read
|
||||
const dictionary& compressibilityProperties
|
||||
)
|
||||
{
|
||||
compressibilityModel::read(compressibilityProperties);
|
||||
barotropicCompressibilityModel::read(compressibilityProperties);
|
||||
|
||||
compressibilityProperties_.lookup("psiv") >> psiv_;
|
||||
compressibilityProperties_.lookup("psil") >> psil_;
|
@ -36,7 +36,7 @@ SourceFiles
|
||||
#ifndef Chung_H
|
||||
#define Chung_H
|
||||
|
||||
#include "compressibilityModel.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -52,7 +52,7 @@ namespace compressibilityModels
|
||||
|
||||
class Chung
|
||||
:
|
||||
public compressibilityModel
|
||||
public barotropicCompressibilityModel
|
||||
{
|
||||
// Private data
|
||||
|
@ -0,0 +1,7 @@
|
||||
barotropicCompressibilityModel/barotropicCompressibilityModel.C
|
||||
barotropicCompressibilityModel/newBarotropicCompressibilityModel.C
|
||||
linear/linear.C
|
||||
Wallis/Wallis.C
|
||||
Chung/Chung.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libbarotropicCompressibilityModel
|
@ -0,0 +1,5 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume
|
@ -35,7 +35,7 @@ namespace compressibilityModels
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(Wallis, 0);
|
||||
addToRunTimeSelectionTable(compressibilityModel, Wallis, dictionary);
|
||||
addToRunTimeSelectionTable(barotropicCompressibilityModel, Wallis, dictionary);
|
||||
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ Foam::compressibilityModels::Wallis::Wallis
|
||||
const volScalarField& gamma
|
||||
)
|
||||
:
|
||||
compressibilityModel(compressibilityProperties, gamma),
|
||||
barotropicCompressibilityModel(compressibilityProperties, gamma),
|
||||
psiv_(compressibilityProperties_.lookup("psiv")),
|
||||
psil_(compressibilityProperties_.lookup("psil")),
|
||||
rhovSat_(compressibilityProperties_.lookup("rhovSat")),
|
||||
@ -72,7 +72,7 @@ bool Foam::compressibilityModels::Wallis::read
|
||||
const dictionary& compressibilityProperties
|
||||
)
|
||||
{
|
||||
compressibilityModel::read(compressibilityProperties);
|
||||
barotropicCompressibilityModel::read(compressibilityProperties);
|
||||
|
||||
compressibilityProperties_.lookup("psiv") >> psiv_;
|
||||
compressibilityProperties_.lookup("psil") >> psil_;
|
@ -36,7 +36,7 @@ SourceFiles
|
||||
#ifndef Wallis_H
|
||||
#define Wallis_H
|
||||
|
||||
#include "compressibilityModel.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -52,7 +52,7 @@ namespace compressibilityModels
|
||||
|
||||
class Wallis
|
||||
:
|
||||
public compressibilityModel
|
||||
public barotropicCompressibilityModel
|
||||
{
|
||||
// Private data
|
||||
|
@ -23,23 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
InClass
|
||||
compressibilityModel
|
||||
barotropicCompressibilityModel
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "compressibilityModel.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(compressibilityModel, 0);
|
||||
defineRunTimeSelectionTable(compressibilityModel, dictionary);
|
||||
defineTypeNameAndDebug(barotropicCompressibilityModel, 0);
|
||||
defineRunTimeSelectionTable(barotropicCompressibilityModel, dictionary);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::compressibilityModel::compressibilityModel
|
||||
Foam::barotropicCompressibilityModel::barotropicCompressibilityModel
|
||||
(
|
||||
const dictionary& compressibilityProperties,
|
||||
const volScalarField& gamma
|
||||
@ -63,7 +63,7 @@ Foam::compressibilityModel::compressibilityModel
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::compressibilityModel::read
|
||||
bool Foam::barotropicCompressibilityModel::read
|
||||
(
|
||||
const dictionary& compressibilityProperties
|
||||
)
|
@ -23,18 +23,18 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::compressibilityModel
|
||||
Foam::barotropicCompressibilityModel
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
compressibilityModel.C
|
||||
newCompressibilityModel.C
|
||||
barotropicCompressibilityModel.C
|
||||
newbarotropicCompressibilityModel.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef compressibilityModel_H
|
||||
#define compressibilityModel_H
|
||||
#ifndef barotropicCompressibilityModel_H
|
||||
#define barotropicCompressibilityModel_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "typeInfo.H"
|
||||
@ -49,10 +49,10 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class compressibilityModel Declaration
|
||||
Class barotropicCompressibilityModel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class compressibilityModel
|
||||
class barotropicCompressibilityModel
|
||||
{
|
||||
|
||||
protected:
|
||||
@ -68,16 +68,16 @@ protected:
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow copy construct
|
||||
compressibilityModel(const compressibilityModel&);
|
||||
barotropicCompressibilityModel(const barotropicCompressibilityModel&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const compressibilityModel&);
|
||||
void operator=(const barotropicCompressibilityModel&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("compressibilityModel");
|
||||
TypeName("barotropicCompressibilityModel");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
@ -85,7 +85,7 @@ public:
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
compressibilityModel,
|
||||
barotropicCompressibilityModel,
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& compressibilityProperties,
|
||||
@ -98,7 +98,7 @@ public:
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected compressibility model
|
||||
static autoPtr<compressibilityModel> New
|
||||
static autoPtr<barotropicCompressibilityModel> New
|
||||
(
|
||||
const dictionary& compressibilityProperties,
|
||||
const volScalarField& gamma
|
||||
@ -108,7 +108,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
compressibilityModel
|
||||
barotropicCompressibilityModel
|
||||
(
|
||||
const dictionary& compressibilityProperties,
|
||||
const volScalarField& gamma
|
||||
@ -117,7 +117,7 @@ public:
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~compressibilityModel()
|
||||
virtual ~barotropicCompressibilityModel()
|
||||
{}
|
||||
|
||||
|
@ -24,40 +24,41 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "compressibilityModel.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::compressibilityModel> Foam::compressibilityModel::New
|
||||
Foam::autoPtr<Foam::barotropicCompressibilityModel>
|
||||
Foam::barotropicCompressibilityModel::New
|
||||
(
|
||||
const dictionary& compressibilityProperties,
|
||||
const volScalarField& gamma
|
||||
)
|
||||
{
|
||||
word compressibilityModelTypeName
|
||||
word bcModelTypeName
|
||||
(
|
||||
compressibilityProperties.lookup("compressibilityModel")
|
||||
compressibilityProperties.lookup("barotropicCompressibilityModel")
|
||||
);
|
||||
|
||||
Info<< "Selecting compressibility model "
|
||||
<< compressibilityModelTypeName << endl;
|
||||
<< bcModelTypeName << endl;
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(compressibilityModelTypeName);
|
||||
dictionaryConstructorTablePtr_->find(bcModelTypeName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"compressibilityModel::New(const volScalarField&)"
|
||||
) << "Unknown compressibilityModel type "
|
||||
<< compressibilityModelTypeName << endl << endl
|
||||
<< "Valid compressibilityModels are : " << endl
|
||||
"barotropicCompressibilityModel::New(const volScalarField&)"
|
||||
) << "Unknown barotropicCompressibilityModel type "
|
||||
<< bcModelTypeName << endl << endl
|
||||
<< "Valid barotropicCompressibilityModels are : " << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<compressibilityModel>
|
||||
return autoPtr<barotropicCompressibilityModel>
|
||||
(
|
||||
cstrIter()(compressibilityProperties, gamma)
|
||||
);
|
@ -35,7 +35,7 @@ namespace compressibilityModels
|
||||
{
|
||||
|
||||
defineTypeNameAndDebug(linear, 0);
|
||||
addToRunTimeSelectionTable(compressibilityModel, linear, dictionary);
|
||||
addToRunTimeSelectionTable(barotropicCompressibilityModel, linear, dictionary);
|
||||
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ Foam::compressibilityModels::linear::linear
|
||||
const volScalarField& gamma
|
||||
)
|
||||
:
|
||||
compressibilityModel(compressibilityProperties, gamma),
|
||||
barotropicCompressibilityModel(compressibilityProperties, gamma),
|
||||
psiv_(compressibilityProperties_.lookup("psiv")),
|
||||
psil_(compressibilityProperties_.lookup("psil"))
|
||||
{
|
||||
@ -70,7 +70,7 @@ bool Foam::compressibilityModels::linear::read
|
||||
const dictionary& compressibilityProperties
|
||||
)
|
||||
{
|
||||
compressibilityModel::read(compressibilityProperties);
|
||||
barotropicCompressibilityModel::read(compressibilityProperties);
|
||||
|
||||
compressibilityProperties_.lookup("psiv") >> psiv_;
|
||||
compressibilityProperties_.lookup("psil") >> psil_;
|
@ -36,7 +36,7 @@ SourceFiles
|
||||
#ifndef linear_H
|
||||
#define linear_H
|
||||
|
||||
#include "compressibilityModel.H"
|
||||
#include "barotropicCompressibilityModel.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -52,7 +52,7 @@ namespace compressibilityModels
|
||||
|
||||
class linear
|
||||
:
|
||||
public compressibilityModel
|
||||
public barotropicCompressibilityModel
|
||||
{
|
||||
// Private data
|
||||
|
Loading…
Reference in New Issue
Block a user