Merge remote-tracking branch 'origin/nr/equationReaderFix' into nextRelease

This commit is contained in:
Henrik Rusche 2013-08-30 12:12:42 +02:00
commit b3c75bcab5
106 changed files with 19052 additions and 13619 deletions

View file

@ -0,0 +1,14 @@
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I../../../../src/equationReader/lnInclude
EXE_LIBS = \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lequationReader

View file

@ -0,0 +1,16 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
);
UEqn().relax();
eqnResidual = solve
(
UEqn() == -fvc::grad(p)
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);

View file

@ -0,0 +1,9 @@
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}

View file

@ -0,0 +1,42 @@
Info << "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info << "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);

View file

@ -26,146 +26,74 @@ Application
equationReaderDemo equationReaderDemo
Description Description
Sample application testing the equationReader extension, and demonstrating simpleFOAM with an equationReader for demonstration purposes
its use.
Author Author
David L. F. Gaden David L. F. Gaden
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "argList.H" #include "singlePhaseTransportModel.H"
#include "IFstream.H" #include "RASModel.H"
#include "OFstream.H" #include "IOEquationReader.H"
#include "equationReader.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
# include "createEquationReader.H"
# include "loadEquationData.H"
# include "initializeSourceFields.H"
# include "initContinuityErrs.H"
fileName path(args.rootPath()/args.caseName()); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Create dictionary Info<< "\nStarting time loop\n" << endl;
Info << "Reading testDict dictionary" << token::NL << endl;
IFstream tfIF(path/"testDict");
const dictionary testDict(tfIF);
// Demonstrate stand-alone operation while (runTime.loop())
Info << "Begin stand-alone operation..." << endl; {
Info<< "Time = " << runTime.timeName() << nl << endl;
Info << "Reading a scalar... "; dictionary simple = mesh.solutionDict().subDict("SIMPLE");
scalar readSa(readScalar(testDict.lookup("standAloneScalar")));
Info << "done. Result = " << readSa << endl;
Info << "Reading a dimensionedScalar ... ";
dimensionedScalar readDSa(testDict.lookup("standAloneDScalar"));
Info << "done. Result = " << readDSa << token::NL << endl;
// Create the equationReader object int nNonOrthCorr =
Info << "Creating the equationReader object" << token::NL << endl; simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
equationReader eqns;
// Demonstrate giving data sources to equationReader bool momentumPredictor =
// -First create the data sources simple.lookupOrDefault<Switch>("momentumPredictor", true);
Info << "Creating data sources: dictionary ptrs... ";
IFstream tfIF2(path/"testDict2");
const dictionary testDict2(tfIF2);
IFstream tfIF3(path/"testDict3");
const dictionary testDict3(tfIF3);
Info << "scalars... ";
scalar Sa(0.1);
scalar Sb(0.2);
scalar Sc(0.3);
Info << "dimensionedScalar ptrs... ";
dimensionedScalar DSa("DSa", dimless, 1);
dimensionedScalar DSb("DSb", dimless, 2);
dimensionedScalar DSc("DSc", dimless, 3);
Info << "output dimensionedScalar ptrs... ";
dimensionedScalar passiveOutA("passiveOutA", dimless, 0);
dimensionedScalar activeOutB("activeOutB", dimless, 0);
dimensionedScalar passiveOutC("passiveOutC", dimless, 0);
dimensionedScalar passiveOutD("passiveOutD", dimless, 0);
dimensionedScalar passiveOutF("passiveOutF", dimless, 0);
Info << "done." << endl;
Info << "Linking in the data sources: dictionary ptrs... "; # include "initConvergenceCheck.H"
eqns.addDataSource(testDict);
eqns.addDataSource(testDict2);
eqns.addDataSource(testDict3);
Info << "dimensionedScalar ptrs... "; p.storePrevIter();
eqns.addDataSource(DSa);
eqns.addDataSource(DSb);
eqns.addDataSource(DSc);
Info << "scalar ptrs... "; // Pressure-velocity SIMPLE corrector
eqns.addDataSource(Sa, "Sa"); {
eqns.addDataSource(Sb, "Sb"); # include "UEqn.H"
eqns.addDataSource(Sc, "Sc"); # include "pEqn.H"
Info << "done." << token::NL << endl;
// Demonstrate passive output
Info << "Reading equation a from testDict with no output variable" << endl;
eqns.readEquation(testDict, "a");
Info << "Evaluating equation a ... ";
passiveOutA = eqns.evaluate("a");
Info << "done. Result = " << passiveOutA << token::NL << endl;
// Demonstrate active output
Info << "Reading equation b from testDict, linking an output variable"
<< endl;
eqns.readEquation(testDict, "b", activeOutB);
Info << "Output variable before update() = " << activeOutB << endl;
Info << "Begining .update() - this evaluates all equations with active "
<< "output..." << endl;
eqns.update();
Info << "Done. Output variable after update() = " << activeOutB
<< token::NL << endl;
// Demonstrating variable dependence
Info << "Equation c depends on equation a. Reading it will link them."
<< endl;
Info << "Reading equation c from testDict... ";
eqns.readEquation(testDict, "c");
Info << "done." << endl;
Info << "Evaluating c will force an evaluate of a." << endl;
Info << "Evaluating ... ";
passiveOutC = eqns.evaluate("c");
Info << "done. Result = " << passiveOutC << token::NL << endl;
// Demonstrate on-the-fly equation creation
Info << "Equation d depends on equation e, but equation e is never "
<< "explicitly " << endl << "read by equationReaderDemo. Reading equation"
<< " d will automatically " << endl << "create equation e on-the-fly. "
<< endl;
Info << "Reading equation d from testDict ... ";
eqns.readEquation(testDict, "d");
Info << "done." << endl << "Again, evaluating d will force an evaluate of "
<< "e." << endl;
Info << "Evaluating d ... ";
passiveOutD = eqns.evaluate("d");
Info << "done. The result is = " << passiveOutD << token::NL << endl;
// Demonstrate dependence
Info << "Equations can draw from any sources added to equationReader." << endl;
Info << "Equation f is very complex, drawing from numerous sources." << endl;
Info << "Reading equation f ... ";
eqns.readEquation(testDict, "f");
Info << "done. Evaluating equation f ... ";
passiveOutF = eqns.evaluate("f");
Info << "done." << token::NL << "The result is: " << passiveOutF << endl;
Info << token::NL << "Creating output..." << endl;
OFstream os(path/"outputDict");
os << eqns;
eqns.dataSourceStatus(os);
return(0);
} }
turbulence->correct();
# include "evaluateEquations.H"
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
# include "convergenceCheck.H"
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View file

@ -0,0 +1,157 @@
// Update dependents
eqnSrcR == turbulence->R();
// scalars
scalarOut = eqns.evaluateScalar("sOut");
dimensionedScalarOut = eqns.evaluateDimensionedScalar("dsOut");
eqns.evaluateDimensionedScalarField(dimensionedScalarFieldOut, "dsfOut");
eqns.evaluateGeometricScalarField(volScalarFieldOut, "volSfOut");
// vectors
vectorOut.x() = eqns.evaluateScalar("vOut.x");
vectorOut.y() = eqns.evaluateScalar("vOut.y");
vectorOut.z() = eqns.evaluateScalar("vOut.z");
dimensionedVectorOut.value().x() = eqns.evaluateScalar("dvOut.x");
dimensionedVectorOut.value().y() = eqns.evaluateScalar("dvOut.y");
dimensionedVectorOut.value().z() = eqns.evaluateScalar("dvOut.z");
// There is currently no elegant way to check the dimensions of each
// component of a "dimensionedType". (dimensionedTypeFields and
// GeometricTypeFields work automatically, though.) This is how we do
// it:
dimensionedVectorOut.dimensions() = eqns.evaluateDimensions("dvOut.x");
dimensionedVectorOut.dimensions() = eqns.evaluateDimensions("dvOut.y");
dimensionedVectorOut.dimensions() = eqns.evaluateDimensions("dvOut.z");
eqns.evaluateDimensionedTypeField
(
dimensionedVectorFieldOut,
"x",
"dvfOut.x"
);
eqns.evaluateDimensionedTypeField
(
dimensionedVectorFieldOut,
"y",
"dvfOut.y"
);
eqns.evaluateDimensionedTypeField
(
dimensionedVectorFieldOut,
"z",
"dvfOut.z"
);
eqns.evaluateGeometricTypeField(volVectorFieldOut, "x", "volVfOut.x");
eqns.evaluateGeometricTypeField(volVectorFieldOut, "y", "volVfOut.y");
eqns.evaluateGeometricTypeField(volVectorFieldOut, "z", "volVfOut.z");
// tensors
tensorOut.xx() = eqns.evaluateScalar("tOut.xx");
tensorOut.xy() = eqns.evaluateScalar("tOut.xy");
tensorOut.xz() = eqns.evaluateScalar("tOut.xz");
tensorOut.yx() = eqns.evaluateScalar("tOut.yx");
tensorOut.yy() = eqns.evaluateScalar("tOut.yy");
tensorOut.yz() = eqns.evaluateScalar("tOut.yz");
tensorOut.zx() = eqns.evaluateScalar("tOut.zx");
tensorOut.zy() = eqns.evaluateScalar("tOut.zy");
tensorOut.zz() = eqns.evaluateScalar("tOut.zz");
dimensionedTensorOut.value().xx() = eqns.evaluateScalar("dtOut.xx");
dimensionedTensorOut.value().xy() = eqns.evaluateScalar("dtOut.xy");
dimensionedTensorOut.value().xz() = eqns.evaluateScalar("dtOut.xz");
dimensionedTensorOut.value().yx() = eqns.evaluateScalar("dtOut.yx");
dimensionedTensorOut.value().yy() = eqns.evaluateScalar("dtOut.yy");
dimensionedTensorOut.value().yz() = eqns.evaluateScalar("dtOut.yz");
dimensionedTensorOut.value().zx() = eqns.evaluateScalar("dtOut.zx");
dimensionedTensorOut.value().zy() = eqns.evaluateScalar("dtOut.zy");
dimensionedTensorOut.value().zz() = eqns.evaluateScalar("dtOut.zz");
// There is currently no elegant way to check the dimensions of each
// component of a "dimensionedType". (dimensionedTypeFields and
// GeometricTypeFields work automatically, though.) This is how we do
// it:
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.xx");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.xy");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.xz");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.yx");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.yy");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.yz");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.zx");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.zy");
dimensionedTensorOut.dimensions() = eqns.evaluateDimensions("dtOut.zz");
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"xx",
"dtfOut.xx"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"xy",
"dtfOut.xy"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"xz",
"dtfOut.xz"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"yx",
"dtfOut.yx"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"yy",
"dtfOut.yy"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"yz",
"dtfOut.yz"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"zx",
"dtfOut.zx"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"zy",
"dtfOut.zy"
);
eqns.evaluateDimensionedTypeField
(
dimensionedTensorFieldOut,
"zz",
"dtfOut.zz"
);
eqns.evaluateGeometricTypeField(volTensorFieldOut, "xx", "volTfOut.xx");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "xy", "volTfOut.xy");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "xz", "volTfOut.xz");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "yx", "volTfOut.yx");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "yy", "volTfOut.yy");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "yz", "volTfOut.yz");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "zx", "volTfOut.zx");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "zy", "volTfOut.zy");
eqns.evaluateGeometricTypeField(volTensorFieldOut, "zz", "volTfOut.zz");
// Update the equation output dictionary
eqnOutputDict.set("sOut", scalarOut);
eqnOutputDict.set("dsOut", dimensionedScalarOut);
eqnOutputDict.set("vOut", vectorOut);
eqnOutputDict.set("dvOut", dimensionedVectorOut);
eqnOutputDict.set("tOut", tensorOut);
eqnOutputDict.set("dtOut", dimensionedTensorOut);

View file

@ -0,0 +1,7 @@
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
simple.readIfPresent("convergence", convergenceCriterion);

View file

@ -0,0 +1,191 @@
// Initializing the scalarFields
forAll(sfA, cellIndex)
{
scalar cellValue(scalar(cellIndex) / 100000);
sfA[cellIndex] = 10 + cellValue;
sfB[cellIndex] = 20 + cellValue;
sfC[cellIndex] = 30 + cellValue;
}
// Initializing the volScalarFields
label globalI(0);
forAll(vsfA.internalField(), cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vsfA.internalField()[cellIndex] = 40 + cellValue;
vsfB.internalField()[cellIndex] = 50 + cellValue;
vsfC.internalField()[cellIndex] = 60 + cellValue;
globalI++;
}
forAll(vsfA.boundaryField(), geoIndex)
{
forAll(vsfA.boundaryField()[geoIndex], cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vsfA.boundaryField()[geoIndex][cellIndex] = 40 + cellValue;
vsfB.boundaryField()[geoIndex][cellIndex] = 50 + cellValue;
vsfC.boundaryField()[geoIndex][cellIndex] = 60 + cellValue;
globalI++;
}
}
// Initializing the vectorFields
forAll(vfA, cellIndex)
{
scalar cellValue(scalar(cellIndex) / 100000);
vfA[cellIndex] = vector
(
1000 + cellValue,
1000 + cellValue,
1000 + cellValue
);
vfB[cellIndex] = vector
(
2000 + cellValue,
-2000 - cellValue,
2000 + cellValue
);
vfC[cellIndex] = vector
(
3000 + cellValue,
3000 + cellValue,
-3000 - cellValue
);
}
// Initializing the volVectorFields
globalI = 0;
forAll(vvfA.internalField(), cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vvfA.internalField()[cellIndex] = vector
(
4000 + cellValue,
4000 + cellValue,
4000 + cellValue
);
vvfB.internalField()[cellIndex] = vector
(
5000 + cellValue,
-5000 - cellValue,
5000 + cellValue
);
vvfC.internalField()[cellIndex] = vector
(
6000 + cellValue,
6000 + cellValue,
-6000 - cellValue
);
globalI++;
}
forAll(vvfA.boundaryField(), geoIndex)
{
forAll(vvfA.boundaryField()[geoIndex], cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
vvfA.boundaryField()[geoIndex][cellIndex] = vector
(
4000 + cellValue,
4000 + cellValue,
4000 + cellValue
);
vvfB.boundaryField()[geoIndex][cellIndex] = vector
(
5000 + cellValue,
-5000 - cellValue,
5000 + cellValue
);
vvfC.boundaryField()[geoIndex][cellIndex] = vector
(
6000 + cellValue,
6000 + cellValue,
-6000 - cellValue
);
globalI++;
}
}
// Initializing the tensorFields
forAll(tfA, cellIndex)
{
scalar cellValue(scalar(cellIndex) / 100000);
scalar tA(cellValue + 100000);
scalar tB(cellValue + 200000);
scalar tC(cellValue + 300000);
tfA[cellIndex] = tensor
(
tA, -tA, tA,
-tA, tA, -tA,
tA, -tA, tA
);
tfB[cellIndex] = tensor
(
tB, tB, -tB,
tB, -tB, tB,
-tB, tB, -tB
);
tfC[cellIndex] = tensor
(
tC, tC, -tC,
-tC, tC, tC,
-tC, -tC, tC
);
}
// Initializing the volTectorFields
globalI = 0;
forAll(vtfA.internalField(), cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
scalar tA(cellValue + 400000);
scalar tB(cellValue + 500000);
scalar tC(cellValue + 600000);
vtfA.internalField()[cellIndex] = tensor
(
tA, -tA, tA,
-tA, tA, -tA,
tA, -tA, tA
);
vtfB.internalField()[cellIndex] = tensor
(
tB, tB, -tB,
tB, -tB, tB,
-tB, tB, -tB
);
vtfC.internalField()[cellIndex] = tensor
(
tC, tC, -tC,
-tC, tC, tC,
-tC, -tC, tC
);
globalI++;
}
forAll(vtfA.boundaryField(), geoIndex)
{
forAll(vtfA.boundaryField()[geoIndex], cellIndex)
{
scalar cellValue(scalar(globalI) / 100000);
scalar tA(cellValue + 400000);
scalar tB(cellValue + 500000);
scalar tC(cellValue + 600000);
vtfA.boundaryField()[geoIndex][cellIndex] = tensor
(
tA, -tA, tA,
-tA, tA, -tA,
tA, -tA, tA
);
vtfB.boundaryField()[geoIndex][cellIndex] = tensor
(
tB, tB, -tB,
tB, -tB, tB,
-tB, tB, -tB
);
vtfC.boundaryField()[geoIndex][cellIndex] = tensor
(
tC, tC, -tC,
-tC, tC, tC,
-tC, -tC, tC
);
globalI++;
}
}

View file

