Imported new equationReader
This commit is contained in:
parent
d36caeaa10
commit
031c1b07e3
71 changed files with 21645 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
equationReaderDemo.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/equationReaderDemo
|
|
@ -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
|
||||
|
|
@ -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);
|
|
@ -0,0 +1,9 @@
|
|||
// check convergence
|
||||
|
||||
if (maxResidual < convergenceCriterion)
|
||||
{
|
||||
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
|
||||
runTime.writeAndEnd();
|
||||
Info<< "latestTime = " << runTime.timeName() << endl;
|
||||
}
|
||||
|
|
@ -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)
|
||||
);
|
|
@ -0,0 +1,99 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
equationReaderDemo
|
||||
|
||||
Description
|
||||
simpleFOAM with an equationReader for demonstration purposes
|
||||
|
||||
Author
|
||||
David L. F. Gaden
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "singlePhaseTransportModel.H"
|
||||
#include "RASModel.H"
|
||||
#include "IOEquationReader.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
# include "createFields.H"
|
||||
# include "createEquationReader.H"
|
||||
# include "loadEquationData.H"
|
||||
# include "initializeSourceFields.H"
|
||||
# include "initContinuityErrs.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (runTime.loop())
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
dictionary simple = mesh.solutionDict().subDict("SIMPLE");
|
||||
|
||||
int nNonOrthCorr =
|
||||
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
|
||||
|
||||
bool momentumPredictor =
|
||||
simple.lookupOrDefault<Switch>("momentumPredictor", true);
|
||||
|
||||
# include "initConvergenceCheck.H"
|
||||
|
||||
p.storePrevIter();
|
||||
|
||||
// Pressure-velocity SIMPLE corrector
|
||||
{
|
||||
# include "UEqn.H"
|
||||
# include "pEqn.H"
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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);
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
// initialize values for convergence checks
|
||||
|
||||
scalar eqnResidual = 1, maxResidual = 0;
|
||||
scalar convergenceCriterion = 0;
|
||||
|
||||
simple.readIfPresent("convergence", convergenceCriterion);
|
||||
|
|
@ -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++;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
@ -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();
|
||||
|
73
src/equationReader/IOEquationReader/IOEquationReader.C
Normal file
73
src/equationReader/IOEquationReader/IOEquationReader.C
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "IOEquationReader.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(IOEquationReader, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOEquationReader::IOEquationReader
|
||||
(
|
||||
const IOobject& io,
|
||||
const bool showDataSourceInfo
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
showDataSourceInfo_(showDataSourceInfo)
|
||||
{
|
||||
if
|
||||
(
|
||||
io.readOpt() == IOobject::MUST_READ
|
||||
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
|
||||
)
|
||||
{
|
||||
readStream(typeName) >> *this;
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOEquationReader::~IOEquationReader()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::IOEquationReader::name() const
|
||||
{
|
||||
return regIOobject::name();
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
116
src/equationReader/IOEquationReader/IOEquationReader.H
Normal file
116
src/equationReader/IOEquationReader/IOEquationReader.H
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::IOEquationReader
|
||||
|
||||
Description
|
||||
IOEquationReader is an equationReader with IOobject functionality for easy
|
||||
input and output. Originally created so equations can be written out at
|
||||
every timestep if desired.
|
||||
|
||||
SourceFiles
|
||||
IOEquationReader.C
|
||||
IOEquationReaderIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOEquationReader_H
|
||||
#define IOEquationReader_H
|
||||
|
||||
#include "equationReader.H"
|
||||
#include "regIOobject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IOEquationReader Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IOEquationReader
|
||||
:
|
||||
public regIOobject,
|
||||
public equationReader
|
||||
{
|
||||
|
||||
// Private member data
|
||||
|
||||
//- Output flag - true = include data source info in output file
|
||||
bool showDataSourceInfo_;
|
||||
|
||||
public:
|
||||
|
||||
TypeName("equationReader");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given an IOobject. When true, showDataSourceInfo causes
|
||||
// IOequationReader to include the dataSource info in its output file,
|
||||
// even though it cannot read this data.
|
||||
IOEquationReader
|
||||
(
|
||||
const IOobject&,
|
||||
const bool showDataSourceInfo = false
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~IOEquationReader();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Access showDataSourceInfo flag
|
||||
inline bool& showDataSourceInfo()
|
||||
{
|
||||
return showDataSourceInfo_;
|
||||
}
|
||||
|
||||
//- Name function is needed to disambiguate those inherited
|
||||
// from regIOobject and dictionary
|
||||
const word& name() const;
|
||||
|
||||
//- ReadData function required for regIOobject read operation
|
||||
virtual bool readData(Istream&);
|
||||
|
||||
//- WriteData function required for regIOobject write operation
|
||||
virtual bool writeData(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
58
src/equationReader/IOEquationReader/IOEquationReaderIO.C
Normal file
58
src/equationReader/IOEquationReader/IOEquationReaderIO.C
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "IOEquationReader.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool IOEquationReader::readData(Istream& is)
|
||||
{
|
||||
is >> *this;
|
||||
return !is.bad();
|
||||
}
|
||||
|
||||
|
||||
bool IOEquationReader::writeData(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
if (showDataSourceInfo_)
|
||||
{
|
||||
dataSourceStatus(os);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
14
src/equationReader/Make/files
Normal file
14
src/equationReader/Make/files
Normal 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_USER_LIBBIN)/libequationReader
|
0
src/equationReader/Make/options
Normal file
0
src/equationReader/Make/options
Normal file
112
src/equationReader/equation/equation.C
Normal file
112
src/equationReader/equation/equation.C
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "equation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* const Foam::equation::typeName = "equation";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::equation::equation()
|
||||
:
|
||||
equationName_(word::null),
|
||||
ops_(0),
|
||||
rawText_(""),
|
||||
lastResult_(word::null, dimless, 0),
|
||||
overrideDimensions_(dimless),
|
||||
changeDimensions_(false)
|
||||
{}
|
||||
|
||||
|
||||
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)
|
||||
:
|
||||
equationName_(name),
|
||||
ops_(0),
|
||||
rawText_(""),
|
||||
lastResult_(word::null, dimless, 0),
|
||||
overrideDimensions_(dimless),
|
||||
changeDimensions_(false)
|
||||
{
|
||||
operator>>(is, *this);
|
||||
}
|
||||
|
||||
|
||||
Foam::equation::equation
|
||||
(
|
||||
const Foam::word& equationName,
|
||||
const Foam::string& rawText,
|
||||
const Foam::dimensionSet& overrideDimensions,
|
||||
const bool& changeDimensions
|
||||
)
|
||||
:
|
||||
equationName_(equationName),
|
||||
ops_(0),
|
||||
rawText_(rawText),
|
||||
lastResult_(equationName, dimless, 0),
|
||||
overrideDimensions_(overrideDimensions),
|
||||
changeDimensions_(changeDimensions)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::equation::~equation()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::equation::clear() const
|
||||
{
|
||||
ops_.clear();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::equation::operator=(Foam::equation& eqn)
|
||||
{
|
||||
equationName_ = eqn.equationName_;
|
||||
rawText_ = eqn.rawText_;
|
||||
// this->operations() = eqn.operations();
|
||||
overrideDimensions_.reset(eqn.overrideDimensions_);
|
||||
changeDimensions_ = eqn.changeDimensions_;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
236
src/equationReader/equation/equation.H
Normal file
236
src/equationReader/equation/equation.H
Normal file
|
@ -0,0 +1,236 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::equation
|
||||
|
||||
Description
|
||||
An equation, read from a dictionary. Effectively just a container class
|
||||
holding all data associated with an individual equation. Functions are
|
||||
implemented in masterDictionary.
|
||||
|
||||
SourceFiles
|
||||
equationI.H
|
||||
equation.C
|
||||
equationIO.C
|
||||
|
||||
Author
|
||||
David L. F. Gaden
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef equation_H
|
||||
#define equation_H
|
||||
|
||||
//#include "equationOperationList.H"
|
||||
//#include "dimensionedScalar.H"
|
||||
#include "scalarField.H"
|
||||
#include "dimensionSet.H"
|
||||
#include "equationOperation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class equation;
|
||||
|
||||
// Friend IOstream Operators
|
||||
|
||||
Istream& operator>>(Istream&, equation&);
|
||||
Ostream& operator<<(Ostream&, const equation&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class equation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class equation
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
word equationName_;
|
||||
|
||||
//- Operation list
|
||||
mutable PtrList<equationOperation> ops_;
|
||||
|
||||
//- raw text read from the dictionary
|
||||
mutable string rawText_;
|
||||
|
||||
//- Result of most recent evaluate() or update()
|
||||
mutable dimensionedScalar lastResult_;
|
||||
|
||||
//- Override dimensions - if read from a dictionary with dimensions,
|
||||
// eg: nu nu [0 2 -1 0 0 0 0] "sin(theta)";
|
||||
// the dimensionedScalar resulting from evaluate() is given these
|
||||
// dimensions
|
||||
mutable dimensionSet overrideDimensions_;
|
||||
|
||||
//- true if there is a dimension override
|
||||
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:
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
equation();
|
||||
|
||||
//- Construct copy
|
||||
equation(const equation&);
|
||||
|
||||
//- Construct from Istream with optional name
|
||||
equation(Istream& is, const word& name = word::null);
|
||||
|
||||
//- Construct from components
|
||||
equation
|
||||
(
|
||||
const word& equationName,
|
||||
const string& rawText,
|
||||
const dimensionSet& overrideDimensions = dimless,
|
||||
const bool& changeDimensions = false
|
||||
);
|
||||
|
||||
// Destructor
|
||||
~equation();
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Equation name
|
||||
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
|
||||
inline word& name();
|
||||
|
||||
//- Equation text
|
||||
inline const string& rawText() const;
|
||||
|
||||
//- Set equation text
|
||||
inline void setRawText(const string& newRawText) const;
|
||||
|
||||
//- Last result
|
||||
inline const dimensionedScalar& lastResult() const;
|
||||
|
||||
//- Set the last result
|
||||
inline void setLastResult
|
||||
(
|
||||
const dimensionedScalar& newResult
|
||||
) const;
|
||||
|
||||
//- Set the value of the last result
|
||||
inline void setLastResult(const word& newName) const;
|
||||
|
||||
//- Set the dimensions of the last result
|
||||
inline void setLastResult(const dimensionSet& newDims) const;
|
||||
|
||||
//- Set the value of the last result
|
||||
inline void setLastResult(const scalar& newScalar) const;
|
||||
|
||||
//- Dimension override
|
||||
inline const dimensionSet& overrideDimensions() const;
|
||||
|
||||
//- Set override dimensions
|
||||
inline void setOverrideDimensions
|
||||
(
|
||||
const dimensionSet& newDims
|
||||
) const;
|
||||
|
||||
//- changeDimensions flag
|
||||
inline const bool& changeDimensions() const;
|
||||
|
||||
//- Set the changeDimensions flag
|
||||
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
|
||||
|
||||
//- Copy only the header info - rawText, equationName,
|
||||
// dimensionOverride, and changeDimensions
|
||||
void operator=(equation&);
|
||||
|
||||
//- Access to ops_
|
||||
inline equationOperation& operator[](const label) const;
|
||||
|
||||
// Friend IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, equation&);
|
||||
friend Ostream& operator<<(Ostream&, const equation&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "equationI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
152
src/equationReader/equation/equationI.H
Normal file
152
src/equationReader/equation/equationI.H
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 word& equation::name() const
|
||||
{
|
||||
return 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_;
|
||||
}
|
||||
|
||||
|
||||
inline const string& equation::rawText() const
|
||||
{
|
||||
return rawText_;
|
||||
}
|
||||
|
||||
|
||||
inline void equation::setRawText(const string& newRawText) const
|
||||
{
|
||||
rawText_ = newRawText;
|
||||
}
|
||||
|
||||
|
||||
inline const dimensionedScalar& equation::lastResult() const
|
||||
{
|
||||
return lastResult_;
|
||||
}
|
||||
|
||||
|
||||
inline void equation::setLastResult(const word& newName) const
|
||||
{
|
||||
lastResult_.name() = newName;
|
||||
}
|
||||
|
||||
|
||||
inline void equation::setLastResult(const dimensionSet& newDims) const
|
||||
{
|
||||
lastResult_.dimensions().reset(newDims);
|
||||
}
|
||||
|
||||
|
||||
inline void equation::setLastResult(const scalar& newScalar) const
|
||||
{
|
||||
lastResult_.value() = newScalar;
|
||||
}
|
||||
|
||||
|
||||
inline const dimensionSet& equation::overrideDimensions() const
|
||||
{
|
||||
return overrideDimensions_;
|
||||
}
|
||||
|
||||
inline void equation::setOverrideDimensions
|
||||
(
|
||||
const dimensionSet& newDims
|
||||
) const
|
||||
{
|
||||
overrideDimensions_.reset(newDims);
|
||||
}
|
||||
|
||||
|
||||
inline const bool& equation::changeDimensions() const
|
||||
{
|
||||
return changeDimensions_;
|
||||
}
|
||||
|
||||
|
||||
inline void equation::setChangeDimensions(bool newFlag) const
|
||||
{
|
||||
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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
108
src/equationReader/equation/equationIO.C
Normal file
108
src/equationReader/equation/equationIO.C
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "equation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Friend IOstream Operators * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, equation& I)
|
||||
{
|
||||
// Acceptable istream formats:
|
||||
// scalar;
|
||||
// string;
|
||||
// [dimensionSet] scalar;
|
||||
// [dimensionSet] string;
|
||||
// name [dimensionSet] scalar;
|
||||
// name [dimensionSet] string;
|
||||
|
||||
if (I.equationName_ == word::null)
|
||||
{
|
||||
I.equationName_ = "fromIstream";
|
||||
}
|
||||
token t(is);
|
||||
if (t.isString())
|
||||
{
|
||||
I.rawText_ = t.stringToken();
|
||||
}
|
||||
else if (t.isNumber())
|
||||
{
|
||||
I.rawText_ = string(name(t.number()));
|
||||
}
|
||||
else if (t.isPunctuation())
|
||||
{
|
||||
is.putBack(t);
|
||||
I.changeDimensions_ = true;
|
||||
I.overrideDimensions_.reset(dimensionSet(is));
|
||||
token t2(is);
|
||||
if (t2.isString())
|
||||
{
|
||||
is.putBack(t2);
|
||||
I.rawText_ = string(is);
|
||||
}
|
||||
else // number
|
||||
{
|
||||
I.rawText_ = string(name(t.number()));
|
||||
}
|
||||
}
|
||||
else if (t.isWord())
|
||||
{
|
||||
word garbage(t.wordToken());
|
||||
I.changeDimensions_ = true;
|
||||
I.overrideDimensions_.reset(dimensionSet(is));
|
||||
token t2(is);
|
||||
if (t2.isString())
|
||||
{
|
||||
is.putBack(t2);
|
||||
I.rawText_ = string(is);
|
||||
}
|
||||
else // number
|
||||
{
|
||||
I.rawText_ = string(name(t.number()));
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const equation& I)
|
||||
{
|
||||
if (I.changeDimensions_)
|
||||
{
|
||||
os << I.overrideDimensions_ << token::TAB
|
||||
<< I.rawText_;
|
||||
}
|
||||
else
|
||||
{
|
||||
os << I.rawText_;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
827
src/equationReader/equationOperation/equationOperation.C
Normal file
827
src/equationReader/equationOperation/equationOperation.C
Normal file
|
@ -0,0 +1,827 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "dimensionedScalar.H"
|
||||
#include "equationReader.H"
|
||||
#include "equationOperation.H"
|
||||
//#include "equationOperationList.H"
|
||||
|
||||
class dimensionedScalar;
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* const Foam::equationOperation::typeName = "equationOperation";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
(
|
||||
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,
|
||||
void (Foam::equationReader::*opScalarFieldFunction)
|
||||
(
|
||||
const equationReader *,
|
||||
const label,
|
||||
const label,
|
||||
const label,
|
||||
label&,
|
||||
scalarField&,
|
||||
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
|
||||
)
|
||||
:
|
||||
source_(source),
|
||||
sourceIndex_(sourceIndex),
|
||||
componentIndex_(componentIndex),
|
||||
dictLookupIndex_(dictLookupIndex),
|
||||
operation_(operation),
|
||||
getSourceScalarFieldFunction_(getSourceScalarFieldFunction),
|
||||
opScalarFieldFunction_(opScalarFieldFunction),
|
||||
getSourceScalarFunction_(getSourceScalarFunction),
|
||||
opScalarFunction_(opScalarFunction),
|
||||
getSourceDimsFunction_(getSourceDimsFunction),
|
||||
opDimsFunction_(opDimsFunction)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::equationOperation::~equationOperation()
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * Member functions * * * * * * * * * * * * * * //
|
||||
Foam::equationOperation::operationType
|
||||
Foam::equationOperation::findOp(const Foam::word& opName)
|
||||
{
|
||||
if (opName == "retrieve")
|
||||
{
|
||||
return otretrieve;
|
||||
}
|
||||
else if (opName == "store")
|
||||
{
|
||||
return otstore;
|
||||
}
|
||||
else if (opName == "plus")
|
||||
{
|
||||
return otplus;
|
||||
}
|
||||
else if (opName == "minus")
|
||||
{
|
||||
return otminus;
|
||||
}
|
||||
else if (opName == "times")
|
||||
{
|
||||
return ottimes;
|
||||
}
|
||||
else if (opName == "divide")
|
||||
{
|
||||
return otdivide;
|
||||
}
|
||||
else if (opName == "pow")
|
||||
{
|
||||
return otpow;
|
||||
}
|
||||
else if (opName == "sign")
|
||||
{
|
||||
return otsign;
|
||||
}
|
||||
else if (opName == "pos")
|
||||
{
|
||||
return otpos;
|
||||
}
|
||||
else if (opName == "neg")
|
||||
{
|
||||
return otneg;
|
||||
}
|
||||
else if (opName == "mag")
|
||||
{
|
||||
return otmag;
|
||||
}
|
||||
else if (opName == "limit")
|
||||
{
|
||||
return otlimit;
|
||||
}
|
||||
else if (opName == "minMod")
|
||||
{
|
||||
return otminMod;
|
||||
}
|
||||
else if (opName == "sqrtSumSqr")
|
||||
{
|
||||
return otsqrtSumSqr;
|
||||
}
|
||||
else if (opName == "sqr")
|
||||
{
|
||||
return otsqr;
|
||||
}
|
||||
else if (opName == "pow3")
|
||||
{
|
||||
return otpow3;
|
||||
}
|
||||
else if (opName == "pow4")
|
||||
{
|
||||
return otpow4;
|
||||
}
|
||||
else if (opName == "pow5")
|
||||
{
|
||||
return otpow5;
|
||||
}
|
||||
else if (opName == "pow6")
|
||||
{
|
||||
return otpow6;
|
||||
}
|
||||
else if (opName == "inv")
|
||||
{
|
||||
return otinv;
|
||||
}
|
||||
else if (opName == "sqrt")
|
||||
{
|
||||
return otsqrt;
|
||||
}
|
||||
else if (opName == "cbrt")
|
||||
{
|
||||
return otcbrt;
|
||||
}
|
||||
else if (opName == "hypot")
|
||||
{
|
||||
return othypot;
|
||||
}
|
||||
else if (opName == "exp")
|
||||
{
|
||||
return otexp;
|
||||
}
|
||||
else if (opName == "log")
|
||||
{
|
||||
return otlog;
|
||||
}
|
||||
else if (opName == "log10")
|
||||
{
|
||||
return otlog10;
|
||||
}
|
||||
else if (opName == "sin")
|
||||
{
|
||||
return otsin;
|
||||
}
|
||||
else if (opName == "cos")
|
||||
{
|
||||
return otcos;
|
||||
}
|
||||
else if (opName == "tan")
|
||||
{
|
||||
return ottan;
|
||||
}
|
||||
else if (opName == "asin")
|
||||
{
|
||||
return otasin;
|
||||
}
|
||||
else if (opName == "acos")
|
||||
{
|
||||
return otacos;
|
||||
}
|
||||
else if (opName == "atan")
|
||||
{
|
||||
return otatan;
|
||||
}
|
||||
else if (opName == "atan2")
|
||||
{
|
||||
return otatan2;
|
||||
}
|
||||
else if (opName == "sinh")
|
||||
{
|
||||
return otsinh;
|
||||
}
|
||||
else if (opName == "cosh")
|
||||
{
|
||||
return otcosh;
|
||||
}
|
||||
else if (opName == "tanh")
|
||||
{
|
||||
return ottanh;
|
||||
}
|
||||
else if (opName == "asinh")
|
||||
{
|
||||
return otasinh;
|
||||
}
|
||||
else if (opName == "acosh")
|
||||
{
|
||||
return otacosh;
|
||||
}
|
||||
else if (opName == "atanh")
|
||||
{
|
||||
return otatanh;
|
||||
}
|
||||
else if (opName == "erf")
|
||||
{
|
||||
return oterf;
|
||||
}
|
||||
else if (opName == "erfc")
|
||||
{
|
||||
return oterfc;
|
||||
}
|
||||
else if (opName == "lgamma")
|
||||
{
|
||||
return otlgamma;
|
||||
}
|
||||
else if (opName == "j0")
|
||||
{
|
||||
return otj0;
|
||||
}
|
||||
else if (opName == "j1")
|
||||
{
|
||||
return otj1;
|
||||
}
|
||||
else if (opName == "jn")
|
||||
{
|
||||
return otjn;
|
||||
}
|
||||
else if (opName == "y0")
|
||||
{
|
||||
return oty0;
|
||||
}
|
||||
else if (opName == "y1")
|
||||
{
|
||||
return oty1;
|
||||
}
|
||||
else if (opName == "yn")
|
||||
{
|
||||
return otyn;
|
||||
}
|
||||
else if (opName == "max")
|
||||
{
|
||||
return otmax;
|
||||
}
|
||||
else if (opName == "min")
|
||||
{
|
||||
return otmin;
|
||||
}
|
||||
else if (opName == "stabilise")
|
||||
{
|
||||
return otstabilise;
|
||||
}
|
||||
else
|
||||
{
|
||||
return otnone;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::equationOperation::opName
|
||||
(
|
||||
const Foam::equationOperation::operationType& op
|
||||
)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case otnone:
|
||||
return "none";
|
||||
case otretrieve:
|
||||
return "retrieve";
|
||||
case otstore:
|
||||
return "store";
|
||||
case otplus:
|
||||
return "plus";
|
||||
case otminus:
|
||||
return "minus";
|
||||
case ottimes:
|
||||
return "times";
|
||||
case otdivide:
|
||||
return "divide";
|
||||
case otpow:
|
||||
return "pow";
|
||||
case otsign:
|
||||
return "sign";
|
||||
case otpos:
|
||||
return "pos";
|
||||
case otneg:
|
||||
return "neg";
|
||||
case otmag:
|
||||
return "mag";
|
||||
case otlimit:
|
||||
return "limit";
|
||||
case otminMod:
|
||||
return "minMod";
|
||||
case otsqrtSumSqr:
|
||||
return "sqrtSumSqr";
|
||||
case otsqr:
|
||||
return "sqr";
|
||||
case otpow3:
|
||||
return "pow3";
|
||||
case otpow4:
|
||||
return "pow4";
|
||||
case otpow5:
|
||||
return "pow5";
|
||||
case otpow6:
|
||||
return "pow6";
|
||||
case otinv:
|
||||
return "inv";
|
||||
case otsqrt:
|
||||
return "sqrt";
|
||||
case otcbrt:
|
||||
return "cbrt";
|
||||
case othypot:
|
||||
return "hypot";
|
||||
case otexp:
|
||||
return "exp";
|
||||
case otlog:
|
||||
return "log";
|
||||
case otlog10:
|
||||
return "log10";
|
||||
case otsin:
|
||||
return "sin";
|
||||
case otcos:
|
||||
return "cos";
|
||||
case ottan:
|
||||
return "tan";
|
||||
case otasin:
|
||||
return "asin";
|
||||
case otacos:
|
||||
return "acos";
|
||||
case otatan:
|
||||
return "atan";
|
||||
case otatan2:
|
||||
return "atan2";
|
||||
case otsinh:
|
||||
return "sinh";
|
||||
case otcosh:
|
||||
return "cosh";
|
||||
case ottanh:
|
||||
return "tanh";
|
||||
case otasinh:
|
||||
return "asinh";
|
||||
case otacosh:
|
||||
return "acosh";
|
||||
case otatanh:
|
||||
return "atanh";
|
||||
case oterf:
|
||||
return "erf";
|
||||
case oterfc:
|
||||
return "erfc";
|
||||
case otlgamma:
|
||||
return "lgamma";
|
||||
case otj0:
|
||||
return "j0";
|
||||
case otj1:
|
||||
return "j1";
|
||||
case otjn:
|
||||
return "jn";
|
||||
case oty0:
|
||||
return "y0";
|
||||
case oty1:
|
||||
return "y1";
|
||||
case otyn:
|
||||
return "yn";
|
||||
case otmax:
|
||||
return "max";
|
||||
case otmin:
|
||||
return "min";
|
||||
case otstabilise:
|
||||
return "stabilise";
|
||||
default:
|
||||
return "unlisted";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::equationOperation::sourceName
|
||||
(
|
||||
const Foam::equationOperation::sourceTypeEnum& st
|
||||
)
|
||||
{
|
||||
switch (st)
|
||||
{
|
||||
case stnone:
|
||||
return "none";
|
||||
case ststorage:
|
||||
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:
|
||||
return "unlisted";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::equationOperation::assignSourceScalarFieldFunction
|
||||
(
|
||||
const scalarField& (Foam::equationReader::*getSourceScalarFieldFunction)
|
||||
(
|
||||
const equationReader *,
|
||||
const label,
|
||||
const label,
|
||||
const label,
|
||||
const label
|
||||
) const
|
||||
) const
|
||||
{
|
||||
getSourceScalarFieldFunction_ = getSourceScalarFieldFunction;
|
||||
}
|
||||
|
||||
|
||||
void Foam::equationOperation::assignOpScalarFieldFunction
|
||||
(
|
||||
void (Foam::equationReader::*opScalarFieldFunction)
|
||||
(
|
||||
const equationReader *,
|
||||
const label,
|
||||
const label,
|
||||
const label,
|
||||
label&,
|
||||
scalarField&,
|
||||
const scalarField&
|
||||
) const
|
||||
) const
|
||||
{
|
||||
opScalarFieldFunction_ = opScalarFieldFunction;
|
||||
}
|
||||
|
||||
|
||||
void Foam::equationOperation::assignSourceScalarFunction
|
||||
(
|
||||
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 equationOperationIndex,
|
||||
const label maxStoreIndex,
|
||||
const label storageOffset
|
||||
) const
|
||||
{
|
||||
return (eqnReader->*getSourceScalarFieldFunction_)
|
||||
(
|
||||
eqnReader,
|
||||
equationIndex,
|
||||
equationOperationIndex,
|
||||
maxStoreIndex,
|
||||
storageOffset
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::equationOperation::opScalarFieldFunction
|
||||
(
|
||||
const equationReader * eqnReader,
|
||||
const label index,
|
||||
const label i,
|
||||
const label storageOffset,
|
||||
label& storageIndex,
|
||||
scalarField& x,
|
||||
const scalarField& source
|
||||
) const
|
||||
{
|
||||
(eqnReader->*opScalarFieldFunction_)
|
||||
(
|
||||
eqnReader,
|
||||
index,
|
||||
i,
|
||||
storageOffset,
|
||||
storageIndex,
|
||||
x,
|
||||
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 * * * * * * * * * * * * * //
|
||||
|
||||
int Foam::operator==(const equationOperation& I1, const equationOperation& I2)
|
||||
{
|
||||
return
|
||||
(
|
||||
I1.sourceType() == I2.sourceType()
|
||||
&& I1.sourceIndex() == I2.sourceIndex()
|
||||
&& I1.dictLookupIndex() == I2.dictLookupIndex()
|
||||
&& I1.operation() == I2.operation()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
int Foam::operator!=(const equationOperation& I1, const equationOperation& I2)
|
||||
{
|
||||
// Invert the '==' operator ('0'='false')
|
||||
return I1 == I2 ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * 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 * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, equationOperation& I)
|
||||
{
|
||||
label st(I.source_);
|
||||
label op(I.operation_);
|
||||
|
||||
is >> st >> I.sourceIndex_ >> I.dictLookupIndex_ >> op;
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const equationOperation& I)
|
||||
{
|
||||
label st(I.source_);
|
||||
label op(I.operation_);
|
||||
|
||||
return os << nl << "/* sourceType: */\t" << st
|
||||
<< " /* "
|
||||
<< equationOperation::sourceName(I.source_)
|
||||
<< " */" << nl
|
||||
<< "/* sourceIndex: */\t" << I.sourceIndex_ << nl
|
||||
<< "/* componentIndex:*/\t" << I.componentIndex_ << nl
|
||||
<< "/* dictIndex */\t" << I. dictLookupIndex_ << nl
|
||||
<< "/* operation: */\t" << op
|
||||
<< " /* "
|
||||
<< equationOperation::opName(I.operation_)
|
||||
<< " */" << nl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
558
src/equationReader/equationOperation/equationOperation.H
Normal file
558
src/equationReader/equationOperation/equationOperation.H
Normal 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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
97
src/equationReader/equationOperation/equationOperationI.H
Normal file
97
src/equationReader/equationOperation/equationOperationI.H
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 equationOperation::sourceTypeEnum&
|
||||
equationOperation::sourceType() const
|
||||
{
|
||||
return source_;
|
||||
}
|
||||
|
||||
|
||||
inline equationOperation::sourceTypeEnum&
|
||||
equationOperation::sourceType()
|
||||
{
|
||||
return source_;
|
||||
}
|
||||
|
||||
|
||||
inline const label& equationOperation::sourceIndex() const
|
||||
{
|
||||
return sourceIndex_;
|
||||
}
|
||||
|
||||
|
||||
inline label& equationOperation::sourceIndex()
|
||||
{
|
||||
return sourceIndex_;
|
||||
}
|
||||
|
||||
|
||||
inline const label& equationOperation::componentIndex() const
|
||||
{
|
||||
return componentIndex_;
|
||||
}
|
||||
|
||||
|
||||
inline label& equationOperation::componentIndex()
|
||||
{
|
||||
return componentIndex_;
|
||||
}
|
||||
|
||||
|
||||
inline const label& equationOperation::dictLookupIndex() const
|
||||
{
|
||||
return dictLookupIndex_;
|
||||
}
|
||||
|
||||
|
||||
inline label& equationOperation::dictLookupIndex()
|
||||
{
|
||||
return dictLookupIndex_;
|
||||
}
|
||||
|
||||
|
||||
inline const equationOperation::operationType&
|
||||
equationOperation::operation() const
|
||||
{
|
||||
return operation_;
|
||||
}
|
||||
|
||||
|
||||
inline equationOperation::operationType& equationOperation::operation()
|
||||
{
|
||||
return operation_;
|
||||
}
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
1646
src/equationReader/equationReader/equationReader.C
Normal file
1646
src/equationReader/equationReader/equationReader.C
Normal file
File diff suppressed because it is too large
Load diff
910
src/equationReader/equationReader/equationReader.H
Normal file
910
src/equationReader/equationReader/equationReader.H
Normal 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
552
src/equationReader/equationReader/equationReaderCreateMap.C
Normal file
552
src/equationReader/equationReader/equationReaderCreateMap.C
Normal file
|
@ -0,0 +1,552 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::equationReader::createMap
|
||||
(
|
||||
const label index,
|
||||
const tokenList& tl,
|
||||
PtrList<equationOperation>& map,
|
||||
labelList& opLvl,
|
||||
labelList& pl
|
||||
) const
|
||||
{
|
||||
// equation * eqn(&this->operator[](index));
|
||||
|
||||
// current parenthesis level - note, a negative parenthesis value indicates
|
||||
// that this is the root level of a function, and therefore ',' is allowed
|
||||
label p(0);
|
||||
|
||||
forAll(tl, i)
|
||||
{
|
||||
if (tl[i].isNumber())
|
||||
{
|
||||
// Internal constant. Save to internalScalars and record source
|
||||
opLvl[i] = 0;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stinternalScalar,
|
||||
addInternalScalar(tl[i].number()) + 1,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otnone
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (tl[i].isWord())
|
||||
{
|
||||
// could be a variable name, function or mathematical constant
|
||||
// - check for function first - function is [word][punctuation '(']
|
||||
if
|
||||
(
|
||||
(i < (tl.size() - 1))
|
||||
&& (tl[i + 1].isPunctuation())
|
||||
&& (tl[i + 1].pToken() == token::BEGIN_LIST)
|
||||
)
|
||||
{
|
||||
// Function detected; function brackets are negative
|
||||
opLvl[i] = 4;
|
||||
p = -mag(p) - 1;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::findOp(tl[i].wordToken())
|
||||
)
|
||||
);
|
||||
|
||||
if (map[i].operation() == equationOperation::otnone)
|
||||
{
|
||||
OStringStream description;
|
||||
description << tl[i].wordToken() << " is not a recognized "
|
||||
<< "function.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
i,
|
||||
i,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
|
||||
// Set next token as well (function opening parenthesis)
|
||||
i++;
|
||||
opLvl[i] = 4;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otnone
|
||||
)
|
||||
);
|
||||
}
|
||||
else if
|
||||
(
|
||||
(tl[i].wordToken() == "e_")
|
||||
|| (tl[i].wordToken() == "pi_")
|
||||
|| (tl[i].wordToken() == "twoPi_")
|
||||
|| (tl[i].wordToken() == "piByTwo_")
|
||||
|| (tl[i].wordToken() == "GREAT_")
|
||||
|| (tl[i].wordToken() == "VGREAT_")
|
||||
|| (tl[i].wordToken() == "ROOTVGREAT_")
|
||||
|| (tl[i].wordToken() == "SMALL_")
|
||||
|| (tl[i].wordToken() == "VSMALL_")
|
||||
|| (tl[i].wordToken() == "ROOTVSMALL_")
|
||||
)
|
||||
{
|
||||
// Mathematical constant
|
||||
if
|
||||
(
|
||||
findSource(tl[i].wordToken()).sourceType()
|
||||
!= equationOperation::stnone
|
||||
)
|
||||
{
|
||||
// Found a possible conflicting variable name - warn
|
||||
WarningIn("equationReader::createMap")
|
||||
<< "Equation for " << operator[](index).name()
|
||||
<< ", given by:" << token::NL << token::TAB
|
||||
<< operator[](index).rawText() << token:: NL << "refers "
|
||||
<< "to '" << tl[i].wordToken() << "'. Although "
|
||||
<< "variable " << tl[i].wordToken() << "was found in "
|
||||
<< "the data sources, " << tl[i].wordToken() << " is a"
|
||||
<< " mathematical constant. The mathematical constant "
|
||||
<< "will be used." << endl;
|
||||
}
|
||||
|
||||
opLvl[i] = 0;
|
||||
pl[i] = p;
|
||||
label internalIndex(0);
|
||||
if (tl[i].wordToken() == "e_")
|
||||
{
|
||||
// MathConstantScope is a hack that allows equationReader
|
||||
// to work in multiple versions of OpenFOAM. See
|
||||
// include/versionSpecific.H
|
||||
internalIndex =
|
||||
addInternalScalar(MathConstantScope::e) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "pi_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(MathConstantScope::pi) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "twoPi_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(MathConstantScope::twoPi) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "piByTwo_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(MathConstantScope::piByTwo) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "GREAT_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(GREAT) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "VGREAT_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(VGREAT) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "ROOTVGREAT_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(ROOTVGREAT) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "SMALL_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(SMALL) + 1;
|
||||
}
|
||||
else if (tl[i].wordToken() == "VSMALL_")
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(VSMALL) + 1;
|
||||
}
|
||||
else // tl[i].wordToken() == "ROOTVSMALL_"
|
||||
{
|
||||
internalIndex =
|
||||
addInternalScalar(ROOTVSMALL) + 1;
|
||||
}
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stinternalScalar,
|
||||
internalIndex,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otnone
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Variable name
|
||||
opLvl[i] = 0;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation(findSource(tl[i].wordToken()))
|
||||
);
|
||||
if (map[i].sourceIndex() == 0)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Variable name " << tl[i].wordToken()
|
||||
<< " not found in any available sources.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
i,
|
||||
i,
|
||||
"equationReader::parse",
|
||||
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())
|
||||
{
|
||||
switch (tl[i].pToken())
|
||||
{
|
||||
case token::BEGIN_LIST: // (
|
||||
opLvl[i] = 4;
|
||||
p = mag(p) + 1;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otnone
|
||||
)
|
||||
);
|
||||
break;
|
||||
case token::END_LIST: // )
|
||||
{
|
||||
opLvl[i] = -4;
|
||||
pl[i] = p;
|
||||
p = mag(p) - 1;
|
||||
if (p < 0)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Too many ')'.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
i,
|
||||
i,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Look for preceding parenthesis change - was it negative?
|
||||
for (label j(i - 1); j >= 0; j--)
|
||||
{
|
||||
if (mag(pl[j]) == p)
|
||||
{
|
||||
if (pl[j] < 0)
|
||||
{
|
||||
p = -p;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otnone
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
case token::COMMA: // ,
|
||||
// , is only accepted in a function level parenthesis
|
||||
if (p < 0)
|
||||
{
|
||||
opLvl[i] = 5;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otnone
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
OStringStream description;
|
||||
description << "The comma, ',' does not make sense "
|
||||
<< "here. Only permitted in the root parenthesis "
|
||||
<< "level of a function.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
i,
|
||||
i,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
break;
|
||||
case token::ADD: // +
|
||||
opLvl[i] = 1;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otplus
|
||||
)
|
||||
);
|
||||
break;
|
||||
case token::SUBTRACT: // -
|
||||
opLvl[i] = 1;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otminus
|
||||
)
|
||||
);
|
||||
break;
|
||||
case token::MULTIPLY: // *
|
||||
opLvl[i] = 2;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::ottimes
|
||||
)
|
||||
);
|
||||
break;
|
||||
case token::DIVIDE: // /
|
||||
opLvl[i] = 2;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otdivide
|
||||
)
|
||||
);
|
||||
break;
|
||||
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;
|
||||
pl[i] = p;
|
||||
map.set
|
||||
(
|
||||
i,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otpow
|
||||
)
|
||||
);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Punctuation character '" << tl[i].pToken()
|
||||
<< "' is prohibitted.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
i,
|
||||
i,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
break;
|
||||
}
|
||||
} // end punctuation switch
|
||||
} // end if punctuation
|
||||
else
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Unrecognized token: [" << tl[i] << "].";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
i,
|
||||
i,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
} // mapping loop
|
||||
|
||||
if (p)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Parentheses do not match. Expecting " << mag(p)
|
||||
<< " additional ')'s.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
0,
|
||||
tl.size() - 1,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
|
||||
// Assign negatives (distinguish these from subtraction)
|
||||
// The difference is characterized by the preceding character:
|
||||
// -preceeded by an operator = negative '+' '-' '*' '/' '^'
|
||||
// -preceeded by an open bracket = negative '('
|
||||
// -preceeded by a comma = negative ','
|
||||
// -preceeded by a variable = subtract 'word' or 'number'
|
||||
// -preceeded by a close bracket = subtract ')'
|
||||
// Negatives are identified by a negative dictLookupIndex
|
||||
|
||||
if (map[0].operation() == equationOperation::otminus)
|
||||
{
|
||||
opLvl[0] = 2;
|
||||
map[0].dictLookupIndex() = -1;
|
||||
}
|
||||
|
||||
for (label i(1); i < map.size(); i++)
|
||||
{
|
||||
if (map[i].operation() == equationOperation::otminus)
|
||||
{
|
||||
if (opLvl[i-1] > 0)
|
||||
{
|
||||
opLvl[i] = 2;
|
||||
map[i].dictLookupIndex() = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
270
src/equationReader/equationReader/equationReaderDebugP.C
Normal file
270
src/equationReader/equationReader/equationReaderDebugP.C
Normal 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
214
src/equationReader/equationReader/equationReaderDebugP.H
Normal file
214
src/equationReader/equationReader/equationReaderDebugP.H
Normal 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;
|
||||
|
1963
src/equationReader/equationReader/equationReaderEvalDimsP.C
Normal file
1963
src/equationReader/equationReader/equationReaderEvalDimsP.C
Normal file
File diff suppressed because it is too large
Load diff
954
src/equationReader/equationReader/equationReaderEvalDimsP.H
Normal file
954
src/equationReader/equationReader/equationReaderEvalDimsP.H
Normal 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;
|
|
@ -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
|
||||
)
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
@ -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;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
820
src/equationReader/equationReader/equationReaderEvalScalarP.C
Normal file
820
src/equationReader/equationReader/equationReaderEvalScalarP.C
Normal 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);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
575
src/equationReader/equationReader/equationReaderEvalScalarP.H
Normal file
575
src/equationReader/equationReader/equationReaderEvalScalarP.H
Normal 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;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
688
src/equationReader/equationReader/equationReaderEvaluate.C
Normal file
688
src/equationReader/equationReader/equationReaderEvaluate.C
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
503
src/equationReader/equationReader/equationReaderGetSourceDimsP.C
Normal file
503
src/equationReader/equationReader/equationReaderGetSourceDimsP.C
Normal 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);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
181
src/equationReader/equationReader/equationReaderGetSourceDimsP.H
Normal file
181
src/equationReader/equationReader/equationReaderGetSourceDimsP.H
Normal 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;
|
||||
|
|
@ -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_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
@ -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;
|
||||
|
178
src/equationReader/equationReader/equationReaderI.H
Normal file
178
src/equationReader/equationReader/equationReaderI.H
Normal 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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
100
src/equationReader/equationReader/equationReaderIO.C
Normal file
100
src/equationReader/equationReader/equationReaderIO.C
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "equation.H"
|
||||
#include "equationOperation.H"
|
||||
#include "equationReader.H"
|
||||
#include "fileNameList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::equationReader::dataSourceStatus(Ostream& os) const
|
||||
{
|
||||
dictionary dict;
|
||||
dict.set("activeSources", activeSourceNames_);
|
||||
fileNameList dictPaths(dictSources_.size());
|
||||
forAll(dictSources_, i)
|
||||
{
|
||||
dictPaths[i] = dictSources_[i].name();
|
||||
}
|
||||
dict.set("dictSources", dictPaths);
|
||||
dict.set("dictLookups", dictLookups_);
|
||||
dict.set("scalarSources", scalarSources_.outputDictionary());
|
||||
dict.set("vectorSources", vectorSources_.outputDictionary());
|
||||
dict.set("tensorSources", tensorSources_.outputDictionary());
|
||||
dict.set("diagTensorSources", diagTensorSources_.outputDictionary());
|
||||
dict.set("symmTensorSources", symmTensorSources_.outputDictionary());
|
||||
dict.set
|
||||
(
|
||||
"sphericalTensorSources",
|
||||
sphericalTensorSources_.outputDictionary()
|
||||
);
|
||||
dict.set("cellIndex", cellIndex_);
|
||||
dict.set("internalScalars", internalScalars_);
|
||||
dictionary superDict;
|
||||
superDict.set("dataSources", dict);
|
||||
os << superDict;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Friend IOstream Operators * * * * * * * * * * * //
|
||||
|
||||
Foam::Istream& Foam::operator>>(Istream& is, equationReader& I)
|
||||
{
|
||||
dictionary dict(is);
|
||||
dictionary eqnsDict(dict.subDict("equations"));
|
||||
wordList eqnNames(eqnsDict.toc());
|
||||
forAll(eqnNames, i)
|
||||
{
|
||||
equation eq
|
||||
(
|
||||
eqnsDict.subDict(eqnNames[i]).lookup(eqnNames[i]),
|
||||
eqnNames[i]
|
||||
);
|
||||
I.createEquation(eq);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const equationReader& I)
|
||||
{
|
||||
dictionary eqnsDict;
|
||||
forAll(I, i)
|
||||
{
|
||||
dictionary eqnEntry;
|
||||
eqnEntry.set(I[i].name(), I[i]);
|
||||
eqnEntry.set("lastResult", I[i].lastResult());
|
||||
eqnsDict.set(I[i].name(), eqnEntry);
|
||||
}
|
||||
dictionary dict;
|
||||
dict.set("equations", eqnsDict);
|
||||
os << dict;
|
||||
return os;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
770
src/equationReader/equationReader/equationReaderParse.C
Normal file
770
src/equationReader/equationReader/equationReaderParse.C
Normal file
|
@ -0,0 +1,770 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::equationReader::parse(label index) const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info << "Parsing equation " << operator[](index).name()
|
||||
<< " at index " << index << "." << endl;
|
||||
}
|
||||
if ((index > size()) || (index < 0))
|
||||
{
|
||||
FatalErrorIn("equationReader::parse(index)")
|
||||
<< "Index " << index << " out of bounds (0, "
|
||||
<< size() - 1 << ")"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
clearEquation(index);
|
||||
|
||||
// First, ensure there are no ':' or '&' characters. This is to
|
||||
// accommodate the stringPreconditioner, which uses these special
|
||||
// characters as work-arounds to limitations imposed by the token class.
|
||||
if
|
||||
(
|
||||
operator[](index).rawText().string::find(":") != string::npos
|
||||
&& operator[](index).rawText().string::find("&") != string::npos
|
||||
)
|
||||
{
|
||||
FatalErrorIn("equationReader::parse")
|
||||
<< "Parsing error in the equation for "
|
||||
<< operator[](index).name() << ", given by:" << token::NL
|
||||
<< token::NL << token::TAB << operator[](index).rawText()
|
||||
<< token::NL << token::NL << "Colons, ':', and ampersands '&' are "
|
||||
<< "prohibitted."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Precondition the string, and load it into a stream
|
||||
IStringStream rawStream(stringPreconditioner(operator[](index).rawText()));
|
||||
tokenList tl;
|
||||
|
||||
bool forceEnd(false);
|
||||
|
||||
// Read tokens from raw equation string stream
|
||||
while (!rawStream.eof() && !forceEnd)
|
||||
{
|
||||
tl.setSize(tl.size() + 1);
|
||||
tl[tl.size() - 1] = token(rawStream);
|
||||
|
||||
// Bug fix - equations ending in brackets read an extra token of type
|
||||
// ERROR at the end, caused by string replace ')' with ' ) ' above
|
||||
if (tl[tl.size() - 1].type() == token::ERROR)
|
||||
{
|
||||
tl.setSize(tl.size() - 1);
|
||||
forceEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
// map:
|
||||
// - variable / constant: conatins source data only (first three fields)
|
||||
// - operation: conatains operation number only (last field)
|
||||
// - brackets, comma: all are zero
|
||||
PtrList<equationOperation> map(tl.size());
|
||||
|
||||
// opLvl: level of operation precedence
|
||||
// 0. variable
|
||||
// 1. + -
|
||||
// 2. * / and negatives
|
||||
// 3. ^
|
||||
// 4. ( ) and functions; special case -4 indicates close bracket ')'
|
||||
// 5. , used only in functions
|
||||
labelList opLvl(tl.size());
|
||||
|
||||
// parenthesis level, negative means function root
|
||||
labelList pl(tl.size());
|
||||
|
||||
createMap(index, tl, map, opLvl, pl);
|
||||
|
||||
// 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;
|
||||
forAll(tl, i)
|
||||
{
|
||||
Info << tl[i];
|
||||
if (tl[i].isNumber())
|
||||
{
|
||||
Info << " isNumber ";
|
||||
}
|
||||
if (tl[i].isPunctuation())
|
||||
{
|
||||
Info << " isPunctuation ";
|
||||
}
|
||||
if (tl[i].isWord())
|
||||
{
|
||||
Info << " isWord ";
|
||||
}
|
||||
Info << endl;
|
||||
}
|
||||
Info << "opLvl is: " << opLvl << endl;
|
||||
Info << "pl is: " << pl << endl;
|
||||
Info << "Map is: " << map << endl;
|
||||
}*/
|
||||
|
||||
// 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
|
||||
// parsed, the indices lists will shrink, but tl, pl, opLvl, and map will
|
||||
// not. Indices lists:
|
||||
//
|
||||
// - eqnIndices - the full working list
|
||||
// - subEqnIndices - the current group with the highest parenthesis level
|
||||
// - subEqnIndices2 - used when evaluating multiparameter functions
|
||||
//
|
||||
// Anytime we are 'trimming', we are removing elements from these lists.
|
||||
//
|
||||
// The main parsing loop:
|
||||
// - find the max parenthesis level magnitude
|
||||
// - if pl < 0, it is a function, look for a comma
|
||||
// -- no comma:
|
||||
// send the expression to parseExpression
|
||||
// if it is a function, evaluate the function
|
||||
// store the result, trim the indices
|
||||
// -- comma
|
||||
// same as above, except parseExpression both sides of the comma
|
||||
// - once the eqnIndices are down to a single size, parsing is done
|
||||
|
||||
label storeIndex(-1);
|
||||
|
||||
// Create an index list of all the tokens we're working with - initially
|
||||
// it is all of them
|
||||
labelList eqnIndices(tl.size());
|
||||
forAll(eqnIndices, i)
|
||||
{
|
||||
eqnIndices[i] = i;
|
||||
}
|
||||
|
||||
// Main parsing loop
|
||||
while (eqnIndices.size() > 1)
|
||||
{
|
||||
labelList subEqnIndices(findMaxParenthesis(pl, eqnIndices));
|
||||
if (opLvl[subEqnIndices[0]] == 4)
|
||||
{
|
||||
// Expression is enclosed in brackets - trim them
|
||||
if (pl[subEqnIndices[0]] < 0)
|
||||
{
|
||||
// This is a function:
|
||||
// - trim function name, but leave it in parent indexList
|
||||
// - first bracket is second index
|
||||
pl[subEqnIndices[0]] = 0;
|
||||
trimList(subEqnIndices, 0, 0);
|
||||
trimListWithParent(eqnIndices, subEqnIndices, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a function, first bracket is first index
|
||||
trimListWithParent(eqnIndices, subEqnIndices, 0, 0);
|
||||
}
|
||||
|
||||
// Trimming trailing bracket
|
||||
trimListWithParent
|
||||
(
|
||||
eqnIndices,
|
||||
subEqnIndices,
|
||||
subEqnIndices.size() - 1,
|
||||
subEqnIndices.size() - 1
|
||||
);
|
||||
}
|
||||
|
||||
// Move negatives into the source index
|
||||
absorbNegatives(index, tl, eqnIndices, subEqnIndices, map, opLvl);
|
||||
|
||||
label commaIndex(-1);
|
||||
label commaPos(-1);
|
||||
|
||||
// Look for a comma
|
||||
forAll(subEqnIndices, i)
|
||||
{
|
||||
if (opLvl[subEqnIndices[i]] == 5)
|
||||
{
|
||||
commaIndex = i;
|
||||
commaPos = subEqnIndices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (subEqnIndices.size() == 2)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Empty expression '()' found.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
subEqnIndices[0],
|
||||
subEqnIndices[subEqnIndices.size() - 1],
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
|
||||
if (commaIndex == -1)
|
||||
{
|
||||
// standard parenthesis or single parameter function
|
||||
label resultIndex
|
||||
(
|
||||
parseExpression
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
opLvl,
|
||||
map,
|
||||
subEqnIndices,
|
||||
storeIndex
|
||||
)
|
||||
);
|
||||
|
||||
trimListWithParent
|
||||
(
|
||||
eqnIndices,
|
||||
subEqnIndices,
|
||||
0,
|
||||
subEqnIndices.size() - 1,
|
||||
findIndex(resultIndex, subEqnIndices)
|
||||
);
|
||||
|
||||
label currentIndex(-1);
|
||||
|
||||
if (pl[resultIndex] < 0)
|
||||
{
|
||||
// This is a single parameter function call - evaluate it
|
||||
operator[](index).setSize(operator[](index).size() + 3);
|
||||
|
||||
// retrieve parameter value
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 3,
|
||||
new equationOperation
|
||||
(
|
||||
map[resultIndex].sourceType(),
|
||||
map[resultIndex].sourceIndex(),
|
||||
map[resultIndex].componentIndex(),
|
||||
map[resultIndex].dictLookupIndex(),
|
||||
equationOperation::otretrieve
|
||||
)
|
||||
);
|
||||
|
||||
// perform function operation
|
||||
currentIndex = findIndex(resultIndex, eqnIndices);
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 2,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::stnone,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
map[eqnIndices[currentIndex - 1]].operation()
|
||||
)
|
||||
);
|
||||
|
||||
// store result
|
||||
storeIndex++;
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::ststorage,
|
||||
storeIndex + 1,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otstore
|
||||
)
|
||||
);
|
||||
|
||||
// Set term in map to store location
|
||||
map[resultIndex] =
|
||||
operator[](index)
|
||||
[
|
||||
operator[](index).size() - 1
|
||||
];
|
||||
map[resultIndex].operation() = equationOperation::otnone;
|
||||
|
||||
// Trim function call from indices list
|
||||
currentIndex = findIndex(resultIndex, eqnIndices);
|
||||
trimList(eqnIndices, currentIndex - 1, currentIndex - 1);
|
||||
}
|
||||
// reduce the parenthesis level of result
|
||||
pl[resultIndex] = mag(pl[resultIndex]) - 1;
|
||||
|
||||
if (pl[resultIndex] > 0)
|
||||
{
|
||||
// Look for preceding parenthesis change - was it negative?
|
||||
currentIndex = findIndex(resultIndex, eqnIndices);
|
||||
for (label i(currentIndex - 1); i >= 0; i--)
|
||||
{
|
||||
if (mag(pl[eqnIndices[i]]) == pl[eqnIndices[currentIndex]])
|
||||
{
|
||||
if (pl[eqnIndices[i]] < 0)
|
||||
{
|
||||
pl[eqnIndices[currentIndex]] =
|
||||
-pl[eqnIndices[currentIndex]];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end standard parenthesis / single parameter function
|
||||
else if
|
||||
(
|
||||
(commaIndex < 1) || (commaIndex >= (subEqnIndices.size() - 1))
|
||||
)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Misplaced comma. '(,[expression)' or "
|
||||
<< "'([expression],)' found.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
commaPos,
|
||||
commaPos,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// multi-parameter function
|
||||
// Split the expression into two - before & after the comma
|
||||
labelList subEqnIndices2
|
||||
(
|
||||
subEqnIndices.size() - commaIndex - 1
|
||||
);
|
||||
forAll(subEqnIndices2, i)
|
||||
{
|
||||
subEqnIndices2[i] = subEqnIndices[i + commaIndex + 1];
|
||||
}
|
||||
subEqnIndices.setSize(commaIndex + 1);
|
||||
trimListWithParent
|
||||
(
|
||||
eqnIndices,
|
||||
subEqnIndices,
|
||||
commaIndex,
|
||||
commaIndex
|
||||
);
|
||||
|
||||
// Parse the first parameter
|
||||
label resultIndex
|
||||
(
|
||||
parseExpression
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
opLvl,
|
||||
map,
|
||||
subEqnIndices,
|
||||
storeIndex
|
||||
)
|
||||
);
|
||||
|
||||
trimListWithParent
|
||||
(
|
||||
eqnIndices,
|
||||
subEqnIndices,
|
||||
0,
|
||||
subEqnIndices.size() - 1,
|
||||
findIndex(resultIndex, subEqnIndices)
|
||||
);
|
||||
|
||||
// Parse the second parameter
|
||||
label resultIndex2
|
||||
(
|
||||
parseExpression
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
opLvl,
|
||||
map,
|
||||
subEqnIndices2,
|
||||
storeIndex
|
||||
)
|
||||
);
|
||||
|
||||
trimListWithParent
|
||||
(
|
||||
eqnIndices,
|
||||
subEqnIndices2,
|
||||
0,
|
||||
subEqnIndices2.size() - 1,
|
||||
findIndex(resultIndex2, subEqnIndices2)
|
||||
);
|
||||
|
||||
// Perform multiparameter function operations
|
||||
// first retrieve the first parameter
|
||||
operator[](index).setSize(operator[](index).size() + 3);
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 3,
|
||||
new equationOperation
|
||||
(
|
||||
map[resultIndex].sourceType(),
|
||||
map[resultIndex].sourceIndex(),
|
||||
map[resultIndex].componentIndex(),
|
||||
map[resultIndex].dictLookupIndex(),
|
||||
equationOperation::otretrieve
|
||||
)
|
||||
);
|
||||
|
||||
// perform the function operation (2nd parameter is source)
|
||||
label currentIndex(findIndex(resultIndex, eqnIndices));
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 2,
|
||||
new equationOperation
|
||||
(
|
||||
map[resultIndex2].sourceType(),
|
||||
map[resultIndex2].sourceIndex(),
|
||||
map[resultIndex2].componentIndex(),
|
||||
map[resultIndex2].dictLookupIndex(),
|
||||
map[eqnIndices[currentIndex - 1]].operation()
|
||||
)
|
||||
);
|
||||
|
||||
// store result
|
||||
storeIndex++;
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::ststorage,
|
||||
storeIndex + 1,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otstore
|
||||
)
|
||||
);
|
||||
|
||||
// Set term in map to store location
|
||||
map.set
|
||||
(
|
||||
resultIndex,
|
||||
new equationOperation
|
||||
(
|
||||
operator[](index)[operator[](index).size() - 1]
|
||||
)
|
||||
);
|
||||
map[resultIndex].operation() = equationOperation::otnone;
|
||||
|
||||
// trim function call from indices list
|
||||
trimList(eqnIndices, currentIndex - 1, currentIndex - 1);
|
||||
|
||||
// trim second parameter from indices list
|
||||
label currentIndex2(findIndex(resultIndex2, eqnIndices));
|
||||
trimList(eqnIndices, currentIndex2, currentIndex2);
|
||||
|
||||
// reduce the parenthesis level of result
|
||||
pl[resultIndex] = mag(pl[resultIndex]) - 1;
|
||||
|
||||
if (pl[resultIndex] > 0)
|
||||
{
|
||||
currentIndex = findIndex(resultIndex, eqnIndices);
|
||||
// Look for preceding parenthesis change - was it negative?
|
||||
for (label i(currentIndex - 1); i >= 0; i--)
|
||||
{
|
||||
if (mag(pl[eqnIndices[i]]) == pl[eqnIndices[currentIndex]])
|
||||
{
|
||||
if (pl[eqnIndices[i]] < 0)
|
||||
{
|
||||
pl[eqnIndices[currentIndex]] =
|
||||
-pl[eqnIndices[currentIndex]];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// break;
|
||||
} // end default case
|
||||
} // end main parsing loop
|
||||
|
||||
// Special case - equations with only one effective term:
|
||||
// e.g. "2", "-2", "-(2)", "-(((((2)))))", etc..
|
||||
// will complete their parse with an empty operation list
|
||||
if (operator[](index).size() == 0)
|
||||
{
|
||||
|
||||
labelList subEqnIndices(findMaxParenthesis(pl, eqnIndices));
|
||||
absorbNegatives(index, tl, eqnIndices, subEqnIndices, map, opLvl);
|
||||
|
||||
if (opLvl[subEqnIndices[0]] != 0)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Expecting a variable or literal constant.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
0,
|
||||
0,
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
|
||||
// Add two operations - the first retrieves the variable, the second
|
||||
// is a dummy because the last operation is trimmed before exitting
|
||||
// equationReader::parse
|
||||
operator[](index).setSize(operator[](index).size() + 2);
|
||||
|
||||
// retrieve parameter value
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 2,
|
||||
new equationOperation
|
||||
(
|
||||
map[subEqnIndices[0]].sourceType(),
|
||||
map[subEqnIndices[0]].sourceIndex(),
|
||||
map[subEqnIndices[0]].componentIndex(),
|
||||
map[subEqnIndices[0]].dictLookupIndex(),
|
||||
equationOperation::otretrieve
|
||||
)
|
||||
);
|
||||
|
||||
// Store this result
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::ststorage,
|
||||
storeIndex + 1,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otstore
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// The last operation is an otstore. Add an otretrieve to finalize.
|
||||
// We could eliminate the last otstore, but this will miss the final
|
||||
// absorbNegatives, if one existed.
|
||||
operator[](index).setSize(operator[](index).size() + 1);
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
map[eqnIndices[0]].sourceType(),
|
||||
map[eqnIndices[0]].sourceIndex(),
|
||||
map[eqnIndices[0]].componentIndex(),
|
||||
map[eqnIndices[0]].dictLookupIndex(),
|
||||
equationOperation::otretrieve
|
||||
)
|
||||
);
|
||||
|
||||
// Link the eval function pointers (for efficiency)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::equationReader::parseExpression
|
||||
(
|
||||
label index,
|
||||
const tokenList& tl,
|
||||
const labelList& opLvl,
|
||||
PtrList<equationOperation>& map,
|
||||
const labelList& indices,
|
||||
label& storeIndex
|
||||
) const
|
||||
{
|
||||
// equation * eqn(&this->operator[](index));
|
||||
label returnMe(-1);
|
||||
labelList subIndices(indices);
|
||||
labelList opIndices;
|
||||
|
||||
bool done(false);
|
||||
while (!done)
|
||||
{
|
||||
opIndices = findMaxOperation(opLvl, subIndices);
|
||||
if (!(opIndices.size() % 2))
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Expected pattern: [number] [operation] [number] "
|
||||
<< "[operation] ... violated.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
opIndices[0],
|
||||
opIndices[opIndices.size() - 1],
|
||||
"equationReader::parseExpression",
|
||||
description
|
||||
);
|
||||
}
|
||||
if (!opIndices.size())
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Empty expression found, e.g. '()'.";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
subIndices[0],
|
||||
subIndices[subIndices.size() - 1],
|
||||
"equationReader::parseExpression",
|
||||
description
|
||||
);
|
||||
}
|
||||
if (opIndices.size() == 1)
|
||||
{
|
||||
// This means only one term existed between the brackets, nothing
|
||||
// needs to be done.
|
||||
if (opLvl[opIndices[0]] != 0)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Detected an isolated operator, e.g. (+).";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
opIndices[0],
|
||||
opIndices[0],
|
||||
"equationReader::parse",
|
||||
description
|
||||
);
|
||||
}
|
||||
done = true;
|
||||
returnMe = opIndices[0];
|
||||
}
|
||||
else if (opIndices.size() > 1)
|
||||
{
|
||||
// More than one term. Do a retrieve, then enter the operations
|
||||
// loop.
|
||||
if (opLvl[opIndices[0]] != 0)
|
||||
{
|
||||
OStringStream description;
|
||||
description << "Expected pattern: [number] [operation] "
|
||||
<< "[number] [operation] ... violated. First token is "
|
||||
<< "not a [number].";
|
||||
fatalParseError
|
||||
(
|
||||
index,
|
||||
tl,
|
||||
opIndices[0],
|
||||
opIndices[opIndices.size() - 1],
|
||||
"equationReader::parseExpression",
|
||||
description
|
||||
);
|
||||
}
|
||||
operator[](index).setSize(operator[](index).size() + 1);
|
||||
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
map[opIndices[0]].sourceType(),
|
||||
map[opIndices[0]].sourceIndex(),
|
||||
map[opIndices[0]].componentIndex(),
|
||||
map[opIndices[0]].dictLookupIndex(),
|
||||
equationOperation::otretrieve
|
||||
)
|
||||
);
|
||||
|
||||
trimListWithParent(subIndices, opIndices, 0, 0);
|
||||
|
||||
// Begin operations loop
|
||||
while (opIndices.size() > 1)
|
||||
{
|
||||
operator[](index).setSize(operator[](index).size() + 1);
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
map[opIndices[1]].sourceType(),
|
||||
map[opIndices[1]].sourceIndex(),
|
||||
map[opIndices[1]].componentIndex(),
|
||||
map[opIndices[1]].dictLookupIndex(),
|
||||
map[opIndices[0]].operation()
|
||||
)
|
||||
);
|
||||
|
||||
if (opIndices.size() > 2)
|
||||
{
|
||||
// Remove the two operation indices from the working list
|
||||
trimListWithParent(subIndices, opIndices, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Last operation, perform a store
|
||||
operator[](index).setSize(operator[](index).size() + 1);
|
||||
storeIndex++;
|
||||
operator[](index).set
|
||||
(
|
||||
operator[](index).size() - 1,
|
||||
new equationOperation
|
||||
(
|
||||
equationOperation::ststorage,
|
||||
storeIndex + 1,
|
||||
0,
|
||||
0,
|
||||
equationOperation::otstore
|
||||
)
|
||||
);
|
||||
|
||||
returnMe = opIndices[1];
|
||||
map.set
|
||||
(
|
||||
opIndices[1],
|
||||
new equationOperation
|
||||
(
|
||||
operator[](index)[operator[](index).size() - 1]
|
||||
)
|
||||
);
|
||||
map[opIndices[1]].operation() = equationOperation::otnone;
|
||||
trimListWithParent(subIndices, opIndices, 0, 0);
|
||||
}
|
||||
} // end operations loop
|
||||
} // end if (opIndices.size() > 1)
|
||||
} // main parsing loop
|
||||
return returnMe;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
349
src/equationReader/equationReader/equationReaderTemplates.C
Normal file
349
src/equationReader/equationReader/equationReaderTemplates.C
Normal 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]
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef equationReaderVersion_H
|
||||
# define equationReaderVersion_H
|
||||
# define equationReaderVersionMajor 0
|
||||
# define equationReaderVersionMinor 6
|
||||
# define equationReaderVersionBuild 0
|
||||
#endif
|
122
src/equationReader/equationReader/equationReaders.C
Normal file
122
src/equationReader/equationReader/equationReaders.C
Normal 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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
89
src/equationReader/equationSource/equationScalarSource.C
Normal file
89
src/equationReader/equationSource/equationScalarSource.C
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "equationScalarSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
519
src/equationReader/equationSource/equationSource.C
Normal file
519
src/equationReader/equationSource/equationSource.C
Normal 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
309
src/equationReader/equationSource/equationSource.H
Normal file
309
src/equationReader/equationSource/equationSource.H
Normal 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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
79
src/equationReader/equationSource/equationSourceI.H
Normal file
79
src/equationReader/equationSource/equationSourceI.H
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
{
|
||||
|
||||
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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
60
src/equationReader/equationSource/equationSources.C
Normal file
60
src/equationReader/equationSource/equationSources.C
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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"
|
||||
#include "diagTensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
#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"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
96
src/equationReader/equationVariable/equationVariable.H
Normal file
96
src/equationReader/equationVariable/equationVariable.H
Normal 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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
22
src/equationReader/include/createEquationReader.H
Normal file
22
src/equationReader/include/createEquationReader.H
Normal 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
|
||||
);
|
12
src/equationReader/include/versionSpecific.H
Normal file
12
src/equationReader/include/versionSpecific.H
Normal 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
|
71
tutorials/equationReader/README
Normal file
71
tutorials/equationReader/README
Normal 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
|
50
tutorials/equationReader/equationReaderDemo/pitzDaily/0/R
Normal file
50
tutorials/equationReader/equationReaderDemo/pitzDaily/0/R
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
52
tutorials/equationReader/equationReaderDemo/pitzDaily/0/U
Normal file
52
tutorials/equationReader/equationReaderDemo/pitzDaily/0/U
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*--------------------------------*- 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 volVectorField;
|
||||
object U;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 1 -1 0 0 0 0];
|
||||
|
||||
internalField uniform (0 0 0);
|
||||
|
||||
boundaryField
|
||||
{
|
||||
inlet
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform (10 0 0);
|
||||
}
|
||||
|
||||
outlet
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
upperWall
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
|
||||
lowerWall
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
50
tutorials/equationReader/equationReaderDemo/pitzDaily/0/k
Normal file
50
tutorials/equationReader/equationReaderDemo/pitzDaily/0/k
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
50
tutorials/equationReader/equationReaderDemo/pitzDaily/0/p
Normal file
50
tutorials/equationReader/equationReaderDemo/pitzDaily/0/p
Normal 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 p;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
dimensions [0 2 -2 0 0 0 0];
|
||||
|
||||
internalField uniform 0;
|
||||
|
||||
boundaryField
|
||||
{
|
||||
inlet
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
outlet
|
||||
{
|
||||
type fixedValue;
|
||||
value uniform 0;
|
||||
}
|
||||
|
||||
upperWall
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
lowerWall
|
||||
{
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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";
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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
|
||||
(
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
|
@ -0,0 +1,52 @@
|
|||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 2.1.x |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class polyBoundaryMesh;
|
||||
location "constant/polyMesh";
|
||||
object boundary;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
5
|
||||
(
|
||||
inlet
|
||||
{
|
||||
type patch;
|
||||
nFaces 30;
|
||||
startFace 24170;
|
||||
}
|
||||
outlet
|
||||
{
|
||||
type patch;
|
||||
nFaces 57;
|
||||
startFace 24200;
|
||||
}
|
||||
upperWall
|
||||
{
|
||||
type wall;
|
||||
nFaces 223;
|
||||
startFace 24257;
|
||||
}
|
||||
lowerWall
|
||||
{
|
||||
type wall;
|
||||
nFaces 250;
|
||||
startFace 24480;
|
||||
}
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
nFaces 24450;
|
||||
startFace 24730;
|
||||
}
|
||||
)
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -0,0 +1,47 @@
|
|||
/*--------------------------------*- 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 controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application simpleFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 10;
|
||||
|
||||
deltaT 1;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 1;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 12;
|
||||
|
||||
writeCompression uncompressed;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable yes;
|
||||
|
||||
// ************************************************************************* //
|
|
@ -0,0 +1,70 @@
|
|||
/*--------------------------------*- 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 fvSchemes;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
ddtSchemes
|
||||
{
|
||||
default steadyState;
|
||||
}
|
||||
|
||||
gradSchemes
|
||||
{
|
||||
default Gauss linear;
|
||||
grad(p) Gauss linear;
|
||||
grad(U) Gauss linear;
|
||||
}
|
||||
|
||||
divSchemes
|
||||
{
|
||||
default none;
|
||||
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
|
||||
{
|
||||
default none;
|
||||
laplacian(nuEff,U) 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
|
||||
{
|
||||
default linear;
|
||||
interpolate(U) linear;
|
||||
}
|
||||
|
||||
snGradSchemes
|
||||
{
|
||||
default corrected;
|
||||
}
|
||||
|
||||
fluxRequired
|
||||
{
|
||||
default no;
|
||||
p;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
|
@ -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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
Reference in a new issue