Removed old equationReader

This commit is contained in:
David L. F. Gaden 2013-08-29 14:59:46 -05:00
parent d143ebc16b
commit d36caeaa10
57 changed files with 0 additions and 16213 deletions

View file

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

View file

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
equationReaderDemo
Description
Sample application testing the equationReader extension, and demonstrating
its use.
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "OFstream.H"
#include "equationReader.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
fileName path(args.rootPath()/args.caseName());
// Create dictionary
Info << "Reading testDict dictionary" << token::NL << endl;
IFstream tfIF(path/"testDict");
const dictionary testDict(tfIF);
// Demonstrate stand-alone operation
Info << "Begin stand-alone operation..." << endl;
Info << "Reading a scalar... ";
scalar readSa(readScalar(testDict.lookup("standAloneScalar")));
Info << "done. Result = " << readSa << endl;
Info << "Reading a dimensionedScalar ... ";
dimensionedScalar readDSa(testDict.lookup("standAloneDScalar"));
Info << "done. Result = " << readDSa << token::NL << endl;
// Create the equationReader object
Info << "Creating the equationReader object" << token::NL << endl;
equationReader eqns;
// Demonstrate giving data sources to equationReader
// -First create the data sources
Info << "Creating data sources: dictionary ptrs... ";
IFstream tfIF2(path/"testDict2");
const dictionary testDict2(tfIF2);
IFstream tfIF3(path/"testDict3");
const dictionary testDict3(tfIF3);
Info << "scalars... ";
scalar Sa(0.1);
scalar Sb(0.2);
scalar Sc(0.3);
Info << "dimensionedScalar ptrs... ";
dimensionedScalar DSa("DSa", dimless, 1);
dimensionedScalar DSb("DSb", dimless, 2);
dimensionedScalar DSc("DSc", dimless, 3);
Info << "output dimensionedScalar ptrs... ";
dimensionedScalar passiveOutA("passiveOutA", dimless, 0);
dimensionedScalar activeOutB("activeOutB", dimless, 0);
dimensionedScalar passiveOutC("passiveOutC", dimless, 0);
dimensionedScalar passiveOutD("passiveOutD", dimless, 0);
dimensionedScalar passiveOutF("passiveOutF", dimless, 0);
Info << "done." << endl;
Info << "Linking in the data sources: dictionary ptrs... ";
eqns.addDataSource(testDict);
eqns.addDataSource(testDict2);
eqns.addDataSource(testDict3);
Info << "dimensionedScalar ptrs... ";
eqns.addDataSource(DSa);
eqns.addDataSource(DSb);
eqns.addDataSource(DSc);
Info << "scalar ptrs... ";
eqns.addDataSource(Sa, "Sa");
eqns.addDataSource(Sb, "Sb");
eqns.addDataSource(Sc, "Sc");
Info << "done." << token::NL << endl;
// Demonstrate passive output
Info << "Reading equation a from testDict with no output variable" << endl;
eqns.readEquation(testDict, "a");
Info << "Evaluating equation a ... ";
passiveOutA = eqns.evaluate("a");
Info << "done. Result = " << passiveOutA << token::NL << endl;
// Demonstrate active output
Info << "Reading equation b from testDict, linking an output variable"
<< endl;
eqns.readEquation(testDict, "b", activeOutB);
Info << "Output variable before update() = " << activeOutB << endl;
Info << "Begining .update() - this evaluates all equations with active "
<< "output..." << endl;
eqns.update();
Info << "Done. Output variable after update() = " << activeOutB
<< token::NL << endl;
// Demonstrating variable dependence
Info << "Equation c depends on equation a. Reading it will link them."
<< endl;
Info << "Reading equation c from testDict... ";
eqns.readEquation(testDict, "c");
Info << "done." << endl;
Info << "Evaluating c will force an evaluate of a." << endl;
Info << "Evaluating ... ";
passiveOutC = eqns.evaluate("c");
Info << "done. Result = " << passiveOutC << token::NL << endl;
// Demonstrate on-the-fly equation creation
Info << "Equation d depends on equation e, but equation e is never "
<< "explicitly " << endl << "read by equationReaderDemo. Reading equation"
<< " d will automatically " << endl << "create equation e on-the-fly. "
<< endl;
Info << "Reading equation d from testDict ... ";
eqns.readEquation(testDict, "d");
Info << "done." << endl << "Again, evaluating d will force an evaluate of "
<< "e." << endl;
Info << "Evaluating d ... ";
passiveOutD = eqns.evaluate("d");
Info << "done. The result is = " << passiveOutD << token::NL << endl;
// Demonstrate dependence
Info << "Equations can draw from any sources added to equationReader." << endl;
Info << "Equation f is very complex, drawing from numerous sources." << endl;
Info << "Reading equation f ... ";
eqns.readEquation(testDict, "f");
Info << "done. Evaluating equation f ... ";
passiveOutF = eqns.evaluate("f");
Info << "done." << token::NL << "The result is: " << passiveOutF << endl;
Info << token::NL << "Creating output..." << endl;
OFstream os(path/"outputDict");
os << eqns;
eqns.dataSourceStatus(os);
return(0);
}

View file

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

View file

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

View file

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

View file