@ -0,0 +1,607 @@
// *** Adding data sources ***
// Add time
// We could try addSource(runTime), but since runTime.name()
// constantly changes, we assign it our own name:
eqns.scalarSources().addSource(runTime.value(), "t", dimTime);
// Add mesh coordinates (cell centres) gives variable names:
// C.x, C.y, C.z
eqns.vectorSources().addSource(mesh.C());
// Add mesh volumes
eqns.scalarSources().addSource(mesh.V());
// Add simpleFoam's existing variables
eqns.scalarSources().addSource(p);
eqns.vectorSources().addSource(U);
// Adding a "derived" variable - one that exists only temporarily e.g.:
// turbulence->R() - since it does not permanently exist, this won't
// work:
// eqns.symmTensorSources().addSource(turbulence->R());
// You have to create your own permanent variable, and update it at
// every timestep:
volSymmTensorField eqnSrcR
(
IOobject
(
"R_",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
turbulence->R()
);
eqns.symmTensorSources().addSource(eqnSrcR);
// Add a dictionary source
IOdictionary equationDict
(
IOobject
(
"equationDict",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
eqns.addSource(equationDict);
// Generic sources for demo purposes:
// Scalars
scalar sA(1.0);
scalar sB(2.0);
scalar sC(3.0);
eqns.scalarSources().addSource(sA, "sA");
eqns.scalarSources().addSource(sB, "sB");
eqns.scalarSources().addSource(sC, "sC");
// Dimensioned scalars
dimensionedScalar dsA("dsA", dimless, 4.0);
dimensionedScalar dsB("dsB", dimless, 5.0);
dimensionedScalar dsC("dsC", dimless, 6.0);
eqns.scalarSources().addSource(dsA);
eqns.scalarSources().addSource(dsB);
eqns.scalarSources().addSource(dsC);
// scalarFields
scalarField sfA(mesh.nCells(), 0.0);
scalarField sfB(mesh.nCells(), 0.0);
scalarField sfC(mesh.nCells(), 0.0);
eqns.scalarSources().addSource(sfA, "sfA");
eqns.scalarSources().addSource(sfB, "sfB");
eqns.scalarSources().addSource(sfC, "sfC");
// volScalarFields
volScalarField vsfA
(
IOobject
(
"vsfA",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("vsfA", dimless, 0.0)
);
volScalarField vsfB
(
IOobject
(
"vsfB",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("vsfB", dimless, 0.0)
);
volScalarField vsfC
(
IOobject
(
"vsfC",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("vsfC", dimless, 0.0)
);
eqns.scalarSources().addSource(vsfA);
eqns.scalarSources().addSource(vsfB);
eqns.scalarSources().addSource(vsfC);
// Vectors
vector vA(100.0, 100.0, 100.0);
vector vB(200.0, -200.0, 200.0);
vector vC(300.0, 300.0, -300.0);
eqns.vectorSources().addSource(vA, "vA");
eqns.vectorSources().addSource(vB, "vB");
eqns.vectorSources().addSource(vC, "vC");
dimensionedVector dvA("dvA", dimless, vector(400.0, 400.0, 400.0));
dimensionedVector dvB("dvB", dimless, vector(500.0, -500.0, 500.0));
dimensionedVector dvC("dvC", dimless, vector(600.0, 600.0, -600.0));
eqns.vectorSources().addSource(dvA);
eqns.vectorSources().addSource(dvB);
eqns.vectorSources().addSource(dvC);
// vectorFields
vectorField vfA(mesh.nCells(), vector(0.0, 0.0, 0.0));
vectorField vfB(mesh.nCells(), vector(0.0, 0.0, 0.0));
vectorField vfC(mesh.nCells(), vector(0.0, 0.0, 0.0));
eqns.vectorSources().addSource(vfA, "vfA");
eqns.vectorSources().addSource(vfB, "vfB");
eqns.vectorSources().addSource(vfC, "vfC");
volVectorField vvfA
(
IOobject
(
"vvfA",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector("vvfA", dimless, vector(0.0, 0.0, 0.0))
);
volVectorField vvfB
(
IOobject
(
"vvfB",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector("vvfB", dimless, vector(0.0, 0.0, 0.0))
);
volVectorField vvfC
(
IOobject
(
"vvfC",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedVector("vvfC", dimless, vector(0.0, 0.0, 0.0))
);
eqns.vectorSources().addSource(vvfA);
eqns.vectorSources().addSource(vvfB);
eqns.vectorSources().addSource(vvfC);
// Tensor
tensor tA
(
10000.0, 10000.0, 10000.0,
10000.0, 10000.0, 10000.0,
10000.0, 10000.0, 10000.0
);
tensor tB
(
20000.0, 20000.0, 20000.0,
20000.0, 20000.0, 20000.0,
20000.0, 20000.0, 20000.0
);
tensor tC
(
30000.0, 30000.0, 30000.0,
30000.0, 30000.0, 30000.0,
30000.0, 30000.0, 30000.0
);
eqns.tensorSources().addSource(tA, "tA");
eqns.tensorSources().addSource(tB, "tB");
eqns.tensorSources().addSource(tC, "tC");
dimensionedTensor dtA
(
"dtA",
dimless,
tensor
(
40000.0, 40000.0, 40000.0,
40000.0, 40000.0, 40000.0,
40000.0, 40000.0, 40000.0
)
);
dimensionedTensor dtB
(
"dtB",
dimless,
tensor
(
50000.0, 50000.0, 50000.0,
50000.0, 50000.0, 50000.0,
50000.0, 50000.0, 50000.0
)
);
dimensionedTensor dtC
(
"dtC",
dimless,
tensor
(
60000.0, 60000.0, 60000.0,
60000.0, 60000.0, 60000.0,
60000.0, 60000.0, 60000.0
)
);
eqns.tensorSources().addSource(dtA);
eqns.tensorSources().addSource(dtB);
eqns.tensorSources().addSource(dtC);
// tensorFields
tensorField tfA
(
mesh.nCells(),
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
);
tensorField tfB
(
mesh.nCells(),
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
);
tensorField tfC
(
mesh.nCells(),
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
);
eqns.tensorSources().addSource(tfA, "tfA");
eqns.tensorSources().addSource(tfB, "tfB");
eqns.tensorSources().addSource(tfC, "tfC");
// volTensorFields
volTensorField vtfA
(
IOobject
(
"vtfA",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedTensor
(
"vtfA",
dimless,
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
)
);
volTensorField vtfB
(
IOobject
(
"vtfB",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedTensor
(
"vtfB",
dimless,
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
)
);
volTensorField vtfC
(
IOobject
(
"vtfC",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedTensor
(
"vtfC",
dimless,
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
)
);
eqns.tensorSources().addSource(vtfA);
eqns.tensorSources().addSource(vtfB);
eqns.tensorSources().addSource(vtfC);
// And so on and so forth, including:
// - Types;
// - dimensionedTypes;
// - Fields;
// - DimensionedFields; and
// - GeometricFields,
// where Types can be:
// - scalar
// - vector
// - tensor
// - diagTensor
// - symmTensor
// - sphericalTensor
// *** Reading in the equations ***
// You can read from any dictionary, but I'll just reuse the source
// dictionary we created above.
// scalar equations
eqns.readEquation(equationDict, "sOut");
eqns.readEquation(equationDict, "dsOut");
eqns.readEquation(equationDict, "dsfOut");
eqns.readEquation(equationDict, "volSfOut");
// vector equations
eqns.readEquation(equationDict, "vOut.x");
eqns.readEquation(equationDict, "vOut.y");
eqns.readEquation(equationDict, "vOut.z");
eqns.readEquation(equationDict, "dvOut.x");
eqns.readEquation(equationDict, "dvOut.y");
eqns.readEquation(equationDict, "dvOut.z");
eqns.readEquation(equationDict, "dvfOut.x");
eqns.readEquation(equationDict, "dvfOut.y");
eqns.readEquation(equationDict, "dvfOut.z");
eqns.readEquation(equationDict, "volVfOut.x");
eqns.readEquation(equationDict, "volVfOut.y");
eqns.readEquation(equationDict, "volVfOut.z");
// tensor equations
eqns.readEquation(equationDict, "tOut.xx");
eqns.readEquation(equationDict, "tOut.xy");
eqns.readEquation(equationDict, "tOut.xz");
eqns.readEquation(equationDict, "tOut.yx");
eqns.readEquation(equationDict, "tOut.yy");
eqns.readEquation(equationDict, "tOut.yz");
eqns.readEquation(equationDict, "tOut.zx");
eqns.readEquation(equationDict, "tOut.zy");
eqns.readEquation(equationDict, "tOut.zz");
eqns.readEquation(equationDict, "dtOut.xx");
eqns.readEquation(equationDict, "dtOut.xy");
eqns.readEquation(equationDict, "dtOut.xz");
eqns.readEquation(equationDict, "dtOut.yx");
eqns.readEquation(equationDict, "dtOut.yy");
eqns.readEquation(equationDict, "dtOut.yz");
eqns.readEquation(equationDict, "dtOut.zx");
eqns.readEquation(equationDict, "dtOut.zy");
eqns.readEquation(equationDict, "dtOut.zz");
eqns.readEquation(equationDict, "dtfOut.xx");
eqns.readEquation(equationDict, "dtfOut.xy");
eqns.readEquation(equationDict, "dtfOut.xz");
eqns.readEquation(equationDict, "dtfOut.yx");
eqns.readEquation(equationDict, "dtfOut.yy");
eqns.readEquation(equationDict, "dtfOut.yz");
eqns.readEquation(equationDict, "dtfOut.zx");
eqns.readEquation(equationDict, "dtfOut.zy");
eqns.readEquation(equationDict, "dtfOut.zz");
eqns.readEquation(equationDict, "volTfOut.xx");
eqns.readEquation(equationDict, "volTfOut.xy");
eqns.readEquation(equationDict, "volTfOut.xz");
eqns.readEquation(equationDict, "volTfOut.yx");
eqns.readEquation(equationDict, "volTfOut.yy");
eqns.readEquation(equationDict, "volTfOut.yz");
eqns.readEquation(equationDict, "volTfOut.zx");
eqns.readEquation(equationDict, "volTfOut.zy");
eqns.readEquation(equationDict, "volTfOut.zz");
// *** Create output objects ***
// output dictionary (for objects that don't output themselves)
IOdictionary eqnOutputDict
(
IOobject
(
"eqnOutput",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
)
);
// scalars
scalar scalarOut;
dimensionedScalar dimensionedScalarOut
(
"dsOut",
eqns.evaluateDimensions("dsOut"),
0.0
);
DimensionedField<scalar, volMesh> dimensionedScalarFieldOut
(
IOobject
(
"dsfOut",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar
(
"dsfOut",
eqns.evaluateDimensions("dsfOut"),
0.0
)
);
volScalarField volScalarFieldOut
(
IOobject
(
"volSfOut",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar
(
"volSfOut",
eqns.evaluateDimensions("volSfOut"),
0.0
)
);
// vector
vector vectorOut;
dimensionedVector dimensionedVectorOut
(
"dvOut",
eqns.evaluateDimensions("dvOut.x"),
vector(0.0, 0.0, 0.0)
);
DimensionedField<vector, volMesh> dimensionedVectorFieldOut
(
IOobject
(
"dvfOut",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector
(
"dvfOut",
eqns.evaluateDimensions("dvfOut.x"),
vector(0.0, 0.0, 0.0)
)
);
volVectorField volVectorFieldOut
(
IOobject
(
"volVfOut",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedVector
(
"volVfOut",
eqns.evaluateDimensions("volVfOut.x"),
vector(0.0, 0.0, 0.0)
)
);
// tensors
tensor tensorOut;
dimensionedTensor dimensionedTensorOut
(
"dtOut",
eqns.evaluateDimensions("dtOut.xx"),
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
);
DimensionedField<tensor, volMesh> dimensionedTensorFieldOut
(
IOobject
(
"dtfOut",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedTensor
(
"dtfOut",
eqns.evaluateDimensions("dtfOut.xx"),
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
)
);
volTensorField volTensorFieldOut
(
IOobject
(
"volTfOut",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedTensor
(
"volTfOut",
eqns.evaluateDimensions("volTfOut.xx"),
tensor
(
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0
)
)
);

View file

@ -0,0 +1,44 @@
p.boundaryField().updateCoeffs();
volScalarField AU = UEqn().A();
U = UEqn().H()/AU;
UEqn.clear();
phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);
// Non-orthogonal pressure corrector loop
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(1.0/AU, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
// Retain the residual from the first iteration
if (nonOrth == 0)
{
eqnResidual = pEqn.solve().initialResidual();
maxResidual = max(eqnResidual, maxResidual);
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
# include "continuityErrs.H"
// Explicitly relax pressure for momentum corrector
p.relax();
// Momentum corrector
U -= fvc::grad(p)/AU;
U.correctBoundaryConditions();

View file

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

View file

@ -1,6 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume \

View file

@ -1,74 +0,0 @@
Info<< "Reading transportProperties\n" << endl;
IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
dimensionedScalar nu
(
transportProperties.lookup("nu")
);
Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Creating dummy field\n" << endl;
volScalarField dummy
(
IOobject
(
"dummy",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
p
);
dummy.dimensions().reset(dimless);
Info << "Dummy name " << dummy.name() << endl;
forAll(dummy, i)
{
dummy[i] = i;
}
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);

View file

@ -1,357 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
equationReaderTester
Description
Sample application testing the equationReader in a finite volume solver
environment.
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "IOEquationReader.H"
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
fileName path(args.rootPath()/args.caseName());
// Create the equationReader object
Info << "Creating the equationReader object" << token::NL << endl;
IOEquationReader eqns
(
IOobject
(
"eqns",
runTime.timeName(),
runTime,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
true
);
// Create dictionaries
Info << "Reading testDict dictionaries" << token::NL << endl;
IFstream tfIF1(path/"testDict1");
const dictionary testDict1(tfIF1);
IFstream tfIF2(path/"testDict2");
const dictionary testDict2(tfIF2);
IFstream tfIF3(path/"testDict3");
const dictionary testDict3(tfIF3);
IFstream tfIF4(path/"testDict4");
const dictionary testDict4(tfIF4);
IFstream tfIF5(path/"testDict5");
const dictionary testDict5(tfIF5);
IFstream tfIF6(path/"testDict6");
const dictionary testDict6(tfIF6);
IFstream tfIF7(path/"testDict7");
const dictionary testDict7(tfIF7);
IFstream tfIF8(path/"testDict8");
const dictionary testDict8(tfIF8);
IFstream tfIF9(path/"testDict9");
const dictionary testDict9(tfIF9);
IFstream tfIF10(path/"testDict10");
const dictionary testDict10(tfIF10);
scalar Sa(0.1);
scalar Sb(0.2);
scalar Sc(0.3);
scalar Sd(0.4);
scalar Se(0.5);
scalar Sf(0.6);
scalar Sg(0.7);
scalar Sh(0.8);
scalar Si(0.9);
scalar Sj(0.10);
scalar Sk(0.11);
scalar Sl(0.12);
dimensionedScalar DSa("DSa", dimless, 1);
dimensionedScalar DSb("DSb", dimless, 2);
dimensionedScalar DSc("DSc", dimless, 3);
dimensionedScalar DSd("DSd", dimless, 4);
dimensionedScalar DSe("DSe", dimless, 5);
dimensionedScalar DSf("DSf", dimless, 6);
dimensionedScalar DSg("DSg", dimless, 7);
dimensionedScalar DSh("DSh", dimless, 8);
dimensionedScalar DSi("DSi", dimless, 9);
dimensionedScalar DSj("DSj", dimless, 10);
dimensionedScalar DSk("DSk", dimless, 11);
dimensionedScalar DSl("DSl", dimless, 12);
dimensionedScalar DSm("DSm", dimless, 13);
dimensionedScalar DSn("DSn", dimless, 14);
dimensionedScalar DSo("DSo", dimless, 15);
dimensionedScalar DStime("DStime", dimless, 0);
dimensionedScalar Aa("Aa", dimless, 0);
dimensionedScalar Ab("Ab", dimless, 0);
dimensionedScalar Ac("Ac", dimless, 0);
dimensionedScalar Ad("Ad", dimless, 0);
dimensionedScalar Ae("Ae", dimless, 0);
dimensionedScalar Af("Af", dimless, 0);
dimensionedScalar Pa("Pa", dimless, 0);
dimensionedScalar Pb("Pb", dimless, 0);
dimensionedScalar Pc("Pc", dimless, 0);
dimensionedScalar Pd("Pd", dimless, 0);
dimensionedScalar Pe("Pe", dimless, 0);
dimensionedScalar Pf("Pf", dimless, 0);
eqns.addDataSource(testDict1);
eqns.addDataSource(testDict2);
eqns.addDataSource(testDict3);
eqns.addDataSource(testDict4);
eqns.addDataSource(testDict5);
eqns.addDataSource(testDict6);
eqns.addDataSource(testDict7);
eqns.addDataSource(testDict8);
eqns.addDataSource(testDict9);
eqns.addDataSource(testDict10);
eqns.addDataSource(DSa);
eqns.addDataSource(DSb);
eqns.addDataSource(DSc);
eqns.addDataSource(DSd);
eqns.addDataSource(DSe);
eqns.addDataSource(DSf);
eqns.addDataSource(DSg);
eqns.addDataSource(DSh);
eqns.addDataSource(DSi);
eqns.addDataSource(DSj);
eqns.addDataSource(DSk);
eqns.addDataSource(DSl);
eqns.addDataSource(DSm);
eqns.addDataSource(DSn);
eqns.addDataSource(DSo);
eqns.addDataSource(DStime);
eqns.addDataSource(Sa, "Sa");
eqns.addDataSource(Sb, "Sb");
eqns.addDataSource(Sc, "Sc");
eqns.addDataSource(Sd, "Se");
eqns.addDataSource(Se, "Sd");
eqns.addDataSource(Sf, "Sf");
eqns.addDataSource(Sg, "Sg");
eqns.addDataSource(Sh, "Sh");
eqns.addDataSource(Si, "Si");
eqns.addDataSource(Sj, "Sj");
eqns.addDataSource(Sk, "Sk");
eqns.addDataSource(Sl, "Sl");
label listIndex(0);
eqns.addDataSource(p);
eqns.addDataSource(dummy);
eqns.setListIndex(listIndex);
eqns.readEquation(testDict1, "Pa");
eqns.readEquation(testDict1, "Pb");
eqns.readEquation(testDict1, "Pc");
eqns.readEquation(testDict1, "Pd");
eqns.readEquation(testDict1, "Pe");
eqns.readEquation(testDict1, "Pf");
eqns.readEquation(testDict1, "Aa", Aa);
eqns.readEquation(testDict1, "Ab", Ab);
eqns.readEquation(testDict1, "Ac", Ac);
eqns.readEquation(testDict1, "Ad", Ad);
eqns.readEquation(testDict1, "Ae", Ae);
eqns.readEquation(testDict1, "Af", Af);
eqns.readEquation(testDict1, "nu", nu);
scalar saA(readScalar(testDict1.lookup("saA")));
scalar saB(readScalar(testDict1.lookup("saB")));
scalar saC(readScalar(testDict1.lookup("saC")));
scalar saD(readScalar(testDict1.lookup("saD")));
scalar saE(readScalar(testDict1.lookup("saE")));
scalar saF(readScalar(testDict1.lookup("saF")));
dimensionedScalar dsaA(testDict1.lookup("dsaA"));
dimensionedScalar dsaB(testDict1.lookup("dsaB"));
dimensionedScalar dsaC(testDict1.lookup("dsaC"));
dimensionedScalar dsaD(testDict1.lookup("dsaD"));
dimensionedScalar dsaE(testDict1.lookup("dsaE"));
dimensionedScalar dsaF(testDict1.lookup("dsaF"));
Info << "Stand-alone test:" << endl;
Info << "saA = " << saA << endl;
Info << "saB = " << saB << endl;
Info << "saC = " << saC << endl;
Info << "saD = " << saD << endl;
Info << "saE = " << saE << endl;
Info << "saF = " << saF << endl;
Info << "dsaA = " << dsaA << endl;
Info << "dsaB = " << dsaB << endl;
Info << "dsaC = " << dsaC << endl;
Info << "dsaD = " << dsaD << endl;
Info << "dsaE = " << dsaE << endl;
Info << "dsaF = " << dsaF << endl;
Info << "Pa is at index " << eqns.lookup("Pa") << endl;
Info << "Pb is at index " << eqns.lookup("Pb") << endl;
Info << "Pc is at index " << eqns.lookup("Pc") << endl;
Info << "Pd is at index " << eqns.lookup("Pd") << endl;
Info << "Pe is at index " << eqns.lookup("Pe") << endl;
Info << "Pf is at index " << eqns.lookup("Pf") << endl;
Info << "Aa is at index " << eqns.lookup("Aa") << endl;
Info << "Ab is at index " << eqns.lookup("Ab") << endl;
Info << "Ac is at index " << eqns.lookup("Ac") << endl;
Info << "Ad is at index " << eqns.lookup("Ad") << endl;
Info << "Ae is at index " << eqns.lookup("Ae") << endl;
Info << "Af is at index " << eqns.lookup("Af") << endl;
Info << "nu is at index " << eqns.lookup("nu") << endl;
Info<< "\nStarting time loop\n" << endl;
for (runTime++; !runTime.end(); runTime++)
{
Info<< "Time = " << runTime.timeName() << nl << endl;
DStime.value() = runTime.value();
Info << "Moving p index to ";
listIndex++;
if (listIndex == p.size())
{
listIndex = 0;
}
Info << listIndex << "..." << endl;
eqns.setListIndex(listIndex);
Info << "Passive reread..." << endl;
eqns.readEquation(testDict1, "Pa");
eqns.readEquation(testDict1, "Pb");
eqns.readEquation(testDict1, "Pc");
Info << "Active reread..." << endl;
eqns.readEquation(testDict1, "Aa", Aa);
eqns.readEquation(testDict1, "Ab", Ab);
eqns.readEquation(testDict1, "Ac", Ac);
Info << "Updating active equations..." << endl;
eqns.update();
Info << "Aa = " << Aa << endl;
Info << "Ab = " << Ab << endl;
Info << "Ac = " << Ac << endl;
Info << "Ad = " << Ad << endl;
Info << "Ae = " << Ae << endl;
Info << "Af = " << Af << endl;
Info << "nu = " << nu << endl;
Info << "Evaluating passive equations: Pa, ";
Pa = eqns.evaluate("Pa");
Info << "Pb, ";
Pb = eqns.evaluate("Pb");
Info << "Pc, ";
Pc = eqns.evaluate("Pc");
Info << "Pd, ";
Pe = eqns.evaluate("Pd");
Info << "Pe, ";
Pd = eqns.evaluate("Pe");
Info << "Pf." << endl;
Pf = eqns.evaluate("Pf");
Info << "Pa = " << Pa << endl;
Info << "Pb = " << Pb << endl;
Info << "Pc = " << Pc << endl;
Info << "Pd = " << Pd << endl;
Info << "Pe = " << Pe << endl;
Info << "Pf = " << Pf << endl;
# include "readPISOControls.H"
# include "CourantNo.H"
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
solve(UEqn == -fvc::grad(p));
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);
adjustPhi(phi, U, p);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
# include "continuityErrs.H"
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View file

@ -66,6 +66,7 @@ fvAgglomerationMethods/Allwmake
wmake libso engine wmake libso engine
wmake libso equationReader
wmake libso multiSolver wmake libso multiSolver
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View file

@ -156,17 +156,6 @@ $(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C
$(functionEntries)/inputModeEntry/inputModeEntry.C $(functionEntries)/inputModeEntry/inputModeEntry.C
$(functionEntries)/removeEntry/removeEntry.C $(functionEntries)/removeEntry/removeEntry.C
equation = $(dictionary)/equation
$(equation)/equationReader/equationReader.C
$(equation)/equationReader/equationReaderIO.C
$(equation)/equation/equation.C
$(equation)/equation/equationIO.C
$(equation)/equationOperation/equationOperation.C
IOEquationReader = db/IOobjects/IOEquationReader
$(IOEquationReader)/IOEquationReader.C
$(IOEquationReader)/IOEquationReaderIO.C
IOdictionary = db/IOobjects/IOdictionary IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/IOdictionary.C $(IOdictionary)/IOdictionary.C
$(IOdictionary)/IOdictionaryIO.C $(IOdictionary)/IOdictionaryIO.C

View file

@ -1,342 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::equationOperation
Description
Defines a single operation to be performed in sequence while evaluating an
equation read from a dictionary.
SourceFiles
equationOperationI.H
equationOperation.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationOperation_H
#define equationOperation_H
#include "word.H"
#include "label.H"
#include "IOstreams.H"
#include "dimensionedScalar.H"
// #include "Istream.H"
// #include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class equationOperation;
class equationReader;
// Friend Operators
int operator==(const equationOperation&, const equationOperation&);
int operator!=(const equationOperation&, const equationOperation&);
// Friend IOstream Operators
Istream& operator>>(Istream&, equationOperation&);
Ostream& operator<<(Ostream&, const equationOperation&);
/*---------------------------------------------------------------------------*\
Class equationOperation Declaration
\*---------------------------------------------------------------------------*/
class equationOperation
{
public:
enum sourceListType
{
slnone,
sldictSource,
slexternalDScalar,
slexternalScalar,
slexternalScalarList,
slinternalScalar,
slequation,
slstorage
};
enum operationType
{
otnone,
otretrieve,
otstore,
otplus,
otminus,
ottimes,
otdivide,
otpow,
otsign,
otpos,
otneg,
otmag,
otlimit,
otminMod,
otsqrtSumSqr,
otsqr,
otpow3,
otpow4,
otpow5,
otinv,
otsqrt,
otcbrt,
othypot,
otexp,
otlog,
otlog10,
otsin,
otcos,
ottan,
otasin,
otacos,
otatan,
otsinh,
otcosh,
ottanh,
otasinh,
otacosh,
otatanh,
oterf,
oterfc,
otlgamma,
otj0,
otj1,
otjn,
oty0,
oty1,
otyn,
otmax,
otmin,
otstabilise
};
private:
// List to read the data from
sourceListType sourceList_;
// Index in the list where the data is located. Note, the
// equationOperationLists created by equationReader make this variable a
// 1-indexed (i.e. starts from 1, not zero) in order to use its sign to
// store the sign of the variable. The sourceLists are zero-indexed, so
// equationReader will constantly be adding / subtracting 1 to get these
// to match
label sourceIndex_;
// Rather than store the keywords that have to be searched in a dictionary,
// equationReader keeps its own list of keywords, and the dictLookupIndex
// is the index in this list. This is only applicable if the sourceList is
// of type sldictSource
label dictLookupIndex_;
// The operation to be performed (+ - sin exp min, etc...)
operationType operation_;
// A pointer to the source data retrieval function
dimensionedScalar (Foam::equationReader::*getSourceFunction_)
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
);
// A pointer to the operation to be performed
void (Foam::equationReader::*opFunction_)
(
equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionedScalar& ds,
dimensionedScalar source
);
public:
// Static data members
static const char* const typeName;
// Constructors
//- Construct null
equationOperation();
//- Construct from components
equationOperation
(
sourceListType sourceList,
label sourceIndex,
label dictLookupIndex,
operationType operation,
dimensionedScalar (Foam::equationReader::*getSourceFunction)
(
equationReader *,
const label,
const label,
const label,
const label
) = NULL,
void (Foam::equationReader::*opFunction)
(
equationReader *,
const label,
const label,
const label,
label&,
dimensionedScalar&,
dimensionedScalar
) = NULL
);
// Destructor
~equationOperation();
// Member functions
// Access
//- Const access to source list
inline const sourceListType& sourceList() const;
//- Access to source list
inline sourceListType& sourceList();
//- Const access to source index
inline const label& sourceIndex() const;
//- Access to source index
inline label& sourceIndex();
//- Const access to dictionary lookup name index
inline const label& dictLookupIndex() const;
//- Access to dictionary lookup name index
inline label& dictLookupIndex();
//- Const access to operation
inline const operationType& operation() const;
//- Access to operation
inline operationType& operation();
// Function pointers
//- Assign the operation function
void assignSourceFunction
(
dimensionedScalar (Foam::equationReader::*getSourceFunction)
(
equationReader *,
const label,
const label,
const label,
const label
)
);
void assignOpFunction
(
void (Foam::equationReader::*opFunction)
(
equationReader *,
const label,
const label,
const label,
label&,
dimensionedScalar&,
dimensionedScalar
)
);
//- Call the getSource function
dimensionedScalar getSourceFunction
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
);
//- Call the operation function
void opFunction
(
equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionedScalar& ds,
dimensionedScalar source
);
// Convenience
//- Look up operation number, given a word
static operationType findOp(const word& opName);
//- Look up operation name
static word opName(const operationType& op);
//- Look up sourceList name
static word sourceName(const sourceListType& sl);
// Friend IOstream Operators
friend Istream& operator>>(Istream&, equationOperation&);
friend Ostream& operator<<(Ostream&, const equationOperation&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationOperationI.H"
#endif

View file

@ -1,768 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::equationReader
Description
The master class for reading equations from a dictionary file. This class
holds all the equations, all the data sources, and gives access to all the
equation parsing / evaluating functions.
SourceFiles
equationReaderI.H
equationReaderPointerFunctions.H
equationReader.C
equationReaderAssignPointerFunctions.C
equationReaderCreateMap.C
equationReaderEvaluate.C
equationReaderGetSource.C
equationReaderIO.C
equationReaderParse.C
equationReaderTemplates.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationReader_H
#define equationReader_H
#include "dictionary.H"
//#include "dimensionedScalar.H"
#include "UPtrList.H"
#include "equationList.H"
#include "tokenList.H"
#include "labelList.H"
#include "DimensionedField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class equationReader;
// *** Located in equationReaderIO.C ***
Istream& operator>>(Istream&, equationReader&);
Ostream& operator<<(Ostream&, const equationReader&);
/*---------------------------------------------------------------------------*\
Class equationReader Declaration
\*---------------------------------------------------------------------------*/
class equationReader
{
// Private data
//- Dependency backtrace, used for circular-reference detection
labelList dependents_;
//- Equations
equationList eqns_;
//- Function pointer (used to avoid a conditional at every operation
// for debug level 2)
void (Foam::equationReader::*reportOperationFunction_)
(
const label&,
const label&,
const dimensionedScalar&
) const;
//- Function pointer (used to avoid a conditional at every operation
// for debug level 2)
void (Foam::equationReader::*reportResultFunction_)
(
const dimensionedScalar&
) const;
// Sources - these are locations where variables appearing in the
// equations can be retrieved
//- Variables that can be looked up in a dictionary
UPtrList<const dictionary> dictSources_;
//- Words to be looked up in a dictionary (equation operation only
// gives indices; this is necessary if the source is a dictionary)
PtrList<word> dictLookups_;
//- Pointers to source scalarLists, used for lists, fields, etc..
UPtrList<const scalarList> externalScalarLists_;
//- Dimensions associated with the externalScalarLists
PtrList<dimensionSet> externalScalarListDimensions_;
//- Names associated with the externalScalarLists
wordList externalScalarListNames_;
//- Current index associated with the externalScalarLists
labelList externalScalarListIndex_;
//- Pointers to external dimensionedScalars
UPtrList<const dimensionedScalar> externalDScalars_;
//- Pointers to external scalars
UPtrList<const scalar> externalScalars_;
//- Names associated with the external scalars
wordList externalScalarNames_;
//- Dimensions associated with the external scalars
PtrList<dimensionSet> externalScalarDimensions_;
//- The output of each equation in the equationList is sent here,
// indexed according to the equationList
UPtrList<scalar> outputScalars_;
//- Names associated with the output scalars
wordList outputScalarNames_;
//- Dimensions associated with the output scalars
PtrList<dimensionSet> outputScalarDimensions_;
//- Pointers to output scalarLists, used for lists, fields, etc..
UPtrList<scalarList> outputScalarLists_;
//- Dimensions associated with the outputScalarLists
PtrList<dimensionSet> outputScalarListDimensions_;
//- Temporary storage during evaluation declared a member
// variable as a bug fix for dropped references and pointers
PtrList<dimensionedScalar> storage_;
//- Internal scalars for storing constants read from equations.
// Moved from equation members to equationReader as a bug fix
PtrList<scalar> internalScalars_;
// Private Member Functions
//- Disallow default bitwise copy construct
equationReader(const equationReader&);
//- Disallow default bitwise assignment
void operator=(const equationReader&);
// Main parser functions
//- Parse an equation
// *** Located in equationReaderParse.C ***
void parse(label index);
// Parses a segment of an equation, used after parenthesis
// precedence is determined. Returns the map index that holds the
// source info for the result
// *** Located in equationReaderParse.C ***
label parseExpression
(
label index,
const tokenList& tl,
const labelList& opLvl,
equationOperationList& map,
const labelList& indices,
label& storeIndex
);
// General parser support functions
//- Post an error related to equation parsing. Reports the exact
// position of the error in the equation string.
void fatalParseError
(
const label index,
const tokenList& tl,
const label fromToken,
const label toToken,
const string& errorIn,
const OStringStream& description
);
//- Modify the equation string going in to the parser:
// - change ^ into : to allow detection of powers
// - add spaces around ( ) + - * / , ^ to prevent expressions from
// combining as words
string stringPreconditioner(const string& rawString);
// Search through a string and replace all instances of findMe with
// replaceWith
void stringReplaceAll
(
string& working,
const string& findMe,
const string& replaceWith
);
//- Create a map of: parenthesis levels, operation levels,
// functions, and variable sources
// *** Located in equationReaderCreateMap.C ***
void createMap
(
const label index,
const tokenList& tl,
equationOperationList& map,
labelList& opLvl,
labelList& pl
);
// Returns a labelList with the indices of the maximum operation
// level. If more than one grouping exists, returns the first one.
labelList findMaxOperation
(
const labelList& opLvl,
const labelList& indices
);
// Returns a labelList with the indices of the maximum parenthesis
// level. If more than one grouping exists, returns the first one.
labelList findMaxParenthesis
(
const labelList& parenthesisList,
const labelList& equationIndices
) const;
// Find all negatives, give the upstream token a negative source
// index, and trim them from the list
void absorbNegatives
(
const label equationIndex,
const tokenList& tl,
labelList& eqnIndices,
labelList& subEqnIndices,
equationOperationList& map,
labelList& opLvl
);
// Sets the first dimensionedScalar equal to the second one without
// tripping dimension checking errors
void dsEqual(dimensionedScalar& dso, const dimensionedScalar& dsi);
// Indexing-related support functions
//- Given a labelList 'indices', remove all entries from position
// 'from' to position 'to', but not including 'exceptFor', if
// specified. Search through labelList 'parent', find the same
// entries by value (not position), and remove these also.
void trimListWithParent
(
labelList& parent,
labelList& indices,
label from,
label to,
label exceptFor = -1
);
//- Removes indices from a labelList, including from and to
// indices, but not including exceptFor index, if specified.
void trimList
(
labelList& indices,
label from,
label to,
label exceptFor = -1
);
//- Search through a labelList and return the index with the value
// 'value'. Return -1 if failed.
label findIndex
(
const label value,
const labelList& indexList
) const;
// Data-handling support functions
//- Return the source list and source index associated with a variable
// name. Searches in this order:
// 1. externalDScalars;
// 2. externalScalars; and
// 3. dictSources.
// Returns the source info upon finding it; does not check for
// duplicates.
equationOperation findSource(const word& varName);
//- Return the dimensionedScalar associated with a source list and
// source index
// *** Located in equationReaderGetSource.C ***
dimensionedScalar getSource
(
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
);
//- Add a constant to the internal scalar source list
label addInternalScalar(const scalar& value);
//- Returns true if the stream is a dimensionedScalar dictionary
// entry.
bool isDimensionedScalar(ITstream& is);
//- Returns true if the stream is a scalar dictionary entry
bool isScalar(ITstream& is);
//- Returns true if the stream is an equation entry
bool isEquation(ITstream& is);
// Function-pointer functions, used for efficient evaluation
// equationReader uses dynamically linked function pointers for
// efficient evaluation and data sourcing. The prototypes for most of
// these functions are located in:
// *** equationReaderPointerFunctions.H ***
# include "equationReaderPointerFunctions.H"
//- Link the functions to the pointers
// *** Located in equationReaderAssignFunctionPointers.C ***
void assignFunctionPointers(const label index);
//- Pointed to by reportOperationFunction_ when debug level is not
// high enough - this function does nothing
void reportOperationDisabled
(
const label& index,
const label& i,
const dimensionedScalar& ds
) const;
//- Pointed to by reportOperationFunction_ when debug level is
// greater than 1. This function sends operation-by-operation
// information to the console
void reportOperationEnabled
(
const label& index,
const label& i,
const dimensionedScalar& ds
) const;
//- Pointed to by reportResultFunction_ when debug level is not
// high enough - this function does nothing
void reportResultDisabled
(
const dimensionedScalar& ds
) const;
//- Pointed to by reportResultFunction_ when debug level is not
// high enough - this function reports the result operation-by-
// operation to the console
void reportResultEnabled
(
const dimensionedScalar& ds
) const;
public:
// Static data members
// static const char* const typeName;
TypeName("equationReader");
// Constructor (construct null)
equationReader();
// Destructor
virtual ~equationReader();
// Member functions
// Adding data sources
//- Add a dictionary
void addDataSource(const dictionary& dict);
//- Add an external scalar
void addDataSource
(
const scalar& value,
const word& name,
const dimensionSet& dimensions = dimless
);
//- Add an external dimensionedScalar
void addDataSource(const dimensionedScalar& ds);
//- Add an external scalarList
void addDataSource
(
const scalarList& slist,
const word& name,
const dimensionSet& dimensions = dimless
);
//- Add an external dimensionedScalarList
// *** Located in equationReaderTemplates.C ***
template<class GeoMesh>
void addDataSource
(
const DimensionedField<scalar, GeoMesh>& dfield
);
//- Change the index for a scalarList source
void setListIndex(const word& name, label newIndex);
//- Change the index for all scalarList sources
void setListIndex(label newIndex);
// Data source access
//- Equations (const only)
inline const equationList& eqns() const;
//- Dictionary source pointers
inline const UPtrList<const dictionary>& dictSources() const;
//- Access to dictionary source pointers
inline UPtrList<const dictionary>& dictSources();
//- Dictionary look-up words (const only)
inline const PtrList<word>& dictLookups() const;
//- External scalarList pointers
inline const
UPtrList<const scalarList>& externalScalarLists() const;
//- Access to external scalarList pointers
inline UPtrList<const scalarList>& externalScalarLists();
//- Dimensions associated with external scalarLists
inline const
PtrList<dimensionSet>& externalScalarListDimensions() const;
//- Access to dimensions associated with external scalarLists
inline PtrList<dimensionSet>& externalScalarListDimensions();
//- Names associated with the external scalarLists
inline const wordList& externalScalarListNames() const;
//- Access to names associated with the external scalarLists
inline wordList& externalScalarListNames();
//- Current index associated with the externalScalarLists
inline const labelList& externalScalarListIndex() const;
//- Access to current index associated with the externalScalarLists
inline labelList& externalScalarListIndex();
//- External dimensioned scalar data source pointers
inline const
UPtrList<const dimensionedScalar>& externalDScalars() const;
//- Access external dimensioned scalar data source pointers
inline UPtrList<const dimensionedScalar>& externalDScalars();
//- External scalar data source pointers
inline const UPtrList<const scalar>& externalScalars() const;
//- Access external scalar data source pointers
inline UPtrList<const scalar>& externalScalars();
//- Const access to external scalar names
inline const wordList& externalScalarNames() const;
//- Access external scalar names
inline wordList& externalScalarNames();
//- Dimensions associated with external scalars
inline const
PtrList<dimensionSet>& externalScalarDimensions() const;
//- Access to dimensions associated with external scalars
inline PtrList<dimensionSet>& externalScalarDimensions();
//- Const access to output scalar data pointers
inline const
UPtrList<scalar>& outputScalars() const;
//- Access output scalar data pointers
inline UPtrList<scalar>& outputScalars();
//- Const access to output scalar names
inline const
wordList& outputScalarNames() const;
//- Access output scalar names
inline wordList& outputScalarNames();
//- Const access to output scalar dimensions
inline const
PtrList<dimensionSet>& outputScalarDimensions() const;
//- Access output scalar dimensions
inline PtrList<dimensionSet>& outputScalarDimensions();
//- Const access to pointers to output scalarLists
inline const UPtrList<scalarList>& outputScalarLists() const;
//- Access to pointers to output scalarLists
inline UPtrList<scalarList>& outputScalarLists();
//- Const access to dimensions associated with outputScalarLists
inline const
PtrList<dimensionSet>& outputScalarListDimensions() const;
//- Access to dimensions associated with outputScalarLists
inline PtrList<dimensionSet>& outputScalarListDimensions();
// Equations
//- Creates a new equation but does not parse it. If equation
// exists, throws an error.
void createEquation
(
equation eqn
);
//- linkOutput functions
// These functions assign or reassign an output variable to an
// equation - enables the use of update()
//- Given equation name, and a dimensionedScalar
void linkOutput
(
const word& eqnName,
dimensionedScalar& outputDVar
);
//- Given equation name, and dimensionedScalar components
void linkOutput
(
const word& eqnName,
scalar& value,
const word& name,
const dimensionSet& dimensions = dimless
);
//- Given an equation name, and a dimensionedField
// *** Located in equationReaderTemplates ***
template<class GeoMesh>
void linkOutput
(
const word& eqnName,
DimensionedField<scalar, GeoMesh>& dfield
);
//- Given an equation name, and scalarList components
void linkOutput
(
const word& eqnName,
scalarList& outputSList,
const dimensionSet& dimensions
);
//- Given the equation index, and dimensionedScalar
void linkOutput
(
label index,
dimensionedScalar& outputDVar
);
//- Given the equation index, and dimensionedScalar components
void linkOutput
(
label index,
scalar& value,
const word& name,
const dimensionSet& dimensions = dimless
);
//- Given the equation index, and DimensionedField
// *** Located in equationReaderTemplates.C ***
template<class GeoMesh>
void linkOutput
(
label index,
DimensionedField<scalar, GeoMesh>& dfield
);
//- Given the equation index, and scalarList components
void linkOutput
(
label index,
scalarList& outputSList,
const dimensionSet& dimensions
);
//- readEquation functions - if equation exists, it assumes this is
// a reread. If parameters include output variables, this
// function will also perform a linkOutput
//- Given an equation
void readEquation
(
equation eqn
);
//- Given an equation and linkOutput to a dimensionedScalar
void readEquation
(
equation eqn,
dimensionedScalar& outputDVar
);
//- Given an equation and linkOutput to a dimensionedScalar's
// components
void readEquation
(
equation eqn,
scalar& value,
const word& name,
const dimensionSet& dimensions = dimless
);
//- Given an equation and linkOutput to a DimensionedField
// *** Located in equationReaderTemplates.C ***
template<class GeoMesh>
void readEquation
(
equation eqn,
DimensionedField<scalar, GeoMesh>& dfield
);
//- Given an equation and linkOutput to a DimensionedField
void readEquation
(
equation eqn,
scalarList& outputSList,
const dimensionSet& dimensions
);
//- Read equation from a dictionary
void readEquation
(
const dictionary& sourceDict,
const word& eqnName
);
//- Read equation from a dictionary and linkOutput to a
// dimensionedScalar
void readEquation
(
const dictionary& sourceDict,
const word& eqnName,
dimensionedScalar& outputDVar
);
//- Read equation from a dictionary and linkOutput to a
// dimensionedScalar's components
void readEquation
(
const dictionary& sourceDict,
const word& eqnName,
scalar& value,
const word& name,
const dimensionSet& dimensions = dimless
);
//- Evaluate a single equation, given a variable name, and return
// new value. Do not set the associated output variable
// *** Located in equationReaderEvaluate.C ***
dimensionedScalar evaluate(const word& equationName);
//- Evaluate a single equation, given an index number, and return
// new value. Does not set the associated output variable.
// storageOffset is for internal use only, do not use this.
// *** Located in equationReaderEvaluate.C ***
dimensionedScalar evaluate
(
const label& index,
label storageOffset = 0
);
//- Evaluate the equation and output the result as a Field, cycling
// through all the source field indices (setFieldIndex)
// Given an index and DimensionedField
// *** Located in equationReaderTemplates.C ***
template<class GeoMesh>
void evaluateField
(
const label& index,
DimensionedField<scalar, GeoMesh>& dfield
);
//- Evaluate the equation and output the result as a scalarList,
// cycling through all the source field indices (setFieldIndex)
// Given an index and scalarList components
// *** Located in equationReaderEvaluate.C ***
void evaluateField
(
const label& index,
scalarList& outputSList,
dimensionSet& dimensions
);
//- Evaluate a single equation, given a variable name, and set the
// associated output variable to the new value
void update(const word& equationName);
//- Evaluate a single equation, given an index number, and set the
// associated output variable to the new value
void update(const label& index);
//- Evaluate all equations, setting the associated output variables
// as they are calculated
void update();
//- Returns true if equationName exists in equationList
bool found(const word& equationName);
//- Returns the index of a given equationName, -1 if not found
label lookup(const word& equationName);
//- Delete an equation, given a name
void deleteEquation(const word& equationName);
//- Delete an equation, given an index number
void deleteEquation(const label& index);
// Input / output related functions
// *** Located in equationReaderIO.C ***
//- Output data source information to the Ostream
Ostream& dataSourceStatus(Ostream& os) const;
friend Istream& operator>>(Istream&, equationReader&);
friend Ostream& operator<<(Ostream&, const equationReader&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationReaderI.H"
#include "equationReaderTemplates.C"
#endif

View file

@ -1,312 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::dimensionedScalar Foam::equationReader::getSourceNone
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
return dimensionedScalar("noSource", dimless, 0);
}
Foam::dimensionedScalar Foam::equationReader::getSourceDictSourceDScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
ITstream srcStrm
(
dictSources_[zeroSourceIndex].lookup(varName)
);
srcStrm >> returnMe;
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceDictSourceScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
returnMe.name() = varName;
returnMe.value() = readScalar
(
dictSources_[zeroSourceIndex].lookup(varName)
);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceExternalDScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dsEqual(returnMe, externalDScalars_[zeroSourceIndex]);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceExternalScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
returnMe.name() = externalScalarNames_[zeroSourceIndex];
returnMe.value() = externalScalars_[zeroSourceIndex];
returnMe.dimensions().reset
(
externalScalarDimensions_[zeroSourceIndex]
);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceExternalScalarList
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dsEqual
(
returnMe,
dimensionedScalar
(
externalScalarListNames_[zeroSourceIndex],
externalScalarListDimensions_[zeroSourceIndex],
externalScalarLists_
[zeroSourceIndex]
[externalScalarListIndex_[zeroSourceIndex]]
)
);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceInternalScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
returnMe.name() = "internalConstant";
returnMe.value() = internalScalars_[zeroSourceIndex];
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceEquation
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
if (debug)
{
Info << "Embedded equation dispatch." << endl;
}
dsEqual(returnMe, evaluate(zeroSourceIndex, maxStoreIndex + 1));
if (debug)
{
Info << "Returned from embedded equation." << endl;
}
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceEquationCircRefDetect
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
equation& eqn(eqns_[equationIndex]);
equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
// Check for circular references
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
forAll(dependents_, i)
{
if (dependents_[i] == zeroSourceIndex)
{
// Circular reference detected
string dependencies;
for (label j(i); j < dependents_.size(); j++)
{
dependencies.append
(
eqns_[j].equationName()
);
dependencies.append("-->");
}
dependencies.append(eqns_[i].equationName());
FatalErrorIn("equationReader::getSource")
<< "Circular reference detected when evaluating "
<< "the equation for " << eqn.equationName()
<< ", given by:" << token::NL << token::TAB
<< eqn.rawText() << token::NL << "The circular "
<< "dependency is:" << token::NL << token::TAB
<< dependencies
<< abort(FatalError);
}
}
if (debug)
{
Info << "Embedded equation dispatch." << endl;
}
dsEqual(returnMe, evaluate(zeroSourceIndex, maxStoreIndex + 1));
eqOp.assignSourceFunction
(
&Foam::equationReader::getSourceEquation
);
if (debug)
{
Info << "Returned from embedded equation." << endl;
}
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceStorage
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
# ifdef FULLDEBUG
if ((zeroSourceIndex + storageOffset) > maxStoreIndex)
{
FatalErrorIn("equationReader::getSouce")
<< "Index " << zeroSourceIndex << " out of bounds (0, "
<< maxStoreIndex - storageOffset << ")"
<< abort(FatalError);
}
# endif
dsEqual(returnMe, storage_[zeroSourceIndex + storageOffset]);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,226 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
inline const equationList& equationReader::eqns() const
{
return eqns_;
}
inline const UPtrList<const dictionary>& equationReader::dictSources() const
{
return dictSources_;
}
inline UPtrList<const dictionary>& equationReader::dictSources()
{
return dictSources_;
}
inline const PtrList<word>& equationReader::dictLookups() const
{
return dictLookups_;
}
inline const
UPtrList<const scalarList>& equationReader::externalScalarLists() const
{
return externalScalarLists_;
}
inline UPtrList<const scalarList>& equationReader::externalScalarLists()
{
return externalScalarLists_;
}
inline const
PtrList<dimensionSet>& equationReader::externalScalarListDimensions() const
{
return externalScalarListDimensions_;
}
inline PtrList<dimensionSet>& equationReader::externalScalarListDimensions()
{
return externalScalarListDimensions_;
}
inline const wordList& equationReader::externalScalarListNames() const
{
return externalScalarListNames_;
}
inline wordList& equationReader::externalScalarListNames()
{
return externalScalarListNames_;
}
inline const labelList& equationReader::externalScalarListIndex() const
{
return externalScalarListIndex_;
}
inline labelList& equationReader::externalScalarListIndex()
{
return externalScalarListIndex_;
}
inline const
UPtrList<const dimensionedScalar>& equationReader::externalDScalars() const
{
return externalDScalars_;
}
inline UPtrList<const dimensionedScalar>& equationReader::externalDScalars()
{
return externalDScalars_;
}
inline const UPtrList<const scalar>& equationReader::externalScalars() const
{
return externalScalars_;
}
inline UPtrList<const scalar>& equationReader::externalScalars()
{
return externalScalars_;
}
inline const wordList& equationReader::externalScalarNames() const
{
return externalScalarNames_;
}
inline wordList& equationReader::externalScalarNames()
{
return externalScalarNames_;
}
inline const
PtrList<dimensionSet>& equationReader::externalScalarDimensions() const
{
return externalScalarDimensions_;
}
inline PtrList<dimensionSet>& equationReader::externalScalarDimensions()
{
return externalScalarDimensions_;
}
inline const
UPtrList<scalar>& equationReader::outputScalars() const
{
return outputScalars_;
}
inline UPtrList<scalar>& equationReader::outputScalars()
{
return outputScalars_;
}
inline const
wordList& equationReader::outputScalarNames() const
{
return outputScalarNames_;
}
inline
wordList& equationReader::outputScalarNames()
{
return outputScalarNames_;
}
inline const
PtrList<dimensionSet>& equationReader::outputScalarDimensions() const
{
return outputScalarDimensions_;
}
inline
PtrList<dimensionSet>& equationReader::outputScalarDimensions()
{
return outputScalarDimensions_;
}
inline const
UPtrList< scalarList>& equationReader::outputScalarLists() const
{
return outputScalarLists_;
}
//- Access to pointers to output scalarLists
inline UPtrList<scalarList>& equationReader::outputScalarLists()
{
return outputScalarLists_;
}
//- Const access to dimensions associated with outputScalarLists
inline const
PtrList<dimensionSet>& equationReader::outputScalarListDimensions() const
{
return outputScalarListDimensions_;
}
//- Access to dimensions associated with outputScalarLists
inline PtrList<dimensionSet>& equationReader::outputScalarListDimensions()
{
return outputScalarListDimensions_;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -26,8 +26,6 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationReader.H"
namespace Foam namespace Foam
{ {
@ -82,20 +80,6 @@ Istream& operator>>(Istream& is, Scalar& s)
{ {
s = t.number(); s = t.number();
} }
else if (t.isString())
{
// DLFG 2011-07-04 Modifications for equationReader
equationReader eqn;
eqn.readEquation
(
equation
(
"fromScalar",
t.stringToken()
)
);
s = eqn.evaluate(0).value();
}
else else
{ {
is.setBad(); is.setBad();

View file

@ -70,5 +70,4 @@ const Foam::word& Foam::IOEquationReader::name() const
return regIOobject::name(); return regIOobject::name();
} }
// ************************************************************************* // // ************************************************************************* //

View file

@ -0,0 +1,14 @@
equationSource/equationSources.C
equation/equation.C
equation/equationIO.C
equationOperation/equationOperation.C
equationReader/equationReaders.C
equationReader/equationReaderIO.C
IOEquationReader/IOEquationReader.C
IOEquationReader/IOEquationReaderIO.C
LIB = $(FOAM_LIBBIN)/libequationReader

View file

View file

@ -36,25 +36,33 @@ const char* const Foam::equation::typeName = "equation";
Foam::equation::equation() Foam::equation::equation()
: :
equationName_(word::null), equationName_(word::null),
ops_(0),
rawText_(""), rawText_(""),
lastResult_(word::null, dimless, 0), lastResult_(word::null, dimless, 0),
overrideDimensions_(dimless), overrideDimensions_(dimless),
changeDimensions_(false) changeDimensions_(false)
{ {}
// internalScalars_ = new scalarList(0);
setSize(0);
}
Foam::equation::equation(const equation& newEqn)
:
equationName_(newEqn.equationName_),
ops_(0),
rawText_(newEqn.rawText_),
lastResult_(word::null, dimless, 0),
overrideDimensions_(newEqn.overrideDimensions_),
changeDimensions_(newEqn.changeDimensions_)
{}
Foam::equation::equation(Istream& is, const word& name) Foam::equation::equation(Istream& is, const word& name)
: :
equationName_(name), equationName_(name),
ops_(0),
rawText_(""), rawText_(""),
lastResult_(word::null, dimless, 0), lastResult_(word::null, dimless, 0),
overrideDimensions_(dimless), overrideDimensions_(dimless),
changeDimensions_(false) changeDimensions_(false)
{ {
// internalScalars_ = new scalarList(0);
operator>>(is, *this); operator>>(is, *this);
} }
@ -68,20 +76,28 @@ Foam::equation::equation
) )
: :
equationName_(equationName), equationName_(equationName),
ops_(0),
rawText_(rawText), rawText_(rawText),
lastResult_(equationName, dimless, 0), lastResult_(equationName, dimless, 0),
overrideDimensions_(overrideDimensions), overrideDimensions_(overrideDimensions),
changeDimensions_(changeDimensions) changeDimensions_(changeDimensions)
{ {}
// internalScalars_ = new scalarList(0);
setSize(0);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::equation::~equation() Foam::equation::~equation()
{} {}
// * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * * //
void Foam::equation::clear() const
{
ops_.clear();
}
// * * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * //
void Foam::equation::operator=(Foam::equation& eqn) void Foam::equation::operator=(Foam::equation& eqn)
@ -93,6 +109,4 @@ void Foam::equation::operator=(Foam::equation& eqn)
changeDimensions_ = eqn.changeDimensions_; changeDimensions_ = eqn.changeDimensions_;
} }
// ************************************************************************* // // ************************************************************************* //

View file

@ -43,10 +43,11 @@ Author
#ifndef equation_H #ifndef equation_H
#define equation_H #define equation_H
#include "equationOperationList.H" //#include "equationOperationList.H"
//#include "dimensionedScalar.H" //#include "dimensionedScalar.H"
#include "scalarList.H" #include "scalarField.H"
#include "dimensionSet.H" #include "dimensionSet.H"
#include "equationOperation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,35 +68,37 @@ Ostream& operator<<(Ostream&, const equation&);
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class equation class equation
:
public equationOperationList
{ {
// Private data // Private data
word equationName_; word equationName_;
//- Operation list
mutable PtrList<equationOperation> ops_;
//- raw text read from the dictionary //- raw text read from the dictionary
string rawText_; mutable string rawText_;
//- Result of most recent evaluate() or update() //- Result of most recent evaluate() or update()
dimensionedScalar lastResult_; mutable dimensionedScalar lastResult_;
//- Constants appearing in the equation are stored here
// scalarList * internalScalars_;
//- Names of variables that need to be read from a dictionary are
// stored here
// wordList dictLookups_;
//- Override dimensions - if read from a dictionary with dimensions, //- Override dimensions - if read from a dictionary with dimensions,
// eg: nu nu [0 2 -1 0 0 0 0] "sin(theta)"; // eg: nu nu [0 2 -1 0 0 0 0] "sin(theta)";
// the dimensionedScalar resulting from evaluate() is given these // the dimensionedScalar resulting from evaluate() is given these
// dimensions // dimensions
dimensionSet overrideDimensions_; mutable dimensionSet overrideDimensions_;
//- true if there is a dimension override //- true if there is a dimension override
bool changeDimensions_; mutable bool changeDimensions_;
//- Maximum field size of output, indexed by geoIndex
mutable labelList maxFieldSizes_;
// Private member functions
//- Disallow default bitwise assignment
void operator=(const equation&);
public: public:
@ -109,6 +112,9 @@ public:
//- Construct null //- Construct null
equation(); equation();
//- Construct copy
equation(const equation&);
//- Construct from Istream with optional name //- Construct from Istream with optional name
equation(Istream& is, const word& name = word::null); equation(Istream& is, const word& name = word::null);
@ -129,57 +135,84 @@ public:
// Access // Access
//- Equation name //- Equation name
inline const word& equationName() const; inline const word& name() const;
//- Size of operation list
inline label size() const;
//- setSize of operation list
inline void setSize(const label newSize) const;
//- set an element of operation list
inline autoPtr<equationOperation> set
(
const label elementIndex,
equationOperation * newOperation
) const;
//- Change the equation name //- Change the equation name
inline word& equationName(); inline word& name();
//- Equation text //- Equation text
inline const string& rawText() const; inline const string& rawText() const;
//- Set the equation text //- Set equation text
inline string& rawText(); inline void setRawText(const string& newRawText) const;
//- Last result //- Last result
inline const dimensionedScalar& lastResult() const; inline const dimensionedScalar& lastResult() const;
//- Set the last result //- Set the last result
inline dimensionedScalar& lastResult(); inline void setLastResult
(
const dimensionedScalar& newResult
) const;
//- Easy access to operations //- Set the value of the last result
inline const equationOperationList& ops() const; inline void setLastResult(const word& newName) const;
inline equationOperationList& ops(); //- Set the dimensions of the last result
inline void setLastResult(const dimensionSet& newDims) const;
//- Locally stored constants //- Set the value of the last result
// inline const scalarList * internalScalars() const; inline void setLastResult(const scalar& newScalar) const;
//- Set the locally stored constants
// inline scalarList * internalScalars();
//- Dictionary variable lookup names
// inline const wordList& dictLookups() const;
//- Set the dictionary variable lookup names
// inline wordList& dictLookups();
//- Dimension override //- Dimension override
inline const dimensionSet& overrideDimensions() const; inline const dimensionSet& overrideDimensions() const;
//- Set the dimension override //- Set override dimensions
inline dimensionSet& overrideDimensions(); inline void setOverrideDimensions
(
const dimensionSet& newDims
) const;
//- changeDimensions flag //- changeDimensions flag
inline const bool& changeDimensions() const; inline const bool& changeDimensions() const;
//- Set the changeDimensions flag //- Set the changeDimensions flag
inline bool& changeDimensions(); inline void setChangeDimensions(bool newFlag) const;
//- Return maxFieldSizes
inline const labelList& maxFieldSizes() const;
//- Set maxFieldSizes
inline void setMaxFieldSizes
(
const labelList& newSizes
) const;
// Delete the operation list
void clear() const;
// Operators // Operators
// Copy only the header info - rawText, equationName, dimensionOverride
// and changeDimensions //- Copy only the header info - rawText, equationName,
// dimensionOverride, and changeDimensions
void operator=(equation&); void operator=(equation&);
//- Access to ops_
inline equationOperation& operator[](const label) const;
// Friend IOstream Operators // Friend IOstream Operators
friend Istream& operator>>(Istream&, equation&); friend Istream& operator>>(Istream&, equation&);
@ -196,4 +229,8 @@ public:
#include "equationI.H" #include "equationI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -30,13 +30,35 @@ License
namespace Foam namespace Foam
{ {
inline const word& equation::equationName() const inline const word& equation::name() const
{ {
return equationName_; return equationName_;
} }
inline word& equation::equationName() inline label equation::size() const
{
return ops_.size();
}
inline void equation::setSize(const label newSize) const
{
ops_.setSize(newSize);
}
inline autoPtr<equationOperation> equation::set
(
const label elementIndex,
equationOperation * newOperation
) const
{
return ops_.set(elementIndex, newOperation);
}
inline word& equation::name()
{ {
return equationName_; return equationName_;
} }
@ -48,9 +70,9 @@ inline const string& equation::rawText() const
} }
inline string& equation::rawText() inline void equation::setRawText(const string& newRawText) const
{ {
return rawText_; rawText_ = newRawText;
} }
@ -60,53 +82,35 @@ inline const dimensionedScalar& equation::lastResult() const
} }
inline dimensionedScalar& equation::lastResult() inline void equation::setLastResult(const word& newName) const
{ {
return lastResult_; lastResult_.name() = newName;
} }
inline const equationOperationList& equation::ops() const inline void equation::setLastResult(const dimensionSet& newDims) const
{ {
const equationOperationList& oplist(*this); lastResult_.dimensions().reset(newDims);
return oplist;
} }
inline equationOperationList& equation::ops()
inline void equation::setLastResult(const scalar& newScalar) const
{ {
equationOperationList& opList(*this); lastResult_.value() = newScalar;
return opList;
} }
/*inline const scalarList * equation::internalScalars() const
{
return internalScalars_;
}
inline scalarList * equation::internalScalars()
{
return internalScalars_;
}*/
/*inline const wordList& equation::dictLookups() const
{
return dictLookups_;
}
inline wordList& equation::dictLookups()
{
return dictLookups_;
}*/
inline const dimensionSet& equation::overrideDimensions() const inline const dimensionSet& equation::overrideDimensions() const
{ {
return overrideDimensions_; return overrideDimensions_;
} }
inline void equation::setOverrideDimensions
inline dimensionSet& equation::overrideDimensions() (
const dimensionSet& newDims
) const
{ {
return overrideDimensions_; overrideDimensions_.reset(newDims);
} }
@ -116,9 +120,31 @@ inline const bool& equation::changeDimensions() const
} }
inline bool& equation::changeDimensions() inline void equation::setChangeDimensions(bool newFlag) const
{ {
return changeDimensions_; changeDimensions_ = newFlag;
}
inline const labelList& equation::maxFieldSizes() const
{
return maxFieldSizes_;
}
inline void equation::setMaxFieldSizes
(
const labelList& newSizes
) const
{
maxFieldSizes_ = newSizes;
}
// * * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * //
inline equationOperation& equation::operator[](const label equationIndex) const
{
return ops_[equationIndex];
} }
} // End namespace Foam } // End namespace Foam

View file

@ -44,7 +44,6 @@ Foam::Istream& Foam::operator>>(Istream& is, equation& I)
{ {
I.equationName_ = "fromIstream"; I.equationName_ = "fromIstream";
} }
token t(is); token t(is);
if (t.isString()) if (t.isString())
{ {

View file

@ -27,7 +27,6 @@ License
#include "dimensionedScalar.H" #include "dimensionedScalar.H"
#include "equationReader.H" #include "equationReader.H"
#include "equationOperation.H" #include "equationOperation.H"
#include "error.H"
//#include "equationOperationList.H" //#include "equationOperationList.H"
class dimensionedScalar; class dimensionedScalar;
@ -43,38 +42,96 @@ Foam::equationOperation::equationOperation()
{} {}
Foam::equationOperation::equationOperation(const equationOperation& eqop)
:
source_(eqop.source_),
sourceIndex_(eqop.sourceIndex_),
componentIndex_(eqop.componentIndex_),
dictLookupIndex_(eqop.dictLookupIndex_),
operation_(eqop.operation_),
getSourceScalarFieldFunction_(eqop.getSourceScalarFieldFunction_),
opScalarFieldFunction_(eqop.opScalarFieldFunction_),
getSourceScalarFunction_(eqop.getSourceScalarFunction_),
opScalarFunction_(eqop.opScalarFunction_),
getSourceDimsFunction_(eqop.getSourceDimsFunction_),
opDimsFunction_(eqop.opDimsFunction_)
{}
Foam::equationOperation::equationOperation Foam::equationOperation::equationOperation
( (
sourceListType sourceList, sourceTypeEnum source,
label sourceIndex, label sourceIndex,
label componentIndex,
label dictLookupIndex, label dictLookupIndex,
operationType operation, operationType operation,
dimensionedScalar (Foam::equationReader::*getSourceFunction) const scalarField& (Foam::equationReader::*getSourceScalarFieldFunction)
( (
equationReader *, const equationReader *,
const label, const label,
const label, const label,
const label, const label,
const label const label
), ) const,
void (Foam::equationReader::*opFunction) void (Foam::equationReader::*opScalarFieldFunction)
( (
equationReader *, const equationReader *,
const label, const label,
const label, const label,
const label, const label,
label&, label&,
dimensionedScalar&, scalarField&,
dimensionedScalar const scalarField&
) ) const,
scalar (Foam::equationReader::*getSourceScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const,
void (Foam::equationReader::*opScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
scalar&,
scalar
) const,
dimensionSet (Foam::equationReader::*getSourceDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const,
void (Foam::equationReader::*opDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
dimensionSet&,
dimensionSet
) const
) )
: :
sourceList_(sourceList), source_(source),
sourceIndex_(sourceIndex), sourceIndex_(sourceIndex),
componentIndex_(componentIndex),
dictLookupIndex_(dictLookupIndex), dictLookupIndex_(dictLookupIndex),
operation_(operation), operation_(operation),
getSourceFunction_(getSourceFunction), getSourceScalarFieldFunction_(getSourceScalarFieldFunction),
opFunction_(opFunction) opScalarFieldFunction_(opScalarFieldFunction),
getSourceScalarFunction_(getSourceScalarFunction),
opScalarFunction_(opScalarFunction),
getSourceDimsFunction_(getSourceDimsFunction),
opDimsFunction_(opDimsFunction)
{} {}
@ -159,6 +216,10 @@ Foam::equationOperation::operationType
{ {
return otpow5; return otpow5;
} }
else if (opName == "pow6")
{
return otpow6;
}
else if (opName == "inv") else if (opName == "inv")
{ {
return otinv; return otinv;
@ -211,6 +272,10 @@ Foam::equationOperation::operationType
{ {
return otatan; return otatan;
} }
else if (opName == "atan2")
{
return otatan2;
}
else if (opName == "sinh") else if (opName == "sinh")
{ {
return otsinh; return otsinh;
@ -335,6 +400,8 @@ Foam::word Foam::equationOperation::opName
return "pow4"; return "pow4";
case otpow5: case otpow5:
return "pow5"; return "pow5";
case otpow6:
return "pow6";
case otinv: case otinv:
return "inv"; return "inv";
case otsqrt: case otsqrt:
@ -361,6 +428,8 @@ Foam::word Foam::equationOperation::opName
return "acos"; return "acos";
case otatan: case otatan:
return "atan"; return "atan";
case otatan2:
return "atan2";
case otsinh: case otsinh:
return "sinh"; return "sinh";
case otcosh: case otcosh:
@ -398,100 +467,172 @@ Foam::word Foam::equationOperation::opName
case otstabilise: case otstabilise:
return "stabilise"; return "stabilise";
default: default:
FatalErrorIn return "unlisted";
(
"Foam::word Foam::equationOperation::opName"
"(const Foam::equationOperation::operationType& op)"
)
<< "invalid operation"
<< exit(FatalError);
return "invalid";
} }
} }
Foam::word Foam::equationOperation::sourceName Foam::word Foam::equationOperation::sourceName
( (
const Foam::equationOperation::sourceListType& sl const Foam::equationOperation::sourceTypeEnum& st
) )
{ {
switch (sl) switch (st)
{ {
case slnone: case stnone:
return "none"; return "none";
case sldictSource: case ststorage:
return "dictionary";
case slexternalDScalar:
return "dimensionedScalar";
case slexternalScalar:
return "scalar";
case slexternalScalarList:
return "scalarList";
case slinternalScalar:
return "constant";
case slequation:
return "equation";
case slstorage:
return "memory"; return "memory";
case stactiveSource:
return "activeEquationVariable";
case stequation:
return "equation";
case stinternalScalar:
return "constant";
case stdictSource:
return "dictionary";
case stscalarSource:
return "scalar";
case stscalarFieldSource:
return "scalarField";
case stvectorSource:
return "vector";
case stvectorFieldSource:
return "vectorField";
case sttensorSource:
return "tensor";
case sttensorFieldSource:
return "tensorField";
case stdiagTensorSource:
return "diagTensor";
case stdiagTensorFieldSource:
return "diagTensorField";
case stsymmTensorSource:
return "symmTensor";
case stsymmTensorFieldSource:
return "symmTensorField";
case stsphericalTensorSource:
return "sphericalTensor";
case stsphericalTensorFieldSource:
return "sphericalTensorField";
default: default:
FatalErrorIn return "unlisted";
(
"Foam::word Foam::equationOperation::opName"
"(const Foam::equationOperation::operationType& op)"
)
<< "invalid source"
<< exit(FatalError);
return "invalid";
} }
} }
void Foam::equationOperation::assignSourceFunction void Foam::equationOperation::assignSourceScalarFieldFunction
( (
dimensionedScalar (Foam::equationReader::*getSourceFunction) const scalarField& (Foam::equationReader::*getSourceScalarFieldFunction)
( (
equationReader *, const equationReader *,
const label, const label,
const label, const label,
const label, const label,
const label const label
) ) const
) ) const
{ {
getSourceFunction_ = getSourceFunction; getSourceScalarFieldFunction_ = getSourceScalarFieldFunction;
} }
void Foam::equationOperation::assignOpFunction void Foam::equationOperation::assignOpScalarFieldFunction
( (
void (Foam::equationReader::*opFunction) void (Foam::equationReader::*opScalarFieldFunction)
( (
equationReader *, const equationReader *,
const label, const label,
const label, const label,
const label, const label,
label&, label&,
dimensionedScalar&, scalarField&,
dimensionedScalar const scalarField&
) ) const
) ) const
{ {
opFunction_ = opFunction; opScalarFieldFunction_ = opScalarFieldFunction;
} }
Foam::dimensionedScalar Foam::equationOperation::getSourceFunction void Foam::equationOperation::assignSourceScalarFunction
( (
equationReader * eqnReader, scalar (Foam::equationReader::*getSourceScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const
) const
{
getSourceScalarFunction_ = getSourceScalarFunction;
}
void Foam::equationOperation::assignOpScalarFunction
(
void (Foam::equationReader::*opScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
scalar&,
scalar
) const
) const
{
opScalarFunction_ = opScalarFunction;
}
void Foam::equationOperation::assignSourceDimsFunction
(
dimensionSet (Foam::equationReader::*getSourceDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const
) const
{
getSourceDimsFunction_ = getSourceDimsFunction;
}
void Foam::equationOperation::assignOpDimsFunction
(
void (Foam::equationReader::*opDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
dimensionSet&,
dimensionSet
) const
) const
{
opDimsFunction_ = opDimsFunction;
}
const Foam::scalarField& Foam::equationOperation::getSourceScalarFieldFunction
(
const equationReader * eqnReader,
const label equationIndex, const label equationIndex,
const label equationOperationIndex, const label equationOperationIndex,
const label maxStoreIndex, const label maxStoreIndex,
const label storageOffset const label storageOffset
) ) const
{ {
return (eqnReader->*getSourceFunction_) return (eqnReader->*getSourceScalarFieldFunction_)
( (
eqnReader, eqnReader,
equationIndex, equationIndex,
@ -502,37 +643,125 @@ Foam::dimensionedScalar Foam::equationOperation::getSourceFunction
} }
void Foam::equationOperation::opFunction void Foam::equationOperation::opScalarFieldFunction
( (
equationReader * eqnReader, const equationReader * eqnReader,
const label index, const label index,
const label i, const label i,
const label storageOffset, const label storageOffset,
label& storageIndex, label& storageIndex,
dimensionedScalar& ds, scalarField& x,
dimensionedScalar source const scalarField& source
) ) const
{ {
(eqnReader->*opFunction_) (eqnReader->*opScalarFieldFunction_)
( (
eqnReader, eqnReader,
index, index,
i, i,
storageOffset, storageOffset,
storageIndex, storageIndex,
ds, x,
source source
); );
} }
Foam::scalar Foam::equationOperation::getSourceScalarFunction
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
return (eqnReader->*getSourceScalarFunction_)
(
eqnReader,
equationIndex,
equationOperationIndex,
maxStoreIndex,
storageOffset
);
}
void Foam::equationOperation::opScalarFunction
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
scalar& x,
scalar source
) const
{
(eqnReader->*opScalarFunction_)
(
eqnReader,
index,
i,
storageOffset,
storageIndex,
x,
source
);
}
Foam::dimensionSet Foam::equationOperation::getSourceDimsFunction
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
return (eqnReader->*getSourceDimsFunction_)
(
eqnReader,
equationIndex,
equationOperationIndex,
maxStoreIndex,
storageOffset
);
}
void Foam::equationOperation::opDimsFunction
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const
{
(eqnReader->*opDimsFunction_)
(
eqnReader,
index,
i,
storageOffset,
storageIndex,
xDims,
sourceDims
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
int Foam::operator==(const equationOperation& I1, const equationOperation& I2) int Foam::operator==(const equationOperation& I1, const equationOperation& I2)
{ {
return return
( (
I1.sourceList() == I2.sourceList() I1.sourceType() == I2.sourceType()
&& I1.sourceIndex() == I2.sourceIndex() && I1.sourceIndex() == I2.sourceIndex()
&& I1.dictLookupIndex() == I2.dictLookupIndex() && I1.dictLookupIndex() == I2.dictLookupIndex()
&& I1.operation() == I2.operation() && I1.operation() == I2.operation()
@ -547,28 +776,52 @@ int Foam::operator!=(const equationOperation& I1, const equationOperation& I2)
} }
// * * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * //
void Foam::equationOperation::operator=(Foam::equationOperation& eqn)
{
source_ = eqn.source_;
sourceIndex_ = eqn.sourceIndex_;
componentIndex_ = eqn.componentIndex_;
dictLookupIndex_ = eqn.dictLookupIndex_;
operation_ = eqn.operation_;
getSourceScalarFieldFunction_ = eqn.getSourceScalarFieldFunction_;
opScalarFieldFunction_ = eqn.opScalarFieldFunction_;
getSourceScalarFunction_ = eqn.getSourceScalarFunction_;
opScalarFunction_ = eqn.opScalarFunction_;
getSourceDimsFunction_ = eqn.getSourceDimsFunction_;
opDimsFunction_ = eqn.opDimsFunction_;
}
// * * * * * * * * * * * * * Friend IOstream Operators * * * * * * * * * * * // // * * * * * * * * * * * * * Friend IOstream Operators * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, equationOperation& I) Foam::Istream& Foam::operator>>(Istream& is, equationOperation& I)
{ {
label sl(I.sourceList_); label st(I.source_);
label op(I.operation_); label op(I.operation_);
is >> sl >> I.sourceIndex_ >> I.dictLookupIndex_ >> op; is >> st >> I.sourceIndex_ >> I.dictLookupIndex_ >> op;
return is; return is;
} }
Foam::Ostream& Foam::operator<<(Ostream& os, const equationOperation& I) Foam::Ostream& Foam::operator<<(Ostream& os, const equationOperation& I)
{ {
label sl(I.sourceList_); label st(I.source_);
label op(I.operation_); label op(I.operation_);
return os << nl << "/* sourceList: */\t" << sl << nl return os << nl << "/* sourceType: */\t" << st
<< " /* "
<< equationOperation::sourceName(I.source_)
<< " */" << nl
<< "/* sourceIndex: */\t" << I.sourceIndex_ << nl << "/* sourceIndex: */\t" << I.sourceIndex_ << nl
<< "/* componentIndex:*/\t" << I.componentIndex_ << nl
<< "/* dictIndex */\t" << I. dictLookupIndex_ << nl << "/* dictIndex */\t" << I. dictLookupIndex_ << nl
<< "/* operation: */\t" << op << nl; << "/* operation: */\t" << op
<< " /* "
<< equationOperation::opName(I.operation_)
<< " */" << nl;
} }
// ************************************************************************* // // ************************************************************************* //

View file

@ -0,0 +1,558 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::equationOperation
Description
Defines a single operation to be performed in sequence while evaluating an
equation read from a dictionary.
SourceFiles
equationOperationI.H
equationOperation.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationOperation_H
#define equationOperation_H
#include "word.H"
#include "label.H"
#include "IOstreams.H"
#include "dimensionedScalar.H"
// #include "Istream.H"
// #include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class equationOperation;
class equationReader;
// Friend Operators
int operator==(const equationOperation&, const equationOperation&);
int operator!=(const equationOperation&, const equationOperation&);
// Friend IOstream Operators
Istream& operator>>(Istream&, equationOperation&);
Ostream& operator<<(Ostream&, const equationOperation&);
/*---------------------------------------------------------------------------*\
Class equationOperation Declaration
\*---------------------------------------------------------------------------*/
class equationOperation
{
public:
enum sourceTypeEnum
{
stnone,
ststorage,
stactiveSource,
stequation,
stinternalScalar,
stdictSource,
stscalarSource,
stscalarFieldSource,
stvectorSource,
stvectorFieldSource,
sttensorSource,
sttensorFieldSource,
stdiagTensorSource,
stdiagTensorFieldSource,
stsymmTensorSource,
stsymmTensorFieldSource,
stsphericalTensorSource,
stsphericalTensorFieldSource
};
enum operationType
{
otnone,
otretrieve,
otstore,
otplus,
otminus,
ottimes,
otdivide,
otpow,
otsign,
otpos,
otneg,
otmag,
otlimit,
otminMod,
otsqrtSumSqr,
otsqr,
otpow3,
otpow4,
otpow5,
otpow6,
otinv,
otsqrt,
otcbrt,
othypot,
otexp,
otlog,
otlog10,
otsin,
otcos,
ottan,
otasin,
otacos,
otatan,
otatan2,
otsinh,
otcosh,
ottanh,
otasinh,
otacosh,
otatanh,
oterf,
oterfc,
otlgamma,
otj0,
otj1,
otjn,
oty0,
oty1,
otyn,
otmax,
otmin,
otstabilise
};
private:
// Source to read the data from
sourceTypeEnum source_;
// Index in the field where the data is located. Note, the
// equationOperation lists created by equationReader make this variable a
// 1-indexed (i.e. starts from 1, not zero) in order to use its sign to
// store the sign of the variable. The sourceTypes are zero-indexed, so
// equationReader will constantly be adding / subtracting 1 to get these
// to match
label sourceIndex_;
// Component index - for Types with multiple components
label componentIndex_;
// Rather than store the keywords that have to be searched in a dictionary,
// equationReader keeps its own list of keywords, and the dictLookupIndex
// is the index in this list. This is only applicable if the sourceType is
// of type sldictSource
label dictLookupIndex_;
// The operation to be performed (+ - sin exp min, etc...)
operationType operation_;
// A pointer to the scalarField source data retrieval function
mutable const scalarField&
(Foam::equationReader::*getSourceScalarFieldFunction_)
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
// A pointer to the scalarField operation to be performed
mutable void (Foam::equationReader::*opScalarFieldFunction_)
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
scalarField& x,
const scalarField& source
) const;
// A pointer to the scalar source data retrieval function
mutable scalar (Foam::equationReader::*getSourceScalarFunction_)
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
// A pointer to the scalar operation to be performed
mutable void (Foam::equationReader::*opScalarFunction_)
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
scalar& x,
scalar source
) const;
// A pointer to the dimensions source data retrieval function
mutable dimensionSet (Foam::equationReader::*getSourceDimsFunction_)
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
// A pointer to the dimension operation to be performed
mutable void (Foam::equationReader::*opDimsFunction_)
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
public:
// Static data members
static const char* const typeName;
// Constructors
//- Construct null
equationOperation();
//- Construct copy
equationOperation(const equationOperation& eqop);
//- Construct from components
equationOperation
(
sourceTypeEnum source,
label sourceIndex,
label componentIndex,
label dictLookupIndex,
operationType operation,
const scalarField&
(Foam::equationReader::*getSourceScalarFieldFunction_)
(
const equationReader *,
const label,
const label,
const label,
const label
) const = NULL,
void (Foam::equationReader::*opScalarFieldFunction_)
(
const equationReader *,
const label,
const label,
const label,
label&,
scalarField&,
const scalarField&
) const = NULL,
scalar (Foam::equationReader::*getSourceScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const = NULL,
void (Foam::equationReader::*opScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
scalar&,
scalar
) const = NULL,
dimensionSet (Foam::equationReader::*getSourceDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const = NULL,
void (Foam::equationReader::*opDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
dimensionSet&,
dimensionSet
) const = NULL
);
// Destructor
~equationOperation();
// Member functions
// Access
//- Const access to source
inline const sourceTypeEnum& sourceType() const;
//- Access to source
inline sourceTypeEnum& sourceType();
//- Const access to source index
inline const label& sourceIndex() const;
//- Access to source index
inline label& sourceIndex();
//- Const access to componentIndex
inline const label& componentIndex() const;
//- Access to componentIndex
inline label& componentIndex();
//- Const access to dictionary lookup name index
inline const label& dictLookupIndex() const;
//- Access to dictionary lookup name index
inline label& dictLookupIndex();
//- Const access to operation
inline const operationType& operation() const;
//- Access to operation
inline operationType& operation();
// Function pointers
//- Assign the source scalarField function
void assignSourceScalarFieldFunction
(
const scalarField&
(Foam::equationReader::*getSourceScalarFieldFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const
) const;
//- Assign the operation scalarField function
void assignOpScalarFieldFunction
(
void (Foam::equationReader::*opScalarFieldFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
scalarField&,
const scalarField&
) const
) const;
//- Assign the source scalar function
void assignSourceScalarFunction
(
scalar (Foam::equationReader::*getSourceScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const
) const;
//- Assign the operation scalar function
void assignOpScalarFunction
(
void (Foam::equationReader::*opScalarFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
scalar&,
scalar
) const
) const;
//- Assign the source dimensions function
void assignSourceDimsFunction
(
dimensionSet (Foam::equationReader::*getSourceDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
const label
) const
) const;
//- Assign the operation dimensions function
void assignOpDimsFunction
(
void (Foam::equationReader::*opDimsFunction)
(
const equationReader *,
const label,
const label,
const label,
label&,
dimensionSet&,
dimensionSet
) const
) const;
//- Call the getSourceScalarField function
const scalarField& getSourceScalarFieldFunction
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
//- Call the operation scalarField function
void opScalarFieldFunction
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
scalarField& x,
const scalarField& source
) const;
//- Call the getSourceScalar function
scalar getSourceScalarFunction
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
//- Call the operation scalar function
void opScalarFunction
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
scalar& x,
scalar source
) const;
//- Call the getSourceDims function
dimensionSet getSourceDimsFunction
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
void opDimsFunction
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
// Convenience
//- Look up operation number, given a word
static operationType findOp(const word& opName);
//- Look up operation name
static word opName(const operationType& op);
//- Look up sourceType name
static word sourceName(const sourceTypeEnum& st);
// Operators
void operator=(equationOperation&);
// Friend IOstream Operators
friend Istream& operator>>(Istream&, equationOperation&);
friend Ostream& operator<<(Ostream&, const equationOperation&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationOperationI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -29,17 +29,17 @@ License
namespace Foam namespace Foam
{ {
inline const equationOperation::sourceListType& inline const equationOperation::sourceTypeEnum&
equationOperation::sourceList() const equationOperation::sourceType() const
{ {
return sourceList_; return source_;
} }
inline equationOperation::sourceListType& inline equationOperation::sourceTypeEnum&
equationOperation::sourceList() equationOperation::sourceType()
{ {
return sourceList_; return source_;
} }
@ -54,6 +54,19 @@ inline label& equationOperation::sourceIndex()
return sourceIndex_; return sourceIndex_;
} }
inline const label& equationOperation::componentIndex() const
{
return componentIndex_;
}
inline label& equationOperation::componentIndex()
{
return componentIndex_;
}
inline const label& equationOperation::dictLookupIndex() const inline const label& equationOperation::dictLookupIndex() const
{ {
return dictLookupIndex_; return dictLookupIndex_;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,910 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::equationReader
Description
The master class for reading equations from a dictionary file. This class
holds all the equations, all the data sources, and gives access to all the
equation parsing / evaluating functions.
Has in-depth debug logging to help find problems with equations. Debug
switches:
@verbatim
0 - None
1 - Report scalar evaluations (per equation)
2 - Report scalar evaluations (per operation - very verbose)
3 - Report dimension evaluations (per equation)
4 - Report dimension evaluations (per operation - very verbose)
5 - Combine 1 and 3 above
6 - Combine 2 and 4 above
@endverbatim
Additional index checking implemented in FULLDEBUG mode.
SourceFiles
Since there are so many files for this object, each function that is not
implemented in equationReader.C has a comment indicating the associated
file.
Inline functions
equationReaderI.H
Standard functions
equationReader.C
equationReaderAssignFunctionPointers.C
equationReaderCreateMap.C
equationReaderEvaluate.C
equationReaderParse.C
Templates included with norepository
equationReaderTemplates.C
Template specialization
equationReaders.C
Input / output functions
equationReaderIO.C
Files with functions called through function-pointers
equationReaderDebugP.H
equationReaderDebugP.C
equationReaderEvalDimsP.H
equationReaderEvalDimsP.C
equationReaderEvalScalarP.H
equationReaderEvalScalarP.C
equationReaderGetSourceDimsP.H
equationReaderGetSourceDimsP.C
equationReaderGetSourceScalarP.H
equationReaderGetSourceScalarP.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationReader_H
#define equationReader_H
#include "versionSpecific.H"
#include "equationReaderVersion.H"
#include "equationSource.H"
#include "equationVariable.H"
#include "dictionary.H"
#include "diagTensor.H"
//#include "dimensionedScalar.H"
#include "UPtrList.H"
//#include "equationList.H"
#include "tokenList.H"
#include "labelList.H"
#include "GeometricFields.H"
//#include "DimensionedField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class equation;
class equationOperation;
// *** Located in equationReaderIO.C ***
class equationReader;
Istream& operator>>(Istream&, equationReader&);
Ostream& operator<<(Ostream&, const equationReader&);
/*---------------------------------------------------------------------------*\
Class equationReader Declaration
\*---------------------------------------------------------------------------*/
class equationReader
//:public PtrList<equation>
{
// Private data
//- Equations
mutable PtrList<equation> eqns_;
//- Dependency backtrace, used for circular-reference detection
mutable labelList dependents_;
// Debug function pointers
// equationReader has in-depth debug logging to help users identify
// problems with their equations. The debugging lines are encountered
// so frequently that they would seriously impact performance if a
// conventional conditional framework is used: "if (debug)". To
// improve execution time, debug function pointers and associated
// functions are used.
// *** Data and prototypes located in equationReaderDebugP.H ***
// *** Implementation located in equationReaderDebugP.C ***
# include "equationReaderDebugP.H"
// Sources - these are locations where variables appearing in the
// equations can be retrieved
//- Internal scalars for storing constants read from equations.
mutable PtrList<scalar> internalScalars_;
//- Variables that can be looked up in a dictionary
UPtrList<const dictionary> dictSources_;
//- Words to be looked up in a dictionary (equation operation only
// gives indices; this is necessary if the source is a dictionary)
mutable PtrList<word> dictLookups_;
//- Active equation variable sources
mutable UPtrList<const equationVariable> activeSources_;
//- List of active equation variable names
mutable wordList activeSourceNames_;
//- External scalar sources
equationSource<scalar> scalarSources_;
//- External vector sources
equationSource<vector> vectorSources_;
//- External tensor sources
equationSource<tensor> tensorSources_;
//- External diagTensor sources
equationSource<diagTensor> diagTensorSources_;
//- External symmetricTensor sources
equationSource<symmTensor> symmTensorSources_;
//- External sphericalTensor sources
equationSource<sphericalTensor> sphericalTensorSources_;
//- Current geoIndex of source fields
mutable label geoIndex_;
//- Current cellIndex of source fields
mutable label cellIndex_;
//- Temporary storage during evaluation
//mutable fieldSize_;
mutable scalarField tempSrcField_;
mutable PtrList<scalarField> storageScalarFields_;
mutable scalarList storageScalars_;
mutable PtrList<dimensionSet> storageDims_;
// Private Member Functions
//- Disallow default bitwise copy construct
equationReader(const equationReader&);
//- Disallow default bitwise assignment
void operator=(const equationReader&);
//- Internal dimensions evaluation function
// *** Located in equationReaderEvaluate.C ***
dimensionSet internalEvaluateDimensions
(
const label& equationIndex,
label storageOffset
) const;
//- Internal scalar evaluation function
// *** Located in equationReaderEvaluate.C ***
scalar internalEvaluateScalar
(
const label& equationIndex,
label storageOffset
) const;
//- Internal scalarField evaluation function
// *** Located in equationReaderEvaluate.C ***
void internalEvaluateScalarField
(
scalarField& result,
const label& equationIndex,
label storageOffset
) const;
//- Internal final dimension checking / error throwing
// *** Located in equationReaderEvaluate.C ***
void checkFinalDimensions
(
const label& equationIndex,
dimensionSet& expectedDimensions,
const word& outputName
) const;
// Main parser functions
//- Parse an equation
// *** Located in equationReaderParse.C ***
void parse(label index) const;
// Parses a segment of an equation, used after parenthesis
// precedence is determined. Returns the map index that holds the
// source info for the result
// *** Located in equationReaderParse.C ***
label parseExpression
(
label index,
const tokenList& tl,
const labelList& opLvl,
PtrList<equationOperation>& map,
const labelList& indices,
label& storeIndex
) const;
// General parser support functions
//- Creates a new equation but does not parse it. If equation
// exists, throws an error. Returns equationIndex.
label createEquation
(
equation& eqn
) const;
//- Post an error related to equation parsing. Reports the exact
// position of the error in the equation string.
void fatalParseError
(
const label index,
const tokenList& tl,
const label fromToken,
const label toToken,
const string& errorIn,
const OStringStream& description
) const;
//- Modify the equation string going in to the parser:
// - change ^ into : to allow detection of powers
// - add spaces around ( ) + - * / , ^ to prevent expressions from
// combining as words
static string stringPreconditioner(const string& rawString);
//- Search through a string and replace all instances of findMe
// with replaceWith
static void stringReplaceAll
(
string& working,
const string& findMe,
const string& replaceWith
);
//- Create a map of: parenthesis levels, operation levels,
// functions, and variable sources
// *** Located in equationReaderCreateMap.C ***
void createMap
(
const label index,
const tokenList& tl,
PtrList<equationOperation>& map,
labelList& opLvl,
labelList& pl
) const;
//- Bug fix - once map is created, we find any 'pow(a,b)' instances
// and remove the b part to a seperate equation
void removePowExponents
(
const label index,
tokenList& tl,
PtrList<equationOperation>& map,
labelList& opLvl,
labelList& pl
) const;
//- Returns a labelList with the indices of the maximum operation
// level. If more than one grouping exists, returns the first
// one.
labelList findMaxOperation
(
const labelList& opLvl,
const labelList& indices
) const;
//- Returns a labelList with the indices of the maximum parenthesis
// level. If more than one grouping exists, returns the first
// one.
labelList findMaxParenthesis
(
const labelList& parenthesisList,
const labelList& equationIndices
) const;
//- Find all negatives, give the upstream token a negative source
// index, and trim them from the list
void absorbNegatives
(
const label equationIndex,
const tokenList& tl,
labelList& eqnIndices,
labelList& subEqnIndices,
PtrList<equationOperation>& map,
labelList& opLvl
) const;
//- Finds the maximum field size that can be returned from an
// equation, based on its sources, indexed by geoIndex
void findMaxFieldSize(const label equationIndex) const;
//- Sets the first dimensionedScalar equal to the second one
// without tripping dimension checking errors
void dsEqual
(
dimensionedScalar& dso,
const dimensionedScalar& dsi
) const;
// Indexing-related support functions
//- Given a labelList 'indices', remove all entries from position
// 'from' to position 'to', but not including 'exceptFor', if
// specified. Search through labelList 'parent', find the same
// entries by value (not position), and remove these also.
static void trimListWithParent
(
labelList& parent,
labelList& indices,
label from,
label to,
label exceptFor = -1
);
//- Removes indices from a labelList, including from and to
// indices, but not including exceptFor index, if specified.
static void trimList
(
labelList& indices,
label from,
label to,
label exceptFor = -1
);
//- Search through a labelList and return the index with the value
// 'value'. Return -1 if failed.
static label findIndex
(
const label value,
const labelList& indexList
);
// Data-handling support functions
//- Return the source list and source index associated with a
// variable name. Searches in this order:
// - other known equations
// - activeSources;
// - scalarSources, then scalarFieldSources;
// - vectorSources, then vectorFieldSources;
// - tensorSources, then tensorFieldSources;
// - diagTensorSources, then diagTensorFieldSources;
// - symmTensorSources, then symmTensorFieldSources;
// - sphericalTensorSources, then sphericalTensorFieldSources;
// - dictSources, which may be either:
// -- a scalar;
// -- a dimensionedScalar; or
// -- a yet unknown equation;
// Returns the source info upon finding it; does not check for
// duplicates.
equationOperation findSource(const word& varName) const;
//- Add a constant to the internal scalar source list
label addInternalScalar(const scalar& value) const;
// Function-pointer functions, used for efficient evaluation
// equationReader uses dynamically linked function pointers for
// efficient evaluation and data sourcing. This has the effect of
// moving all conditionals to the initial parsing stage, allowing the
// equations to be evaluated without conditonals. Since conditionals
// are slow, execution speed approaches that of hard-coded equations.
//
// Data sourcing functions for dimensionSet evaluation:
// *** Prototypes located in equationReaderGetSourceDimsP.H ***
// *** Implemented in equationReaderGetSourceDimsP.C ***
//
// Data sourcing functions for scalar evaluation:
// *** Prototypes located in equationReaderGetSourceScalarP.H ***
// *** Implemented in equationReaderGetSourceScalarP.C ***
//
// Data sourcing functions for scalarField evaluation:
// *** Prototypes located in equationReaderGetSourceScalarFieldP.H ***
// *** Implemented in equationReaderGetSourceScalarFieldP.C ***
//
// Evaluation functions for dimensionSet evaluation:
// *** Prototypes located in equationReaderEvalDimsP.H ***
// *** Implemented in equationReaderEvalDimsP.C ***
//
// Evaluation functions for scalar evaluation:
// *** Prototypes located in equationReaderEvalScalarP.H ***
// *** Implemented in equationReaderEvalScalarP.C ***
//
// Evaluation functions for scalarField evaluation:
// *** Prototypes located in equationReaderEvalScalarFieldP.H ***
// *** Implemented in equationReaderEvalScalarFieldP.C ***
# include "equationReaderGetSourceDimsP.H"
# include "equationReaderGetSourceScalarP.H"
# include "equationReaderGetSourceScalarFieldP.H"
# include "equationReaderEvalDimsP.H"
# include "equationReaderEvalScalarP.H"
# include "equationReaderEvalScalarFieldP.H"
//- Link the functions to the pointers
// *** Located in equationReaderAssignFunctionPointers.C ***
void assignFunctionPointers(const label index) const;
// Functions to emulate "is a" PtrList<equation>, rather than "has a"
// (because the equations have to be mutable)
//- Set size of equation list (private)
void setSize(const label newSize) const;
//- Set the an element of the equation list (private)
void set(const label index, equation * eqn) const;
public:
// Static data members
TypeName("equationReader");
// Constructor (construct null)
equationReader(bool showSplash = true);
// Destructor
virtual ~equationReader();
// Member functions
// Access
//- Version number
word version() const;
//- Equation list
inline const PtrList<equation>& eqns() const;
//- Internal scalars
// *** Located in equationReaderI.H ***
inline const PtrList<scalar>& internalScalars() const;
//- Dictionary sources
// *** Located in equationReaderI.H ***
inline const UPtrList<const dictionary>& dictSources() const;
//- Dictionary lookup words
// *** Located in equationReaderI.H ***
inline const PtrList<word>& dictLookups() const;
//- Active equation variable sources
// *** Located in equationReaderI.H ***
inline const UPtrList<const equationVariable>&
activeSources() const;
//- Active equation variable source names
// *** Located in equationReaderI.H ***
inline const wordList& activeSourceNames() const;
//- Access scalar sources
// *** Located in equationReaderI.H ***
inline const equationSource<scalar>& scalarSources() const;
inline equationSource<scalar>& scalarSources();
//- Access vector sources
// *** Located in equationReaderI.H ***
inline const equationSource<vector>& vectorSources() const;
inline equationSource<vector>& vectorSources();
//- Access tensor sources
// *** Located in equationReaderI.H ***
inline const equationSource<tensor>& tensorSources() const;
inline equationSource<tensor>& tensorSources();
//- Access diagTensor sources
// *** Located in equationReaderI.H ***
inline const equationSource<diagTensor>& diagTensorSources() const;
inline equationSource<diagTensor>& diagTensorSources();
//- Access symmetricTensor sources
// *** Located in equationReaderI.H ***
inline const equationSource<symmTensor>& symmTensorSources() const;
inline equationSource<symmTensor>& symmTensorSources();
//- Access sphericalTensor sources
// *** Located in equationReaderI.H ***
inline const equationSource<sphericalTensor>&
sphericalTensorSources() const;
inline equationSource<sphericalTensor>& sphericalTensorSources();
//- Current geoIndex with the fields
// *** Located in equationReaderI.H ***
inline const label& geoIndex() const;
//- Change the index for fields
// *** Located in equationReaderI.H ***
inline void setGeoIndex(label newIndex);
//- Current cellIndex with the fields
// *** Located in equationReaderI.H ***
inline const label& cellIndex() const;
//- Change the index for fields
// *** Located in equationReaderI.H ***
inline void setCellIndex(label newIndex);
// Data lookup
//- Returns true if equationName exists in equation list
bool found(const word& equationName);
//- Returns the index of a given equationName, -1 if not found
label lookup(const word& equationName) const;
// Adding data sources
//- Add a dictionary
void addSource(const dictionary& dict);
//- Add an active variable
void addSource(const equationVariable& aVar);
// Equations
//- Read an equation, given the equation.
// okayToReread: false=throw error if equation already exists
// true=reread the equation
// Returns equationIndex that is assigned
label readEquation
(
equation eqn,
bool okayToReread = false
);
//- Read an equation from a dictionary
// okayToReread: false=throw error if equation already exists
// true=reread the equation
// Returns equationIndex that is assigned
label readEquation
(
const dictionary& sourceDict,
const word& eqnName,
bool okayToReread = false
);
//- Force an equation to re-parse
void clearEquation(const label equationIndex) const;
//- Delete an equation, given a name
void deleteEquation(const word& equationName);
//- Delete an equation, given an index number
void deleteEquation(const label& index);
// Evaluate equations
//- Return a scalar, given the equation name
// *** Located in equationReaderEvaluate.C ***
scalar evaluateScalar
(
const word& equationName,
const label cellIndex = 0,
const label geoIndex = 0
) const;
//- Return a scalar, given the equation index
// *** Located in equationReaderEvaluate.C ***
scalar evaluateScalar
(
const label equationIndex,
const label cellIndex = 0,
const label geoIndex = 0
) const;
//- Return the resulting dimensions, given an equation name
// *** Located in equationReaderEvaluate.C ***
dimensionSet evaluateDimensions(const word& equationName) const;
//- Return the resulting dimensions, given an equation index
// *** Located in equationReaderEvaluate.C ***
dimensionSet evaluateDimensions(const label equationIndex) const;
//- Return a dimensionedScalar, given the equation name
// *** Located in equationReaderEvaluate.C ***
dimensionedScalar evaluateDimensionedScalar
(
const word& equationName,
const label cellIndex = 0,
const label geoIndex = 0
) const;
//- Return a dimensionedScalar, given the equation index
// *** Located in equationReaderEvaluate.C ***
dimensionedScalar evaluateDimensionedScalar
(
const label equationIndex,
const label cellIndex = 0,
const label geoIndex = 0
) const;
//- Fill a given scalarField, given an equation name
// *** Located in equationReaderEvaluate.C ***
void evaluateScalarField
(
scalarField& resultField,
const word& equationName,
const label geoIndex = 0
) const;
//- Fill a given scalarField, given an equation index
// *** Located in equationReaderEvaluate.C ***
void evaluateScalarField
(
scalarField& resultField,
const label equationIndex,
const label geoIndex = 0
) const;
//- Fill the named component of a given Field<Type>, given an
// equation name
// *** Located in equationReaderTemplates.C ***
template<class Type>
void evaluateTypeField
(
Field<Type>& resultField,
const word& componentName,
const word& equationName,
const label geoIndex = 0
) const;
//- Fill the given component of a given Field<Type>, given an
// equation index
// *** Located in equationReaderTemplates.C ***
template<class Type>
void evaluateTypeField
(
Field<Type>& resultField,
const label componentIndex,
const label equationIndex,
const label geoIndex = 0
) const;
//- Fill a given dimensioned scalarField, given an equation name
// *** Located in equationReaderTemplates.C ***
template<class GeoMesh>
void evaluateDimensionedScalarField
(
DimensionedField<scalar, GeoMesh>& resultDField,
const word& equationName,
const label geoIndex = 0
) const;
//- Fill a given dimensioned scalarField, given an equation index
// *** Located in equationReaderTemplates.C ***
template<class GeoMesh>
void evaluateDimensionedScalarField
(
DimensionedField<scalar, GeoMesh>& resultDField,
const label equationIndex,
const label geoIndex = 0
) const;
//- Fill the named component of a given dimensionedField<Type>,
// given an equation name
// *** Located in equationReaderTemplates.C ***
template<class Type, class GeoMesh>
void evaluateDimensionedTypeField
(
DimensionedField<Type, GeoMesh>& resultDField,
const word& componentName,
const word& equationName,
const label geoIndex = 0
) const;
//- Fill the given component of a given dimensionedField<Type>,
// given an equation index
// *** Located in equationReaderTemplates.C ***
template<class Type, class GeoMesh>
void evaluateDimensionedTypeField
(
DimensionedField<Type, GeoMesh>& resultDField,
const label componentIndex,
const label equationIndex,
const label geoIndex = 0
) const;
//- Fill a given GeometricScalarField, given an equation name
// *** Located in equationReaderTemplates.C ***
template<template<class> class PatchField, class GeoMesh>
void evaluateGeometricScalarField
(
GeometricField<scalar, PatchField, GeoMesh>& resultGField,
const word& equationName
) const;
//- Fill a given GeometricField, given an equation index
// *** Located in equationReaderTemplates.C ***
template <template<class> class PatchField, class GeoMesh>
void evaluateGeometricScalarField
(
GeometricField<scalar, PatchField, GeoMesh>& resultGField,
const label equationIndex
) const;
//- Fill the named component of a given GeometricField<Type>,
// given an equation name
// *** Located in equationReaderTemplates.C ***
template
<
class Type, template<class> class PatchField, class GeoMesh
>
void evaluateGeometricTypeField
(
GeometricField<Type, PatchField, GeoMesh>& resultGField,
const word& componentName,
const word& equationName
) const;
//- Fill the given component of a given GeometricField<Type>,
// given an equation index
// *** Located in equationReaderTemplates.C ***
template
<
class Type, template<class> class PatchField, class GeoMesh
>
void evaluateGeometricTypeField
(
GeometricField<Type, PatchField, GeoMesh>& resultGField,
const label componentIndex,
const label equationIndex
) const;
// Tools
//- Returns true if the stream is a dimensionedScalar dictionary
// entry.
static bool isDimensionedScalar(ITstream& is);
//- Returns true if the stream is a word dictionary entry
static bool isWord(ITstream& is);
//- Returns true if the stream is a scalar dictionary entry
static bool isScalar(ITstream& is);
//- Returns true if the stream is a nameless dimensionedScalar
// dictionary entry
static bool isNamelessDimensionedScalar(ITstream& is);
//- Returns true if the stream is an equation entry
static bool isEquation(ITstream& is);
// Functions to emulate "is a" PtrList<equation>, rather than "has a"
// (because the equations have to be mutable)
//- Index operator
const equation& operator[](const label equationIndex) const;
//- Index operator
equation& operator[](const label equationIndex);
//- Return size of equation list
label size() const;
// Input / output related functions
// *** Located in equationReaderIO.C ***
//- Output data source information to the Ostream
Ostream& dataSourceStatus(Ostream& os) const;
friend Istream& operator>>(Istream&, equationReader&);
friend Ostream& operator<<(Ostream&, const equationReader&);
};
// Scalar specialisation
template<>
void equationReader::evaluateTypeField
(
scalarField& resultField,
const word& componentName,
const word& equationName,
const label geoIndex
) const;
// Scalar specialisation
template<>
void equationReader::evaluateTypeField
(
scalarField& resultField,
const label componentIndex,
const label equationIndex,
const label geoIndex
) const;
/*
// Scalar specialisation
template<class GeoMesh>
void evaluateDimensionedTypeField
(
DimensionedField<scalar, GeoMesh>& resultDField,
const word& componentName,
const word& equationName,
const label geoIndex
) const;
// Scalar specialisation
template<class GeoMesh>
void evaluateDimensionedTypeField
(
DimensionedField<scalar, GeoMesh>& resultDField,
const label componentIndex,
const label equationIndex,
const label geoIndex
) const;
// Scalar specialisation
template<template<class> class PatchField, class GeoMesh>
evaluateGeometricTypeField
(
GeometricField
<
scalar, template<class> class PatchField, class GeoMesh
>& resultGField,
const word& componentName,
const word& equationName
) const;
// Scalar specialisation
template<template<class> class PatchField, class GeoMesh>
evaluateGeometricTypeField
(
GeometricField
<
scalar, template<class> class PatchField, class GeoMesh
>& resultGField,
const label componentIndex,
const label equationIndex
) const;
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationReaderI.H"
#ifdef NoRepository
# include "equationReaderTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,10 @@ void Foam::equationReader::createMap
( (
const label index, const label index,
const tokenList& tl, const tokenList& tl,
equationOperationList& map, PtrList<equationOperation>& map,
labelList& opLvl, labelList& opLvl,
labelList& pl labelList& pl
) ) const
{ {
// equation * eqn(&this->operator[](index)); // equation * eqn(&this->operator[](index));
@ -49,35 +49,18 @@ void Foam::equationReader::createMap
// Internal constant. Save to internalScalars and record source // Internal constant. Save to internalScalars and record source
opLvl[i] = 0; opLvl[i] = 0;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slinternalScalar, i,
new equationOperation
(
equationOperation::stinternalScalar,
addInternalScalar(tl[i].number()) + 1, addInternalScalar(tl[i].number()) + 1,
0, 0,
equationOperation::otnone
);
/*
//Bug fix
eqn = &this->operator[](index);
eqn->internalScalars()->setSize
(
eqn->internalScalars()->size() + 1
);
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = tl[i].number();
opLvl[i] = 0;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slinternalScalar,
eqn->internalScalars()->size(),
0, 0,
equationOperation::otnone equationOperation::otnone
)
); );
*/
} }
else if (tl[i].isWord()) else if (tl[i].isWord())
{ {
@ -94,12 +77,17 @@ void Foam::equationReader::createMap
opLvl[i] = 4; opLvl[i] = 4;
p = -mag(p) - 1; p = -mag(p) - 1;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::findOp(tl[i].wordToken()) equationOperation::findOp(tl[i].wordToken())
)
); );
if (map[i].operation() == equationOperation::otnone) if (map[i].operation() == equationOperation::otnone)
@ -122,12 +110,17 @@ void Foam::equationReader::createMap
i++; i++;
opLvl[i] = 4; opLvl[i] = 4;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otnone equationOperation::otnone
)
); );
} }
else if else if
@ -145,21 +138,17 @@ void Foam::equationReader::createMap
) )
{ {
// Mathematical constant // Mathematical constant
//Bug fix
// eqn = &this->operator[](index);
if if
( (
findSource(tl[i].wordToken()).sourceList() findSource(tl[i].wordToken()).sourceType()
!= equationOperation::slnone != equationOperation::stnone
) )
{ {
// Found a possible conflicting variable name - warn // Found a possible conflicting variable name - warn
WarningIn("equationReader::createMap") WarningIn("equationReader::createMap")
<< "Equation for " << eqns_[index].equationName() << "Equation for " << operator[](index).name()
<< ", given by:" << token::NL << token::TAB << ", given by:" << token::NL << token::TAB
<< eqns_[index].rawText() << token:: NL << "refers " << operator[](index).rawText() << token:: NL << "refers "
<< "to '" << tl[i].wordToken() << "'. Although " << "to '" << tl[i].wordToken() << "'. Although "
<< "variable " << tl[i].wordToken() << "was found in " << "variable " << tl[i].wordToken() << "was found in "
<< "the data sources, " << tl[i].wordToken() << " is a" << "the data sources, " << tl[i].wordToken() << " is a"
@ -167,33 +156,31 @@ void Foam::equationReader::createMap
<< "will be used." << endl; << "will be used." << endl;
} }
/* eqn->internalScalars()->setSize
(
eqn->internalScalars()->size() + 1
);
*/
opLvl[i] = 0; opLvl[i] = 0;
pl[i] = p; pl[i] = p;
label internalIndex(0); label internalIndex(0);
if (tl[i].wordToken() == "e_") if (tl[i].wordToken() == "e_")
{ {
// MathConstantScope is a hack that allows equationReader
// to work in multiple versions of OpenFOAM. See
// include/versionSpecific.H
internalIndex = internalIndex =
addInternalScalar(mathematicalConstant::e) + 1; addInternalScalar(MathConstantScope::e) + 1;
} }
else if (tl[i].wordToken() == "pi_") else if (tl[i].wordToken() == "pi_")
{ {
internalIndex = internalIndex =
addInternalScalar(mathematicalConstant::pi) + 1; addInternalScalar(MathConstantScope::pi) + 1;
} }
else if (tl[i].wordToken() == "twoPi_") else if (tl[i].wordToken() == "twoPi_")
{ {
internalIndex = internalIndex =
addInternalScalar(mathematicalConstant::twoPi) + 1; addInternalScalar(MathConstantScope::twoPi) + 1;
} }
else if (tl[i].wordToken() == "piByTwo_") else if (tl[i].wordToken() == "piByTwo_")
{ {
internalIndex = internalIndex =
addInternalScalar(mathematicalConstant::piByTwo) + 1; addInternalScalar(MathConstantScope::piByTwo) + 1;
} }
else if (tl[i].wordToken() == "GREAT_") else if (tl[i].wordToken() == "GREAT_")
{ {
@ -225,101 +212,29 @@ void Foam::equationReader::createMap
internalIndex = internalIndex =
addInternalScalar(ROOTVSMALL) + 1; addInternalScalar(ROOTVSMALL) + 1;
} }
map[i] = equationOperation map.set
( (
equationOperation::slinternalScalar, i,
new equationOperation
(
equationOperation::stinternalScalar,
internalIndex, internalIndex,
0, 0,
equationOperation::otnone
);
/*
if (tl[i].wordToken() == "e_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::e;
}
else if (tl[i].wordToken() == "pi_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::pi;
}
else if (tl[i].wordToken() == "twoPi_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::twoPi;
}
else if (tl[i].wordToken() == "piByTwo_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::piByTwo;
}
else if (tl[i].wordToken() == "GREAT_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = GREAT;
}
else if (tl[i].wordToken() == "VGREAT_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = VGREAT;
}
else if (tl[i].wordToken() == "ROOTVGREAT_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = ROOTVGREAT;
}
else if (tl[i].wordToken() == "SMALL_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = SMALL;
}
else if (tl[i].wordToken() == "VSMALL_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = VSMALL;
}
else if (tl[i].wordToken() == "ROOTVSMALL_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = ROOTVSMALL;
}
opLvl[i] = 0;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slinternalScalar,
eqn->internalScalars()->size(),
0, 0,
equationOperation::otnone equationOperation::otnone
)
); );
*/
} }
else else
{ {
// Variable name // Variable name
opLvl[i] = 0; opLvl[i] = 0;
pl[i] = p; pl[i] = p;
map[i] = findSource(tl[i].wordToken()); map.set
(
i,
new equationOperation(findSource(tl[i].wordToken()))
);
if (map[i].sourceIndex() == 0) if (map[i].sourceIndex() == 0)
{ {
OStringStream description; OStringStream description;
@ -335,6 +250,23 @@ void Foam::equationReader::createMap
description description
); );
} }
if (map[i].componentIndex() < 0)
{
OStringStream description;
description << "Variable name " << tl[i].wordToken()
<< " is interpretted as variablePart.componentPart, "
<< "and the componentPart is not valid, or is "
<< "required, but is missing.";
fatalParseError
(
index,
tl,
i,
i,
"equationReader::parse",
description
);
}
} }
} }
else if (tl[i].isPunctuation()) else if (tl[i].isPunctuation())
@ -345,12 +277,17 @@ void Foam::equationReader::createMap
opLvl[i] = 4; opLvl[i] = 4;
p = mag(p) + 1; p = mag(p) + 1;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otnone equationOperation::otnone
)
); );
break; break;
case token::END_LIST: // ) case token::END_LIST: // )
@ -387,12 +324,17 @@ void Foam::equationReader::createMap
} }
} }
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otnone equationOperation::otnone
)
); );
break; break;
} }
@ -402,12 +344,17 @@ void Foam::equationReader::createMap
{ {
opLvl[i] = 5; opLvl[i] = 5;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otnone equationOperation::otnone
)
); );
} }
else else
@ -430,58 +377,100 @@ void Foam::equationReader::createMap
case token::ADD: // + case token::ADD: // +
opLvl[i] = 1; opLvl[i] = 1;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otplus equationOperation::otplus
)
); );
break; break;
case token::SUBTRACT: // - case token::SUBTRACT: // -
opLvl[i] = 1; opLvl[i] = 1;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otminus equationOperation::otminus
)
); );
break; break;
case token::MULTIPLY: // * case token::MULTIPLY: // *
opLvl[i] = 2; opLvl[i] = 2;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::ottimes equationOperation::ottimes
)
); );
break; break;
case token::DIVIDE: // / case token::DIVIDE: // /
opLvl[i] = 2; opLvl[i] = 2;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otdivide equationOperation::otdivide
)
); );
break; break;
case token::COLON: // :, means ^ case token::COLON: // :, means ^
{
OStringStream description;
description << "The '^' operator is not currently "
<< "supported. Use pow(a,b) instead.";
fatalParseError
(
index,
tl,
i,
i,
"equationReader::parse",
description
);
break;
}
/*
opLvl[i] = 3; opLvl[i] = 3;
pl[i] = p; pl[i] = p;
map[i] = equationOperation map.set
( (
equationOperation::slnone, i,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
equationOperation::otpow equationOperation::otpow
)
); );
break; break;
*/
default: default:
{ {
OStringStream description; OStringStream description;

View file

@ -0,0 +1,270 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::equationReader::reportEmbeddedDispatchDisabled () const
{
// do nothing
}
void Foam::equationReader::reportEmbeddedDispatchEnabled () const
{
Info << "Embedded equation dispatch." << endl;
}
void Foam::equationReader::reportEmbeddedReturnDisabled () const
{
// do nothing
}
void Foam::equationReader::reportEmbeddedReturnEnabled () const
{
Info << "Returned from embedded equation." << endl;
}
void Foam::equationReader::reportScalarEvalStartDisabled
(
const label& index
) const
{
// Do nothing
}
void Foam::equationReader::reportScalarEvalStartEnabled
(
const label& equationIndex
) const
{
const equation& eqn(operator[](equationIndex));
Info << "Evaluating equation " << equationIndex << ", "
<< eqn.name() << " at (geoIndex, cellIndex)=("
<< geoIndex_ << ", " << cellIndex_ << "), given by:"
<< token::NL << token::TAB << eqn.rawText() << endl;
}
void Foam::equationReader::reportScalarOperationDisabled
(
const label& index,
const label& i
) const
{
// do nothing
}
void Foam::equationReader::reportScalarOperationEnabled
(
const label& index,
const label& i
) const
{
const equationOperation& eqop(operator[](index)[i]);
const label zeroSourceIndex(mag(eqop.sourceIndex()) - 1);
Info << "Performing operation: ["
<< equationOperation::opName(eqop.operation()) << "] using source [";
switch (eqop.sourceType())
{
case equationOperation::stnone:
Info << "none";
break;
case equationOperation::ststorage:
Info << "memory spot (" << zeroSourceIndex << ")";
break;
case equationOperation::stactiveSource:
Info << activeSourceNames_[zeroSourceIndex];
break;
case equationOperation::stequation:
Info << operator[](zeroSourceIndex).name();
break;
case equationOperation::stinternalScalar:
Info << "constant (" << internalScalars_[zeroSourceIndex] << ")";
break;
case equationOperation::stdictSource:
Info << dictLookups_[zeroSourceIndex];
break;
case equationOperation::stscalarSource:
Info << scalarSources_.singleName(zeroSourceIndex);
break;
case equationOperation::stscalarFieldSource:
Info << scalarSources_.fieldName(zeroSourceIndex);
break;
case equationOperation::stvectorSource:
Info << vectorSources_.singleName(zeroSourceIndex);
break;
case equationOperation::stvectorFieldSource:
Info << vectorSources_.fieldName(zeroSourceIndex);
break;
case equationOperation::sttensorSource:
Info << tensorSources_.singleName(zeroSourceIndex);
break;
case equationOperation::sttensorFieldSource:
Info << tensorSources_.fieldName(zeroSourceIndex);
break;
case equationOperation::stdiagTensorSource:
Info << diagTensorSources_.singleName(zeroSourceIndex);
break;
case equationOperation::stdiagTensorFieldSource:
Info << diagTensorSources_.fieldName(zeroSourceIndex);
break;
case equationOperation::stsymmTensorSource:
Info << symmTensorSources_.singleName(zeroSourceIndex);
break;
case equationOperation::stsymmTensorFieldSource:
Info << symmTensorSources_.fieldName(zeroSourceIndex);
break;
case equationOperation::stsphericalTensorSource:
Info << sphericalTensorSources_.singleName(zeroSourceIndex);
break;
case equationOperation::stsphericalTensorFieldSource:
Info << sphericalTensorSources_.fieldName(zeroSourceIndex);
break;
}
Info << "] read from ["
<< equationOperation::sourceName(eqop.sourceType()) << "]..." << endl;
}
void Foam::equationReader::reportScalarResultDisabled
(
const scalar& x
) const
{
// do nothing
}
void Foam::equationReader::reportScalarResultEnabled
(
const scalar& x
) const
{
Info << "Operation result is " << x << endl;
}
void Foam::equationReader::reportScalarEvalEndDisabled
(
const scalar& x
) const
{
// Do nothing
}
void Foam::equationReader::reportScalarEvalEndEnabled
(
const scalar& x
) const
{
Info << "Equation evaluated. Result is: " << x << endl;
}
void Foam::equationReader::reportDimsEvalStartDisabled
(
const label& index
) const
{
// Do nothing
}
void Foam::equationReader::reportDimsEvalStartEnabled
(
const label& equationIndex
) const
{
const equation& eqn(operator[](equationIndex));
Info << "Evaluating equation " << equationIndex << ", "
<< eqn.name() << " at (geoIndex, cellIndex)=("
<< geoIndex_ << ", " << cellIndex_ << "), given by:"
<< token::NL << token::TAB << eqn.rawText() << endl;
}
void Foam::equationReader::reportDimsOperationDisabled
(
const label& index,
const label& i
) const
{
// do nothing
}
void Foam::equationReader::reportDimsOperationEnabled
(
const label& index,
const label& i
) const
{
reportScalarOperationEnabled(index, i);
}
void Foam::equationReader::reportDimsResultDisabled
(
const dimensionSet& xDims
) const
{
// do nothing
}
void Foam::equationReader::reportDimsResultEnabled
(
const dimensionSet& xDims
) const
{
Info << "Operation result is " << xDims << endl;
}
void Foam::equationReader::reportDimsEvalEndDisabled
(
const dimensionSet& xDims
) const
{
// Do nothing
}
void Foam::equationReader::reportDimsEvalEndEnabled
(
const dimensionSet& xDims
) const
{
Info << "Equation evaluated. Result is: " << xDims << endl;
}
// ************************************************************************* //

View file

@ -0,0 +1,214 @@
// Private data related to scalar functions
//- Function pointer (used to avoid a conditional at every evaluation
// for debug levels > 0)
void (Foam::equationReader::*reportEmbeddedDispatchFunction_)() const;
//- Function pointer (used to avoid a conditional at every evaluation
// for debug levels > 0)
void (Foam::equationReader::*reportEmbeddedReturnFunction_)() const;
//- Function pointer (used to avoid a conditional at every evaluation
// for debug levels 1,2,5 or 6)
void (Foam::equationReader::*reportScalarEvalStartFunction_)
(
const label&
) const;
//- Function pointer (used to avoid a conditional at every operation
// for debug level 2 or 6)
void (Foam::equationReader::*reportScalarOperationFunction_)
(
const label&,
const label&
) const;
//- Function pointer (used to avoid a conditional at every operation
// for debug level 2 or 6)
void (Foam::equationReader::*reportScalarResultFunction_)
(
const scalar&
) const;
//- Function pointer (used to avoid a conditional at every evaluation
// for debug levels 1,2,5 or 6)
void (Foam::equationReader::*reportScalarEvalEndFunction_)
(
const scalar&
) const;
// Private data related to dimensionSet functions
//- Function pointer (used to avoid a conditional at every evaluation
// for debug levels 3,4,5 or 6)
void (Foam::equationReader::*reportDimsEvalStartFunction_)
(
const label&
) const;
//- Function pointer (used to avoid a conditional at every operation
// for debug level 4 or 6)
void (Foam::equationReader::*reportDimsOperationFunction_)
(
const label&,
const label&
) const;
//- Function pointer (used to avoid a conditional at every operation
// for debug level 4 or 6)
void (Foam::equationReader::*reportDimsResultFunction_)
(
const dimensionSet&
) const;
//- Function pointer (used to avoid a conditional at every evaluation
// for debug levels 3,4,5 or 6)
void (Foam::equationReader::*reportDimsEvalEndFunction_)
(
const dimensionSet&
) const;
// Private member functions related to scalar functions
//- Pointed to by reportEmbeddedDispatchFunction_ when debug level
// is 0 - this function does nothing
void reportEmbeddedDispatchDisabled () const;
//- Pointed to by reportEmbeddedDispatchFunction_ when debug level
// is not 0 - this function prints a line to the console
void reportEmbeddedDispatchEnabled () const;
//- Pointed to by reportEmbeddedReturnFunction_ when debug level
// is 0 - this function does nothing
void reportEmbeddedReturnDisabled () const;
//- Pointed to by reportEmbeddedReturnFunction_ when debug level
// is not 0 - this function prints a line to the console
void reportEmbeddedReturnEnabled () const;
//- Pointed to by reportScalarEvalStartFunction_ when debug level
// is none of: 1,2,5,6 - this function does nothing
void reportScalarEvalStartDisabled
(
const label& index
) const;
//- Pointed to by reportScalarEvalStartFunction_ when debug level
// is any of: 1,2,5,6 - this function reports evaluation has
// commenced (with details) to the console
void reportScalarEvalStartEnabled
(
const label& index
) const;
//- Pointed to by reportScalarOperationFunction_ when debug level
// is neither 2 nor 6 - this function does nothing
void reportScalarOperationDisabled
(
const label& index,
const label& i
) const;
//- Pointed to by reportScalarOperationFunction_ when debug level
// is 2 or 6. This function sends operation-by-operation
// information to the console
void reportScalarOperationEnabled
(
const label& index,
const label& i
) const;
//- Pointed to by reportScalarResultFunction_ when debug level is
// neither 2 nor 6 - this function does nothing
void reportScalarResultDisabled
(
const scalar& x
) const;
//- Pointed to by reportScalarResultFunction_ when debug level is
// 2 or 6. This function reports the result operation-by-
// operation to the console
void reportScalarResultEnabled
(
const scalar& x
) const;
//- Pointed to by reportScalarEvalEndFunction_ when debug level
// is none of: 1,2,5,6 - this function does nothing
void reportScalarEvalEndDisabled
(
const scalar& x
) const;
//- Pointed to by reportScalarEvalEndFunction_ when debug level
// is any of: 1,2,5,6 - this function reports evaluation has
// completed (with details) to the console
void reportScalarEvalEndEnabled
(
const scalar& x
) const;
// Private member functions related to dimensionSet function
//- Pointed to by reportDimsEvalStartFunction_ when debug level
// is none of: 3,4,5,6 - this function does nothing
void reportDimsEvalStartDisabled
(
const label& index
) const;
//- Pointed to by reportDimsEvalStartFunction_ when debug level
// is any of: 3,4,5,6 - this function reports evaluation has
// commenced (with details) to the console
void reportDimsEvalStartEnabled
(
const label& index
) const;
//- Pointed to by reportDimsOperationFunction_ when debug level
// is neither 4 nor 6 - this function does nothing
void reportDimsOperationDisabled
(
const label& index,
const label& i
) const;
//- Pointed to by reportDimsOperationFunction_ when debug level
// is 4 or 6. This function sends operation-by-operation
// information to the console
void reportDimsOperationEnabled
(
const label& index,
const label& i
) const;
//- Pointed to by reportDimsResultFunction_ when debug level is
// neither 4 nor 6- this function does nothing
void reportDimsResultDisabled
(
const dimensionSet& xDims
) const;
//- Pointed to by reportDimsResultFunction_ when debug level is
// 4 or 6. This function reports the result operation-by-
// operation to the console
void reportDimsResultEnabled
(
const dimensionSet& xDims
) const;
//- Pointed to by reportDimsEvalEndFunction_ when debug level
// is none of: 3,4,5,6 - this function does nothing
void reportDimsEvalEndDisabled
(
const dimensionSet& xDims
) const;
//- Pointed to by reportDimsEvalEndFunction_ when debug level
// is any of: 3,4,5,6 - this function reports evaluation has
// completed (with details) to the console
void reportDimsEvalEndEnabled
(
const dimensionSet& xDims
) const;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,954 @@
// Private member data
// evaluateDims has an extra set of pointer functions that evaluateScalar
// does not. If equation::changeDimensions() is true, it is pointless to
// perform a full evaluation, as the result will always be equation::
// overrideDimensions(). Therefore evaluateDims has a pointer function
// that either calls the standard evaluateDimsEnabled, or the shortcut
// function evaluateDimsDisabled. Since each equation may require
// different treatment, there is a pointer function for each equation. The
// pointers are therefore in a list.
//- Typedef the evaluateDims function pointer to make it available to
// PtrList
typedef dimensionSet (Foam::equationReader::*evaluateDimsFunction)
(
const label equationIndex,
const label maxStoreIndex
) const;
// List of evaluateDims function pointers, indexed by equation
mutable PtrList<evaluateDimsFunction> evaluateDimsFunctions_;
// Private member functions
//- Called when changeDimensions is false
dimensionSet evaluateDimsEnabled
(
const label equationIndex,
const label maxStoreIndex
) const;
//- Called when changeDimensions is true
dimensionSet evaluateDimsDisabled
(
const label equationIndex,
const label maxStoreIndex
) const;
// dimensionSet evaluation pointer functions
void evalDimsNone
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsRetrieve
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsStore
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPlus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPlusDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMinus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMinusDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsTimes
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsDivide
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPow
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPowDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSign
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSignDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsNeg
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMag
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLimit
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMinMod
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSqrtSumSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPow3
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPow4
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPow5
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsPow6
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsInv
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSqrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsCbrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsHypot
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsHypotDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsExp
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsExpDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLog
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLogDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLog10
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLog10DimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSinDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsCos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsCosDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsTan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsTanDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAsin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAsinDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAcos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAcosDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAtan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAtanDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAtan2
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsSinhDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsCosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsCoshDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsTanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsTanhDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAsinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAsinhDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAcosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAcoshDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAtanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsAtanhDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsErf
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsErfDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsErfc
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsErfcDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLgamma
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsLgammaDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsJ0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsJ0DimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsJ1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsJ1DimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsJn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsJnDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsY0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsY0DimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsY1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsY1DimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsYn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsYnDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMax
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMaxDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsMinDimCheck
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;
void evalDimsStabilise
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
dimensionSet& xDims,
dimensionSet sourceDims
) const;

View file

@ -0,0 +1,842 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::equationReader::evalScalarFieldNone
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
FatalErrorIn("equationReader::evalScalarFieldNone")
<< "Empty operation called in equation "
<< operator[](index).name()
<< ", given by:" << token::NL << token::TAB
<< operator[](index).rawText() << token::NL
<< "Empty operations should only exist temporarily during parsing, "
<< "and they should not remain in the operation list at this point. "
<< "Either you have corrupt data, or this is a bug."
<< abort(FatalError);
}
void Foam::equationReader::evalScalarFieldRetrieve
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
x = source;
}
void Foam::equationReader::evalScalarFieldStore
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
storeIndex++;
storageScalarFields_.setSize(storeIndex + storageOffset + 1);
storageScalarFields_.set
(
storeIndex + storageOffset,
new scalarField(x)
);
x = 0.0;
}
void Foam::equationReader::evalScalarFieldPlus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
x += source;
}
void Foam::equationReader::evalScalarFieldMinus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
x -= source;
}
void Foam::equationReader::evalScalarFieldTimes
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
x *= source;
}
void Foam::equationReader::evalScalarFieldDivide
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
x /= source;
}
void Foam::equationReader::evalScalarFieldPow
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pow(x, x, source);
}
void Foam::equationReader::evalScalarFieldSign
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
sign(x, x);
}
void Foam::equationReader::evalScalarFieldPos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pos(x, x);
}
void Foam::equationReader::evalScalarFieldNeg
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
neg(x, x);
}
void Foam::equationReader::evalScalarFieldMag
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
x = mag(x);
}
void Foam::equationReader::evalScalarFieldLimit
(
const equationReader * eqnReader,
const label index,
const label iIn,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
TFOR_ALL_F_OP_FUNC_F_F
(
scalar, x, =, ::Foam::limit, scalar, x, scalar, source
)
}
void Foam::equationReader::evalScalarFieldMinMod
(
const equationReader * eqnReader,
const label index,
const label iIn,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
TFOR_ALL_F_OP_FUNC_F_F
(
scalar, x, =, ::Foam::minMod, scalar, x, scalar, source
)
}
void Foam::equationReader::evalScalarFieldSqrtSumSqr
(
const equationReader * eqnReader,
const label index,
const label iIn,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
TFOR_ALL_F_OP_FUNC_F_F
(
scalar, x, =, ::Foam::sqrtSumSqr, scalar, x, scalar, source
)
}
void Foam::equationReader::evalScalarFieldSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
sqr(x, x);
}
void Foam::equationReader::evalScalarFieldPow3
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pow3(x, x);
}
void Foam::equationReader::evalScalarFieldPow4
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pow4(x, x);
}
void Foam::equationReader::evalScalarFieldPow5
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pow5(x, x);
}
void Foam::equationReader::evalScalarFieldPow6
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pow6(x, x);
}
void Foam::equationReader::evalScalarFieldInv
(
const equationReader * eqnReader,
const label index,
const label iIn,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
TFOR_ALL_F_OP_FUNC_F
(
scalar, x, =, ::Foam::inv, scalar, x
)
}
void Foam::equationReader::evalScalarFieldSqrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
sqrt(x, x);
}
void Foam::equationReader::evalScalarFieldCbrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
pow(x, x, 1.0/3.0);
}
void Foam::equationReader::evalScalarFieldHypot
(
const equationReader * eqnReader,
const label index,
const label iIn,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
TFOR_ALL_F_OP_FUNC_F_F
(
scalar, x, =, ::Foam::hypot, scalar, x, scalar, source
)
}
void Foam::equationReader::evalScalarFieldExp
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
exp(x, x);
}
void Foam::equationReader::evalScalarFieldLog
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
log(x, x);
}
void Foam::equationReader::evalScalarFieldLog10
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
log10(x, x);
}
void Foam::equationReader::evalScalarFieldSin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
sin(x, x);
}
void Foam::equationReader::evalScalarFieldCos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
cos(x, x);
}
void Foam::equationReader::evalScalarFieldTan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
tan(x, x);
}
void Foam::equationReader::evalScalarFieldAsin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
asin(x, x);
}
void Foam::equationReader::evalScalarFieldAcos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
acos(x, x);
}
void Foam::equationReader::evalScalarFieldAtan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
atan(x, x);
}
void Foam::equationReader::evalScalarFieldAtan2
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
atan2(x, x, source);
}
void Foam::equationReader::evalScalarFieldSinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
sinh(x, x);
}
void Foam::equationReader::evalScalarFieldCosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
cosh(x, x);
}
void Foam::equationReader::evalScalarFieldTanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
tanh(x, x);
}
void Foam::equationReader::evalScalarFieldAsinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
asinh(x, x);
}
void Foam::equationReader::evalScalarFieldAcosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
acosh(x, x);
}
void Foam::equationReader::evalScalarFieldAtanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
atanh(x, x);
}
void Foam::equationReader::evalScalarFieldErf
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
erf(x, x);
}
void Foam::equationReader::evalScalarFieldErfc
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
erfc(x, x);
}
void Foam::equationReader::evalScalarFieldLgamma
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
lgamma(x, x);
}
void Foam::equationReader::evalScalarFieldJ0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
j0(x, x);
}
void Foam::equationReader::evalScalarFieldJ1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
j1(x, x);
}
void Foam::equationReader::evalScalarFieldJn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
int xi(x[0]);
jn(x, xi, source);
}
void Foam::equationReader::evalScalarFieldY0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
y0(x, x);
}
void Foam::equationReader::evalScalarFieldY1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
y1(x, x);
}
void Foam::equationReader::evalScalarFieldYn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
int xi(x[0]);
yn(x, xi, source);
}
void Foam::equationReader::evalScalarFieldMax
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
max(x, x, source);
}
void Foam::equationReader::evalScalarFieldMin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
min(x, x, source);
}
void Foam::equationReader::evalScalarFieldStabilise
(
const equationReader * eqnReader,
const label index,
const label iIn,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const
{
TFOR_ALL_F_OP_FUNC_F_F
(
scalar, x, =, ::Foam::stabilise, scalar, x, scalar, source
)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,575 @@
// scalar evaluation pointer functions
void evalScalarFieldNone
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldRetrieve
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldStore
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPlus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldMinus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldTimes
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldDivide
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPow
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldSign
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldNeg
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldMag
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldLimit
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldMinMod
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldSqrtSumSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPow3
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPow4
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPow5
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldPow6
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldInv
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldSqrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldCbrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldHypot
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldExp
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldLog
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldLog10
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldSin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldCos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldTan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAsin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAcos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAtan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAtan2
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldSinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldCosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldTanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAsinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAcosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldAtanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldErf
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldErfc
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldLgamma
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldJ0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldJ1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldJn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldY0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldY1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldYn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldMax
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldMin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
void evalScalarFieldStabilise
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalarField& x,
const scalarField& source
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,820 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::equationReader::evalScalarNone
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
FatalErrorIn("equationReader::evalScalarNone")
<< "Empty operation called in equation "
<< operator[](index).name()
<< ", given by:" << token::NL << token::TAB
<< operator[](index).rawText() << token::NL
<< "Empty operations should only exist temporarily during parsing, "
<< "and they should not remain in the operation list at this point. "
<< "Either you have corrupt data, or this is a bug."
<< abort(FatalError);
}
void Foam::equationReader::evalScalarRetrieve
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = source;
}
void Foam::equationReader::evalScalarStore
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
storeIndex++;
storageScalars_.setSize(storeIndex + storageOffset + 1);
storageScalars_[storeIndex + storageOffset] = x;
x = 0;
}
void Foam::equationReader::evalScalarPlus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x += source;
}
void Foam::equationReader::evalScalarMinus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x -= source;
}
void Foam::equationReader::evalScalarTimes
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x *= source;
}
void Foam::equationReader::evalScalarDivide
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x /= source;
}
void Foam::equationReader::evalScalarPow
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = pow(x, source);
}
void Foam::equationReader::evalScalarSign
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = sign(x);
}
void Foam::equationReader::evalScalarPos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = pos(x);
}
void Foam::equationReader::evalScalarNeg
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = neg(x);
}
void Foam::equationReader::evalScalarMag
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = mag(x);
}
void Foam::equationReader::evalScalarLimit
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = limit(x, source);
}
void Foam::equationReader::evalScalarMinMod
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = minMod(x, source);
}
void Foam::equationReader::evalScalarSqrtSumSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = sqrtSumSqr(x, source);
}
void Foam::equationReader::evalScalarSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = sqr(x);
}
void Foam::equationReader::evalScalarPow3
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = pow3(x);
}
void Foam::equationReader::evalScalarPow4
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = pow4(x);
}
void Foam::equationReader::evalScalarPow5
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = pow5(x);
}
void Foam::equationReader::evalScalarPow6
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = pow6(x);
}
void Foam::equationReader::evalScalarInv
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = inv(x);
}
void Foam::equationReader::evalScalarSqrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = sqrt(x);
}
void Foam::equationReader::evalScalarCbrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = cbrt(x);
}
void Foam::equationReader::evalScalarHypot
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = hypot(x, source);
}
void Foam::equationReader::evalScalarExp
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = exp(x);
}
void Foam::equationReader::evalScalarLog
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = log(x);
}
void Foam::equationReader::evalScalarLog10
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = log10(x);
}
void Foam::equationReader::evalScalarSin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = sin(x);
}
void Foam::equationReader::evalScalarCos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = cos(x);
}
void Foam::equationReader::evalScalarTan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = tan(x);
}
void Foam::equationReader::evalScalarAsin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = asin(x);
}
void Foam::equationReader::evalScalarAcos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = acos(x);
}
void Foam::equationReader::evalScalarAtan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = atan(x);
}
void Foam::equationReader::evalScalarAtan2
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = atan2(x, source);
}
void Foam::equationReader::evalScalarSinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = sinh(x);
}
void Foam::equationReader::evalScalarCosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = cosh(x);
}
void Foam::equationReader::evalScalarTanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = tanh(x);
}
void Foam::equationReader::evalScalarAsinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = asinh(x);
}
void Foam::equationReader::evalScalarAcosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = acosh(x);
}
void Foam::equationReader::evalScalarAtanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = atanh(x);
}
void Foam::equationReader::evalScalarErf
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = erf(x);
}
void Foam::equationReader::evalScalarErfc
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = erfc(x);
}
void Foam::equationReader::evalScalarLgamma
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = lgamma(x);
}
void Foam::equationReader::evalScalarJ0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = j0(x);
}
void Foam::equationReader::evalScalarJ1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = j1(x);
}
void Foam::equationReader::evalScalarJn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
int xi(x);
x = jn(xi, source);
}
void Foam::equationReader::evalScalarY0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = y0(x);
}
void Foam::equationReader::evalScalarY1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = y1(x);
}
void Foam::equationReader::evalScalarYn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
int xi(x);
x = yn(xi, source);
}
void Foam::equationReader::evalScalarMax
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = max(x, source);
}
void Foam::equationReader::evalScalarMin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = min(x, source);
}
void Foam::equationReader::evalScalarStabilise
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const
{
x = stabilise(x, source);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,575 @@
// scalar evaluation pointer functions
void evalScalarNone
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarRetrieve
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarStore
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPlus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarMinus
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarTimes
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarDivide
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPow
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarSign
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarNeg
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarMag
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarLimit
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarMinMod
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarSqrtSumSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarSqr
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPow3
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPow4
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPow5
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarPow6
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarInv
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarSqrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarCbrt
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarHypot
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarExp
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarLog
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarLog10
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarSin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarCos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarTan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAsin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAcos
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAtan
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAtan2
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarSinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarCosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarTanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAsinh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAcosh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarAtanh
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarErf
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarErfc
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarLgamma
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarJ0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarJ1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarJn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarY0
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarY1
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarYn
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarMax
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarMin
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
void evalScalarStabilise
(
const equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storeIndex,
scalar& x,
scalar source
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,688 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::dimensionSet Foam::equationReader::internalEvaluateDimensions
(
const label& equationIndex,
label storageOffset
) const
{
# ifdef FULLDEBUG
// Bounds checking
if ((equationIndex < 0) || (equationIndex >= size()))
{
FatalErrorIn("equationReader::internalEvaluateDimensions")
<< "equationIndex " << equationIndex << " out of bounds (0, "
<< size() - 1 << ")"
<< abort(FatalError);
}
# endif
const equation& eqn(operator[](equationIndex));
// Launch the reportDimsEvalStartFunction, which does this:
// if ((debug == 3) || (debug == 4) || (debug == 5) || (debug == 6))
// {
// reportDimsEvalStartEnabled(equationIndex);
// // reports details to the console that evaluation has commenced
// }
// else
// {
// reportDimsEvalStartDisabled(equationIndex);
// // does nothing
// }
(*this.*reportDimsEvalStartFunction_)(equationIndex);
if (eqn.size() == 0)
{
parse(equationIndex);
}
label storeIndex(-1);
dimensionSet xDims(dimless);
for (label i(0); i < eqn.size(); i++)
{
# ifdef FULLDEBUG
if
(
(
(i == 0)
|| (eqn[i - 1].operation() == equationOperation::otstore)
)
&& (
eqn[i].operation()
!= equationOperation::otretrieve
)
)
{
FatalErrorIn("equationReader::internalEvaluateDimensions")
<< "Bad operation list. Operation at " << i << " either "
<< "follows a 'store', or is the first operation. Therefore "
<< "it should be retrieve, but it is " << eqn[i].operation()
<< "."
<< abort(FatalError);
}
# endif
// Execute getSource function to which this operation points
dimensionSet sourceDims
(
eqn[i].getSourceDimsFunction
(
this,
equationIndex,
i,
storeIndex + storageOffset,
storageOffset
)
);
// Launch the reportDimsOperationFunction, which does this:
// if ((debug == 4) || (debug == 6))
// {
// reportDimsOperationEnabled(equationIndex, i);
// // posts operation-by-operation information to the console
// }
// else
// {
// reportDimsOperationDisabled(equationIndex, i);
// // does nothing
// }
(*this.*reportDimsOperationFunction_)(equationIndex, i);
// Execute the eval function to which this operation points
eqn[i].opDimsFunction
(
this,
equationIndex,
i,
storageOffset,
storeIndex,
xDims,
sourceDims
);
// Launch the reportDimsResultFunction, which does this:
// if ((debug == 4) || (debug == 6))
// {
// reportDimsResultEnabled(xDims);
// // posts result to the console
// }
// else
// {
// reportDimsResultDisabled(xDims);
// // does nothing
// }
(*this.*reportDimsResultFunction_)(xDims);
}
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
storageDims_.setSize(storageOffset);
// Launch the reportScalarEvalEndFunction, which does this:
// if ((debug == 3) || (debug == 4) || (debug == 5) || (debug == 6))
// {
// reportDimsEvalEndEnabled(xDims);
// // reports details to the console that evaluation has completed
// }
// else
// {
// reportDimsEvalEndDisabled(xDims);
// // does nothing
// }
(*this.*reportDimsEvalEndFunction_)(xDims);
eqn.setLastResult(xDims);
return xDims;
}
Foam::scalar Foam::equationReader::internalEvaluateScalar
(
const label& equationIndex,
label storageOffset
) const
{
# ifdef FULLDEBUG
// Bounds checking
if ((equationIndex < 0) || (equationIndex >= size()))
{
FatalErrorIn("equationReader::internalEvaluateScalar")
<< "equationIndex " << equationIndex << " out of bounds (0, "
<< size() - 1 << ")"
<< abort(FatalError);
}
# endif
const equation& eqn(operator[](equationIndex));
// Launch the reportScalarEvalStartFunction, which does this:
// if ((debug == 1) || (debug == 2) || (debug == 5) || (debug == 6))
// {
// reportScalarEvalStartEnabled(equationIndex);
// // reports details to the console that evaluation has commenced
// }
// else
// {
// reportScalarEvalStartDisabled(equationIndex);
// // does nothing
// }
(*this.*reportScalarEvalStartFunction_)(equationIndex);
if (eqn.size() == 0)
{
parse(equationIndex);
}
label storeIndex(-1);
scalar x(0.0);
for (label i(0); i < eqn.size(); i++)
{
# ifdef FULLDEBUG
if
(
(
(i == 0)
|| (eqn[i - 1].operation() == equationOperation::otstore)
)
&& (
eqn[i].operation()
!= equationOperation::otretrieve
)
)
{
FatalErrorIn("equationReader::internalEvaluateScalar")
<< "Bad operation list. Operation at " << i << " either "
<< "follows a 'store', or is the first operation. Therefore "
<< "it should be retrieve, but it is " << eqn[i].operation()
<< "."
<< abort(FatalError);
}
# endif
// Execute getSource function to which this operation points
scalar source
(
eqn[i].getSourceScalarFunction
(
this,
equationIndex,
i,
storeIndex + storageOffset,
storageOffset
)
);
// Launch the reportScalarOperationFunction, which does this:
// if ((debug == 2) || (debug == 6))
// {
// reportScalarOperationEnabled(equationIndex, i);
// // posts operation-by-operation information to the console
// }
// else
// {
// reportScalarOperationDisabled(equationIndex, i);
// // does nothing
// }
(*this.*reportScalarOperationFunction_)(equationIndex, i);
// Execute the eval function to which this operation points
eqn[i].opScalarFunction
(
this,
equationIndex,
i,
storageOffset,
storeIndex,
x,
source
);
// Launch the reportScalarResultFunction, which does this:
// if ((debug == 2) || (debug == 6))
// {
// reportScalarResultEnabled(x);
// // posts result to the console
// }
// else
// {
// reportScalarResultDisabled(x);
// // does nothing
// }
(*this.*reportScalarResultFunction_)(x);
}
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
storageScalars_.setSize(storageOffset);
// Launch the reportScalarEvalEndFunction, which does this:
// if ((debug == 1) || (debug == 2) || (debug == 5) || (debug == 6))
// {
// reportScalarEvalEndEnabled(equationIndex);
// // reports details to the console that evaluation has completed
// }
// else
// {
// reportScalarEvalEndDisabled(equationIndex);
// // does nothing
// }
(*this.*reportScalarEvalEndFunction_)(x);
eqn.setLastResult(x);
return x;
}
void Foam::equationReader::internalEvaluateScalarField
(
scalarField& result,
const label& equationIndex,
label storageOffset
) const
{
# ifdef FULLDEBUG
// Bounds checking
if ((equationIndex < 0) || (equationIndex >= size()))
{
FatalErrorIn("equationReader::internalEvaluateScalarField")
<< "equationIndex " << equationIndex << " out of bounds (0, "
<< size() - 1 << ")"
<< abort(FatalError);
}
# endif
tempSrcField_.setSize(result.size());
const equation& eqn(operator[](equationIndex));
// Launch the reportScalarEvalStartFunction, which does this:
// if ((debug == 1) || (debug == 2) || (debug == 5) || (debug == 6))
// {
// reportScalarEvalStartEnabled(equationIndex);
// // reports details to the console that evaluation has commenced
// }
// else
// {
// reportScalarEvalStartDisabled(equationIndex);
// // does nothing
// }
(*this.*reportScalarEvalStartFunction_)(equationIndex);
if (eqn.size() == 0)
{
parse(equationIndex);
}
label storeIndex(-1);
result = 0.0;
for (label i(0); i < eqn.size(); i++)
{
# ifdef FULLDEBUG
if
(
(
(i == 0)
|| (eqn[i - 1].operation() == equationOperation::otstore)
)
&& (
eqn[i].operation()
!= equationOperation::otretrieve
)
)
{
FatalErrorIn("equationReader::internalEvaluateScalarField")
<< "Bad operation list. Operation at " << i << " either "
<< "follows a 'store', or is the first operation. Therefore "
<< "it should be retrieve, but it is " << eqn[i].operation()
<< "."
<< abort(FatalError);
}
# endif
// Execute getSource function to which this operation points
const scalarField& source
(
eqn[i].getSourceScalarFieldFunction
(
this,
equationIndex,
i,
storeIndex + storageOffset,
storageOffset
)
);
// Launch the reportScalarOperationFunction, which does this:
// if ((debug == 2) || (debug == 6))
// {
// reportScalarOperationEnabled(equationIndex, i);
// // posts operation-by-operation information to the console
// }
// else
// {
// reportScalarOperationDisabled(equationIndex, i);
// // does nothing
// }
(*this.*reportScalarOperationFunction_)(equationIndex, i);
// Execute the eval function to which this operation points
eqn[i].opScalarFieldFunction
(
this,
equationIndex,
i,
storageOffset,
storeIndex,
result,
source
);
// Launch the reportScalarResultFunction, which does this:
// if ((debug == 2) || (debug == 6))
// {
// reportScalarResultEnabled(x);
// // posts result to the console
// }
// else
// {
// reportScalarResultDisabled(x);
// // does nothing
// }
(*this.*reportScalarResultFunction_)(result[0]);
}
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
storageScalarFields_.setSize(storageOffset);
// Launch the reportScalarEvalEndFunction, which does this:
// if ((debug == 1) || (debug == 2) || (debug == 5) || (debug == 6))
// {
// reportScalarEvalEndEnabled(equationIndex);
// // reports details to the console that evaluation has completed
// }
// else
// {
// reportScalarEvalEndDisabled(equationIndex);
// // does nothing
// }
(*this.*reportScalarEvalEndFunction_)(result[0]);
eqn.setLastResult(result[result.size() - 1]);
tempSrcField_.setSize(0);
}
void Foam::equationReader::checkFinalDimensions
(
const label& equationIndex,
dimensionSet& expectedDimensions,
const word& outputName
) const
{
const equation& eqn(operator[](equationIndex));
dimensionSet outputDims(evaluateDimensions(equationIndex));
if ((outputDims != expectedDimensions) && (dimensionSet::debug))
{
WarningIn("equationReader::checkFinalDimenions")
<< "Dimension error thrown for equation " << eqn.name()
<< ". Output dimensions: " << outputDims << "do not match "
<< "dimensions of destination field " << outputName << ", "
<< expectedDimensions << ". You can initialize " << outputName
<< "'s dimensions with:" << token::NL
<< token::TAB << outputName << ".dimensions().reset" << token::NL
<< token::TAB << "(" << token::NL << token::TAB << token::TAB
<< "equationReaderObject.evaluateDimensions(" << equationIndex
<< "))" << endl;
}
expectedDimensions = outputDims;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::equationReader::evaluateScalar
(
const word& equationName,
const label cellIndex,
const label geoIndex
) const
{
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateScalar")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
return evaluateScalar(equationIndex, cellIndex, geoIndex);
}
Foam::scalar Foam::equationReader::evaluateScalar
(
const label equationIndex,
const label cellIndex,
const label geoIndex
) const
{
# ifdef FULLDEBUG
const equation& eqn(operator[](equationIndex));
// Index checking
const labelList& maxFieldSizes(eqn.maxFieldSizes());
if ((geoIndex < 0) || (cellIndex < 0))
{
FatalErrorIn("equationReader::evaluateScalar")
<< "Evaluating " << eqn.name() << ": geoIndex (" << geoIndex
<< ") or cellIndex (" << cellIndex << ") cannot be negative."
<< abort(FatalError);
}
else if (maxFieldSizes.size() > 0)
{
if (geoIndex >= maxFieldSizes.size())
{
FatalErrorIn("equationReader::evaluateScalar")
<< "Evaluating " << eqn.name() << ": geoIndex ("
<< geoIndex << ") out of range (0 .. "
<< maxFieldSizes.size() - 1 << ")."
<< abort(FatalError);
}
else if (cellIndex >= maxFieldSizes[geoIndex])
{
FatalErrorIn("equationReader::evaluateScalar")
<< "Evaluating " << eqn.name() << ": cellIndex ("
<< cellIndex << ") out of range (0 .. "
<< maxFieldSizes[geoIndex] - 1 << ")."
<< abort(FatalError);
}
}
# endif
cellIndex_ = cellIndex;
geoIndex_ = geoIndex;
return internalEvaluateScalar(equationIndex, 0);
}
Foam::dimensionSet
Foam::equationReader::evaluateDimensions(const word& equationName) const
{
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateDimensions")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
return evaluateDimensions(equationIndex);
}
Foam::dimensionSet
Foam::equationReader::evaluateDimensions(const label equationIndex) const
{
// Call the associated evaluateDimensions function pointer - has the same
// effect as this:
//
// const equation& eqn(operator[](equationIndex));
// if (eqn.changeDimensions())
// {
// evaluateDimsDisabled(equationIndex, 0);
// // which in turn does: return eqn.overrideDimensions();
// }
// else
// {
// evaluadeDimsEnabled(equationIndex);
// // which in turn does:
// // return internalEvaluateDimensions(equationIndex, 0);
// }
return dimensionSet
(
(*this.*evaluateDimsFunctions_[equationIndex])
(equationIndex, 0)
);
}
Foam::dimensionedScalar Foam::equationReader::evaluateDimensionedScalar
(
const word& equationName,
const label cellIndex,
const label geoIndex
) const
{
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateDimensionedScalar")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
return evaluateDimensionedScalar(equationIndex, cellIndex, geoIndex);
}
Foam::dimensionedScalar Foam::equationReader::evaluateDimensionedScalar
(
const label equationIndex,
const label cellIndex,
const label geoIndex
) const
{
return dimensionedScalar
(
operator[](equationIndex).name(),
evaluateDimensions(equationIndex),
evaluateScalar(equationIndex, cellIndex, geoIndex)
);
}
void Foam::equationReader::evaluateScalarField
(
scalarField& resultField,
const word& equationName,
const label geoIndex
) const
{
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateScalarField")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
evaluateScalarField(resultField, equationIndex, geoIndex);
}
void Foam::equationReader::evaluateScalarField
(
scalarField& resultField,
const label equationIndex,
const label geoIndex
) const
{
# ifdef FULLDEBUG
const equation& eqn(operator[](equationIndex));
// Index checking
const labelList& maxFieldSizes(eqn.maxFieldSizes());
if (geoIndex < 0)
{
FatalErrorIn("equationReader::evaluateScalarField")
<< "Evaluating " << eqn.name() << ": geoIndex (" << geoIndex
<< ") cannot be negative."
<< abort(FatalError);
}
else if (maxFieldSizes.size() > 0)
{
if (geoIndex >= maxFieldSizes.size())
{
FatalErrorIn("equationReader::evaluateScalarField")
<< "Evaluating " << eqn.name() << ": geoIndex ("
<< geoIndex << ") out of range (0 .. "
<< maxFieldSizes.size() - 1 << ")."
<< abort(FatalError);
}
else if (resultField.size() != maxFieldSizes[geoIndex])
{
FatalErrorIn("equationReader::evaluateScalarField")
<< "Evaluating " << eqn.name() << ": field size mismatch. "
<< "result.size() = " << resultField.size() << ", "
<< "expected = " << maxFieldSizes[geoIndex] - 1 << "."
<< abort(FatalError);
}
}
# endif
geoIndex_ = geoIndex;
if (resultField.size())
{
internalEvaluateScalarField(resultField, equationIndex, 0);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,503 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::dimensionSet Foam::equationReader::getDimsSrcNone
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
return dimless;
}
Foam::dimensionSet Foam::equationReader::getDimsSrcStorage
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
# ifdef FULLDEBUG
if ((zeroSourceIndex + storageOffset) > maxStoreIndex)
{
FatalErrorIn("equationReader::getDimsSrcStorage")
<< "Index " << zeroSourceIndex << " out of bounds (0, "
<< maxStoreIndex - storageOffset << ")"
<< abort(FatalError);
}
# endif
return storageDims_[zeroSourceIndex + storageOffset];
}
Foam::dimensionSet Foam::equationReader::getDimsSrcActiveSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return activeSources_[zeroSourceIndex].dimensions();
}
Foam::dimensionSet Foam::equationReader::getDimsSrcEquation
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
// Launch the reportEmbeddedDispatchFunction:
// if (debug)
// {
// reportEmbeddedDispatchEnabled;
// // or: Info << "Embedded equation dispatch." << endl;
// }
// else
// {
// reportEmbeddedDispatchDisabled();
// // does nothing
// }
(*this.*reportEmbeddedDispatchFunction_)();
// Call the associated evaluateDimensions function pointer - has the same
// effect as this:
//
// const equation& eqn(operator[](zeroSourceIndex));
// if (eqn.changeDimensions())
// {
// evaluateDimsDisabled(zeroSourceIndex, maxStoreIndex + 1);
// // which in turn does: return eqn.overrideDimensions();
// }
// else
// {
// evaluadeDimsEnabled(zeroSourceIndex, maxStoreIndex + 1);
// // which in turn does:
// // return internalEvaluateDimensions
// // (zeroSourceIndex, maxStoreIndex + 1);
// }
dimensionSet returnMe
(
(*this.*evaluateDimsFunctions_[zeroSourceIndex])
(zeroSourceIndex, maxStoreIndex + 1)
);
// Launch the reportEmbeddedReturnFunction:
// if (debug)
// {
// reportEmbeddedReturnEnabled;
// // or: Info << "Return from equation equation." << endl;
// }
// else
// {
// reportEmbeddedReturnDisabled();
// // does nothing
// }
(*this.*reportEmbeddedReturnFunction_)();
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
return returnMe;
}
Foam::dimensionSet Foam::equationReader::getDimsSrcEquationCircRefDetect
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
// Check for circular references
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
forAll(dependents_, i)
{
if (dependents_[i] == zeroSourceIndex)
{
// Circular reference detected
string dependencies;
for (label j(i); j < dependents_.size(); j++)
{
dependencies.append
(
operator[](dependents_[j]).name()
);
dependencies.append("-->");
}
dependencies.append(operator[](dependents_[i]).name());
FatalErrorIn
(
"equationReader::getDimsSrcEquationCircRefDetect"
)
<< "Circular reference detected when evaluating "
<< "the equation for " << eqn.name()
<< ", given by:" << token::NL << token::TAB
<< eqn.rawText() << token::NL << "The circular "
<< "dependency is:" << token::NL << token::TAB
<< dependencies
<< abort(FatalError);
}
}
// Launch the reportEmbeddedDispatchFunction:
// if (debug)
// {
// reportEmbeddedDispatchEnabled;
// // or: Info << "Embedded equation dispatch." << endl;
// }
// else
// {
// reportEmbeddedDispatchDisabled();
// // does nothing
// }
(*this.*reportEmbeddedDispatchFunction_)();
// Call the associated evaluateDimensions function pointer - has the same
// effect as this:
//
// const equation& eqn(operator[](zeroSourceIndex));
// if (eqn.changeDimensions())
// {
// evaluateDimsDisabled(zeroSourceIndex, maxStoreIndex + 1);
// // which in turn does: return eqn.overrideDimensions();
// }
// else
// {
// evaluadeDimsEnabled(zeroSourceIndex, maxStoreIndex + 1);
// // which in turn does:
// // return internalEvaluateDimensions
// // (zeroSourceIndex, maxStoreIndex + 1);
// }
dimensionSet returnMe
(
(*this.*evaluateDimsFunctions_[zeroSourceIndex])
(zeroSourceIndex, maxStoreIndex + 1)
);
// Launch the reportEmbeddedReturnFunction:
// if (debug)
// {
// reportEmbeddedReturnEnabled;
// // or: Info << "Return from equation equation." << endl;
// }
// else
// {
// reportEmbeddedReturnDisabled();
// // does nothing
// }
(*this.*reportEmbeddedReturnFunction_)();
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
return returnMe;
}
Foam::dimensionSet Foam::equationReader::getDimsSrcInternalScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
return dimless;
}
Foam::dimensionSet Foam::equationReader::getDimsSrcDictSourceDScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
dimensionedScalar ds("noSource", dimless, 0);
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
ITstream srcStrm
(
dictSources_[zeroSourceIndex].lookup(varName)
);
srcStrm >> ds;
return ds.dimensions();
}
Foam::dimensionSet Foam::equationReader::getDimsSrcDictSourceScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
return dimless;
}
Foam::dimensionSet Foam::equationReader::getDimsSrcScalarSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return scalarSources_.singleDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcScalarFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return scalarSources_.fieldDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcVectorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return vectorSources_.singleDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcVectorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return vectorSources_.fieldDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return tensorSources_.singleDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return tensorSources_.fieldDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcDiagTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return diagTensorSources_.singleDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcDiagTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return diagTensorSources_.fieldDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcSymmTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return symmTensorSources_.singleDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcSymmTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return symmTensorSources_.fieldDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcSphericalTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return sphericalTensorSources_.singleDimensions(zeroSourceIndex);
}
Foam::dimensionSet Foam::equationReader::getDimsSrcSphericalTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
return sphericalTensorSources_.fieldDimensions(zeroSourceIndex);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,181 @@
// Get source dimension functions
dimensionSet getDimsSrcNone
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcStorage
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcActiveSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcEquation
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcEquationCircRefDetect
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcInternalScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcDictSourceDScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcDictSourceScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcScalarSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcScalarFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcVectorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcVectorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcDiagTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcDiagTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcSymmTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcSymmTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcSphericalTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
dimensionSet getDimsSrcSphericalTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;