@ -1,357 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
equationReaderTester
Description
Sample application testing the equationReader in a finite volume solver
environment.
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "IOEquationReader.H"
#include "fvCFD.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"
# include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
fileName path(args.rootPath()/args.caseName());
// Create the equationReader object
Info << "Creating the equationReader object" << token::NL << endl;
IOEquationReader eqns
(
IOobject
(
"eqns",
runTime.timeName(),
runTime,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
true
);
// Create dictionaries
Info << "Reading testDict dictionaries" << token::NL << endl;
IFstream tfIF1(path/"testDict1");
const dictionary testDict1(tfIF1);
IFstream tfIF2(path/"testDict2");
const dictionary testDict2(tfIF2);
IFstream tfIF3(path/"testDict3");
const dictionary testDict3(tfIF3);
IFstream tfIF4(path/"testDict4");
const dictionary testDict4(tfIF4);
IFstream tfIF5(path/"testDict5");
const dictionary testDict5(tfIF5);
IFstream tfIF6(path/"testDict6");
const dictionary testDict6(tfIF6);
IFstream tfIF7(path/"testDict7");
const dictionary testDict7(tfIF7);
IFstream tfIF8(path/"testDict8");
const dictionary testDict8(tfIF8);
IFstream tfIF9(path/"testDict9");
const dictionary testDict9(tfIF9);
IFstream tfIF10(path/"testDict10");
const dictionary testDict10(tfIF10);
scalar Sa(0.1);
scalar Sb(0.2);
scalar Sc(0.3);
scalar Sd(0.4);
scalar Se(0.5);
scalar Sf(0.6);
scalar Sg(0.7);
scalar Sh(0.8);
scalar Si(0.9);
scalar Sj(0.10);
scalar Sk(0.11);
scalar Sl(0.12);
dimensionedScalar DSa("DSa", dimless, 1);
dimensionedScalar DSb("DSb", dimless, 2);
dimensionedScalar DSc("DSc", dimless, 3);
dimensionedScalar DSd("DSd", dimless, 4);
dimensionedScalar DSe("DSe", dimless, 5);
dimensionedScalar DSf("DSf", dimless, 6);
dimensionedScalar DSg("DSg", dimless, 7);
dimensionedScalar DSh("DSh", dimless, 8);
dimensionedScalar DSi("DSi", dimless, 9);
dimensionedScalar DSj("DSj", dimless, 10);
dimensionedScalar DSk("DSk", dimless, 11);
dimensionedScalar DSl("DSl", dimless, 12);
dimensionedScalar DSm("DSm", dimless, 13);
dimensionedScalar DSn("DSn", dimless, 14);
dimensionedScalar DSo("DSo", dimless, 15);
dimensionedScalar DStime("DStime", dimless, 0);
dimensionedScalar Aa("Aa", dimless, 0);
dimensionedScalar Ab("Ab", dimless, 0);
dimensionedScalar Ac("Ac", dimless, 0);
dimensionedScalar Ad("Ad", dimless, 0);
dimensionedScalar Ae("Ae", dimless, 0);
dimensionedScalar Af("Af", dimless, 0);
dimensionedScalar Pa("Pa", dimless, 0);
dimensionedScalar Pb("Pb", dimless, 0);
dimensionedScalar Pc("Pc", dimless, 0);
dimensionedScalar Pd("Pd", dimless, 0);
dimensionedScalar Pe("Pe", dimless, 0);
dimensionedScalar Pf("Pf", dimless, 0);
eqns.addDataSource(testDict1);
eqns.addDataSource(testDict2);
eqns.addDataSource(testDict3);
eqns.addDataSource(testDict4);
eqns.addDataSource(testDict5);
eqns.addDataSource(testDict6);
eqns.addDataSource(testDict7);
eqns.addDataSource(testDict8);
eqns.addDataSource(testDict9);
eqns.addDataSource(testDict10);
eqns.addDataSource(DSa);
eqns.addDataSource(DSb);
eqns.addDataSource(DSc);
eqns.addDataSource(DSd);
eqns.addDataSource(DSe);
eqns.addDataSource(DSf);
eqns.addDataSource(DSg);
eqns.addDataSource(DSh);
eqns.addDataSource(DSi);
eqns.addDataSource(DSj);
eqns.addDataSource(DSk);
eqns.addDataSource(DSl);
eqns.addDataSource(DSm);
eqns.addDataSource(DSn);
eqns.addDataSource(DSo);
eqns.addDataSource(DStime);
eqns.addDataSource(Sa, "Sa");
eqns.addDataSource(Sb, "Sb");
eqns.addDataSource(Sc, "Sc");
eqns.addDataSource(Sd, "Se");
eqns.addDataSource(Se, "Sd");
eqns.addDataSource(Sf, "Sf");
eqns.addDataSource(Sg, "Sg");
eqns.addDataSource(Sh, "Sh");
eqns.addDataSource(Si, "Si");
eqns.addDataSource(Sj, "Sj");
eqns.addDataSource(Sk, "Sk");
eqns.addDataSource(Sl, "Sl");
label listIndex(0);
eqns.addDataSource(p);
eqns.addDataSource(dummy);
eqns.setListIndex(listIndex);
eqns.readEquation(testDict1, "Pa");
eqns.readEquation(testDict1, "Pb");
eqns.readEquation(testDict1, "Pc");
eqns.readEquation(testDict1, "Pd");
eqns.readEquation(testDict1, "Pe");
eqns.readEquation(testDict1, "Pf");
eqns.readEquation(testDict1, "Aa", Aa);
eqns.readEquation(testDict1, "Ab", Ab);
eqns.readEquation(testDict1, "Ac", Ac);
eqns.readEquation(testDict1, "Ad", Ad);
eqns.readEquation(testDict1, "Ae", Ae);
eqns.readEquation(testDict1, "Af", Af);
eqns.readEquation(testDict1, "nu", nu);
scalar saA(readScalar(testDict1.lookup("saA")));
scalar saB(readScalar(testDict1.lookup("saB")));
scalar saC(readScalar(testDict1.lookup("saC")));
scalar saD(readScalar(testDict1.lookup("saD")));
scalar saE(readScalar(testDict1.lookup("saE")));
scalar saF(readScalar(testDict1.lookup("saF")));
dimensionedScalar dsaA(testDict1.lookup("dsaA"));
dimensionedScalar dsaB(testDict1.lookup("dsaB"));
dimensionedScalar dsaC(testDict1.lookup("dsaC"));
dimensionedScalar dsaD(testDict1.lookup("dsaD"));
dimensionedScalar dsaE(testDict1.lookup("dsaE"));
dimensionedScalar dsaF(testDict1.lookup("dsaF"));
Info << "Stand-alone test:" << endl;
Info << "saA = " << saA << endl;
Info << "saB = " << saB << endl;
Info << "saC = " << saC << endl;
Info << "saD = " << saD << endl;
Info << "saE = " << saE << endl;
Info << "saF = " << saF << endl;
Info << "dsaA = " << dsaA << endl;
Info << "dsaB = " << dsaB << endl;
Info << "dsaC = " << dsaC << endl;
Info << "dsaD = " << dsaD << endl;
Info << "dsaE = " << dsaE << endl;
Info << "dsaF = " << dsaF << endl;
Info << "Pa is at index " << eqns.lookup("Pa") << endl;
Info << "Pb is at index " << eqns.lookup("Pb") << endl;
Info << "Pc is at index " << eqns.lookup("Pc") << endl;
Info << "Pd is at index " << eqns.lookup("Pd") << endl;
Info << "Pe is at index " << eqns.lookup("Pe") << endl;
Info << "Pf is at index " << eqns.lookup("Pf") << endl;
Info << "Aa is at index " << eqns.lookup("Aa") << endl;
Info << "Ab is at index " << eqns.lookup("Ab") << endl;
Info << "Ac is at index " << eqns.lookup("Ac") << endl;
Info << "Ad is at index " << eqns.lookup("Ad") << endl;
Info << "Ae is at index " << eqns.lookup("Ae") << endl;
Info << "Af is at index " << eqns.lookup("Af") << endl;
Info << "nu is at index " << eqns.lookup("nu") << endl;
Info<< "\nStarting time loop\n" << endl;
for (runTime++; !runTime.end(); runTime++)
{
Info<< "Time = " << runTime.timeName() << nl << endl;
DStime.value() = runTime.value();
Info << "Moving p index to ";
listIndex++;
if (listIndex == p.size())
{
listIndex = 0;
}
Info << listIndex << "..." << endl;
eqns.setListIndex(listIndex);
Info << "Passive reread..." << endl;
eqns.readEquation(testDict1, "Pa");
eqns.readEquation(testDict1, "Pb");
eqns.readEquation(testDict1, "Pc");
Info << "Active reread..." << endl;
eqns.readEquation(testDict1, "Aa", Aa);
eqns.readEquation(testDict1, "Ab", Ab);
eqns.readEquation(testDict1, "Ac", Ac);
Info << "Updating active equations..." << endl;
eqns.update();
Info << "Aa = " << Aa << endl;
Info << "Ab = " << Ab << endl;
Info << "Ac = " << Ac << endl;
Info << "Ad = " << Ad << endl;
Info << "Ae = " << Ae << endl;
Info << "Af = " << Af << endl;
Info << "nu = " << nu << endl;
Info << "Evaluating passive equations: Pa, ";
Pa = eqns.evaluate("Pa");
Info << "Pb, ";
Pb = eqns.evaluate("Pb");
Info << "Pc, ";
Pc = eqns.evaluate("Pc");
Info << "Pd, ";
Pe = eqns.evaluate("Pd");
Info << "Pe, ";
Pd = eqns.evaluate("Pe");
Info << "Pf." << endl;
Pf = eqns.evaluate("Pf");
Info << "Pa = " << Pa << endl;
Info << "Pb = " << Pb << endl;
Info << "Pc = " << Pc << endl;
Info << "Pd = " << Pd << endl;
Info << "Pe = " << Pe << endl;
Info << "Pf = " << Pf << endl;
# include "readPISOControls.H"
# include "CourantNo.H"
fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
solve(UEqn == -fvc::grad(p));
// --- PISO loop
for (int corr=0; corr<nCorr; corr++)
{
volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi);
adjustPhi(phi, U, p);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rUA, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
# include "continuityErrs.H"
U -= rUA*fvc::grad(p);
U.correctBoundaryConditions();
}
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
// ************************************************************************* //

View file

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

View file

@ -1,74 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#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();
}
// ************************************************************************* //