View file

@ -0,0 +1,630 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcNone
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
tempSrcField_ = 0.0;
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcStorage
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
# ifdef FULLDEBUG
if ((zeroSourceIndex + storageOffset) > maxStoreIndex)
{
FatalErrorIn("equationReader::getSouce")
<< "Index " << zeroSourceIndex << " out of bounds (0, "
<< maxStoreIndex - storageOffset << ")"
<< abort(FatalError);
}
# endif
scalarField& returnMe
(
storageScalarFields_[zeroSourceIndex + storageOffset]
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcActiveSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
activeSources_[zeroSourceIndex].evaluateScalarField
(
tempSrcField_,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcEquation
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
// Launch the reportEmbeddedDispatchFunction:
// if (debug)
// {
// reportEmbeddedDispatchEnabled;
// // or: Info << "Embedded equation dispatch." << endl;
// }
// else
// {
// reportEmbeddedDispatchDisabled();
// // does nothing
// }
(*this.*reportEmbeddedDispatchFunction_)();
scalarField result(tempSrcField_.size(), 0.0);
internalEvaluateScalarField
(
result,
zeroSourceIndex,
maxStoreIndex + 1
);
// Launch the reportEmbeddedReturnFunction:
// if (debug)
// {
// reportEmbeddedReturnEnabled;
// // or: Info << "Return from equation equation." << endl;
// }
// else
// {
// reportEmbeddedReturnDisabled();
// // does nothing
// }
(*this.*reportEmbeddedReturnFunction_)();
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
tempSrcField_ = result * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcEquationCircRefDetect
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
// Check for circular references
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
forAll(dependents_, i)
{
if (dependents_[i] == zeroSourceIndex)
{
// Circular reference detected
string dependencies;
for (label j(i); j < dependents_.size(); j++)
{
dependencies.append
(
operator[](dependents_[j]).name()
);
dependencies.append("-->");
}
dependencies.append(operator[](dependents_[i]).name());
FatalErrorIn
(
"equationReader::getScalarFieldSrcEquationCircRefDetect"
)
<< "Circular reference detected when evaluating "
<< "the equation for " << eqn.name()
<< ", given by:" << token::NL << token::TAB
<< eqn.rawText() << token::NL << "The circular "
<< "dependency is:" << token::NL << token::TAB
<< dependencies
<< abort(FatalError);
}
}
// Launch the reportEmbeddedDispatchFunction:
// if (debug)
// {
// reportEmbeddedDispatchEnabled;
// // or: Info << "Embedded equation dispatch." << endl;
// }
// else
// {
// reportEmbeddedDispatchDisabled();
// // does nothing
// }
(*this.*reportEmbeddedDispatchFunction_)();
scalarField result(tempSrcField_.size(), 0.0);
internalEvaluateScalarField
(
result,
zeroSourceIndex,
maxStoreIndex + 1
);
eqOp.assignSourceScalarFunction
(
&Foam::equationReader::getScalarSrcEquation
);
eqOp.assignSourceScalarFieldFunction
(
&Foam::equationReader::getScalarFieldSrcEquation
);
// Launch the reportEmbeddedReturnFunction:
// if (debug)
// {
// reportEmbeddedReturnEnabled;
// // or: Info << "Return from equation equation." << endl;
// }
// else
// {
// reportEmbeddedReturnDisabled();
// // does nothing
// }
(*this.*reportEmbeddedReturnFunction_)();
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
tempSrcField_ = result * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcInternalScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = internalScalars_[zeroSourceIndex];
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcDictSourceDScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
dimensionedScalar ds("noSource", dimless, 0.0);
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
ITstream srcStrm
(
dictSources_[zeroSourceIndex].lookup(varName)
);
srcStrm >> ds;
tempSrcField_ = ds.value() * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcDictSourceScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
scalar returnMe
(
readScalar(dictSources_[zeroSourceIndex].lookup(varName))
);
tempSrcField_ = returnMe * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcScalarSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = scalarSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
) * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcScalarFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalarSources_.fullFieldValue
(
tempSrcField_,
zeroSourceIndex,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcVectorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = vectorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
) * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcVectorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
vectorSources_.fullFieldValue
(
tempSrcField_,
zeroSourceIndex,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = tensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
) * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tensorSources_.fullFieldValue
(
tempSrcField_,
zeroSourceIndex,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcDiagTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = diagTensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
) * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcDiagTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
diagTensorSources_.fullFieldValue
(
tempSrcField_,
zeroSourceIndex,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcSymmTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = symmTensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
) * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcSymmTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
symmTensorSources_.fullFieldValue
(
tempSrcField_,
zeroSourceIndex,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcSphericalTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
tempSrcField_ = sphericalTensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
) * sign(eqOp.sourceIndex());
return tempSrcField_;
}
const Foam::scalarField&
Foam::equationReader::getScalarFieldSrcSphericalTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
sphericalTensorSources_.fullFieldValue
(
tempSrcField_,
zeroSourceIndex,
eqOp.componentIndex(),
geoIndex_
);
tempSrcField_ *= sign(eqOp.sourceIndex());
return tempSrcField_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,181 @@
// Get source scalar functions
const scalarField& getScalarFieldSrcNone
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcStorage
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcActiveSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcEquation
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcEquationCircRefDetect
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcInternalScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcDictSourceDScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcDictSourceScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcScalarSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcScalarFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcVectorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcVectorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcDiagTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcDiagTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcSymmTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcSymmTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcSphericalTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
const scalarField& getScalarFieldSrcSphericalTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;