View file

@ -1,116 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::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
// ************************************************************************* //

View file

@ -1,58 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#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
// ************************************************************************* //

View file

@ -1,98 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "equation.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* const Foam::equation::typeName = "equation";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::equation::equation()
:
equationName_(word::null),
rawText_(""),
lastResult_(word::null, dimless, 0),
overrideDimensions_(dimless),
changeDimensions_(false)
{
// internalScalars_ = new scalarList(0);
setSize(0);
}
Foam::equation::equation(Istream& is, const word& name)
:
equationName_(name),
rawText_(""),
lastResult_(word::null, dimless, 0),
overrideDimensions_(dimless),
changeDimensions_(false)
{
// internalScalars_ = new scalarList(0);
operator>>(is, *this);
}
Foam::equation::equation
(
const Foam::word& equationName,
const Foam::string& rawText,
const Foam::dimensionSet& overrideDimensions,
const bool& changeDimensions
)
:
equationName_(equationName),
rawText_(rawText),
lastResult_(equationName, dimless, 0),
overrideDimensions_(overrideDimensions),
changeDimensions_(changeDimensions)
{
// internalScalars_ = new scalarList(0);
setSize(0);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::equation::~equation()
{}
// * * * * * * * * * * * * * * * * * 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_;
}
// ************************************************************************* //

View file

@ -1,199 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::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 "scalarList.H"
#include "dimensionSet.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
:
public equationOperationList
{
// Private data
word equationName_;
//- raw text read from the dictionary
string rawText_;
//- Result of most recent evaluate() or update()
dimensionedScalar lastResult_;
//- Constants appearing in the equation are stored here
// scalarList * internalScalars_;
//- Names of variables that need to be read from a dictionary are
// stored here
// wordList dictLookups_;
//- Override dimensions - if read from a dictionary with dimensions,
// eg: nu nu [0 2 -1 0 0 0 0] "sin(theta)";
// the dimensionedScalar resulting from evaluate() is given these
// dimensions
dimensionSet overrideDimensions_;
//- true if there is a dimension override
bool changeDimensions_;
public:
// Static data members
static const char* const typeName;
// Constructors
//- Construct null
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& equationName() const;
//- Change the equation name
inline word& equationName();
//- Equation text
inline const string& rawText() const;
//- Set the equation text
inline string& rawText();
//- Last result
inline const dimensionedScalar& lastResult() const;
//- Set the last result
inline dimensionedScalar& lastResult();
//- Easy access to operations
inline const equationOperationList& ops() const;
inline equationOperationList& ops();
//- Locally stored constants
// inline const scalarList * internalScalars() const;
//- Set the locally stored constants
// inline scalarList * internalScalars();
//- Dictionary variable lookup names
// inline const wordList& dictLookups() const;
//- Set the dictionary variable lookup names
// inline wordList& dictLookups();
//- Dimension override
inline const dimensionSet& overrideDimensions() const;
//- Set the dimension override
inline dimensionSet& overrideDimensions();
//- changeDimensions flag
inline const bool& changeDimensions() const;
//- Set the changeDimensions flag
inline bool& changeDimensions();
// Operators
// Copy only the header info - rawText, equationName, dimensionOverride
// and changeDimensions
void operator=(equation&);
// Friend IOstream Operators
friend Istream& operator>>(Istream&, equation&);
friend Ostream& operator<<(Ostream&, const equation&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationI.H"
#endif

View file

@ -1,126 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
inline const word& equation::equationName() const
{
return equationName_;
}
inline word& equation::equationName()
{
return equationName_;
}
inline const string& equation::rawText() const
{
return rawText_;
}
inline string& equation::rawText()
{
return rawText_;
}
inline const dimensionedScalar& equation::lastResult() const
{
return lastResult_;
}
inline dimensionedScalar& equation::lastResult()
{
return lastResult_;
}
inline const equationOperationList& equation::ops() const
{
const equationOperationList& oplist(*this);
return oplist;
}
inline equationOperationList& equation::ops()
{
equationOperationList& opList(*this);
return opList;
}
/*inline const scalarList * equation::internalScalars() const
{
return internalScalars_;
}
inline scalarList * equation::internalScalars()
{
return internalScalars_;
}*/
/*inline const wordList& equation::dictLookups() const
{
return dictLookups_;
}
inline wordList& equation::dictLookups()
{
return dictLookups_;
}*/
inline const dimensionSet& equation::overrideDimensions() const
{
return overrideDimensions_;
}
inline dimensionSet& equation::overrideDimensions()
{
return overrideDimensions_;
}
inline const bool& equation::changeDimensions() const
{
return changeDimensions_;
}
inline bool& equation::changeDimensions()
{
return changeDimensions_;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::equationList
Description
List of equations
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationList_H
#define equationList_H
#include "equation.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef PtrList<equation> equationList;
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,574 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "dimensionedScalar.H"
#include "equationReader.H"
#include "equationOperation.H"
#include "error.H"
//#include "equationOperationList.H"
class dimensionedScalar;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const char* const Foam::equationOperation::typeName = "equationOperation";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::equationOperation::equationOperation()
{}
Foam::equationOperation::equationOperation
(
sourceListType sourceList,
label sourceIndex,
label dictLookupIndex,
operationType operation,
dimensionedScalar (Foam::equationReader::*getSourceFunction)
(
equationReader *,
const label,
const label,
const label,
const label
),
void (Foam::equationReader::*opFunction)
(
equationReader *,
const label,
const label,
const label,
label&,
dimensionedScalar&,
dimensionedScalar
)
)
:
sourceList_(sourceList),
sourceIndex_(sourceIndex),
dictLookupIndex_(dictLookupIndex),
operation_(operation),
getSourceFunction_(getSourceFunction),
opFunction_(opFunction)
{}
// * * * * * * * * * * * * * * * * 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 == "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 == "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 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 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:
FatalErrorIn
(
"Foam::word Foam::equationOperation::opName"
"(const Foam::equationOperation::operationType& op)"
)
<< "invalid operation"
<< exit(FatalError);
return "invalid";
}
}
Foam::word Foam::equationOperation::sourceName
(
const Foam::equationOperation::sourceListType& sl
)
{
switch (sl)
{
case slnone:
return "none";
case sldictSource:
return "dictionary";
case slexternalDScalar:
return "dimensionedScalar";
case slexternalScalar:
return "scalar";
case slexternalScalarList:
return "scalarList";
case slinternalScalar:
return "constant";
case slequation:
return "equation";
case slstorage:
return "memory";
default:
FatalErrorIn
(
"Foam::word Foam::equationOperation::opName"
"(const Foam::equationOperation::operationType& op)"
)
<< "invalid source"
<< exit(FatalError);
return "invalid";
}
}
void Foam::equationOperation::assignSourceFunction
(
dimensionedScalar (Foam::equationReader::*getSourceFunction)
(
equationReader *,
const label,
const label,
const label,
const label
)
)
{
getSourceFunction_ = getSourceFunction;
}
void Foam::equationOperation::assignOpFunction
(
void (Foam::equationReader::*opFunction)
(
equationReader *,
const label,
const label,
const label,
label&,
dimensionedScalar&,
dimensionedScalar
)
)
{
opFunction_ = opFunction;
}
Foam::dimensionedScalar Foam::equationOperation::getSourceFunction
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
return (eqnReader->*getSourceFunction_)
(
eqnReader,
equationIndex,
equationOperationIndex,
maxStoreIndex,
storageOffset
);
}
void Foam::equationOperation::opFunction
(
equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionedScalar& ds,
dimensionedScalar source
)
{
(eqnReader->*opFunction_)
(
eqnReader,
index,
i,
storageOffset,
storageIndex,
ds,
source
);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
int Foam::operator==(const equationOperation& I1, const equationOperation& I2)
{
return
(
I1.sourceList() == I2.sourceList()
&& 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;
}
// * * * * * * * * * * * * * Friend IOstream Operators * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, equationOperation& I)
{
label sl(I.sourceList_);
label op(I.operation_);
is >> sl >> I.sourceIndex_ >> I.dictLookupIndex_ >> op;
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const equationOperation& I)
{
label sl(I.sourceList_);
label op(I.operation_);
return os << nl << "/* sourceList: */\t" << sl << nl
<< "/* sourceIndex:*/\t" << I.sourceIndex_ << nl
<< "/* dictIndex */\t" << I. dictLookupIndex_ << nl
<< "/* operation: */\t" << op << nl;
}
// ************************************************************************* //

View file

@ -1,342 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::equationOperation
Description
Defines a single operation to be performed in sequence while evaluating an
equation read from a dictionary.
SourceFiles
equationOperationI.H
equationOperation.C
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationOperation_H
#define equationOperation_H
#include "word.H"
#include "label.H"
#include "IOstreams.H"
#include "dimensionedScalar.H"
// #include "Istream.H"
// #include "Ostream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class equationOperation;
class equationReader;
// Friend Operators
int operator==(const equationOperation&, const equationOperation&);
int operator!=(const equationOperation&, const equationOperation&);
// Friend IOstream Operators
Istream& operator>>(Istream&, equationOperation&);
Ostream& operator<<(Ostream&, const equationOperation&);
/*---------------------------------------------------------------------------*\
Class equationOperation Declaration
\*---------------------------------------------------------------------------*/
class equationOperation
{
public:
enum sourceListType
{
slnone,
sldictSource,
slexternalDScalar,
slexternalScalar,
slexternalScalarList,
slinternalScalar,
slequation,
slstorage
};
enum operationType
{
otnone,
otretrieve,
otstore,
otplus,
otminus,
ottimes,
otdivide,
otpow,
otsign,
otpos,
otneg,
otmag,
otlimit,
otminMod,
otsqrtSumSqr,
otsqr,
otpow3,
otpow4,
otpow5,
otinv,
otsqrt,
otcbrt,
othypot,
otexp,
otlog,
otlog10,
otsin,
otcos,
ottan,
otasin,
otacos,
otatan,
otsinh,
otcosh,
ottanh,
otasinh,
otacosh,
otatanh,
oterf,
oterfc,
otlgamma,
otj0,
otj1,
otjn,
oty0,
oty1,
otyn,
otmax,
otmin,
otstabilise
};
private:
// List to read the data from
sourceListType sourceList_;
// Index in the list where the data is located. Note, the
// equationOperationLists created by equationReader make this variable a
// 1-indexed (i.e. starts from 1, not zero) in order to use its sign to
// store the sign of the variable. The sourceLists are zero-indexed, so
// equationReader will constantly be adding / subtracting 1 to get these
// to match
label sourceIndex_;
// Rather than store the keywords that have to be searched in a dictionary,
// equationReader keeps its own list of keywords, and the dictLookupIndex
// is the index in this list. This is only applicable if the sourceList is
// of type sldictSource
label dictLookupIndex_;
// The operation to be performed (+ - sin exp min, etc...)
operationType operation_;
// A pointer to the source data retrieval function
dimensionedScalar (Foam::equationReader::*getSourceFunction_)
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
);
// A pointer to the operation to be performed
void (Foam::equationReader::*opFunction_)
(
equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionedScalar& ds,
dimensionedScalar source
);
public:
// Static data members
static const char* const typeName;
// Constructors
//- Construct null
equationOperation();
//- Construct from components
equationOperation
(
sourceListType sourceList,
label sourceIndex,
label dictLookupIndex,
operationType operation,
dimensionedScalar (Foam::equationReader::*getSourceFunction)
(
equationReader *,
const label,
const label,
const label,
const label
) = NULL,
void (Foam::equationReader::*opFunction)
(
equationReader *,
const label,
const label,
const label,
label&,
dimensionedScalar&,
dimensionedScalar
) = NULL
);
// Destructor
~equationOperation();
// Member functions
// Access
//- Const access to source list
inline const sourceListType& sourceList() const;
//- Access to source list
inline sourceListType& sourceList();
//- Const access to source index
inline const label& sourceIndex() const;
//- Access to source index
inline label& sourceIndex();
//- Const access to dictionary lookup name index
inline const label& dictLookupIndex() const;
//- Access to dictionary lookup name index
inline label& dictLookupIndex();
//- Const access to operation
inline const operationType& operation() const;
//- Access to operation
inline operationType& operation();
// Function pointers
//- Assign the operation function
void assignSourceFunction
(
dimensionedScalar (Foam::equationReader::*getSourceFunction)
(
equationReader *,
const label,
const label,
const label,
const label
)
);
void assignOpFunction
(
void (Foam::equationReader::*opFunction)
(
equationReader *,
const label,
const label,
const label,
label&,
dimensionedScalar&,
dimensionedScalar
)
);
//- Call the getSource function
dimensionedScalar getSourceFunction
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
);
//- Call the operation function
void opFunction
(
equationReader * eqnReader,
const label index,
const label i,
const label storageOffset,
label& storageIndex,
dimensionedScalar& ds,
dimensionedScalar source
);
// Convenience
//- Look up operation number, given a word
static operationType findOp(const word& opName);
//- Look up operation name
static word opName(const operationType& op);
//- Look up sourceList name
static word sourceName(const sourceListType& sl);
// Friend IOstream Operators
friend Istream& operator>>(Istream&, equationOperation&);
friend Ostream& operator<<(Ostream&, const equationOperation&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "equationOperationI.H"
#endif

View file

@ -1,84 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
inline const equationOperation::sourceListType&
equationOperation::sourceList() const
{
return sourceList_;
}
inline equationOperation::sourceListType&
equationOperation::sourceList()
{
return sourceList_;
}
inline const label& equationOperation::sourceIndex() const
{
return sourceIndex_;
}
inline label& equationOperation::sourceIndex()
{
return sourceIndex_;
}
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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::equationOperationList
Description
List of equationOperations
Author
David L. F. Gaden
\*---------------------------------------------------------------------------*/
#ifndef equationOperationList_H
#define equationOperationList_H
#include "equationOperation.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef List<equationOperation> equationOperationList;
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

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

View file

@ -1,563 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::equationReader::createMap
(
const label index,
const tokenList& tl,
equationOperationList& map,
labelList& opLvl,
labelList& pl
)
{
// 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[i] = equationOperation
(
equationOperation::slinternalScalar,
addInternalScalar(tl[i].number()) + 1,
0,
equationOperation::otnone
);
/*
//Bug fix
eqn = &this->operator[](index);
eqn->internalScalars()->setSize
(
eqn->internalScalars()->size() + 1
);
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = tl[i].number();
opLvl[i] = 0;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slinternalScalar,
eqn->internalScalars()->size(),
0,
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[i] = equationOperation
(
equationOperation::slnone,
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[i] = equationOperation
(
equationOperation::slnone,
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
//Bug fix
// eqn = &this->operator[](index);
if
(
findSource(tl[i].wordToken()).sourceList()
!= equationOperation::slnone
)
{
// Found a possible conflicting variable name - warn
WarningIn("equationReader::createMap")
<< "Equation for " << eqns_[index].equationName()
<< ", given by:" << token::NL << token::TAB
<< eqns_[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;
}
/* eqn->internalScalars()->setSize
(
eqn->internalScalars()->size() + 1
);
*/
opLvl[i] = 0;
pl[i] = p;
label internalIndex(0);
if (tl[i].wordToken() == "e_")
{
internalIndex =
addInternalScalar(mathematicalConstant::e) + 1;
}
else if (tl[i].wordToken() == "pi_")
{
internalIndex =
addInternalScalar(mathematicalConstant::pi) + 1;
}
else if (tl[i].wordToken() == "twoPi_")
{
internalIndex =
addInternalScalar(mathematicalConstant::twoPi) + 1;
}
else if (tl[i].wordToken() == "piByTwo_")
{
internalIndex =
addInternalScalar(mathematicalConstant::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[i] = equationOperation
(
equationOperation::slinternalScalar,
internalIndex,
0,
equationOperation::otnone
);
/*
if (tl[i].wordToken() == "e_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::e;
}
else if (tl[i].wordToken() == "pi_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::pi;
}
else if (tl[i].wordToken() == "twoPi_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::twoPi;
}
else if (tl[i].wordToken() == "piByTwo_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = mathematicalConstant::piByTwo;
}
else if (tl[i].wordToken() == "GREAT_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = GREAT;
}
else if (tl[i].wordToken() == "VGREAT_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = VGREAT;
}
else if (tl[i].wordToken() == "ROOTVGREAT_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = ROOTVGREAT;
}
else if (tl[i].wordToken() == "SMALL_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = SMALL;
}
else if (tl[i].wordToken() == "VSMALL_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = VSMALL;
}
else if (tl[i].wordToken() == "ROOTVSMALL_")
{
eqn->internalScalars()->operator[]
(
eqn->internalScalars()->size() - 1
) = ROOTVSMALL;
}
opLvl[i] = 0;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slinternalScalar,
eqn->internalScalars()->size(),
0,
equationOperation::otnone
);
*/
}
else
{
// Variable name
opLvl[i] = 0;
pl[i] = p;
map[i] = 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
);
}
}
}
else if (tl[i].isPunctuation())
{
switch (tl[i].pToken())
{
case token::BEGIN_LIST: // (
opLvl[i] = 4;
p = mag(p) + 1;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slnone,
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[i] = equationOperation
(
equationOperation::slnone,
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[i] = equationOperation
(
equationOperation::slnone,
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[i] = equationOperation
(
equationOperation::slnone,
0,
0,
equationOperation::otplus
);
break;
case token::SUBTRACT: // -
opLvl[i] = 1;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slnone,
0,
0,
equationOperation::otminus
);
break;
case token::MULTIPLY: // *
opLvl[i] = 2;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slnone,
0,
0,
equationOperation::ottimes
);
break;
case token::DIVIDE: // /
opLvl[i] = 2;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slnone,
0,
0,
equationOperation::otdivide
);
break;
case token::COLON: // :, means ^
opLvl[i] = 3;
pl[i] = p;
map[i] = equationOperation
(
equationOperation::slnone,
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;
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,312 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::dimensionedScalar Foam::equationReader::getSourceNone
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
return dimensionedScalar("noSource", dimless, 0);
}
Foam::dimensionedScalar Foam::equationReader::getSourceDictSourceDScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
ITstream srcStrm
(
dictSources_[zeroSourceIndex].lookup(varName)
);
srcStrm >> returnMe;
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceDictSourceScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
word varName(dictLookups_[eqOp.dictLookupIndex()]);
returnMe.name() = varName;
returnMe.value() = readScalar
(
dictSources_[zeroSourceIndex].lookup(varName)
);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceExternalDScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dsEqual(returnMe, externalDScalars_[zeroSourceIndex]);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceExternalScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
returnMe.name() = externalScalarNames_[zeroSourceIndex];
returnMe.value() = externalScalars_[zeroSourceIndex];
returnMe.dimensions().reset
(
externalScalarDimensions_[zeroSourceIndex]
);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceExternalScalarList
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dsEqual
(
returnMe,
dimensionedScalar
(
externalScalarListNames_[zeroSourceIndex],
externalScalarListDimensions_[zeroSourceIndex],
externalScalarLists_
[zeroSourceIndex]
[externalScalarListIndex_[zeroSourceIndex]]
)
);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceInternalScalar
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
returnMe.name() = "internalConstant";
returnMe.value() = internalScalars_[zeroSourceIndex];
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceEquation
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
if (debug)
{
Info << "Embedded equation dispatch." << endl;
}
dsEqual(returnMe, evaluate(zeroSourceIndex, maxStoreIndex + 1));
if (debug)
{
Info << "Returned from embedded equation." << endl;
}
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceEquationCircRefDetect
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
equation& eqn(eqns_[equationIndex]);
equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
// Check for circular references
dependents_.setSize(dependents_.size() + 1);
dependents_[dependents_.size() - 1] = equationIndex;
forAll(dependents_, i)
{
if (dependents_[i] == zeroSourceIndex)
{
// Circular reference detected
string dependencies;
for (label j(i); j < dependents_.size(); j++)
{
dependencies.append
(
eqns_[j].equationName()
);
dependencies.append("-->");
}
dependencies.append(eqns_[i].equationName());
FatalErrorIn("equationReader::getSource")
<< "Circular reference detected when evaluating "
<< "the equation for " << eqn.equationName()
<< ", given by:" << token::NL << token::TAB
<< eqn.rawText() << token::NL << "The circular "
<< "dependency is:" << token::NL << token::TAB
<< dependencies
<< abort(FatalError);
}
}
if (debug)
{
Info << "Embedded equation dispatch." << endl;
}
dsEqual(returnMe, evaluate(zeroSourceIndex, maxStoreIndex + 1));
eqOp.assignSourceFunction
(
&Foam::equationReader::getSourceEquation
);
if (debug)
{
Info << "Returned from embedded equation." << endl;
}
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
Foam::dimensionedScalar Foam::equationReader::getSourceStorage
(
equationReader * eqnReader,
const label equationIndex,
const label equationOperationIndex,
const label maxStoreIndex,
const label storageOffset
)
{
dimensionedScalar returnMe("noSource", dimless, 0);
const equation& eqn(eqns_[equationIndex]);
const equationOperation& eqOp(eqn[equationOperationIndex]);
label zeroSourceIndex = mag(eqOp.sourceIndex()) - 1;
# ifdef FULLDEBUG
if ((zeroSourceIndex + storageOffset) > maxStoreIndex)
{
FatalErrorIn("equationReader::getSouce")
<< "Index " << zeroSourceIndex << " out of bounds (0, "
<< maxStoreIndex - storageOffset << ")"
<< abort(FatalError);
}
# endif
dsEqual(returnMe, storage_[zeroSourceIndex + storageOffset]);
returnMe.value() = sign(eqOp.sourceIndex()) * returnMe.value();
return returnMe;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,226 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
inline const equationList& equationReader::eqns() const
{
return eqns_;
}
inline const UPtrList<const dictionary>& equationReader::dictSources() const
{
return dictSources_;
}
inline UPtrList<const dictionary>& equationReader::dictSources()
{
return dictSources_;
}
inline const PtrList<word>& equationReader::dictLookups() const
{
return dictLookups_;
}
inline const
UPtrList<const scalarList>& equationReader::externalScalarLists() const
{
return externalScalarLists_;
}
inline UPtrList<const scalarList>& equationReader::externalScalarLists()
{
return externalScalarLists_;
}
inline const
PtrList<dimensionSet>& equationReader::externalScalarListDimensions() const
{
return externalScalarListDimensions_;
}
inline PtrList<dimensionSet>& equationReader::externalScalarListDimensions()
{
return externalScalarListDimensions_;
}
inline const wordList& equationReader::externalScalarListNames() const
{
return externalScalarListNames_;
}
inline wordList& equationReader::externalScalarListNames()
{
return externalScalarListNames_;
}
inline const labelList& equationReader::externalScalarListIndex() const
{
return externalScalarListIndex_;
}
inline labelList& equationReader::externalScalarListIndex()
{
return externalScalarListIndex_;
}
inline const
UPtrList<const dimensionedScalar>& equationReader::externalDScalars() const
{
return externalDScalars_;
}
inline UPtrList<const dimensionedScalar>& equationReader::externalDScalars()
{
return externalDScalars_;
}
inline const UPtrList<const scalar>& equationReader::externalScalars() const
{
return externalScalars_;
}
inline UPtrList<const scalar>& equationReader::externalScalars()
{
return externalScalars_;
}
inline const wordList& equationReader::externalScalarNames() const
{
return externalScalarNames_;
}
inline wordList& equationReader::externalScalarNames()
{
return externalScalarNames_;
}
inline const
PtrList<dimensionSet>& equationReader::externalScalarDimensions() const
{
return externalScalarDimensions_;
}
inline PtrList<dimensionSet>& equationReader::externalScalarDimensions()
{
return externalScalarDimensions_;
}
inline const
UPtrList<scalar>& equationReader::outputScalars() const
{
return outputScalars_;
}
inline UPtrList<scalar>& equationReader::outputScalars()
{
return outputScalars_;
}
inline const
wordList& equationReader::outputScalarNames() const
{
return outputScalarNames_;
}
inline
wordList& equationReader::outputScalarNames()
{
return outputScalarNames_;
}
inline const
PtrList<dimensionSet>& equationReader::outputScalarDimensions() const
{
return outputScalarDimensions_;
}
inline
PtrList<dimensionSet>& equationReader::outputScalarDimensions()
{
return outputScalarDimensions_;
}
inline const
UPtrList< scalarList>& equationReader::outputScalarLists() const
{
return outputScalarLists_;
}
//- Access to pointers to output scalarLists
inline UPtrList<scalarList>& equationReader::outputScalarLists()
{
return outputScalarLists_;
}
//- Const access to dimensions associated with outputScalarLists
inline const
PtrList<dimensionSet>& equationReader::outputScalarListDimensions() const
{
return outputScalarListDimensions_;
}
//- Access to dimensions associated with outputScalarLists
inline PtrList<dimensionSet>& equationReader::outputScalarListDimensions()
{
return outputScalarListDimensions_;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,122 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "equationReader.H"
#include "fileNameList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::Ostream& Foam::equationReader::dataSourceStatus(Ostream& os) const
{
dictionary dict;
fileNameList dictPaths(dictSources_.size());
forAll(dictSources_, i)
{
dictPaths[i] = dictSources_[i].name();
}
dict.set("dictSources", dictPaths);
dict.set("dictLookups", dictLookups_);
dict.set("externalDScalars", externalDScalars_);
dict.set("externalScalars", externalScalars_);
dict.set("externalScalarNames", externalScalarNames_);
dict.set("externalScalarListName", externalScalarListNames_);
dict.set("externalScalarListDimensions", externalScalarListDimensions_);
dict.set("externalScalarListIndices", externalScalarListIndex_);
PtrList<dimensionedScalar> outputScalarList;
forAll(eqns_, i)
{
if (outputScalars_.set(i))
{
outputScalarList.setSize(outputScalarList.size() + 1);
outputScalarList.set
(
outputScalarList.size() - 1,
new dimensionedScalar
(
outputScalarNames_[i],
outputScalarDimensions_[i],
outputScalars_[i]
)
);
}
}
dict.set("outputScalars", outputScalarList);
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.eqns_, i)
{
dictionary eqnEntry;
eqnEntry.set(I.eqns_[i].equationName(), I.eqns_[i]);
eqnEntry.set("lastResult", I.eqns_[i].lastResult());
if (I.outputScalars_.set(i))
{
dimensionedScalar ds
(
I.outputScalarNames_[i],
I.outputScalarDimensions_[i],
I.outputScalars_[i]
);
eqnEntry.set("outputVar", ds);
}
eqnsDict.set(I.eqns_[i].equationName(), eqnEntry);
}
dictionary dict;
dict.set("equations", eqnsDict);
os << dict;
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,672 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::equationReader::parse(label index)
{
if (debug)
{
Info << "Parsing equation " << eqns_[index].equationName()
<< " at index " << index << "." << endl;
}
if ((index > eqns_.size()) || (index < 0))
{
FatalErrorIn("equationReader::parse(index)")
<< "Index " << index << " out of bounds (0, "
<< eqns_.size() - 1 << ")"
<< abort(FatalError);
}
eqns_[index].clear();
// 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
(
eqns_[index].rawText().string::find(":") != string::npos
&& eqns_[index].rawText().string::find("&") != string::npos
)
{
FatalErrorIn("equationReader::parse")
<< "Parsing error in the equation for "
<< eqns_[index].equationName() << ", given by:" << token::NL
<< token::NL << token::TAB << eqns_[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(eqns_[index].rawText()));
tokenList tl;
// Read tokens from raw equation string stream
while (!rawStream.eof())
{
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);
}
}
// map:
// - variable / constant: conatins source data only (first three fields)
// - operation: conatains operation number only (last field)
// - brackets, comma: all are zero
equationOperationList 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);
/* Useful for debugging, left in
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
eqns_[index].setSize(eqns_[index].size() + 3);
// retrieve parameter value
eqns_[index].ops()[eqns_[index].size() - 3] = equationOperation
(
map[resultIndex].sourceList(),
map[resultIndex].sourceIndex(),
map[resultIndex].dictLookupIndex(),
equationOperation::otretrieve
);
// perform function operation
currentIndex = findIndex(resultIndex, eqnIndices);
eqns_[index].ops()[eqns_[index].size() - 2] = equationOperation
(
equationOperation::slnone,
0,
0,
map[eqnIndices[currentIndex - 1]].operation()
);
// store result
storeIndex++;
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation
(
equationOperation::slstorage,
storeIndex + 1,
0,
equationOperation::otstore
);
// Set term in map to store location
map[resultIndex] =
eqns_[index].ops()[eqns_[index].ops().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
eqns_[index].setSize(eqns_[index].size() + 3);
eqns_[index].ops()[eqns_[index].size() - 3] = equationOperation
(
map[resultIndex].sourceList(),
map[resultIndex].sourceIndex(),
map[resultIndex].dictLookupIndex(),
equationOperation::otretrieve
);
// perform the function operation (2nd parameter is source)
label currentIndex(findIndex(resultIndex, eqnIndices));
eqns_[index].ops()[eqns_[index].size() - 2] = equationOperation
(
map[resultIndex2].sourceList(),
map[resultIndex2].sourceIndex(),
map[resultIndex2].dictLookupIndex(),
map[eqnIndices[currentIndex - 1]].operation()
);
// store result
storeIndex++;
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation
(
equationOperation::slstorage,
storeIndex + 1,
0,
equationOperation::otstore
);
// Set term in map to store location
map[resultIndex] = eqns_[index].ops()[eqns_[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 (eqns_[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
eqns_[index].setSize(eqns_[index].size() + 2);
// retrieve parameter value
eqns_[index].ops()[eqns_[index].size() - 2] = equationOperation
(
map[subEqnIndices[0]].sourceList(),
map[subEqnIndices[0]].sourceIndex(),
map[subEqnIndices[0]].dictLookupIndex(),
equationOperation::otretrieve
);
// Store this result
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation
(
equationOperation::slstorage,
storeIndex + 1,
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.
eqns_[index].setSize(eqns_[index].size() + 1);
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation
(
map[eqnIndices[0]].sourceList(),
map[eqnIndices[0]].sourceIndex(),
map[eqnIndices[0]].dictLookupIndex(),
equationOperation::otretrieve
);
// Link the eval function pointers (for efficiency)
assignFunctionPointers(index);
}
Foam::label Foam::equationReader::parseExpression
(
label index,
const tokenList& tl,
const labelList& opLvl,
equationOperationList& map,
const labelList& indices,
label& storeIndex
)
{
// 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
);
}
eqns_[index].setSize(eqns_[index].size() + 1);
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation
(
map[opIndices[0]].sourceList(),
map[opIndices[0]].sourceIndex(),
map[opIndices[0]].dictLookupIndex(),
equationOperation::otretrieve
);
trimListWithParent(subIndices, opIndices, 0, 0);
// Begin operations loop
while (opIndices.size() > 1)
{
eqns_[index].setSize(eqns_[index].size() + 1);
eqns_[index].ops()[eqns_[index].size() - 1] = equationOperation
(
map[opIndices[1]].sourceList(),
map[opIndices[1]].sourceIndex(),
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
eqns_[index].setSize(eqns_[index].size() + 1);
storeIndex++;
eqns_[index].ops()[eqns_[index].size() - 1] =
equationOperation
(
equationOperation::slstorage,
storeIndex + 1,
0,
equationOperation::otstore
);
returnMe = opIndices[1];
map[opIndices[1]] =
eqns_[index].ops()[eqns_[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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -1,108 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class GeoMesh>
void Foam::equationReader::addDataSource
(
const DimensionedField<scalar, GeoMesh>& dfield
)
{
// const scalarList * slist(&dfield);
word name(dfield.name());
dimensionSet dims(dfield.dimensions());
addDataSource(dfield, name, dims);
}
template<class GeoMesh>
void Foam::equationReader::evaluateField
(
const label& index,
DimensionedField<scalar, GeoMesh>& dfield
)
{
evaluateField(index, dfield, dfield.dimensions());
}
template<class GeoMesh>
void Foam::equationReader::linkOutput
(
const word& eqnName,
DimensionedField<scalar, GeoMesh>& dfield
)
{
label index(lookup(eqnName));
if (index < 0)
{
FatalErrorIn("equationReader::linkOutput")
<< "Equation name " << eqnName << "not found."
<< abort(FatalError);
}
linkOutput
(
index,
dfield,
dfield.dimensions()
);
}
template<class GeoMesh>
void Foam::equationReader::linkOutput
(
label index,
DimensionedField<scalar, GeoMesh>& dfield
)
{
linkOutput
(
index,
dfield,
dfield.dimensions()
);
}
template<class GeoMesh>
void Foam::equationReader::readEquation
(
equation eqn,
DimensionedField<scalar, GeoMesh>& dfield
)
{
readEquation
(
eqn,
dfield,
dfield.dimensions()
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,41 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0);
}
fixedWalls
{
type fixedValue;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View file

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

View file

@ -1,39 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
movingWall
{
type zeroGradient;
}
fixedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //

View file

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

View file

@ -1,40 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5-dev |
| \\ / A nd | Revision: exported |
| \\/ M anipulation | Web: http://www.OpenFOAM.org |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
3
(
movingWall
{
type wall;
nFaces 20;
startFace 760;
}
fixedWalls
{
type wall;
nFaces 60;
startFace 780;
}
frontAndBack
{
type empty;
nFaces 800;
startFace 840;
}
)
// ************************************************************************* //

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

@ -1,58 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default none;
laplacian(nu,U) Gauss linear corrected;
laplacian((1|A(U)),p) Gauss linear corrected;
}
interpolationSchemes
{
default linear;
interpolate(HbyA) linear;
}
snGradSchemes
{
default corrected;
}
fluxRequired
{
default no;
p;
}
// ************************************************************************* //

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict5;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
fivea 1.0;
fiveb 1.0;
fivec 1.0;
fived 1.0;
fivee 1.0;
fivef 1.0;
fiveg 1.0;
fiveh 1.0;
fivei 1.0;
fivej 1.0;

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict6;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
sixa 1.0;
sixb 1.0;
sixc 1.0;
sixd 1.0;
sixe 1.0;
sixf 1.0;
sixg 1.0;
sixh 1.0;
sixi 1.0;
sixj 1.0;

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict7;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
sevena sevena [0 0 0 0 0 0 0] 1.0;
sevenb sevenb [0 0 0 0 0 0 0] 1.0;
sevenc sevenc [0 0 0 0 0 0 0] 1.0;
sevend sevend [0 0 0 0 0 0 0] 1.0;
sevene sevene [0 0 0 0 0 0 0] 1.0;
sevenf sevenf [0 0 0 0 0 0 0] 1.0;
seveng seveng [0 0 0 0 0 0 0] 1.0;
sevenh sevenh [0 0 0 0 0 0 0] 1.0;
seveni seveni [0 0 0 0 0 0 0] 1.0;
sevenj sevenj [0 0 0 0 0 0 0] 1.0;

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict8;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
eighta eighta [0 0 0 0 0 0 0] 1.0;
eightb eightb [0 0 0 0 0 0 0] 1.0;
eightc eightc [0 0 0 0 0 0 0] 1.0;
eightd eightd [0 0 0 0 0 0 0] 1.0;
eighte eighte [0 0 0 0 0 0 0] 1.0;
eightf eightf [0 0 0 0 0 0 0] 1.0;
eightg eightg [0 0 0 0 0 0 0] 1.0;
eighth eighth [0 0 0 0 0 0 0] 1.0;
eighti eighti [0 0 0 0 0 0 0] 1.0;
eightj eightj [0 0 0 0 0 0 0] 1.0;

View file

@ -1,27 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict9;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Sa..Sl; DSa..DSo; Aa..Af; Pa..Pf
ninea "nineb";
nineb "ninec";
ninec "nined";
nined "ninee";
ninee "ninef";
ninef "nineg";
nineg "nineh";
nineh "ninei";
ninei "ninej";
ninej 1.0;