View file

@ -0,0 +1,624 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::scalar Foam::equationReader::getScalarSrcNone
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
return 0.0;
}
Foam::scalar Foam::equationReader::getScalarSrcStorage
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
# ifdef FULLDEBUG
if ((zeroSourceIndex + storageOffset) > maxStoreIndex)
{
FatalErrorIn("equationReader::getSouce")
<< "Index " << zeroSourceIndex << " out of bounds (0, "
<< maxStoreIndex - storageOffset << ")"
<< abort(FatalError);
}
# endif
scalar returnMe(storageScalars_[zeroSourceIndex + storageOffset]);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcActiveSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
activeSources_[zeroSourceIndex].evaluateScalar
(
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcEquation
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
// Launch the reportEmbeddedDispatchFunction:
// if (debug)
// {
// reportEmbeddedDispatchEnabled;
// // or: Info << "Embedded equation dispatch." << endl;
// }
// else
// {
// reportEmbeddedDispatchDisabled();
// // does nothing
// }
(*this.*reportEmbeddedDispatchFunction_)();
scalar returnMe
(
internalEvaluateScalar(zeroSourceIndex, maxStoreIndex + 1)
);
// Launch the reportEmbeddedReturnFunction:
// if (debug)
// {
// reportEmbeddedReturnEnabled;
// // or: Info << "Return from equation equation." << endl;
// }
// else
// {
// reportEmbeddedReturnDisabled();
// // does nothing
// }
(*this.*reportEmbeddedReturnFunction_)();
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcEquationCircRefDetect
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
// Check for circular references
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
forAll(dependents_, i)
{
if (dependents_[i] == zeroSourceIndex)
{
// Circular reference detected
string dependencies;
for (label j(i); j < dependents_.size(); j++)
{
dependencies.append
(
operator[](dependents_[j]).name()
);
dependencies.append("-->");
}
dependencies.append(operator[](dependents_[i]).name());
FatalErrorIn("equationReader::getScalarSrcEquationCircRefDetect")
<< "Circular reference detected when evaluating "
<< "the equation for " << eqn.name()
<< ", given by:" << token::NL << token::TAB
<< eqn.rawText() << token::NL << "The circular "
<< "dependency is:" << token::NL << token::TAB
<< dependencies
<< abort(FatalError);
}
}
// Launch the reportEmbeddedDispatchFunction:
// if (debug)
// {
// reportEmbeddedDispatchEnabled;
// // or: Info << "Embedded equation dispatch." << endl;
// }
// else
// {
// reportEmbeddedDispatchDisabled();
// // does nothing
// }
scalar returnMe
(
internalEvaluateScalar(zeroSourceIndex, maxStoreIndex + 1)
);
eqOp.assignSourceScalarFunction
(
&Foam::equationReader::getScalarSrcEquation
);
eqOp.assignSourceScalarFieldFunction
(
&Foam::equationReader::getScalarFieldSrcEquation
);
// Launch the reportEmbeddedReturnFunction:
// if (debug)
// {
// reportEmbeddedReturnEnabled;
// // or: Info << "Return from equation equation." << endl;
// }
// else
// {
// reportEmbeddedReturnDisabled();
// // does nothing
// }
(*this.*reportEmbeddedReturnFunction_)();
//Move one level back up on the dependents_ list
if (dependents_.size())
{
dependents_.setSize(dependents_.size() - 1);
}
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcInternalScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe(internalScalars_[zeroSourceIndex]);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcDictSourceDScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
dimensionedScalar ds("noSource", dimless, 0.0);
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
ITstream srcStrm
(
dictSources_[zeroSourceIndex].lookup(varName)
);
srcStrm >> ds;
return ds.value() * sign(eqOp.sourceIndex());
}
Foam::scalar Foam::equationReader::getScalarSrcDictSourceScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
scalar returnMe
(
readScalar(dictSources_[zeroSourceIndex].lookup(varName))
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcScalarSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
scalarSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcScalarFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
scalarSources_.fieldValue
(
zeroSourceIndex,
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcVectorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
vectorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcVectorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
vectorSources_.fieldValue
(
zeroSourceIndex,
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
tensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
tensorSources_.fieldValue
(
zeroSourceIndex,
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcDiagTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
diagTensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcDiagTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
diagTensorSources_.fieldValue
(
zeroSourceIndex,
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcSymmTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
symmTensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcSymmTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
symmTensorSources_.fieldValue
(
zeroSourceIndex,
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcSphericalTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
sphericalTensorSources_.singleValue
(
zeroSourceIndex,
eqOp.componentIndex()
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
Foam::scalar Foam::equationReader::getScalarSrcSphericalTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const
{
const equation& eqn(operator[](equationIndex));
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
scalar returnMe
(
sphericalTensorSources_.fieldValue
(
zeroSourceIndex,
eqOp.componentIndex(),
cellIndex_,
geoIndex_
)
);
returnMe *= sign(eqOp.sourceIndex());
return returnMe;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,181 @@
// Get source scalar functions
scalar getScalarSrcNone
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcStorage
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcActiveSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcEquation
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcEquationCircRefDetect
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcInternalScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcDictSourceDScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcDictSourceScalar
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcScalarSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcScalarFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcVectorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcVectorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcDiagTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcDiagTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcSymmTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcSymmTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcSphericalTensorSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;
scalar getScalarSrcSphericalTensorFieldSource
(
const equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
) const;

View file

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
inline const PtrList<equation>& equationReader::eqns() const
{
return eqns_;
}
inline const PtrList<scalar>&
equationReader::internalScalars() const
{
return internalScalars_;
}
inline const UPtrList<const dictionary>&
equationReader::dictSources() const
{
return dictSources_;
}
inline const PtrList<word>& equationReader::dictLookups() const
{
return dictLookups_;
}
inline const UPtrList<const equationVariable>&
equationReader::activeSources() const
{
return activeSources_;
}
inline const wordList& equationReader::activeSourceNames() const
{
return activeSourceNames_;
}
inline const equationSource<scalar>&
equationReader::scalarSources() const
{
return scalarSources_;
}
inline equationSource<scalar>& equationReader::scalarSources()
{
return scalarSources_;
}
inline const equationSource<vector>&
equationReader::vectorSources() const
{
return vectorSources_;
}
inline equationSource<vector>& equationReader::vectorSources()
{
return vectorSources_;
}
inline const equationSource<tensor>&
equationReader::tensorSources() const
{
return tensorSources_;
}
inline equationSource<tensor>& equationReader::tensorSources()
{
return tensorSources_;
}
inline const equationSource<diagTensor>&
equationReader::diagTensorSources() const
{
return diagTensorSources_;
}
inline equationSource<diagTensor>&
equationReader::diagTensorSources()
{
return diagTensorSources_;
}
inline const equationSource<symmTensor>&
equationReader::symmTensorSources() const
{
return symmTensorSources_;
}
inline equationSource<symmTensor>&
equationReader::symmTensorSources()
{
return symmTensorSources_;
}
inline const equationSource<sphericalTensor>&
equationReader::sphericalTensorSources() const
{
return sphericalTensorSources_;
}
inline equationSource<sphericalTensor>&
equationReader::sphericalTensorSources()
{
return sphericalTensorSources_;
}
/*inline const label& equationReader::geoIndex() const
{
return geoIndex_;
}
inline void equationReader::setGeoIndex(label newIndex)
{
geoIndex_ = newIndex;
}
inline const label& equationReader::cellIndex() const
{
return cellIndex_;
}
inline void equationReader::setCellIndex(label newIndex)
{
cellIndex_ = newIndex;
}*/
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -24,6 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "equation.H"
#include "equationOperation.H"
#include "equationReader.H" #include "equationReader.H"
#include "fileNameList.H" #include "fileNameList.H"
@ -32,6 +34,7 @@ License
Foam::Ostream& Foam::equationReader::dataSourceStatus(Ostream& os) const Foam::Ostream& Foam::equationReader::dataSourceStatus(Ostream& os) const
{ {
dictionary dict; dictionary dict;
dict.set("activeSources", activeSourceNames_);
fileNameList dictPaths(dictSources_.size()); fileNameList dictPaths(dictSources_.size());
forAll(dictSources_, i) forAll(dictSources_, i)
{ {
@ -39,31 +42,17 @@ Foam::Ostream& Foam::equationReader::dataSourceStatus(Ostream& os) const
} }
dict.set("dictSources", dictPaths); dict.set("dictSources", dictPaths);
dict.set("dictLookups", dictLookups_); dict.set("dictLookups", dictLookups_);
dict.set("externalDScalars", externalDScalars_); dict.set("scalarSources", scalarSources_.outputDictionary());
dict.set("externalScalars", externalScalars_); dict.set("vectorSources", vectorSources_.outputDictionary());
dict.set("externalScalarNames", externalScalarNames_); dict.set("tensorSources", tensorSources_.outputDictionary());
dict.set("externalScalarListName", externalScalarListNames_); dict.set("diagTensorSources", diagTensorSources_.outputDictionary());
dict.set("externalScalarListDimensions", externalScalarListDimensions_); dict.set("symmTensorSources", symmTensorSources_.outputDictionary());
dict.set("externalScalarListIndices", externalScalarListIndex_); dict.set
PtrList<dimensionedScalar> outputScalarList;
forAll(eqns_, i)
{
if (outputScalars_.set(i))
{
outputScalarList.setSize(outputScalarList.size() + 1);
outputScalarList.set
( (
outputScalarList.size() - 1, "sphericalTensorSources",
new dimensionedScalar sphericalTensorSources_.outputDictionary()
(
outputScalarNames_[i],
outputScalarDimensions_[i],
outputScalars_[i]
)
); );
} dict.set("cellIndex", cellIndex_);
}
dict.set("outputScalars", outputScalarList);
dict.set("internalScalars", internalScalars_); dict.set("internalScalars", internalScalars_);
dictionary superDict; dictionary superDict;
superDict.set("dataSources", dict); superDict.set("dataSources", dict);
@ -95,22 +84,12 @@ Foam::Istream& Foam::operator>>(Istream& is, equationReader& I)
Foam::Ostream& Foam::operator<<(Ostream& os, const equationReader& I) Foam::Ostream& Foam::operator<<(Ostream& os, const equationReader& I)
{ {
dictionary eqnsDict; dictionary eqnsDict;
forAll(I.eqns_, i) forAll(I, i)
{ {
dictionary eqnEntry; dictionary eqnEntry;
eqnEntry.set(I.eqns_[i].equationName(), I.eqns_[i]); eqnEntry.set(I[i].name(), I[i]);
eqnEntry.set("lastResult", I.eqns_[i].lastResult()); eqnEntry.set("lastResult", I[i].lastResult());
if (I.outputScalars_.set(i)) eqnsDict.set(I[i].name(), eqnEntry);
{
dimensionedScalar ds
(
I.outputScalarNames_[i],
I.outputScalarDimensions_[i],
I.outputScalars_[i]
);
eqnEntry.set("outputVar", ds);
}
eqnsDict.set(I.eqns_[i].equationName(), eqnEntry);
} }
dictionary dict; dictionary dict;
dict.set("equations", eqnsDict); dict.set("equations", eqnsDict);
@ -119,4 +98,3 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const equationReader& I)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -27,46 +27,49 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::equationReader::parse(label index) void Foam::equationReader::parse(label index) const
{ {
if (debug) if (debug)
{ {
Info << "Parsing equation " << eqns_[index].equationName() Info << "Parsing equation " << operator[](index).name()
<< " at index " << index << "." << endl; << " at index " << index << "." << endl;
} }
if ((index > eqns_.size()) || (index < 0)) if ((index > size()) || (index < 0))
{ {
FatalErrorIn("equationReader::parse(index)") FatalErrorIn("equationReader::parse(index)")
<< "Index " << index << " out of bounds (0, " << "Index " << index << " out of bounds (0, "
<< eqns_.size() - 1 << ")" << size() - 1 << ")"
<< abort(FatalError); << abort(FatalError);
} }
eqns_[index].clear(); clearEquation(index);
// First, ensure there are no ':' or '&' characters. This is to // First, ensure there are no ':' or '&' characters. This is to
// accommodate the stringPreconditioner, which uses these special // accommodate the stringPreconditioner, which uses these special
// characters as work-arounds to limitations imposed by the token class. // characters as work-arounds to limitations imposed by the token class.
if if
( (
eqns_[index].rawText().string::find(":") != string::npos operator[](index).rawText().string::find(":") != string::npos
&& eqns_[index].rawText().string::find("&") != string::npos && operator[](index).rawText().string::find("&") != string::npos
) )
{ {
FatalErrorIn("equationReader::parse") FatalErrorIn("equationReader::parse")
<< "Parsing error in the equation for " << "Parsing error in the equation for "
<< eqns_[index].equationName() << ", given by:" << token::NL << operator[](index).name() << ", given by:" << token::NL
<< token::NL << token::TAB << eqns_[index].rawText() << token::NL << token::NL << token::TAB << operator[](index).rawText()
<< token::NL << "Colons, ':', and ampersands '&' are prohibitted." << token::NL << token::NL << "Colons, ':', and ampersands '&' are "
<< "prohibitted."
<< abort(FatalError); << abort(FatalError);
} }
// Precondition the string, and load it into a stream // Precondition the string, and load it into a stream
IStringStream rawStream(stringPreconditioner(eqns_[index].rawText())); IStringStream rawStream(stringPreconditioner(operator[](index).rawText()));
tokenList tl; tokenList tl;
bool forceEnd(false);
// Read tokens from raw equation string stream // Read tokens from raw equation string stream
while (!rawStream.eof()) while (!rawStream.eof() && !forceEnd)
{ {
tl.setSize(tl.size() + 1); tl.setSize(tl.size() + 1);
tl[tl.size() - 1] = token(rawStream); tl[tl.size() - 1] = token(rawStream);
@ -76,6 +79,7 @@ void Foam::equationReader::parse(label index)
if (tl[tl.size() - 1].type() == token::ERROR) if (tl[tl.size() - 1].type() == token::ERROR)
{ {
tl.setSize(tl.size() - 1); tl.setSize(tl.size() - 1);
forceEnd = true;
} }
} }
@ -83,7 +87,7 @@ void Foam::equationReader::parse(label index)
// - variable / constant: conatins source data only (first three fields) // - variable / constant: conatins source data only (first three fields)
// - operation: conatains operation number only (last field) // - operation: conatains operation number only (last field)
// - brackets, comma: all are zero // - brackets, comma: all are zero
equationOperationList map(tl.size()); PtrList<equationOperation> map(tl.size());
// opLvl: level of operation precedence // opLvl: level of operation precedence
// 0. variable // 0. variable
@ -99,7 +103,17 @@ void Foam::equationReader::parse(label index)
createMap(index, tl, map, opLvl, pl); createMap(index, tl, map, opLvl, pl);
/* Useful for debugging, left in // As a bug fix, we find any instance of pow(a,b) and remove the b part to
// a seperate equation. Necessary because we perform scalar and dimension
// evaluations seperately. pow is the only function where we can't figure
// out the dimensions without the value of the exponent. The only way we
// are guaranteed to know the scalar value is if it is a stand-alone
// equation.
removePowExponents(index, tl, map, opLvl, pl);
/* This is useful for debugging, so I left it in
if (debug)
{
Info << "tokenList: " << endl; Info << "tokenList: " << endl;
forAll(tl, i) forAll(tl, i)
{ {
@ -121,7 +135,7 @@ Info << endl;
Info << "opLvl is: " << opLvl << endl; Info << "opLvl is: " << opLvl << endl;
Info << "pl is: " << pl << endl; Info << "pl is: " << pl << endl;
Info << "Map is: " << map << endl; Info << "Map is: " << map << endl;
*/ }*/
// In the main parsing loop, we create labelLists of indices that specify // In the main parsing loop, we create labelLists of indices that specify
// what part of the equation we are working with. As the equation is // what part of the equation we are working with. As the equation is
@ -248,39 +262,58 @@ Info << "Map is: " << map << endl;
if (pl[resultIndex] < 0) if (pl[resultIndex] < 0)
{ {
// This is a single parameter function call - evaluate it // This is a single parameter function call - evaluate it
eqns_[index].setSize(eqns_[index].size() + 3); operator[](index).setSize(operator[](index).size() + 3);
// retrieve parameter value // retrieve parameter value
eqns_[index].ops()[eqns_[index].size() - 3] = equationOperation operator[](index).set
( (
map[resultIndex].sourceList(), operator[](index).size() - 3,
new equationOperation
(
map[resultIndex].sourceType(),
map[resultIndex].sourceIndex(), map[resultIndex].sourceIndex(),
map[resultIndex].componentIndex(),
map[resultIndex].dictLookupIndex(), map[resultIndex].dictLookupIndex(),
equationOperation::otretrieve equationOperation::otretrieve
)
); );
// perform function operation // perform function operation
currentIndex = findIndex(resultIndex, eqnIndices); currentIndex = findIndex(resultIndex, eqnIndices);
eqns_[index].ops()[eqns_[index].size() - 2] = equationOperation operator[](index).set
( (
equationOperation::slnone, operator[](index).size() - 2,
new equationOperation
(
equationOperation::stnone,
0,
0, 0,
0, 0,
map[eqnIndices[currentIndex - 1]].operation() map[eqnIndices[currentIndex - 1]].operation()
)
); );
// store result // store result
storeIndex++; storeIndex++;
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation operator[](index).set
( (
equationOperation::slstorage, operator[](index).size() - 1,
new equationOperation
(
equationOperation::ststorage,
storeIndex + 1, storeIndex + 1,
0, 0,
0,
equationOperation::otstore equationOperation::otstore
)
); );
// Set term in map to store location // Set term in map to store location
map[resultIndex] = map[resultIndex] =
eqns_[index].ops()[eqns_[index].ops().size() - 1]; operator[](index)
[
operator[](index).size() - 1
];
map[resultIndex].operation() = equationOperation::otnone; map[resultIndex].operation() = equationOperation::otnone;
// Trim function call from indices list // Trim function call from indices list
@ -395,37 +428,59 @@ Info << "Map is: " << map << endl;
// Perform multiparameter function operations // Perform multiparameter function operations
// first retrieve the first parameter // first retrieve the first parameter
eqns_[index].setSize(eqns_[index].size() + 3); operator[](index).setSize(operator[](index).size() + 3);
eqns_[index].ops()[eqns_[index].size() - 3] = equationOperation operator[](index).set
( (
map[resultIndex].sourceList(), operator[](index).size() - 3,
new equationOperation
(
map[resultIndex].sourceType(),
map[resultIndex].sourceIndex(), map[resultIndex].sourceIndex(),
map[resultIndex].componentIndex(),
map[resultIndex].dictLookupIndex(), map[resultIndex].dictLookupIndex(),
equationOperation::otretrieve equationOperation::otretrieve
)
); );
// perform the function operation (2nd parameter is source) // perform the function operation (2nd parameter is source)
label currentIndex(findIndex(resultIndex, eqnIndices)); label currentIndex(findIndex(resultIndex, eqnIndices));
eqns_[index].ops()[eqns_[index].size() - 2] = equationOperation operator[](index).set
( (
map[resultIndex2].sourceList(), operator[](index).size() - 2,
new equationOperation
(
map[resultIndex2].sourceType(),
map[resultIndex2].sourceIndex(), map[resultIndex2].sourceIndex(),
map[resultIndex2].componentIndex(),
map[resultIndex2].dictLookupIndex(), map[resultIndex2].dictLookupIndex(),
map[eqnIndices[currentIndex - 1]].operation() map[eqnIndices[currentIndex - 1]].operation()
)
); );
// store result // store result
storeIndex++; storeIndex++;
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation operator[](index).set
( (
equationOperation::slstorage, operator[](index).size() - 1,
new equationOperation
(
equationOperation::ststorage,
storeIndex + 1, storeIndex + 1,
0, 0,
0,
equationOperation::otstore equationOperation::otstore
)
); );
// Set term in map to store location // Set term in map to store location
map[resultIndex] = eqns_[index].ops()[eqns_[index].size() - 1]; map.set
(
resultIndex,
new equationOperation
(
operator[](index)[operator[](index).size() - 1]
)
);
map[resultIndex].operation() = equationOperation::otnone; map[resultIndex].operation() = equationOperation::otnone;
// trim function call from indices list // trim function call from indices list
@ -462,7 +517,7 @@ Info << "Map is: " << map << endl;
// Special case - equations with only one effective term: // Special case - equations with only one effective term:
// e.g. "2", "-2", "-(2)", "-(((((2)))))", etc.. // e.g. "2", "-2", "-(2)", "-(((((2)))))", etc..
// will complete their parse with an empty operation list // will complete their parse with an empty operation list
if (eqns_[index].size() == 0) if (operator[](index).size() == 0)
{ {
labelList subEqnIndices(findMaxParenthesis(pl, eqnIndices)); labelList subEqnIndices(findMaxParenthesis(pl, eqnIndices));
@ -486,42 +541,65 @@ Info << "Map is: " << map << endl;
// Add two operations - the first retrieves the variable, the second // Add two operations - the first retrieves the variable, the second
// is a dummy because the last operation is trimmed before exitting // is a dummy because the last operation is trimmed before exitting
// equationReader::parse // equationReader::parse
eqns_[index].setSize(eqns_[index].size() + 2); operator[](index).setSize(operator[](index).size() + 2);
// retrieve parameter value // retrieve parameter value
eqns_[index].ops()[eqns_[index].size() - 2] = equationOperation operator[](index).set
( (
map[subEqnIndices[0]].sourceList(), operator[](index).size() - 2,
new equationOperation
(
map[subEqnIndices[0]].sourceType(),
map[subEqnIndices[0]].sourceIndex(), map[subEqnIndices[0]].sourceIndex(),
map[subEqnIndices[0]].componentIndex(),
map[subEqnIndices[0]].dictLookupIndex(), map[subEqnIndices[0]].dictLookupIndex(),
equationOperation::otretrieve equationOperation::otretrieve
)
); );
// Store this result // Store this result
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation operator[](index).set
( (
equationOperation::slstorage, operator[](index).size() - 1,
new equationOperation
(
equationOperation::ststorage,
storeIndex + 1, storeIndex + 1,
0, 0,
0,
equationOperation::otstore equationOperation::otstore
)
); );
} }
// The last operation is an otstore. Add an otretrieve to finalize. // The last operation is an otstore. Add an otretrieve to finalize.
// We could eliminate the last otstore, but this will miss the final // We could eliminate the last otstore, but this will miss the final
// absorbNegatives, if one existed. // absorbNegatives, if one existed.
eqns_[index].setSize(eqns_[index].size() + 1); operator[](index).setSize(operator[](index).size() + 1);
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation operator[](index).set
( (
map[eqnIndices[0]].sourceList(), operator[](index).size() - 1,
new equationOperation
(
map[eqnIndices[0]].sourceType(),
map[eqnIndices[0]].sourceIndex(), map[eqnIndices[0]].sourceIndex(),
map[eqnIndices[0]].componentIndex(),
map[eqnIndices[0]].dictLookupIndex(), map[eqnIndices[0]].dictLookupIndex(),
equationOperation::otretrieve equationOperation::otretrieve
)
); );
// Link the eval function pointers (for efficiency) // Link the eval function pointers (for efficiency)
assignFunctionPointers(index); assignFunctionPointers(index);
// Determine the maximum field sizes available for this equation
findMaxFieldSize(index);
if (debug)
{
Info << "Parsing complete for equation " << operator[](index).name()
<< " at index " << index << "." << endl;
}
} }
@ -530,10 +608,10 @@ Foam::label Foam::equationReader::parseExpression
label index, label index,
const tokenList& tl, const tokenList& tl,
const labelList& opLvl, const labelList& opLvl,
equationOperationList& map, PtrList<equationOperation>& map,
const labelList& indices, const labelList& indices,
label& storeIndex label& storeIndex
) ) const
{ {
// equation * eqn(&this->operator[](index)); // equation * eqn(&this->operator[](index));
label returnMe(-1); label returnMe(-1);
@ -614,14 +692,19 @@ Foam::label Foam::equationReader::parseExpression
description description
); );
} }
eqns_[index].setSize(eqns_[index].size() + 1); operator[](index).setSize(operator[](index).size() + 1);
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation operator[](index).set
( (
map[opIndices[0]].sourceList(), operator[](index).size() - 1,
new equationOperation
(
map[opIndices[0]].sourceType(),
map[opIndices[0]].sourceIndex(), map[opIndices[0]].sourceIndex(),
map[opIndices[0]].componentIndex(),
map[opIndices[0]].dictLookupIndex(), map[opIndices[0]].dictLookupIndex(),
equationOperation::otretrieve equationOperation::otretrieve
)
); );
trimListWithParent(subIndices, opIndices, 0, 0); trimListWithParent(subIndices, opIndices, 0, 0);
@ -629,13 +712,18 @@ Foam::label Foam::equationReader::parseExpression
// Begin operations loop // Begin operations loop
while (opIndices.size() > 1) while (opIndices.size() > 1)
{ {
eqns_[index].setSize(eqns_[index].size() + 1); operator[](index).setSize(operator[](index).size() + 1);
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation operator[](index).set
( (
map[opIndices[1]].sourceList(), operator[](index).size() - 1,
new equationOperation
(
map[opIndices[1]].sourceType(),
map[opIndices[1]].sourceIndex(), map[opIndices[1]].sourceIndex(),
map[opIndices[1]].componentIndex(),
map[opIndices[1]].dictLookupIndex(), map[opIndices[1]].dictLookupIndex(),
map[opIndices[0]].operation() map[opIndices[0]].operation()
)
); );
if (opIndices.size() > 2) if (opIndices.size() > 2)
@ -646,20 +734,30 @@ Foam::label Foam::equationReader::parseExpression
else else
{ {
// Last operation, perform a store // Last operation, perform a store
eqns_[index].setSize(eqns_[index].size() + 1); operator[](index).setSize(operator[](index).size() + 1);
storeIndex++; storeIndex++;
eqns_[index].ops()[eqns_[index].size() - 1] = operator[](index).set
equationOperation
( (
equationOperation::slstorage, operator[](index).size() - 1,
new equationOperation
(
equationOperation::ststorage,
storeIndex + 1, storeIndex + 1,
0, 0,
0,
equationOperation::otstore equationOperation::otstore
)
); );
returnMe = opIndices[1]; returnMe = opIndices[1];
map[opIndices[1]] = map.set
eqns_[index].ops()[eqns_[index].size() - 1]; (
opIndices[1],
new equationOperation
(
operator[](index)[operator[](index).size() - 1]
)
);
map[opIndices[1]].operation() = equationOperation::otnone; map[opIndices[1]].operation() = equationOperation::otnone;
trimListWithParent(subIndices, opIndices, 0, 0); trimListWithParent(subIndices, opIndices, 0, 0);
} }

View file

@ -0,0 +1,349 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::equationReader::evaluateTypeField
(
Field<Type>& resultField,
const word& componentName,
const word& equationName,
const label geoIndex
) const
{
// Get equationIndex
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateTypeField")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
// Get componentIndex
Type dummy;
label componentIndex(-1);
forAll(dummy, i)
{
if (Type::componentNames[i] == componentName)
{
componentIndex = i;
break;
}
}
if (componentIndex < 0)
{
wordList validNames(dummy.size());
forAll(dummy, i)
{
validNames[i] = Type::componentNames[i];
}
FatalErrorIn("equationReader::evaluateTypeField")
<< componentName << " is not a valid component name. Valid names "
<< "are " << validNames
<< abort(FatalError);
}
evaluateTypeField(resultField, componentIndex, equationIndex, geoIndex);
}
template<class Type>
void Foam::equationReader::evaluateTypeField
(
Field<Type>& resultField,
const label componentIndex,
const label equationIndex,
const label geoIndex
) const
{
scalarField sf(resultField.size());
evaluateScalarField(sf, equationIndex, geoIndex);
List_ACCESS(Type, resultField, resultFieldP);
List_CONST_ACCESS(scalar, sf, sfP);
/* loop through fields performing f1 OP1 f2 OP2 f3 */
List_FOR_ALL(resultField, i)
List_ELEM(resultField, resultFieldP, i)[componentIndex] =
List_ELEM(sf, sfP, i);
List_END_FOR_ALL
}
template<class GeoMesh>
void Foam::equationReader::evaluateDimensionedScalarField
(
DimensionedField<scalar, GeoMesh>& resultDField,
const word& equationName,
const label geoIndex
) const
{
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateDimensionedScalarField")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
evaluateDimensionedScalarField(resultDField, equationIndex, geoIndex);
}
template<class GeoMesh>
void Foam::equationReader::evaluateDimensionedScalarField
(
DimensionedField<scalar, GeoMesh>& resultDField,
const label equationIndex,
const label geoIndex
) const
{
evaluateScalarField(resultDField.field(), equationIndex, geoIndex);
checkFinalDimensions
(
equationIndex,
resultDField.dimensions(),
resultDField.name()
);
}
template<class Type, class GeoMesh>
void Foam::equationReader::evaluateDimensionedTypeField
(
DimensionedField<Type, GeoMesh>& resultDField,
const word& componentName,
const word& equationName,
const label geoIndex
) const
{
// Get equationIndex
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateDimensionedTypeField")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
// Get componentIndex
Type dummy;
label componentIndex(-1);
forAll(dummy, i)
{
if (Type::componentNames[i] == componentName)
{
componentIndex = i;
break;
}
}
if (componentIndex < 0)
{
wordList validNames(dummy.size());
forAll(dummy, i)
{
validNames[i] = Type::componentNames[i];
}
FatalErrorIn("equationReader::evaluateDimensionedTypeField")
<< componentName << " is not a valid component name. Valid names "
<< "are " << validNames
<< abort(FatalError);
}
evaluateDimensionedTypeField
(
resultDField,
componentIndex,
equationIndex,
geoIndex
);
}
template<class Type, class GeoMesh>
void Foam::equationReader::evaluateDimensionedTypeField
(
DimensionedField<Type, GeoMesh>& resultDField,
const label componentIndex,
const label equationIndex,
const label geoIndex
) const
{
evaluateTypeField
(
resultDField.field(),
componentIndex,
equationIndex,
geoIndex
);
checkFinalDimensions
(
equationIndex,
resultDField.dimensions(),
resultDField.name() + "." + Type::componentNames[componentIndex]
);
}
template<template<class> class PatchField, class GeoMesh>
void Foam::equationReader::evaluateGeometricScalarField
(
GeometricField<scalar, PatchField, GeoMesh>& resultGField,
const word& equationName
) const
{
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateGeometricScalarField")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
evaluateGeometricScalarField(resultGField, equationIndex);
}
template <template<class> class PatchField, class GeoMesh>
void Foam::equationReader::evaluateGeometricScalarField
(
GeometricField<scalar, PatchField, GeoMesh>& resultGField,
const label equationIndex
) const
{
// Internal field: geoIndex = 0
evaluateScalarField
(
resultGField.internalField(),
equationIndex,
0
);
// Boundary fields: geoIndex = patchIndex + 1
forAll(resultGField.boundaryField(), patchIndex)
{
evaluateScalarField
(
resultGField.boundaryField()[patchIndex],
equationIndex,
patchIndex + 1
);
}
checkFinalDimensions
(
equationIndex,
resultGField.dimensions(),
resultGField.name()
);
}
template
<
class Type, template<class> class PatchField, class GeoMesh
>
void Foam::equationReader::evaluateGeometricTypeField
(
GeometricField<Type, PatchField, GeoMesh>& resultGField,
const word& componentName,
const word& equationName
) const
{
// Get equationIndex
label equationIndex(lookup(equationName));
if (equationIndex < 0)
{
FatalErrorIn("equationReader::evaluateGeometricTypeField")
<< "Equation name " << equationName << " not found."
<< abort(FatalError);
}
// Get componentIndex
Type dummy;
label componentIndex(-1);
forAll(dummy, i)
{
if (Type::componentNames[i] == componentName)
{
componentIndex = i;
break;
}
}
if (componentIndex < 0)
{
wordList validNames(dummy.size());
forAll(dummy, i)
{
validNames[i] = Type::componentNames[i];
}
FatalErrorIn("equationReader::evaluateGeometricTypeField")
<< componentName << " is not a valid component name. Valid names "
<< "are " << validNames
<< abort(FatalError);
}
evaluateGeometricTypeField(resultGField, componentIndex, equationIndex);
}
template
<
class Type, template<class> class PatchField, class GeoMesh
>
void Foam::equationReader::evaluateGeometricTypeField
(
GeometricField<Type, PatchField, GeoMesh>& resultGField,
const label componentIndex,
const label equationIndex
) const
{
// Internal field: geoIndex = 0
evaluateTypeField
(
resultGField.internalField(),
componentIndex,
equationIndex,
0
);
// Boundary fields: geoIndex = patchIndex + 1
forAll(resultGField.boundaryField(), patchIndex)
{
evaluateTypeField
(
resultGField.boundaryField()[patchIndex],
componentIndex,
equationIndex,
patchIndex + 1
);
}
checkFinalDimensions
(
equationIndex,
resultGField.dimensions(),
resultGField.name() + "." + Type::componentNames[componentIndex]
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,6 @@
#ifndef equationReaderVersion_H
# define equationReaderVersion_H
# define equationReaderVersionMajor 0
# define equationReaderVersionMinor 6
# define equationReaderVersionBuild 0
#endif

View file

@ -0,0 +1,122 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 "equationReader.H"
#include "equationReader.C"
// * * * * * * * * * * * * * scalar specializations * * * * * * * * * * * * //
namespace Foam
{
template<>
void equationReader::evaluateTypeField
(
Field<scalar>& resultField,
const word& componentName,
const word& equationName,
const label geoIndex
) const
{
evaluateScalarField(resultField, equationName, geoIndex);
}
template<>
void equationReader::evaluateTypeField
(
Field<scalar>& resultField,
const label componentIndex,
const label equationIndex,
const label geoIndex
) const
{
evaluateScalarField(resultField, equationIndex, geoIndex);
}
/* DLFG 2011-09-10
* Today I learned: Partial specialization is not allowed for member functions.
* This code is left here to note what I want to implement in the future.
* Apparently function objects make a nice work-around. For now:
* scalar fields must use evaluate...ScalarField functions;
* other types must use evaluate...TypeField functions;
* This is still safe as a mismatch produces compile-time errors.
template<class GeoMesh>
void equationReader::evaluateDimensionedTypeField<scalar, GeoMesh>
(
DimensionedField<scalar, GeoMesh>& resultDField,
const word& componentName,
const word& equationName,
const label geoIndex
) const
{
evaluateDimensionedScalarField(resultDField, equationName, geoIndex);
}
template<class GeoMesh>
void equationReader::evaluateDimensionedTypeField<scalar, GeoMesh>
(
DimensionedField<scalar, GeoMesh>& resultDField,
const label componentIndex,
const label equationIndex,
const label geoIndex
) const
{
evaluateDimensionedScalarField(resultDField, equationIndex, geoIndex);
}
template<template<class> class PatchField, class GeoMesh>
void equationReader::evaluateGeometricTypeField<scalar, PatchField, GeoMesh>
(
GeometricField<scalar, PatchField, GeoMesh>& resultGField,
const word& componentName,
const word& equationName
) const
{
evaluateGeometricScalarField(resultGField, equationName);
}
template<template<class> class PatchField, class GeoMesh>
void equationReader::evaluateGeometricTypeField<scalar, PatchField, GeoMesh>
(
GeometricField<scalar, PatchField, GeoMesh>& resultGField,
const label componentIndex,
const label equationIndex
) const
{
evaluateGeometricScalarField(resultGField, equationIndex);
}
*/
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -22,32 +22,68 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::equationOperationList
Description
List of equationOperations
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef equationOperationList_H //#include "equationScalarSource.H"
#define equationOperationList_H
#include "equationOperation.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef List<equationOperation> equationOperationList;
template<>
label Foam::equationSource<scalar>::lookupComponentIndex
(
const word& componentName
) const
{
// scalar specialization: also returns 0 if word::null is given
if ((componentName == word::null) || componentName == "x")
{
return 0;
}
return -1;
}
template<>
const scalar& equationSource<scalar>::singleValue
(
label sourceIndex,
label componentIndex
) const
{
return singles_[sourceIndex];
}
template<>
const scalar& equationSource<scalar>::fieldValue
(
label sourceIndex,
label componentIndex,
label cellIndex,
label geoIndex
) const
{
return fields_[sourceIndex][geoIndex][cellIndex];
}
template<>
void equationSource<scalar>::fullFieldValue
(
scalarField& result,
label sourceIndex,
label componentIndex,
label geoIndex
) const
{
//result.setSize(fields_[sourceIndex][geoIndex].size());
result = fields_[sourceIndex][geoIndex];
}
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* // // ************************************************************************* //

View file

@ -0,0 +1,519 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 "equationSource.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::equationSource<Type>::equationSource
(
const word& templateTypeName
)
:
templateTypeName_(templateTypeName)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::equationSource<Type>::~equationSource()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
bool Foam::equationSource<Type>::foundSingle(const word& lookupName) const
{
forAll(singleNames_, sourceIndex)
{
if (singleNames_[sourceIndex] == lookupName)
{
return true;
}
}
return false;
}
template<class Type>
bool Foam::equationSource<Type>::foundField(const word& lookupName) const
{
forAll(fieldNames_, sourceIndex)
{
if (fieldNames_[sourceIndex] == lookupName)
{
return true;
}
}
return false;
}
template<class Type>
Foam::label Foam::equationSource<Type>::lookupSingle
(
const word& lookupName
) const
{
forAll(singleNames_, sourceIndex)
{
if (singleNames_[sourceIndex] == lookupName)
{
return sourceIndex;
}
}
FatalErrorIn("equationSource::lookupSingle")
<< lookupName << " is not a valid " << templateTypeName_ << " single "
<< "data source. Valid names are:" << token::NL << singleNames_
<< abort(FatalError);
return -1;
}
template<class Type>
Foam::label Foam::equationSource<Type>::lookupField
(
const word& lookupName
) const
{
forAll(fieldNames_, sourceIndex)
{
if (fieldNames_[sourceIndex] == lookupName)
{
return sourceIndex;
}
}
FatalErrorIn("equationSource::lookupField")
<< lookupName << " is not a valid " << templateTypeName_ << "Field "
<< "data source. Valid names are:" << token::NL << fieldNames_
<< abort(FatalError);
return -1;
}
template<class Type>
Foam::label Foam::equationSource<Type>::geoSize(label sourceIndex) const
{
return fields_[sourceIndex].size();
}
template<class Type>
Foam::label Foam::equationSource<Type>::fieldSize
(
label sourceIndex,
label geoIndex
) const
{
return fields_[sourceIndex][geoIndex].size();
}
template<class Type>
Foam::label Foam::equationSource<Type>::lookupComponentIndex
(
const word& componentName
) const
{
// Because Type.size() is not static
Type dummy;
for (label compIndex(0); compIndex < dummy.size(); compIndex++)
{
if (Type::componentNames[compIndex] == componentName)
{
return compIndex;
}
}
return -1;
}
template<class Type>
Foam::label Foam::equationSource<Type>::nSingles() const
{
return singles_.size();
}
template<class Type>
Foam::label Foam::equationSource<Type>::nFields() const
{
return fields_.size();
}
template<class Type>
const Foam::scalar& Foam::equationSource<Type>::singleValue
(
label sourceIndex,
label componentIndex
) const
{
return singles_[sourceIndex][componentIndex];
}
template<class Type>
const Foam::dimensionSet& Foam::equationSource<Type>::singleDimensions
(
label sourceIndex
) const
{
return singleDimensions_[sourceIndex];
}
template<class Type>
const Foam::word& Foam::equationSource<Type>::singleName
(
label sourceIndex
) const
{
return singleNames_[sourceIndex];
}
template<class Type>
const Foam::scalar& Foam::equationSource<Type>::fieldValue
(
label sourceIndex,
label componentIndex,
label cellIndex,
label geoIndex
) const
{
return fields_[sourceIndex][geoIndex][cellIndex][componentIndex];
}
template<class Type>
void Foam::equationSource<Type>::fullFieldValue
(
scalarField& result,
label sourceIndex,
label componentIndex,
label geoIndex
) const
{
const Field<Type>& fieldRef(fields_[sourceIndex][geoIndex]);
//result.setSize(fieldRef.size());
forAll(result, cellIndex)
{
result[cellIndex] = fieldRef[cellIndex][componentIndex];
}
}
template<class Type>
const Foam::dimensionSet& Foam::equationSource<Type>::fieldDimensions
(
label sourceIndex
) const
{
return fieldDimensions_[sourceIndex];
}
template<class Type>
const Foam::word& Foam::equationSource<Type>::fieldName
(
label sourceIndex
) const
{
return fieldNames_[sourceIndex];
}
template<class Type>
void Foam::equationSource<Type>::addSource
(
const Type& singleIn,
const word& name,
dimensionSet dimensions
)
{
label newIndex(singles_.size());
singles_.setSize(newIndex + 1);
singleDimensions_.setSize(newIndex + 1);
singleNames_.setSize(newIndex + 1);
singles_.set
(
newIndex,
&singleIn
);
singleDimensions_.set
(
newIndex,
new dimensionSet(dimensions)
);
singleNames_[newIndex] = name;
}
template<class Type>
void Foam::equationSource<Type>::addSource
(
const dimensioned<Type>& dSingleIn
)
{
addSource(dSingleIn.value(), dSingleIn.name(), dSingleIn.dimensions());
}
template<class Type>
void Foam::equationSource<Type>::addSource
(
const Field<Type>& fieldIn,
const word& name,
dimensionSet dimensions
)
{
label newIndex(fields_.size());
fields_.setSize(newIndex + 1);
fieldDimensions_.setSize(newIndex + 1);
fieldNames_.setSize(newIndex + 1);
fields_.set
(
newIndex,
new UPtrList<const Field<Type> >(1)
);
fields_[newIndex].set
(
0,
&fieldIn
);
fieldDimensions_.set
(
newIndex,
new dimensionSet(dimensions)
);
fieldNames_[newIndex] = name;
}
template<class Type>
template<class GeoMesh>
void Foam::equationSource<Type>::addSource
(
const DimensionedField<Type, GeoMesh>& dFieldIn
)
{
addSource
(
dFieldIn.field(),
dFieldIn.name(),
dFieldIn.dimensions()
);
}
template<class Type>
template<template<class> class PatchField, class GeoMesh>
void Foam::equationSource<Type>::addSource
(
const GeometricField<Type, PatchField, GeoMesh>& gFieldIn
)
{
label newIndex(fields_.size());
label newGeoIndex(gFieldIn.boundaryField().size() + 1);
fields_.setSize(newIndex + 1);
fieldDimensions_.setSize(newIndex + 1);
fieldNames_.setSize(newIndex + 1);
// Set dimensions
fieldDimensions_.set
(
newIndex,
new dimensionSet(gFieldIn.dimensions())
);
// Set name
fieldNames_[newIndex] = gFieldIn.name();
// Create fields pointer object
fields_.set
(
newIndex,
new UPtrList<const Field<Type> >(newGeoIndex)
);
// Set internal field
fields_[newIndex].set
(
0,
&gFieldIn.internalField()
);
// Set boundary fields
forAll(gFieldIn.boundaryField(), patchI)
{
fields_[newIndex].set
(
patchI + 1,
&gFieldIn.boundaryField()[patchI]
);
}
}
template<class Type>
void Foam::equationSource<Type>::removeSingle(label sourceIndex)
{
# ifdef FULLDEBUG
if ((sourceIndex < 0) || (sourceIndex >= nSingles()))
{
FatalErrorIn("equationSource::removeSingle")
<< "sourceIndex out of range (0.." << nSingles() << ")"
<< abort(FatalError);
}
# endif
for (label i(sourceIndex); i < (singles_.size() - 1); i++)
{
singles_[i] = singles_[i + 1];
singleDimensions_[i] = singleDimensions_[i + 1];
singleNames_[i] = singleNames_[i + 1];
}
/*
labelList oldToNew(singles_.size());
for (label i(0); i < sourceIndex; i++)
{
oldToNew[i] = i;
}
for (label i(sourceIndex); i < (singles_.size() - 1); i++)
{
oldToNew[i] = i + 1;
}
oldToNew[singles_.size() - 1] = sourceIndex;
singles_.reorder(oldToNew);
singleDimensions_.reorder(oldToNew);
singleNames_.reorder(oldToNew);*/
label newSize(singles_.size() - 1);
singles_.setSize(newSize);
singleDimensions_.setSize(newSize);
singleNames_.setSize(newSize);
}
template<class Type>
void Foam::equationSource<Type>::removeField(label sourceIndex)
{
# ifdef FULLDEBUG
if ((sourceIndex < 0) || (sourceIndex >= nFields()))
{
FatalErrorIn("equationSource::removeSingle")
<< "sourceIndex out of range (0.." << nFields() << ")"
<< abort(FatalError);
}
# endif
for (label i(sourceIndex); i < (fields_.size() - 1); i++)
{
fields_[i] = fields_[i + 1];
fieldDimensions_[i] = fieldDimensions_[i + 1];
fieldNames_[i] = fieldNames_[i + 1];
}
/*
labelList oldToNew(fields_.size());
for (label i(0); i < sourceIndex; i++)
{
oldToNew[i] = i;
}
for (label i(sourceIndex); i < (fields_.size() - 1); i++)
{
oldToNew[i] = i + 1;
}
oldToNew[fields_.size() - 1] = sourceIndex;
fields_.reorder(oldToNew);
fieldDimensions_.reorder(oldToNew);
fieldNames_.reorder(oldToNew);
*/
label newSize(fields_.size() - 1);
fields_.setSize(newSize);
fieldDimensions_.setSize(newSize);
fieldNames_.setSize(newSize);
}
template<class Type>
Foam::dictionary Foam::equationSource<Type>::outputDictionary() const
{
dictionary returnMe;
dictionary singlesDict;
forAll(singles_, sourceIndex)
{
singlesDict.set
(
singleNames_[sourceIndex],
dimensioned<Type>
(
singleNames_[sourceIndex],
singleDimensions_[sourceIndex],
singles_[sourceIndex]
)
);
}
returnMe.set
(
keyType(word("single(" + templateTypeName_ + "s)")),
singlesDict
);
dictionary fieldsDict;
forAll(fields_, sourceIndex)
{
dictionary tempDict;
tempDict.set("dimensions", fieldDimensions_[sourceIndex]);
forAll(fields_[sourceIndex], geoIndex)
{
tempDict.set
(
"field" + geoIndex,
fields_[sourceIndex][geoIndex]
);
}
fieldsDict.set(fieldNames_[sourceIndex], tempDict);
}
returnMe.set
(
keyType(word("field(" + templateTypeName_ + "s)")),
fieldsDict
);
return returnMe;
}
// ************************************************************************* //

View file

@ -0,0 +1,309 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::equationSource
Description
A set of data sources for the equationReader templated by Type.
SourceFiles
equationSourceI.H
equationSource.C
equationSourceTemplates.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationSource_H
#define equationSource_H
#include "word.H"
#include "UPtrList.H"
#include "wordList.H"
#include "PtrList.H"
#include "GeometricFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class equationSource Declaration
\*---------------------------------------------------------------------------*/
template <class Type>
class equationSource
{
// Private data
//- Name of templated type
word templateTypeName_;
//- Individual "Type"s as sources
UPtrList<const Type> singles_;
//- Names associated with singles_
wordList singleNames_;
//- Dimensions associated with singles_
PtrList<dimensionSet> singleDimensions_;
//- Fields of Type - holds the source data for regular
// Field<Type>'s, but also can hold source data for GeometricFields
// fields_[sourceIndex][geoIndex][cellIndex]
// Where:
// sourceIndex is the source variable index
// geoIndex is to accommodate GeometricFields:
// 0 = internalField (or standard Field<Type>)
// 1+ = boundary patch as a Field<Type>
// cellIndex is the index number of the Field<Type>
PtrList<UPtrList<const Field<Type> > > fields_;
//- Dimensions associated with the fields_
PtrList<dimensionSet> fieldDimensions_;
//- Names associated with the fields_
wordList fieldNames_;
public:
// Static data members
static const char* const typeName;
// Constructors
//- Construct from components
explicit equationSource
(
const word& templateTypeName
);
// Destructor
~equationSource();
// Member functions
// Access
//- Individual "Type"s as sources
inline const UPtrList<const Type>& singles() const;
//- Names associated with singles
inline const wordList& singleNames() const;
//- Dimensions associated with singles_
inline const PtrList<dimensionSet>& singleDimensions() const;
//- Fields of Type - holds the source data for regular
inline const PtrList<UPtrList<const Field<Type> > >&
fields() const;
//- Dimensions associated with the fields_
inline const PtrList<dimensionSet>& fieldDimensions() const;
//- Names associated with the fields_
inline const wordList& fieldNames() const;
// Data lookup
//- True if lookupName is a valid single source
bool foundSingle(const word& lookupName) const;
//- True if lookupName is a valid field source
bool foundField(const word& lookupName) const;
//- Returns single sourceIndex for lookupName - fails if not found
label lookupSingle(const word& lookupName) const;
//- Returns field sourceIndex for lookupName - fails if not found
label lookupField(const word& lookupName) const;
//- Returns the number of fields associated with sourceIndex
label geoSize(label sourceIndex) const;
//- Returns the field size associated with source and geo indices
label fieldSize
(
label sourceIndex,
label geoIndex
) const;
//- Return componentIndex for a given component name
// Returns -1 if not found (error handled by calling function)
label lookupComponentIndex(const word& componentName) const;
//- Returns the number of singles_
label nSingles() const;
//- Returns the number of fields_
label nFields() const;
// Data retrieval
//- Retrieve scalar value from singles
const scalar& singleValue
(
label sourceIndex,
label componentIndex
) const;
//- Retrieve dimensions from singles
const dimensionSet& singleDimensions(label sourceIndex) const;
//- Retrieve name associated with singles
const word& singleName(label sourceIndex) const;
//- Retrieve scalar value from field
const scalar& fieldValue
(
label sourceIndex,
label componentIndex,
label cellIndex,
label geoIndex
) const;
//- Retrieve component as entire field
void fullFieldValue
(
scalarField& result,
label sourceIndex,
label componentIndex,
label geoIndex
) const;
//- Retrieve dimensions from field
const dimensionSet& fieldDimensions(label sourceIndex) const;
//- Retrieve name associated with field
const word& fieldName(label sourceIndex) const;
// Adding data sources
//- Add single source
void addSource
(
const Type& singleIn,
const word& name,
dimensionSet dimensions = dimless
);
//- Add dimensionedSingle source
void addSource
(
const dimensioned<Type>& dSingleIn
);
//- Add field source
void addSource
(
const Field<Type>& fieldIn,
const word& name,
dimensionSet dimensions = dimless
);
//- Add dimensioned field source
template<class GeoMesh>
void addSource
(
const DimensionedField<Type, GeoMesh>& dFieldIn
);
//- Add geometric field source
template<template<class> class PatchField, class GeoMesh>
void addSource
(
const GeometricField<Type, PatchField, GeoMesh>& gFieldIn
);
// Removing data sources
//- Remove a single source and reorder index
void removeSingle(label sourceIndex);
//- Remove a field source and reorderd index
void removeField(label sourceIndex);
// Input / output
//- Output sources to a dictionary
dictionary outputDictionary() const;
};
template<>
label equationSource<scalar>::lookupComponentIndex
(
const word& componentName
) const;
template<>
const scalar& equationSource<scalar>::singleValue
(
label sourceIndex,
label componentIndex
) const;
template<>
const scalar& equationSource<scalar>::fieldValue
(
label sourceIndex,
label componentIndex,
label cellIndex,
label geoIndex
) const;
template<>
void equationSource<scalar>::fullFieldValue
(
scalarField& result,
label sourceIndex,
label componentIndex,
label geoIndex
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationSourceI.H"
#ifdef NoRepository
# include "equationSource.C"
//# include "equationScalarSource.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -22,32 +22,58 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::equationList
Description
List of equations
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef equationList_H
#define equationList_H
#include "equation.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef PtrList<equation> equationList;
template<class Type>
inline const UPtrList<const Type>& equationSource<Type>::singles() const
{
return singles_;
}
template<class Type>
inline const wordList& equationSource<Type>::singleNames() const
{
return singleNames_;
}
template<class Type>
inline const PtrList<dimensionSet>&
equationSource<Type>::singleDimensions() const
{
return singleDimensions_;
}
template<class Type>
inline const PtrList<UPtrList<const Field<Type> > >&
equationSource<Type>::fields() const
{
return fields_;
}
template<class Type>
inline const PtrList<dimensionSet>&
equationSource<Type>::fieldDimensions() const
{
return fieldDimensions_;
}
template<class Type>
inline const wordList& equationSource<Type>::fieldNames() const
{
return fieldNames_;
}
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -24,85 +24,37 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "equationSource.H"
#include "diagTensor.H"
template<class GeoMesh> // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
void Foam::equationReader::addDataSource
(
const DimensionedField<scalar, GeoMesh>& dfield
)
{
// const scalarList * slist(&dfield);
word name(dfield.name());
dimensionSet dims(dfield.dimensions());
addDataSource(dfield, name, dims);
}
template<class GeoMesh>
void Foam::equationReader::evaluateField
(
const label& index,
DimensionedField<scalar, GeoMesh>& dfield
)
{
evaluateField(index, dfield, dfield.dimensions());
}
template<class GeoMesh>
void Foam::equationReader::linkOutput
(
const word& eqnName,
DimensionedField<scalar, GeoMesh>& dfield
)
{
label index(lookup(eqnName));
if (index < 0)
{
FatalErrorIn("equationReader::linkOutput")
<< "Equation name " << eqnName << "not found."
<< abort(FatalError);
}
linkOutput
(
index,
dfield,
dfield.dimensions()
);
}
template<class GeoMesh>
void Foam::equationReader::linkOutput
(
label index,
DimensionedField<scalar, GeoMesh>& dfield
)
{
linkOutput
(
index,
dfield,
dfield.dimensions()
);
}
template<class GeoMesh>
void Foam::equationReader::readEquation
(
equation eqn,
DimensionedField<scalar, GeoMesh>& dfield
)
{
readEquation
(
eqn,
dfield,
dfield.dimensions()
);
}
#ifdef __INTEL_COMPILER
# define defineEquationSourceTypeNames(type, Type) \
const char* const Foam::equationSource<type>::typeName = \
"equation" #Type "Source"
#else
# define defineEquationSourceTypeNames(type, Type) \
template<> \
const char* const Foam::equationSource<type>::typeName = \
"equation" #Type "Source"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineEquationSourceTypeNames(scalar, Scalar);
defineEquationSourceTypeNames(vector, Vector);
defineEquationSourceTypeNames(tensor, Tensor);
defineEquationSourceTypeNames(diagTensor, DiagTensor);
defineEquationSourceTypeNames(symmTensor, SymmTensor);
defineEquationSourceTypeNames(sphericalTensor, SphericalTensor);
} // End namespace Foam
#include "equationScalarSource.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -0,0 +1,96 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::equationVariable
Description
A generic interface template for active equation variables for the
equationReader. Use this for objects that act as equation data sources,
but do not store their data in a permanent location.
SourceFiles
equationVariableI.H
equationVariable.C
equationVariableTemplates.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationVariable_H
#define equationVariable_H
#include "word.H"
#include "scalar.H"
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class equationVariable Declaration
\*---------------------------------------------------------------------------*/
class equationVariable
{
public:
// Destructor
virtual ~equationVariable() {}
virtual const word& name() const = 0;
virtual const dimensionSet& dimensions() const = 0;
virtual label lookupComponentIndex(const word) const = 0;
virtual scalar evaluateScalar
(
const label componentIndex,
const label cellIndex,
const label geoIndex
) const = 0;
virtual void evaluateScalarField
(
scalarField& result,
const label componentIndex,
const label geoIndex
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -0,0 +1,22 @@
//
// createEquationReader.H
// ~~~~~~~~~~~~~~~~~~~~~~
Foam::IOEquationReader eqns
(
IOobject
(
"equations",
runTime.timeName(),
runTime,
IOobject::NO_READ,
runTime.controlDict().found("outputEquations")
? Switch(runTime.controlDict().lookup("outputEquations")) == true
? IOobject::AUTO_WRITE
: IOobject::NO_WRITE
: IOobject::NO_WRITE
),
runTime.controlDict().found("outputEquationDataSources")
? bool(Switch(runTime.controlDict().lookup("outputEquationDataSources")))
: false
);

View file

@ -0,0 +1,12 @@
// If your OpenFOAM version number is 1.7.x or less, comment out the next line:
// #define ThisIsFoamVersion2
#ifdef ThisIsFoamVersion2
# ifndef MathConstantScope
# define MathConstantScope constant::mathematical
# endif
#else
# ifndef MathConstantScope
# define MathConstantScope mathematicalConstant
# endif
#endif

View file

@ -0,0 +1,71 @@
|---------------------.
| David L. F. Gaden's |
.----------------|---------------------'
| equationReader | Version: 0.6.0
'----------------|
Description
===========
An extension to OpenFOAM that allows you to read equations from a dictionary
file and (optionally) have them evaluated at every time step.
Original Author
===============
David L. F. Gaden (dlfgaden@gmail.com)
Current Maintainer
==================
David L. F. Gaden (dlfgaden@gmail.com)
Contributors
============
David L. F. Gaden : base version
Documentation
=============
github.com/Marupio/equationReader/wiki
Installation/Compilation
========================
Refer to the documentation.
Contents
========
- src - the library source files
- applications - a demo application that uses equationReader
- tutorials - a sample case that runs the demo application
Required OpenFOAM-Version (Known to work with)
==============================================
1.6-ext
2.1.x
2.2.x
History
=======
2010-07-21: Initial import
2010-08-05: Differentiated versions for OpenFOAM 1.5.x/1.5-dev and
OpenFOAM 1.6+
2010-08-12:
* Added IOobject support for automatic output - IOEquationReader
* Removed need for pointers
* Added support for scalarLists as a data source
* Cleaned up available functions
2010-10-16:
* Added full support for fields - equationReader can now operate across the
entire mesh.
* Bug fixes:
* Dimension-checking for min and max functions
* Moved IOobjects to db directory
2011-09-25: Version 0.5.0
* Improved treatment of fields - now approximately 10x faster
* Introduced version numbers to keep track of changes
2012-10-25: Version 0.5.1
* Moved to git
* Bug fixes:
* Circular reference detection now working
2013-08-29: Version 0.6.0
* Uploaded to github and OpenFOAM-extend
* Restructured applications and tutorials directories for consistency
* Made opening splash optional

View file

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 1.6-ext-1f09367282cf
Exec : equationReaderDemo
Date : Apr 07 2011
Time : 09:03:55
Host : Bruce
PID : 4063
Case : /home/dave/OpenFOAM/dave-1.6-ext/run/tutorials/equationReaderDemo
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Reading testDict dictionary
Begin stand-alone operation...
Reading a scalar... done. Result = 1.94281
Reading a dimensionedScalar ... done. Result = standAloneDScalar [0 0 0 0 0 0 0] 0.080125
Creating the equationReader object
Creating data sources: dictionary ptrs... scalars... dimensionedScalar ptrs... output dimensionedScalar ptrs... done.
Linking in the data sources: dictionary ptrs... dimensionedScalar ptrs... scalar ptrs... done.
Reading equation a from testDict with no output variable
Evaluating equation a ... done. Result = a [0 0 0 0 0 0 0] 0.625
Reading equation b from testDict, linking an output variable
Output variable before update() = activeOutB [0 0 0 0 0 0 0] 0
Begining .update() - this evaluates all equations with active output...
Done. Output variable after update() = activeOutB [0 0 0 0 0 0 0] 0.3235
Equation c depends on equation a. Reading it will link them.
Reading equation c from testDict... done.
Evaluating c will force an evaluate of a.
Evaluating ... done. Result = c [0 0 0 0 0 0 0] 0.805821
Equation d depends on equation e, but equation e is never explicitly
read by equationReaderDemo. Reading equation d will automatically
create equation e on-the-fly.
Reading equation d from testDict ... done.
Again, evaluating d will force an evaluate of e.
Evaluating d ... done. The result is = d [0 0 0 0 0 0 0] 2.04124
Equations can draw from any sources added to equationReader.
Equation f is very complex, drawing from numerous sources.
Reading equation f ... done. Evaluating equation f ... done.
The result is: f [0 0 0 0 0 0 0] -86.1698
Creating output...

View file

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volSymmTensorField;
object R;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform (0 0 0 0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0 0 0 0 0 0);
}
outlet
{
type zeroGradient;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View file

@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.5 | | \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: http://www.OpenFOAM.org | | \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
FoamFile FoamFile
@ -20,13 +20,24 @@ internalField uniform (0 0 0);
boundaryField boundaryField
{ {
movingWall inlet
{ {
type fixedValue; type fixedValue;
value uniform (1 0 0); value uniform (10 0 0);
} }
fixedWalls outlet
{
type zeroGradient;
}
upperWall
{
type fixedValue;
value uniform (0 0 0);
}
lowerWall
{ {
type fixedValue; type fixedValue;
value uniform (0 0 0); value uniform (0 0 0);

View file

@ -0,0 +1,56 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 14.855;
boundaryField
{
inlet
{
type fixedValue;
value uniform 14.855;
}
outlet
{
type zeroGradient;
}
upperWall
{
type epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 14.855;
}
lowerWall
{
type epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 14.855;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0.375;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0.375;
}
outlet
{
type zeroGradient;
}
upperWall
{
type kqRWallFunction;
value uniform 0.375;
}
lowerWall
{
type kqRWallFunction;
value uniform 0.375;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object nuTilda;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0;
}
outlet
{
type zeroGradient;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View file

@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.5 | | \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: http://www.OpenFOAM.org | | \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
FoamFile FoamFile
@ -20,12 +20,23 @@ internalField uniform 0;
boundaryField boundaryField
{ {
movingWall inlet
{ {
type zeroGradient; type zeroGradient;
} }
fixedWalls outlet
{
type fixedValue;
value uniform 0;
}
upperWall
{
type zeroGradient;
}
lowerWall
{ {
type zeroGradient; type zeroGradient;
} }

View file

@ -0,0 +1,200 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
RASModel kEpsilon;
turbulence on;
printCoeffs on;
laminarCoeffs
{
}
kEpsilonCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
}
RNGkEpsilonCoeffs
{
Cmu 0.0845;
C1 1.42;
C2 1.68;
alphak 1.39;
alphaEps 1.39;
eta0 4.38;
beta 0.012;
}
realizableKECoeffs
{
Cmu 0.09;
A0 4.0;
C2 1.9;
alphak 1;
alphaEps 0.833333;
}
kOmegaSSTCoeffs
{
alphaK1 0.85034;
alphaK2 1.0;
alphaOmega1 0.5;
alphaOmega2 0.85616;
gamma1 0.5532;
gamma2 0.4403;
beta1 0.0750;
beta2 0.0828;
betaStar 0.09;
a1 0.31;
c1 10;
Cmu 0.09;
}
NonlinearKEShihCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76932;
A1 1.25;
A2 1000;
Ctau1 -4;
Ctau2 13;
Ctau3 -2;
alphaKsi 0.9;
}
LienCubicKECoeffs
{
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76923;
A1 1.25;
A2 1000;
Ctau1 -4;
Ctau2 13;
Ctau3 -2;
alphaKsi 0.9;
}
QZetaCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaZeta 0.76923;
anisotropic no;
}
LaunderSharmaKECoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
}
LamBremhorstKECoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
}
LienCubicKELowReCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76923;
A1 1.25;
A2 1000;
Ctau1 -4;
Ctau2 13;
Ctau3 -2;
alphaKsi 0.9;
Am 0.016;
Aepsilon 0.263;
Amu 0.00222;
}
LienLeschzinerLowReCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76923;
Am 0.016;
Aepsilon 0.263;
Amu 0.00222;
}
LRRCoeffs
{
Cmu 0.09;
Clrr1 1.8;
Clrr2 0.6;
C1 1.44;
C2 1.92;
Cs 0.25;
Ceps 0.15;
alphaEps 0.76923;
}
LaunderGibsonRSTMCoeffs
{
Cmu 0.09;
Clg1 1.8;
Clg2 0.6;
C1 1.44;
C2 1.92;
C1Ref 0.5;
C2Ref 0.3;
Cs 0.25;
Ceps 0.15;
alphaEps 0.76923;
alphaR 1.22;
}
SpalartAllmarasCoeffs
{
alphaNut 1.5;
Cb1 0.1355;
Cb2 0.622;
Cw2 0.3;
Cw3 2;
Cv1 7.1;
Cv2 5.0;
}
wallFunctionCoeffs
{
kappa 0.4187;
E 9;
}
// ************************************************************************* //

View file

@ -0,0 +1,206 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// equationReaderDemo makes these variables available to your equations:
//
// t time
// C.x x co-ordinate
// C.y y co-ordinate
// C.z z co-ordinate
// V cell volume
// p pressure
// U.x velocity x
// U.y velocity y
// U.z velocity z
// R_.xx Reynolds stress tensor xx
// R_.xy Reynolds stress tensor xy
// R_.xz Reynolds stress tensor xz
// R_.yy Reynolds stress tensor yy
// R_.yz Reynolds stress tensor yz
// R_.zz Reynolds stress tensor zz
// scalar sources:
// sA, sB, sC
// DimensionedScalarSources:
// dsA, dsB, dsC
// scalarField sources (cannot be used for GeometricField output equations)
// sfA, sfB, sfC
// volScalarField sources
// vsfA, vsfB, vsfC
// vector sources
// vA.x, vA.y, vA.z
// vB.x, vB.y, vB.z
// vC.x, vC.y, vC.z
// DimensionedVectorSources:
// dvA.x, dvA.y, dvA.z
// dvB.x, dvB.y, dvB.z
// dvC.x, dvC.y, dvC.z
// vectorField sources (cannot be used for GeometricField output equations)
// vfA.x, vfA.y, vfA.z
// vfB.x, vfB.y, vfB.z
// vfC.x, vfC.y, vfC.z
// volVectorField sources
// vvfA.x, vvfA.y, vvfA.z
// vvfB.x, vvfB.y, vvfB.z
// vvfC.x, vvfC.y, vvfC.z
// tensor sources
// tA.xx, tA.xy, tA.xz, tA.yx, tA.yy, tA.yz, tA.zx, tA.zy, tA.zz
// tB.xx, tB.xy, tB.xz, tB.yx, tB.yy, tB.yz, tB.zx, tB.zy, tB.zz
// tC.xx, tC.xy, tC.xz, tC.yx, tC.yy, tC.yz, tC.zx, tC.zy, tC.zz
// DimensionedTensorSources:
// dtA.xx, dtA.xy, dtA.xz, dtA.yx, dtA.yy, dtA.yz, dtA.zx, dtA.zy, dtA.zz
// dtB.xx, dtB.xy, dtB.xz, dtB.yx, dtB.yy, dtB.yz, dtB.zx, dtB.zy, dtB.zz
// dtC.xx, dtC.xy, dtC.xz, dtC.yx, dtC.yy, dtC.yz, dtC.zx, dtC.zy, dtC.zz
// tensorField sources (cannot be used for GeometricField output equations)
// tfA.xx, tfA.xy, tfA.xz, tfA.yx, tfA.yy, tfA.yz, tfA.zx, tfA.zy, tfA.zz
// tfB.xx, tfB.xy, tfB.xz, tfB.yx, tfB.yy, tfB.yz, tfB.zx, tfB.zy, tfB.zz
// tfC.xx, tfC.xy, tfC.xz, tfC.yx, tfC.yy, tfC.yz, tfC.zx, tfC.zy, tfC.zz
// volVectorField sources
// vtfA.xx, vtfA.xy, vtfA.xz, vtfA.yx, vtfA.yy, vtfA.yz, vtfA.zx, vtfA.zy,
// vtfA.zz
// vtfB.xx, vtfB.xy, vtfB.xz, vtfB.yx, vtfB.yy, vtfB.yz, vtfB.zx, vtfB.zy,
// vtfB.zz
// vtfC.xx, vtfC.xy, vtfC.xz, vtfC.yx, vtfC.yy, vtfC.yz, vtfC.zx, vtfC.zy,
// vtfC.zz
// Also, this dictionary is, itself, a "source", so you can define your own
// variables, including:
// scalars
// dimensionedScalars
// other equations
// * * * * * * * * * * * * * * Scalar Equations * * * * * * * * * * * * * * //
// scalar
// You can use any variables on single scalars. If a field is used, equation
// reader will take the value at cell index 0 unless you tell it otherwise.
// You can mix types, provided you give a valid component. This equation is
// for a scalar, so it ignores dimensions.
sOut "sA + dsB + vC.x + tA.yz";
// dimensionedScalar
// This equation will be evaluated twice: once for the scalar value, and once
// for the dimensionSet. If the dimensions don't match, it will fail. You
// can subscribe a dimensionSet. This will disable dimension-checking, and
// force the outcome to the dimensions you give it - this is shown for dsfOut.
dsOut "sqrt(sqr(vB.x) + sqr(vB.y) + sqr(vB.z))";
// dimenionedScalarField
// You can use any variables on fields. If single variables appear, they are
// assumed uniform throughout the field. If GeometricFields appear, the
// boundary field is ignored. If another field is given, its size must match.
// Index checking is slow, so it is only available in FULLDEBUG mode. In this
// equation, we define a dimensionSet. This forces the outcome to the
// prescribed dimension.
dsfOut [0 0 0 0 0 0 0] "V / C.x * t";
// volScalarField
// This is for a GeometricField. GeometricField equations are very picky
// about their source data. They can either use single-element sources, such
// as scalars, tensors, etc., or other GeometricFields. The GeometricFields
// must have the same sizes.
volSfOut "sOut * vsfA + max(vtfA.yz, vtfA.zy)";
// * * * * * * * * * * * * * * Vector Equations * * * * * * * * * * * * * * //
// vector
// You can't define vector or tensor equations. equationReader only works
// with scalars. To get it to work, you have to evaluate them one component
// at a time. To use a constant built-in to OpenFOAM, append _ to the name.
//vOut.x "U.x / stabilise(C.x, VSMALL_) * t";
//vOut.y "U.y / stabilise(C.y, VSMALL_) * t";
//vOut.z "U.z / stabilise(C.z, VSMALL_) * t";
vOut.x [0 0 0 0 0 0 0] "R_.xx"; //"R_.xx * C.x / dsC";
vOut.y [0 0 0 0 0 0 0] "C.x"; //"R_.xx * C.x / dsC";
vOut.z [0 0 0 0 0 0 0] "R_.xx * C.x / dsC"; //"R_.xx * C.x / dsC";
// dimensionedVector
// To simplify an equation, you can create your own additional equations.
// equationReader will find and evaluate them on-the-fly when needed. This
// only works in dictionaries that are data sources to the equationReader.
dvOut.x "U.x / velocityMagnitude";
dvOut.y "U.y / velocityMagnitude";
dvOut.z "U.z / velocityMagnitude";
velocityMagnitude "sqrt(sqr(U.x) + sqr(U.y) + sqr(U.z))";
// dimensionedVectorField
// Any amount of white space is okay. Use a backslash to break a line. The
// equation can use +, -, *, /, and any functions I could find available to
// scalar or dimensioned scalar. Use the pow(a,b) instead of a^b. Use
// parentheses to any depth you wish.
dvfOut.x [0 0 0 0 0 0 0] "R_.xx * log ( C.x / dsC + 4 ) + 2 * pi_ / 360 \
- max( \
C.x, C.y) * dvOut.x";
dvfOut.y [0 0 0 0 0 0 0] " max \
(\
C.x, \
max \
( \
C.y, \
C.z \
) \
)";
dvfOut.z "1 + 2 * pow(3, pow(2, pow((2*3*4/(7*(8+4))), 3)))";
// You get the idea.
// volVectorField
volVfOut.x "1";
volVfOut.y "1";
volVfOut.z "1";
// * * * * * * * * * * * * * * Tensor Equations * * * * * * * * * * * * * * //
// tensor
tOut.xx "1";
tOut.xy "1";
tOut.xz "1";
tOut.yx "1";
tOut.yy "1";
tOut.yz "1";
tOut.zx "1";
tOut.zy "1";
tOut.zz "1";
// dimensionedTensor
dtOut.xx "1";
dtOut.xy "1";
dtOut.xz "1";
dtOut.yx "1";
dtOut.yy "1";
dtOut.yz "1";
dtOut.zx "1";
dtOut.zy "1";
dtOut.zz "1";
// dimensionedTensorField
dtfOut.xx "1";
dtfOut.xy "1";
dtfOut.xz "1";
dtfOut.yx "1";
dtfOut.yy "1";
dtfOut.yz "1";
dtfOut.zx "1";
dtfOut.zy "1";
dtfOut.zz "1";
// volTensorField
volTfOut.xx "1";
volTfOut.xy "1";
volTfOut.xz "1";
volTfOut.yx "1";
volTfOut.yy "1";
volTfOut.yz "1";
volTfOut.zx "1";
volTfOut.zy "1";
volTfOut.zz "1";
// ************************************************************************* //

View file

@ -0,0 +1,153 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(-20.6 0 -0.5)
(-20.6 3 -0.5)
(-20.6 12.7 -0.5)
(-20.6 25.4 -0.5)
(0 -25.4 -0.5)
(0 -5 -0.5)
(0 0 -0.5)
(0 3 -0.5)
(0 12.7 -0.5)
(0 25.4 -0.5)
(206 -25.4 -0.5)
(206 -8.5 -0.5)
(206 0 -0.5)
(206 6.5 -0.5)
(206 17 -0.5)
(206 25.4 -0.5)
(290 -16.6 -0.5)
(290 -6.3 -0.5)
(290 0 -0.5)
(290 4.5 -0.5)
(290 11 -0.5)
(290 16.6 -0.5)
(-20.6 0 0.5)
(-20.6 3 0.5)
(-20.6 12.7 0.5)
(-20.6 25.4 0.5)
(0 -25.4 0.5)
(0 -5 0.5)
(0 0 0.5)
(0 3 0.5)
(0 12.7 0.5)
(0 25.4 0.5)
(206 -25.4 0.5)
(206 -8.5 0.5)
(206 0 0.5)
(206 6.5 0.5)
(206 17 0.5)
(206 25.4 0.5)
(290 -16.6 0.5)
(290 -6.3 0.5)
(290 0 0.5)
(290 4.5 0.5)
(290 11 0.5)
(290 16.6 0.5)
);
blocks
(
hex (0 6 7 1 22 28 29 23) (18 7 1) simpleGrading (0.5 1.8 1)
hex (1 7 8 2 23 29 30 24) (18 10 1) simpleGrading (0.5 4 1)
hex (2 8 9 3 24 30 31 25) (18 13 1) simpleGrading (0.5 0.25 1)
hex (4 10 11 5 26 32 33 27) (180 18 1) simpleGrading (4 1 1)
hex (5 11 12 6 27 33 34 28) (180 9 1) edgeGrading (4 4 4 4 0.5 1 1 0.5 1 1 1 1)
hex (6 12 13 7 28 34 35 29) (180 7 1) edgeGrading (4 4 4 4 1.8 1 1 1.8 1 1 1 1)
hex (7 13 14 8 29 35 36 30) (180 10 1) edgeGrading (4 4 4 4 4 1 1 4 1 1 1 1)
hex (8 14 15 9 30 36 37 31) (180 13 1) simpleGrading (4 0.25 1)
hex (10 16 17 11 32 38 39 33) (25 18 1) simpleGrading (2.5 1 1)
hex (11 17 18 12 33 39 40 34) (25 9 1) simpleGrading (2.5 1 1)
hex (12 18 19 13 34 40 41 35) (25 7 1) simpleGrading (2.5 1 1)
hex (13 19 20 14 35 41 42 36) (25 10 1) simpleGrading (2.5 1 1)
hex (14 20 21 15 36 42 43 37) (25 13 1) simpleGrading (2.5 0.25 1)
);
edges
(
);
patches
(
patch inlet
(
(0 22 23 1)
(1 23 24 2)
(2 24 25 3)
)
patch outlet
(
(16 17 39 38)
(17 18 40 39)
(18 19 41 40)
(19 20 42 41)
(20 21 43 42)
)
wall upperWall
(
(3 25 31 9)
(9 31 37 15)
(15 37 43 21)
)
wall lowerWall
(
(0 6 28 22)
(6 5 27 28)
(5 4 26 27)
(4 10 32 26)
(10 16 38 32)
)
empty frontAndBack
(
(22 28 29 23)
(23 29 30 24)
(24 30 31 25)
(26 32 33 27)
(27 33 34 28)
(28 34 35 29)
(29 35 36 30)
(30 36 37 31)
(32 38 39 33)
(33 39 40 34)
(34 40 41 35)
(35 41 42 36)
(36 42 43 37)
(0 1 7 6)
(1 2 8 7)
(2 3 9 8)
(4 5 11 10)
(5 6 12 11)
(6 7 13 12)
(7 8 14 13)
(8 9 15 14)
(10 11 17 16)
(11 12 18 17)
(12 13 19 18)
(13 14 20 19)
(14 15 21 20)
)
);
mergePatchPairs
(
);
// ************************************************************************* //

View file

@ -1,9 +1,9 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5-dev | | \\ / O peration | Version: 2.1.x |
| \\ / A nd | Revision: exported | | \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | Web: http://www.OpenFOAM.org | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
FoamFile FoamFile
{ {
@ -15,25 +15,37 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
3 5
( (
movingWall inlet
{ {
type wall; type patch;
nFaces 20; nFaces 30;
startFace 760; startFace 24170;
} }
fixedWalls outlet
{
type patch;
nFaces 57;
startFace 24200;
}
upperWall
{ {
type wall; type wall;
nFaces 60; nFaces 223;
startFace 780; startFace 24257;
}
lowerWall
{
type wall;
nFaces 250;
startFace 24480;
} }
frontAndBack frontAndBack
{ {
type empty; type empty;
nFaces 800; nFaces 24450;
startFace 840; startFace 24730;
} }
) )

View file

@ -0,0 +1,37 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1e-05;
CrossPowerLawCoeffs
{
nu0 nu0 [0 2 -1 0 0 0 0] 1e-06;
nuInf nuInf [0 2 -1 0 0 0 0] 1e-06;
m m [0 0 1 0 0 0 0] 1;
n n [0 0 0 0 0 0 0] 1;
}
BirdCarreauCoeffs
{
nu0 nu0 [0 2 -1 0 0 0 0] 1e-06;
nuInf nuInf [0 2 -1 0 0 0 0] 1e-06;
k k [0 0 1 0 0 0 0] 0;
n n [0 0 0 0 0 0 0] 1;
}
// ************************************************************************* //

View file

@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.5 | | \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: http://www.OpenFOAM.org | | \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
FoamFile FoamFile
@ -14,7 +14,7 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application equationReaderDemo; application simpleFoam;
startFrom startTime; startFrom startTime;
@ -22,7 +22,7 @@ startTime 0;
stopAt endTime; stopAt endTime;
endTime 1; endTime 10;
deltaT 1; deltaT 1;
@ -34,7 +34,7 @@ purgeWrite 0;
writeFormat ascii; writeFormat ascii;
writePrecision 6; writePrecision 12;
writeCompression uncompressed; writeCompression uncompressed;

View file

@ -1,8 +1,8 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.5 | | \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: http://www.OpenFOAM.org | | \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
FoamFile FoamFile
@ -16,32 +16,44 @@ FoamFile
ddtSchemes ddtSchemes
{ {
default Euler; default steadyState;
} }
gradSchemes gradSchemes
{ {
default Gauss linear; default Gauss linear;
grad(p) Gauss linear; grad(p) Gauss linear;
grad(U) Gauss linear;
} }
divSchemes divSchemes
{ {
default none; default none;
div(phi,U) Gauss linear; div(phi,U) Gauss upwind;
div(phi,k) Gauss upwind;
div(phi,epsilon) Gauss upwind;
div(phi,R) Gauss upwind;
div(R) Gauss linear;
div(phi,nuTilda) Gauss upwind;
div((nuEff*dev(grad(U).T()))) Gauss linear; // backwards compatibility
div((nuEff*dev(T(grad(U))))) Gauss linear;
} }
laplacianSchemes laplacianSchemes
{ {
default none; default none;
laplacian(nu,U) Gauss linear corrected; laplacian(nuEff,U) Gauss linear corrected;
laplacian((1|A(U)),p) Gauss linear corrected; laplacian((1|A(U)),p) Gauss linear corrected;
laplacian(DkEff,k) Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected;
laplacian(DREff,R) Gauss linear corrected;
laplacian(DnuTildaEff,nuTilda) Gauss linear corrected;
} }
interpolationSchemes interpolationSchemes
{ {
default linear; default linear;
interpolate(HbyA) linear; interpolate(U) linear;
} }
snGradSchemes snGradSchemes

View file

@ -0,0 +1,78 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.01;
};
U
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0.1;
};
k
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0.1;
};
epsilon
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0.1;
};
R
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0.1;
};
nuTilda
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0.1;
};
}
SIMPLE
{
nNonOrthogonalCorrectors 0;
}
relaxationFactors
{
p 0.3;
U 0.7;
k 0.7;
epsilon 0.7;
R 0.7;
nuTilda 0.7;
}
// ************************************************************************* //

View file

@ -1,47 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// For demonstrating stand-alone operation
// readSa and readDSa equations can only use constants
standAloneScalar "1 + 1/3 * max(2 * sqrt(2), e_)";
standAloneDScalar standAloneDScalar [0 0 0 0 0 0 0] "sin(pi_ / 6) * 1 / 3^(1+2/3)";
// This equation is handled 'passively'
a "5 / 2^3";
// This one is handled 'actively'
b "cos(5 * theta + 8)";
// This one demonstrates variable dependence - a is another equation; DSa is a
// dimensionedScalar explicitly added to the equationReader; and Sb is a scalar
// added to the equationReader
c "a^2 + DSa - cbrt(Sb)";
// This one demonstrates on-the-fly equation parsing - it depends on equation
// e, but equation e is never explicitly read in equationTester.C.
d "2 * exp(inv(e)^2)";
// equationReader will automatically find and parse equation e when evaluating
// equation d.
//e "1 / (a + SMALL_)";
e 7;
// There shouldn't be any limits to the parenthesis depth, variable dependence,
// or number of sources from which the equation draws.
//f "beta";
f "DSa*(Sa+(DSb^Sc-(min(dictTwoA * dictThreeB, dictTwoB * dictThreeA)^DSb*cos(pi_/6)^arbitrary+7)))";

View file

@ -1,25 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictTwoA dictTwoA [0 0 0 0 0 0 0] 0.9;
dictTwoB 0.58;
arbitrary -1;
beta "gamma * kappa";
kappa 0.87;

View file

@ -1,34 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictThreeA "alpha + beta";
dictThreeB "dictThreeA + alpha";
// Uh oh - a duplicate variable. equationReader doesn't check for these.
// It's anyone's guess which one will be used...
arbitrary 1;
// This one will still be parsed, even though it is a single constant
alpha "7.0";
gamma "epsilon + whatever";
epsilon 0.001;
theta 0.665;
whatever 8.5;//elseYouWant [0 0 0 0 0 0 0] 8.5;

View file

@ -1,201 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5-dev |
| \\ / A nd | Revision: exported |
| \\/ M anipulation | Web: http://www.OpenFOAM.org |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class equationReader;
location "0.1";
object eqns;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
{
equations
{
Pa
{
Pa "twoa";
lastResult Pa [ 0 0 0 0 0 0 0 ] 1;
}
twoa
{
twoa "1";
lastResult twoa [ 0 0 0 0 0 0 0 ] 1;
}
Pb
{
Pb "sign(Sa)*cosh(twoa)";
lastResult Pb [ 0 0 0 0 0 0 0 ] 1.54308;
}
Pc
{
Pc "DStime * 1e2 / sinh(foura + fivea / sixa^(sevena-eighta/ninea^inv(tena)))";
lastResult Pc [ 0 0 0 0 0 0 0 ] 2.75721;
}
foura
{
foura "1";
lastResult foura [ 0 0 0 0 0 0 0 ] 1;
}
ninea
{
ninea "nineb";
lastResult ninea [ 0 0 0 0 0 0 0 ] 1;
}
Pd
{
Pd "Pa+Pb+Pc+Pe+Pf+Aa+Ab+Ac+Ad+Ae+Af";
lastResult Pd [ 0 0 0 0 0 0 0 ] 586.516;
}
Pe
{
Pe "Sa+(Sb*Sc^(Sd-Se/Sf^(Sg+Sh^Si)))";
lastResult Pe [ 0 0 0 0 0 0 0 ] 0.411732;
}
Pf
{
Pf "DSa+(DSb*DSc^(DSd-DSe/DSf^inv(DSg+DSh^DSi)))";
lastResult Pf [ 0 0 0 0 0 0 0 ] 1.66667;
}
Aa
{
Aa "twob/log10(twoc*10)+cosh(threef) * DStime/Sa+fiveg^max(sixf,sevenj)";
lastResult Aa [ 0 0 0 0 0 0 0 ] 3.54308;
outputVar Aa [ 0 0 0 0 0 0 0 ] 3.54308;
}
Ab
{
Ab "fourf*log(pos(sevend))*inv(stabilise(Af, SMALL_))";
lastResult Ab [ 0 0 0 0 0 0 0 ] 0;
outputVar Ab [ 0 0 0 0 0 0 0 ] 0;
}
Ac
{
Ac "DSo + DSm * erf(e_^0) + Ad*Ae+Ad";
lastResult Ac [ 0 0 0 0 0 0 0 ] 523.335;
outputVar Ac [ 0 0 0 0 0 0 0 ] 523.335;
}
Ad
{
Ad "Ae+Ae*Af+Pb*inv(stabilise(Af, SMALL_))^Pe+DStime^DSa*twog+sevenh";
lastResult Ad [ 0 0 0 0 0 0 0 ] 38.26;
outputVar Ad [ 0 0 0 0 0 0 0 ] 38.26;
}
Ae
{
Ae "threej + eightg / nineb*DSk - lgamma(ninej)";
lastResult Ae [ 0 0 0 0 0 0 0 ] 12;
outputVar Ae [ 0 0 0 0 0 0 0 ] 12;
}
Af
{
Af "fiveg^fivec+eighti";
lastResult Af [ 0 0 0 0 0 0 0 ] 2;
outputVar Af [ 0 0 0 0 0 0 0 ] 2;
}
twob
{
twob "1";
lastResult twob [ 0 0 0 0 0 0 0 ] 1;
}
twoc
{
twoc "1";
lastResult twoc [ 0 0 0 0 0 0 0 ] 1;
}
threef
{
threef "1";
lastResult threef [ 0 0 0 0 0 0 0 ] 1;
}
fourf
{
fourf "1";
lastResult fourf [ 0 0 0 0 0 0 0 ] 1;
}
twog
{
twog "1";
lastResult twog [ 0 0 0 0 0 0 0 ] 1;
}
threej
{
threej "1";
lastResult threej [ 0 0 0 0 0 0 0 ] 1;
}
nineb
{
nineb "ninec";
lastResult nineb [ 0 0 0 0 0 0 0 ] 1;
}
nu
{
nu [ 0 2 -1 0 0 0 0 ] "0.01 + nuAdd";
lastResult nu [ 0 2 -1 0 0 0 0 ] 0.01001;
outputVar nu [ 0 2 -1 0 0 0 0 ] 0.01001;
}
nuAdd
{
nuAdd [ 0 2 -1 0 0 0 0 ] "DStime / 10000";
lastResult nuAdd [ 0 2 -1 0 0 0 0 ] 1e-05;
}
ninec
{
ninec "nined";
lastResult ninec [ 0 0 0 0 0 0 0 ] 1;
}
nined
{
nined "ninee";
lastResult nined [ 0 0 0 0 0 0 0 ] 1;
}
ninee
{
ninee "ninef";
lastResult ninee [ 0 0 0 0 0 0 0 ] 1;
}
ninef
{
ninef "nineg";
lastResult ninef [ 0 0 0 0 0 0 0 ] 1;
}
nineg
{
nineg "nineh";
lastResult nineg [ 0 0 0 0 0 0 0 ] 1;
}
nineh
{
nineh "ninei";
lastResult nineh [ 0 0 0 0 0 0 0 ] 1;
}
ninei
{
ninei "ninej";
lastResult ninei [ 0 0 0 0 0 0 0 ] 1;
}
}
}
{
dataSources
{
dictSources 10 ( "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict1" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict2" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict3" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict4" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict5" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict6" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict7" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict8" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict9" "/home/dave/OpenFOAM/dave-1.5-dev/run/tutorials/equationReaderTester/testDict10" );
dictLookups 14 ( fivea sixa sevena eighta tena fiveg sixf sevenj sevend sevenh eightg ninej fivec eighti );
externalDScalars 16 ( DSa [ 0 0 0 0 0 0 0 ] 1 DSb [ 0 0 0 0 0 0 0 ] 2 DSc [ 0 0 0 0 0 0 0 ] 3 DSd [ 0 0 0 0 0 0 0 ] 4 DSe [ 0 0 0 0 0 0 0 ] 5 DSf [ 0 0 0 0 0 0 0 ] 6 DSg [ 0 0 0 0 0 0 0 ] 7 DSh [ 0 0 0 0 0 0 0 ] 8 DSi [ 0 0 0 0 0 0 0 ] 9 DSj [ 0 0 0 0 0 0 0 ] 10 DSk [ 0 0 0 0 0 0 0 ] 11 DSl [ 0 0 0 0 0 0 0 ] 12 DSm [ 0 0 0 0 0 0 0 ] 13 DSn [ 0 0 0 0 0 0 0 ] 14 DSo [ 0 0 0 0 0 0 0 ] 15 DStime [ 0 0 0 0 0 0 0 ] 0.1 );
externalScalars 12 ( 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.1 0.11 0.12 );
externalScalarNames 12 ( Sa Sb Sc Se Sd Sf Sg Sh Si Sj Sk Sl );
outputScalars 7 ( Aa [ 0 0 0 0 0 0 0 ] 3.54308 Ab [ 0 0 0 0 0 0 0 ] 0 Ac [ 0 0 0 0 0 0 0 ] 523.335 Ad [ 0 0 0 0 0 0 0 ] 38.26 Ae [ 0 0 0 0 0 0 0 ] 12 Af [ 0 0 0 0 0 0 0 ] 2 nu [ 0 2 -1 0 0 0 0 ] 0.01001 );
internalScalars 8 ( 100 10 1e-15 2.71828 0 0.01 1 10000 );
}
}
// ************************************************************************* //

View file

@ -1,63 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.1;
vertices
(
(0 0 0)
(1 0 0)
(1 1 0)
(0 1 0)
(0 0 0.1)
(1 0 0.1)
(1 1 0.1)
(0 1 0.1)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
);
edges
(
);
patches
(
wall movingWall
(
(3 7 6 2)
)
wall fixedWalls
(
(0 4 7 3)
(2 6 5 1)
(1 5 4 0)
)
empty frontAndBack
(
(0 3 2 1)
(4 5 6 7)
)
);
mergePatchPairs
(
);
// ************************************************************************* //

View file

@ -1,19 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu nu [0 2 -1 0 0 0 0] 0.01;
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -1,33 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application equationReaderTester;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime "2/2";
deltaT 0.01;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
// ************************************************************************* //

View file

@ -1,44 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0;
};
U
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0;
};
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //

View file

@ -1,49 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Scalar standalone test
saA "5^0";
saB "1+1";
saC "1+2";
saD "2^2";
saE "sqrt(25)";
saF "sin(pi_) + cbrt(6^2 * (3 + 2 + 1))";
// Dimensioned scalar standalone test
dsaA dsaA [0.1 0 0 0 0 0 0] "1e-5";
dsaB dsaB [0 0.1 0 0 0 0 0] "sqrt(400)";
dsaC dsaC [0 0 0.1 0 0 0 0] "(5+5*2)*2";
dsaD dsaD [0 0 0 0.1 0 0 0] "5*2^3";
dsaE dsaE [0 0 0 0 0.1 0 0] "log10(1e5)*2*(2^2+1)";
dsaF dsaF [0 0 0 0 0 0.1 0] "60";
// Passive equations
Pa "twoa";
//Pb "2* DSa + sign(Sa) * cosh(twoa^threea) / (Pc + Aa)";
Pb "sign(Sa)*cosh(twoa)";//^threea)";
Pc "DStime * 1e2 / sinh(foura + fivea / sixa^(sevena-eighta/ninea^inv(tena)))";
Pd "Pa+Pb+Pc+Pe+Pf+Aa+Ab+Ac+Ad+Ae+Af";
Pe "Sa+(Sb*Sc^(Sd-Se/Sf^(Sg+Sh^Si)))";
Pf "DSa+(DSb*DSc^(DSd-DSe/DSf^inv(DSg+DSh^DSi)))";
// Active equations
Aa "twob/log10(twoc*10)+cosh(threef) * DStime/Sa+fiveg^max(sixf,sevenj) * dummy";
Ab "fourf*log(pos(sevend))*inv(stabilise(Af, SMALL_))";
Ac "DSo + DSm * erf(e_^0) + Ad*Ae+Ad + pdimless";
Ad "Ae+Ae*Af+Pb*inv(stabilise(Af, SMALL_))^Pe+DStime^DSa*twog+sevenh";
Ae "threej + eightg / nineb*DSk - lgamma(ninej)";
Af "fiveg^fivec+eighti";
nu [0 2 -1 0 0 0 0] "0.01 + nuAdd";

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict10;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
tena 1;
tenb 1;
tenc 1;
tend 1;
tene 1;
tenf 1;
teng 1;
tenh 1;
teni 1;
tenj 1;

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict2;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
twoa "1";
twob "1";
twoc "1";
twod "1";
twoe "1";
twof "1";
twog "1";
twoh "1";
twoi "1";
twoj "1";

View file

@ -1,30 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict3;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
threea "1";
threeb "1";
threec "1";
threed "1";
threee "1";
threef "1";
threeg "1";
threeh "1";
threei "1";
threej "1";
nuAdd [0 2 -1 0 0 0 0] "DStime / 10000";
pdimless [0 0 0 0 0 0 0] "p";

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict4;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
foura "1";
fourb "1";
fourc "1";
fourd "1";
foure "1";
fourf "1";
fourg "1";
fourh "1";
fouri "1";
fourj "1";

Some files were not shown because too many files have changed in this diff Show more