Merge latest nextRelease

--HG--
branch : bgschaid/minorAdditionsBranch
This commit is contained in:
Bernhard F.W. Gschaider 2013-10-10 16:14:21 +02:00
commit 40f9c7af23
554 changed files with 22243 additions and 14300 deletions

2
.gitignore vendored
View file

@ -84,6 +84,8 @@ etc/cshrc
etc/bashrc etc/bashrc
etc/settings.csh etc/settings.csh
etc/settings.sh etc/settings.sh
etc/pref.csh
etc/pref.sh
# make sure that this settings file is not used # make sure that this settings file is not used
etc/bashrc.preset etc/bashrc.preset

3
Allclean Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
rmdepall
wcleanLnIncludeAll

View file

@ -13,7 +13,6 @@ fi
( cd wmake/src && make ) ( cd wmake/src && make )
# build ThirdParty sources # build ThirdParty sources
#( cd $WM_THIRD_PARTY_DIR && ./Allwmake )
# ( cd $WM_THIRD_PARTY_DIR && ./AllMake ) # ( cd $WM_THIRD_PARTY_DIR && ./AllMake )
# We make sure the ThirdParty packages environment variables are up-to-date # We make sure the ThirdParty packages environment variables are up-to-date

60
Allwmake.firstInstall Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
cd ${0%/*} || exit 1 # run from this directory
if [ "$PWD" != "$WM_PROJECT_DIR" ]
then
echo
echo "Error: Current directory is not \$WM_PROJECT_DIR"
echo " The environment variables are not consistent with the installation."
echo " Please source configuration files."
echo
echo "Examples:"
echo " bash: . etc/bashrc"
echo " tcsh: source etc/cshrc"
echo
echo " If you sourced the configuration files, please check the 'foamInstall' entry."
echo
exit 1
fi
if [ -z "$PARAVIEW_SYSTEM" ] && [ -z "$QT_BIN_DIR" ]
then
echo
echo "\$QT_BIN_DIR not set. To compile Paraview from sources"
echo "the command \$QT_BIN_DIR/qmake needs to be valid."
echo
echo "Examples: "
echo " Ubuntu: \"export QT_BIN_DIR=/usr/bin\""
echo " Fedora: \"export QT_BIN_DIR=????\""
echo " openSuse: \"export QT_BIN_DIR=????\""
echo
read -r -p "Proceed without compiling ParaView [Y/n] " response
if [[ $response =~ ^([nN][oO]|[nN])$ ]]
then
exit 0
fi
fi
# wmake is required for subsequent targets
( cd wmake/src && make )
# build ThirdParty sources
( cd $WM_THIRD_PARTY_DIR && ./AllMake.pre )
# We make sure the ThirdParty packages environment variables are up-to-date
# before compiling the rest of OpenFOAM
. $WM_PROJECT_DIR/etc/settings.sh
# build OpenFOAM libraries and applications
src/Allwmake
applications/Allwmake
if [ "$1" = doc ]
then
doc/Allwmake
fi
# build ThirdParty sources that depend on main installation
( cd $WM_THIRD_PARTY_DIR && ./AllMake.post )
# ----------------------------------------------------------------- end-of-file

70
ThirdParty/AllMake.post vendored Executable file
View file

@ -0,0 +1,70 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# AllMake
#
# Description
# Build script for ThirdParty packages.
# You can pass along a list of package RPMs to this script in order
# to populate the local RPM vault before proceeding to the various
# packages installation
#
#
# Author:
# Martin Beaudoin, Hydro-Quebec, (2010)
# Converted to AllMake.post: Dominik Christ, Wikki Ltd, (2013)
#
#------------------------------------------------------------------------------
# run from third-party directory only
cd ${0%/*} || exit 1
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
. tools/makeThirdPartyFunctionsForRPM
#------------------------------------------------------------------------------
echo ========================================
echo Starting ThirdParty Allwmake
echo ========================================
echo
# Running stage 5
# This stage depends on a properly compiled installation
# of OpenFOAM. On a brand new installation of OpenFOAM-1.6-ext,
# this stage should be called last in your compilation process
./AllMake.stage5
echo ========================================
echo Done ThirdParty Allwmake
echo ========================================
echo
# ----------------------------------------------------------------- end-of-file

83
ThirdParty/AllMake.pre vendored Executable file
View file

@ -0,0 +1,83 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / 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 3 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, see <http://www.gnu.org/licenses/>.
#
# Script
# AllMake
#
# Description
# Build script for ThirdParty packages.
# You can pass along a list of package RPMs to this script in order
# to populate the local RPM vault before proceeding to the various
# packages installation
#
#
# Author:
# Martin Beaudoin, Hydro-Quebec, (2010)
# Converted to AllMake.Pre: Dominik Christ, Wikki Ltd, (2013)
#
#------------------------------------------------------------------------------
# run from third-party directory only
cd ${0%/*} || exit 1
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
. tools/makeThirdPartyFunctionsForRPM
#------------------------------------------------------------------------------
echo ========================================
echo Starting ThirdParty Allwmake.pre
echo ========================================
echo
# Running stage 0 (only if RPM filenames are supplied on the command line)
[ "$#" -gt 0 ] && {
./AllMake.stage0 "$@"
shift "$#"
}
# Running stage 1
./AllMake.stage1
# Running stage 2
./AllMake.stage2
# Running stage 3
./AllMake.stage3
# Running stage 4
./AllMake.stage4
echo ========================================
echo Done ThirdParty Allwmake.pre
echo ========================================
echo
# ----------------------------------------------------------------- end-of-file

View file

@ -127,7 +127,8 @@ Group: Development/Tools
--disable-mpi-f90 \ --disable-mpi-f90 \
--disable-mpi-cxx \ --disable-mpi-cxx \
--without-slurm \ --without-slurm \
--enable-mpi-profile $mpiWith --enable-mpi-profile $mpiWith \
--disable-vt
[ -z "$WM_NCOMPPROCS" ] && WM_NCOMPPROCS=1 [ -z "$WM_NCOMPPROCS" ] && WM_NCOMPPROCS=1
make -j $WM_NCOMPPROCS make -j $WM_NCOMPPROCS

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/multiSolver/lnInclude \ -I../../../../src/multiSolver/lnInclude
-I$(LIB_SRC)/multiSolver/multiSolver
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \

View file

@ -26,7 +26,8 @@ Application
multiSolverDemo multiSolverDemo
Description Description
Demonstration multiSolver-enabled application. Combination of icoFoam and scalarTransportFoam for testing of new multiTime
framework.
Author Author
David L. F. Gaden David L. F. Gaden
@ -61,8 +62,10 @@ int main(int argc, char *argv[])
# include "solverScalarTransportFoam.H" # include "solverScalarTransportFoam.H"
// Only necessary if we revisit the same solver domain twice in the same
// superLoop (scalarTransportFoam, in this case)
multiRun++; multiRun++;
// * * * * * * * * * * * * * * * * icoFoam2 * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * icoFoam2 * * * * * * * * * * * * * * * * //
Info << "*** Switching to icoFoam2 ***\n" << endl; Info << "*** Switching to icoFoam2 ***\n" << endl;

View file

@ -31,7 +31,7 @@
volScalarField rUA = 1.0/UEqn.A(); volScalarField rUA = 1.0/UEqn.A();
U = rUA*UEqn.H(); U = rUA*UEqn.H();
phi = (fvc::interpolate(U) & mesh.Sf()) phi = (fvc::interpolate(U) & mesh.Sf())
+ fvc::ddtPhiCorr(rUA, U, phi); + fvc::ddtPhiCorr(rUA, U, phi);
adjustPhi(phi, U, p); adjustPhi(phi, U, p);

View file

@ -12,7 +12,13 @@
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
# include "readSIMPLEControls.H" dictionary simple = mesh.solutionDict().subDict("SIMPLE");
int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
bool momentumPredictor =
simple.lookupOrDefault<Switch>("momentumPredictor", true);
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{ {

View file

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

View file

@ -1,20 +0,0 @@
#!/bin/sh
set -x
wclean solidModels
wclean elasticContactSolidFoam
wclean elasticContactIncrSolidFoam
wclean elasticContactNonLinULSolidFoam
wclean elasticGravitySolidFoam
wclean elasticIncrSolidFoam
wclean elasticNonLinTLSolidFoam
wclean elasticNonLinULSolidFoam
wclean elasticPlasticSolidFoam
wclean elasticPlasticNonLinULSolidFoam
wclean elasticSolidFoam
wclean elasticThermalSolidFoam
wclean icoFsiElasticNonLinULSolidFoam
wclean viscoElasticSolidFoam
(cd utilities && ./Allwclean)

View file

@ -1,11 +1,13 @@
#!/bin/sh #!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
set -x set -x
wmake libso solidModels wmake libso solidModels
wmake elasticContactSolidFoam
wmake elasticContactIncrSolidFoam wmake elasticContactIncrSolidFoam
wmake elasticContactNonLinULSolidFoam wmake elasticContactNonLinULSolidFoam
wmake elasticContactSolidFoam
wmake elasticGravitySolidFoam wmake elasticGravitySolidFoam
wmake elasticIncrSolidFoam wmake elasticIncrSolidFoam
wmake elasticNonLinTLSolidFoam wmake elasticNonLinTLSolidFoam
@ -16,5 +18,3 @@ wmake elasticSolidFoam
wmake elasticThermalSolidFoam wmake elasticThermalSolidFoam
wmake icoFsiElasticNonLinULSolidFoam wmake icoFsiElasticNonLinULSolidFoam
wmake viscoElasticSolidFoam wmake viscoElasticSolidFoam
(cd utilities && ./Allwmake)

View file

@ -1,3 +1,3 @@
elasticContactIncrSolidFoam.C elasticContactIncrSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticContactIncrSolidFoam EXE = $(FOAM_APPBIN)/elasticContactIncrSolidFoam

View file

@ -1,3 +1,3 @@
elasticContactNonLinULSolidFoam.C elasticContactNonLinULSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticContactNonLinULSolidFoam EXE = $(FOAM_APPBIN)/elasticContactNonLinULSolidFoam

View file

@ -1,3 +1,3 @@
elasticContactSolidFoam.C elasticContactSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticContactSolidFoam EXE = $(FOAM_APPBIN)/elasticContactSolidFoam

View file

@ -1,3 +1,3 @@
elasticGravitySolidFoam.C elasticGravitySolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticGravitySolidFoam EXE = $(FOAM_APPBIN)/elasticGravitySolidFoam

View file

@ -1,3 +1,3 @@
elasticIncrSolidFoam.C elasticIncrSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticIncrSolidFoam EXE = $(FOAM_APPBIN)/elasticIncrSolidFoam

View file

@ -1,3 +1,3 @@
elasticNonLinTLSolidFoam.C elasticNonLinTLSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticNonLinTLSolidFoam EXE = $(FOAM_APPBIN)/elasticNonLinTLSolidFoam

View file

@ -1,3 +1,3 @@
elasticNonLinULSolidFoam.C elasticNonLinULSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticNonLinULSolidFoam EXE = $(FOAM_APPBIN)/elasticNonLinULSolidFoam

View file

@ -1,3 +1,3 @@
elasticPlasticNonLinULSolidFoam.C elasticPlasticNonLinULSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticPlasticNonLinULSolidFoam EXE = $(FOAM_APPBIN)/elasticPlasticNonLinULSolidFoam

View file

@ -1,3 +1,3 @@
elasticPlasticSolidFoam.C elasticPlasticSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticPlasticSolidFoam EXE = $(FOAM_APPBIN)/elasticPlasticSolidFoam

View file

@ -1,3 +1,3 @@
elasticSolidFoam.C elasticSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticSolidFoam EXE = $(FOAM_APPBIN)/elasticSolidFoam

View file

@ -1,3 +1,3 @@
elasticThermalSolidFoam.C elasticThermalSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/elasticThermalSolidFoam EXE = $(FOAM_APPBIN)/elasticThermalSolidFoam

View file

@ -2,4 +2,4 @@
icoFsiElasticNonLinULSolidFoam.C icoFsiElasticNonLinULSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/icoFsiElasticNonLinULSolidFoam EXE = $(FOAM_APPBIN)/icoFsiElasticNonLinULSolidFoam

View file

@ -1,6 +0,0 @@
#!/bin/sh
set -x
wclean foamMeshToAbaqus
wclean setMatFromCellZones
wclean patchStressIntegrate

View file

@ -1,7 +0,0 @@
#!/bin/sh
set -x
wmake foamMeshToAbaqus
wmake setMatFromCellZones
wmake patchStressIntegrate

View file

@ -1,3 +0,0 @@
foamMeshToAbaqus.C
EXE = $(FOAM_USER_APPBIN)/foamMeshToAbaqus

View file

@ -1,3 +0,0 @@
patchStressIntegrate.C
EXE = $(FOAM_USER_APPBIN)/patchStressIntegrate

View file

@ -1,3 +0,0 @@
setMatFromCellZones.C
EXE = $(FOAM_USER_APPBIN)/setMatFromCellZones

View file

@ -1,3 +1,3 @@
viscoElasticSolidFoam.C viscoElasticSolidFoam.C
EXE = $(FOAM_USER_APPBIN)/viscoElasticSolidFoam EXE = $(FOAM_APPBIN)/viscoElasticSolidFoam

View file

@ -37,7 +37,7 @@ namespace Foam
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchTypeField makeTemplatePointPatchTypeField
( (
tetPolyPatchVectorField, tetPolyPatchVectorField,
tractionTetPolyPatchVectorField tractionTetPolyPatchVectorField

View file

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

View file

@ -86,6 +86,7 @@ class mergePolyMesh
//- Cell zones //- Cell zones
DynamicList<label> cellZones_; DynamicList<label> cellZones_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct

View file

@ -113,7 +113,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
// Algorithm: // Algorithm:
// During mirroring, the faces that were previously boundary faces // During mirroring, the faces that were previously boundary faces
// in the mirror plane may become ineternal faces. In order to // in the mirror plane may become internal faces. In order to
// deal with the ordering of the faces, the algorithm is split // deal with the ordering of the faces, the algorithm is split
// into two parts. For original faces, the internal faces are // into two parts. For original faces, the internal faces are
// distributed to their owner cells. Once all internal faces are // distributed to their owner cells. Once all internal faces are

View file

@ -1,7 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/multiSolver/lnInclude \ -I../../../../src/multiSolver/lnInclude
-I$(LIB_SRC)/multiSolver/multiSolver
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \

View file

@ -49,11 +49,18 @@ void parseOptions
IStringStream optionsStream(options); IStringStream optionsStream(options);
label nSolverDomains(0); label nSolverDomains(0);
label nSuperLoops(0); label nSuperLoops(0);
// Get solverDomainNames, if any // Get solverDomainNames, if any
while (not optionsStream.eof()) while (not optionsStream.eof())
{ {
token nextOption(optionsStream); token nextOption(optionsStream);
// Bug workaround
if (nextOption.type() == token::ERROR)
{
break;
}
if (nextOption.isLabel()) if (nextOption.isLabel())
{ {
ptrSuperLoops->setSize(++nSuperLoops); ptrSuperLoops->setSize(++nSuperLoops);
@ -76,18 +83,25 @@ void parseOptions
<< abort(FatalError); << abort(FatalError);
} }
} }
// Get superLoopList // Get superLoopList
while (not optionsStream.eof()) while (not optionsStream.eof())
{ {
token nextOption(optionsStream); token nextOption(optionsStream);
// Bug workaround
if (nextOption.type() == token::ERROR)
{
break;
}
if (nextOption.isLabel()) if (nextOption.isLabel())
{ {
ptrSuperLoops->setSize(++nSuperLoops); ptrSuperLoops->setSize(++nSuperLoops);
ptrSuperLoops->operator[](nSuperLoops - 1) ptrSuperLoops->operator[](nSuperLoops - 1)
= nextOption.labelToken(); = nextOption.labelToken();
} }
else if (nSuperLoops > 0) else if (nSuperLoops > 0)
{ {
// might be a range -> label : label // might be a range -> label : label
@ -104,7 +118,7 @@ void parseOptions
( (
ptrSuperLoops->operator[](nSuperLoops - 1) ptrSuperLoops->operator[](nSuperLoops - 1)
); );
if (toValue > fromValue) if (toValue > fromValue)
{ {
// correct range format // correct range format
@ -182,20 +196,20 @@ int main(int argc, char *argv[])
argList::validOptions.insert("postDecompose", ""); argList::validOptions.insert("postDecompose", "");
argList::validOptions.insert("preReconstruct", ""); argList::validOptions.insert("preReconstruct", "");
argList::validOptions.insert("postReconstruct", ""); argList::validOptions.insert("postReconstruct", "");
argList::validOptions.insert("global",""); argList::validOptions.insert("global","");
argList::validOptions.insert("local",""); argList::validOptions.insert("local","");
// default behaviour is purge the case/[time] directory before '-load' // default behaviour is purge the case/[time] directory before '-load'
// command. '-noPurge' prevents this. Allows for more complicated // command. '-noPurge' prevents this. Allows for more complicated
// load data selections by executing multiSolver several times // load data selections by executing multiSolver several times
argList::validOptions.insert("noPurge",""); argList::validOptions.insert("noPurge","");
// default behaviour is: if there is only one solverDomain specified, use // default behaviour is: if there is only one solverDomain specified, use
// setSolverDomain() on it. Same as multiSolver -set solverDomain. // setSolverDomain() on it. Same as multiSolver -set solverDomain.
// '-noSet' prevents this. // '-noSet' prevents this.
argList::validOptions.insert("noSet",""); argList::validOptions.insert("noSet","");
// default behaviour is: if there are storeFields defined, when loading, it // default behaviour is: if there are storeFields defined, when loading, it
// will copy the store fields into every time instance where they are // will copy the store fields into every time instance where they are
// absent. '-noStore' will prevent this. // absent. '-noStore' will prevent this.
@ -224,7 +238,7 @@ int main(int argc, char *argv[])
bool noSet = false; bool noSet = false;
bool noStore = false; bool noStore = false;
label nCommands(0); label nCommands(0);
// Read arguments // Read arguments
if (args.optionFound("list")) if (args.optionFound("list"))
{ {
@ -331,7 +345,7 @@ int main(int argc, char *argv[])
args.rootPath(), args.rootPath(),
args.caseName() args.caseName()
); );
const IOdictionary& mcd(multiRun.multiControlDict()); const IOdictionary& mcd(multiRun.multiControlDict());
wordList solverDomains(0); wordList solverDomains(0);
labelList superLoops(0); labelList superLoops(0);
@ -420,7 +434,7 @@ int main(int argc, char *argv[])
{ {
// Incorrect solver domain name // Incorrect solver domain name
FatalErrorIn("multiSolver::main") FatalErrorIn("multiSolver::main")
<< "solverDomainName " << solverDomains[i] << " is not " << "solverDomainName " << solverDomains[i] << "is not "
<< "found." << "found."
<< abort(FatalError); << abort(FatalError);
} }
@ -504,7 +518,7 @@ int main(int argc, char *argv[])
<< "No data found with specified parameters." << "No data found with specified parameters."
<< abort(FatalError); << abort(FatalError);
} }
} }
switch (command) switch (command)
{ {
@ -517,7 +531,7 @@ int main(int argc, char *argv[])
( (
multiRun.multiDictRegistry().path()/"multiSolver" multiRun.multiDictRegistry().path()/"multiSolver"
); );
forAll(solverDomains, i) forAll(solverDomains, i)
{ {
if (solverDomains[i] == "default") continue; if (solverDomains[i] == "default") continue;
@ -561,7 +575,7 @@ int main(int argc, char *argv[])
<< endl; << endl;
multiRun.purgeTimeDirs(multiRun.multiDictRegistry().path()); multiRun.purgeTimeDirs(multiRun.multiDictRegistry().path());
} }
Info << "Loading data from multiSolver directories to case root" Info << "Loading data from multiSolver directories to case root"
<< endl; << endl;
if if
@ -634,7 +648,7 @@ int main(int argc, char *argv[])
( (
dirEntries[de] dirEntries[de]
); );
// Copy system to processorN // Copy system to processorN
cp cp
( (
@ -642,7 +656,7 @@ int main(int argc, char *argv[])
/multiRun.multiDictRegistry().system(), /multiRun.multiDictRegistry().system(),
multiRun.multiDictRegistry().path()/dirEntries[de] multiRun.multiDictRegistry().path()/dirEntries[de]
); );
// Copy constant/files to processorN/constant // Copy constant/files to processorN/constant
fileNameList constantContents fileNameList constantContents
( (
@ -664,7 +678,7 @@ int main(int argc, char *argv[])
/multiRun.multiDictRegistry().constant() /multiRun.multiDictRegistry().constant()
); );
} }
// Copy constant/directories to processorN/constant // Copy constant/directories to processorN/constant
constantContents = readDir constantContents = readDir
( (
@ -731,7 +745,7 @@ int main(int argc, char *argv[])
Info << "Purging preconditioned time directories" Info << "Purging preconditioned time directories"
<< endl; << endl;
// Clean up extra time directories // Clean up extra time directories
fileNameList dirEntries fileNameList dirEntries
( (
@ -758,7 +772,7 @@ int main(int argc, char *argv[])
// Execute set command - either from an explicit '-set' or from a '-load' // Execute set command - either from an explicit '-set' or from a '-load'
// with only one solverDomain as an option // with only one solverDomain as an option
if if
( (
(command == set) (command == set)
|| ( || (

View file

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

View file

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

View file

@ -3,9 +3,9 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #-------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM. # This file is part of OpenFOAM.
# #
@ -33,14 +33,18 @@
# personal settings to site-wide settings. # personal settings to site-wide settings.
# #
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh: # For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
# @verbatim # \code
# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \ # foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \
# && _foamSource $foamPrefs # && _foamSource $foamPrefs
# @endverbatim # \endcode
# #
#------------------------------------------------------------------------------ # Note
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
#
#-------------------------------------------------------------------------------
usage() { usage() {
[ "$quietOpt" = true ] && exit 1 [ "${optQuiet:-$optSilent}" = true ] && exit 1
exec 1>&2 exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
@ -49,10 +53,12 @@ usage() {
Usage: ${0##*/} [OPTION] fileName Usage: ${0##*/} [OPTION] fileName
${0##*/} [OPTION] -list ${0##*/} [OPTION] -list
options: options:
-all return all files (otherwise stop after the first match)
-list list the directories to be searched -list list the directories to be searched
-mode <mode> any combination of u(user), g(group), o(other) -mode <mode> any combination of u(user), g(group), o(other)
-prefix <dir> specify an alternative installation prefix -prefix <dir> specify an alternative installation prefix
-quiet suppress all normal output -quiet suppress all normal output
-silent suppress all stderr output
-version <ver> specify an alternative OpenFOAM version -version <ver> specify an alternative OpenFOAM version
in the form Maj.Min.Rev (eg, 1.7.0) in the form Maj.Min.Rev (eg, 1.7.0)
-help print the usage -help print the usage
@ -72,13 +78,9 @@ USAGE
exit 1 exit 1
} }
# #-------------------------------------------------------------------------------
# This script must exist in <foamInstall>/OpenFOAM-<VERSION>/bin/
# or <foamInstall>/openfoam<VERSION>/bin/ (for the debian version)
#
#------------------------------------------------------------------------------
# the bindir: # the bin dir:
binDir="${0%/*}" binDir="${0%/*}"
# the project dir: # the project dir:
@ -128,7 +130,7 @@ esac
# default mode is 'ugo' # default mode is 'ugo'
mode=ugo mode=ugo
unset listOpt quietOpt unset optAll optList optQuiet optSilent
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
@ -137,8 +139,11 @@ do
-h | -help) -h | -help)
usage usage
;; ;;
-a | -all)
optAll=true
;;
-l | -list) -l | -list)
listOpt=true optList=true
;; ;;
-m | -mode) -m | -mode)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
@ -160,7 +165,10 @@ do
shift shift
;; ;;
-q | -quiet) -q | -quiet)
quietOpt=true optQuiet=true
;;
-s | -silent)
optSilent=true
;; ;;
-v | -version) -v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
@ -204,15 +212,15 @@ fileName="${1#~OpenFOAM/}"
unset dirList unset dirList
case "$mode" in case "$mode" in
*u*) # user *u*) # user
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$version" userDir="$HOME/.${WM_PROJECT:-OpenFOAM}"
dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}" dirList="$dirList $userDir/$version $userDir"
;; ;;
esac esac
case "$mode" in case "$mode" in
*g*) # group *g*) # group (site)
dirList="$dirList $prefixDir/site/$version" siteDir="${WM_PROJECT_SITE:-$prefixDir/site}"
dirList="$dirList $prefixDir/site" dirList="$dirList $siteDir/$version $siteDir"
;; ;;
esac esac
@ -235,14 +243,15 @@ set -- $dirList
# The main routine # The main routine
# #
if [ "$listOpt" = true ] exitCode=0
if [ "$optList" = true ]
then then
# list directories, or potential file locations # list directories, or potential file locations
[ "$nArgs" -le 1 ] || usage [ "$nArgs" -le 1 ] || usage
# a silly combination, but -quiet has precedence # a silly combination, but -quiet does have precedence
[ "$quietOpt" = true ] && exit 0 [ "$optQuiet" = true ] && exit 0
for dir for dir
do do
@ -253,25 +262,32 @@ then
echo "$dir" echo "$dir"
fi fi
done done
exit 0
else else
[ "$nArgs" -eq 1 ] || usage [ "$nArgs" -eq 1 ] || usage
# general error, eg file not found
exitCode=2
for dir for dir
do do
if [ -f "$dir/$fileName" ] if [ -f "$dir/$fileName" ]
then then
[ "$quietOpt" = true ] || echo "$dir/$fileName" exitCode=0
exit 0 if [ "$optQuiet" = true ]
then
break
else
echo "$dir/$fileName"
[ "$optAll" = true ] || break
fi
fi fi
done done
fi fi
# general error, eg file not found exit $exitCode
exit 2
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

135
bin/foamProbe Executable file
View file

@ -0,0 +1,135 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / 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
#
# Script
# foamProbe
#
# Description
# Proccess a scalar, vetorial or tensorial field of OpenFOAM
# probe file (for monitoring points). The original file will not be changed
# and the fields of each monitoring point will be stored in a new
# directory named probe<Name> (where <Name> is the field name) in the
# directory where are the original probes files.
# The fourth optional parameter can be used to create xmgrace sequentially
# graphs (case is 0)
# for monitoring points or automatically create eps figures (case is 1).
#
# Author:
# Jovani L. Favero, J. F. Mitre (2009)
#
#------------------------------------------------------------------------------
if [ $# -lt 3 ]; then
echo "Usage: foamProbe [<probes files directory> <numbers of monitoring points> <field name> <optional value: 0 - open in xmgrace, 1 - save to eps file>]"
exit 1
fi
# File name, NAME.
NAME=$(basename "$1")
DNAME="$1"
shift
# Number of points, P.
P="$1"
shift
NAME=$(basename "$1")
CNAME="$1"
shift
xmgrace=0
if [ $# -eq 1 ]; then
# Choose to save eps.
save="$1"
xmgrace=1
fi
if [ ! -d "$DNAME" ]; then
echo "Directory $DNAME does not exist."
exit 1
fi
if [ $P -lt 1 ]; then
echo "Can not be less than 1 single monitoring point."
exit 1
fi
cd $DNAME
if [ ! -f "$CNAME" ]; then
echo "Field $CNAME does not exist."
exit 1
fi
# Screen information
echo ""
echo "Wait: Processing $P point(s) in $CNAME file ...."
# Base directory to place processed files
DIR="./probe$NAME/"
if [ ! -d "$DIR" ]; then
mkdir "$DIR"
fi
sed -e "s/ *(/\t/g" -e 's/)//g' "$CNAME" >"$DIR/$NAME"
cd $DIR
column=1
while [ "$column" -le "$P" ]; do
point=$column
column=`expr $column + 1`
cut -f 1,$column "$NAME" |sed -e "s/\t/ /g" -e '/^#/d' >$NAME.base
echo -e "# Time \t Point_$point" >$NAME\_$point
cat $NAME.base >>$NAME\_$point
rm -f $NAME.base
done
cd - &>/dev/null
if [ "$xmgrace" = 1 ]; then
cd probe$CNAME/
field=1
underscore=_
while [ "$field" -le "$P" ]; do
point=$field
field=`expr $field + 1`
echo " Opening file $CNAME$underscore$point"
if [ "$save" = 0 ]; then
echo " Opened $CNAME$underscore$point"
xmgrace -nxy $CNAME\_$point -noask
fi
if [ "$save" -ne 0 ]; then
xmgrace -nxy $CNAME\_$point -hardcopy -printfile $CNAME\_$point.eps -hdevice EPS
echo " Saving file $CNAME$underscore$point.eps"
fi
echo " Closing file $CNAME$underscore$point"
echo ""
done
fi
echo ""
echo "Done!!!"
echo ""
exit 0

View file

@ -98,14 +98,19 @@ fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~
export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_INST_DIR=$FOAM_INST_DIR
export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
: ${WM_PROJECT_USER_DIR:=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION}; export WM_PROJECT_USER_DIR export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
# Location of third-party software
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION}; export WM_THIRD_PARTY_DIR
export WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty
# Source files, possibly with some verbosity # Source files, possibly with some verbosity
_foamSource() _foamSource()
{ {
while [ $# -ge 1 ] while [ $# -ge 1 ]
do do
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2
. $1 . $1
shift shift
done done
@ -115,12 +120,6 @@ _foamSource()
foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` && _foamSource $foamPrefs foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` && _foamSource $foamPrefs
unset foamPrefs unset foamPrefs
# Location of third-party software
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION}; export WM_THIRD_PARTY_DIR
: ${WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/ThirdParty}; export WM_THIRD_PARTY_DIR
# Evaluate command-line parameters # Evaluate command-line parameters
while [ $# -gt 0 ] while [ $# -gt 0 ]
do do

View file

@ -108,7 +108,7 @@ setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
setenv WM_THIRD_PARTY_DIR $WM_PROJECT_DIR/ThirdParty setenv WM_THIRD_PARTY_DIR $WM_PROJECT_DIR/ThirdParty
# Source files, possibly with some verbosity # Source files, possibly with some verbosity
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; source \!*' alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*'
# Add in preset user or site preferences: # Add in preset user or site preferences:
set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh` set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
@ -392,3 +392,4 @@ unset cleanEnv cleanProg colonPath foamInstall foamOldDirs
unalias _foamSource unalias _foamSource
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View file

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

View file

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

View file

@ -30,8 +30,7 @@ License
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
template<class T, unsigned Size> template<class T, unsigned Size>
const Foam::FixedList<T, Size> Foam::FixedList<T, Size>::zero = const Foam::FixedList<T, Size> Foam::FixedList<T, Size>::zero;
Foam::FixedList<T, Size>();
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //

View file

@ -38,7 +38,7 @@ License
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
template<class Type> template<class Type>
const Foam::List<Type> Foam::List<Type>::zero = Foam::List<Type>(); const Foam::List<Type> Foam::List<Type>::zero;
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //

View file

@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
template<class T> template<class T>
const Foam::UList<T> Foam::UList<T>::zero = UList<T>(); const Foam::UList<T> Foam::UList<T>::zero;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

View file

@ -69,14 +69,13 @@ void Foam::UPtrList<T>::setSize(const label newSize)
{ {
clear(); clear();
} }
else if (newSize < oldSize) else if (newSize != oldSize)
{ {
ptrs_.setSize(newSize); ptrs_.setSize(newSize);
} }
else if (newSize > oldSize)
{
ptrs_.setSize(newSize);
if (newSize > oldSize)
{
// set new elements to NULL // set new elements to NULL
for (register label i = oldSize; i < newSize; i++) for (register label i = oldSize; i < newSize; i++)
{ {

View file

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

View file

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

View file

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

View file

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

View file

@ -40,7 +40,8 @@ template<class Type>
const char* const Field<Type>::typeName("Field"); const char* const Field<Type>::typeName("Field");
template<class Type> template<class Type>
const Field<Type> Field<Type>::zero = Field<Type>(); const Field<Type> Field<Type>::zero;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -688,8 +689,7 @@ template<class Type>
template<class Form, class Cmpt, int nCmpt> template<class Form, class Cmpt, int nCmpt>
void Field<Type>::operator=(const VectorSpace<Form,Cmpt,nCmpt>& vs) void Field<Type>::operator=(const VectorSpace<Form,Cmpt,nCmpt>& vs)
{ {
typedef VectorSpace<Form,Cmpt,nCmpt> VSType; TFOR_ALL_F_OP_S(Type, *this, =, (VectorSpace<Form,Cmpt,nCmpt>), vs)
TFOR_ALL_F_OP_S(Type, *this, =, VSType, vs)
} }

View file

@ -589,21 +589,7 @@ const PointPatchField<PatchField, Mesh, PointPatch, MatrixType, Type>& operator+
#endif #endif
#define makePointPatchTypeFieldTypeName(typePatchTypeField) \ #define addToPointPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField) \
\
defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
#define makePointPatchFieldsTypeName(typePatchField, pointPatchType) \
\
makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##ScalarField); \
makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##VectorField); \
makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##SphericalTensorField); \
makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##SymmTensorField); \
makePointPatchTypeFieldTypeName(typePatchField##pointPatchType##TensorField);
#define makePointPatchTypeField(PatchTypeField, typePatchTypeField) \
\
defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
\ \
addToRunTimeSelectionTable \ addToRunTimeSelectionTable \
( \ ( \
@ -623,33 +609,85 @@ addToRunTimeSelectionTable \
); );
#define makePointPatchTypeFieldTypeName(typePatchTypeField) \
\
defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0);
#define makePointPatchFieldsTypeName(typePatchField, pointPatchType) \
\
makePointPatchTypeFieldTypeName \
( \
typePatchField##pointPatchType##ScalarField \
); \
\
makePointPatchTypeFieldTypeName \
( \
typePatchField##pointPatchType##VectorField \
); \
\
makePointPatchTypeFieldTypeName \
( \
typePatchField##pointPatchType##SphericalTensorField \
); \
\
makePointPatchTypeFieldTypeName \
( \
typePatchField##pointPatchType##SymmTensorField \
); \
\
makePointPatchTypeFieldTypeName \
( \
typePatchField##pointPatchType##TensorField \
);
#define makePointPatchTypeField(PatchTypeField, typePatchTypeField) \
\
defineTypeNameAndDebug(typePatchTypeField, 0); \
\
addToPointPatchFieldRunTimeSelection \
( \
PatchTypeField, typePatchTypeField \
);
#define makeTemplatePointPatchTypeField(PatchTypeField, typePatchTypeField) \
\
defineNamedTemplateTypeNameAndDebug(typePatchTypeField, 0); \
\
addToPointPatchFieldRunTimeSelection \
( \
PatchTypeField, typePatchTypeField \
);
#define makePointPatchFields(type, pointPatch, pointPatchType) \ #define makePointPatchFields(type, pointPatch, pointPatchType) \
\ \
makePointPatchTypeField \ makeTemplatePointPatchTypeField \
( \ ( \
pointPatch##ScalarField, \ pointPatch##ScalarField, \
type##pointPatchType##ScalarField \ type##pointPatchType##ScalarField \
); \ ); \
\ \
makePointPatchTypeField \ makeTemplatePointPatchTypeField \
( \ ( \
pointPatch##VectorField, \ pointPatch##VectorField, \
type##pointPatchType##VectorField \ type##pointPatchType##VectorField \
); \ ); \
\ \
makePointPatchTypeField \ makeTemplatePointPatchTypeField \
( \ ( \
pointPatch##SphericalTensorField, \ pointPatch##SphericalTensorField, \
type##pointPatchType##SphericalTensorField \ type##pointPatchType##SphericalTensorField \
); \ ); \
\ \
makePointPatchTypeField \ makeTemplatePointPatchTypeField \
( \ ( \
pointPatch##SymmTensorField, \ pointPatch##SymmTensorField, \
type##pointPatchType##SymmTensorField \ type##pointPatchType##SymmTensorField \
); \ ); \
\ \
makePointPatchTypeField \ makeTemplatePointPatchTypeField \
( \ ( \
pointPatch##TensorField, \ pointPatch##TensorField, \
type##pointPatchType##TensorField \ type##pointPatchType##TensorField \
@ -683,10 +721,24 @@ typedef Type##PointPatchField \
<pointPatch##Field, mesh, patchPatch, typePointPatch, matrixType, vector> \ <pointPatch##Field, mesh, patchPatch, typePointPatch, matrixType, vector> \
type##pointPatchType##VectorField; \ type##pointPatchType##VectorField; \
typedef Type##PointPatchField \ typedef Type##PointPatchField \
<pointPatch##Field, mesh, patchPatch, typePointPatch, matrixType, sphericalTensor>\ < \
pointPatch##Field, \
mesh, \
patchPatch, \
typePointPatch, \
matrixType, \
sphericalTensor \
> \
type##pointPatchType##SphericalTensorField; \ type##pointPatchType##SphericalTensorField; \
typedef Type##PointPatchField \ typedef Type##PointPatchField \
<pointPatch##Field, mesh, patchPatch, typePointPatch, matrixType, symmTensor>\ < \
pointPatch##Field, \
mesh, \
patchPatch, \
typePointPatch, \
matrixType, \
symmTensor \
> \
type##pointPatchType##SymmTensorField; \ type##pointPatchType##SymmTensorField; \
typedef Type##PointPatchField \ typedef Type##PointPatchField \
<pointPatch##Field, mesh, patchPatch, typePointPatch, matrixType, tensor> \ <pointPatch##Field, mesh, patchPatch, typePointPatch, matrixType, tensor> \

View file

@ -29,8 +29,8 @@ License
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
template<class Form, class Type> template<class Form, class Type>
const Foam::Matrix<Form, Type> Foam::Matrix<Form, Type>::zero = const Foam::Matrix<Form, Type> Foam::Matrix<Form, Type>::zero;
Foam::Matrix<Form, Type>();
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //

View file

@ -639,10 +639,7 @@ Foam::BlockAamgPolicy<Type>::restrictMatrix() const
// Matrix restriction done! // Matrix restriction done!
typedef CoeffField<Type> TypeCoeffField; typedef CoeffField<Type> TypeCoeffField;
typedef Field<Type> TypeField;
typedef typename TypeCoeffField::scalarTypeField scalarTypeField;
typedef typename TypeCoeffField::linearTypeField linearTypeField;
typedef typename TypeCoeffField::squareTypeField squareTypeField; typedef typename TypeCoeffField::squareTypeField squareTypeField;
TypeCoeffField& coarseUpper = coarseMatrix.upper(); TypeCoeffField& coarseUpper = coarseMatrix.upper();

View file

@ -57,12 +57,6 @@ void Foam::BlockGaussSeidelPrecon<Type>::BlockSweep
// Klas Jareteg: 2013-02-10: // Klas Jareteg: 2013-02-10:
// Must transfer data between the different CPUs. Notes on the Jacobi // Must transfer data between the different CPUs. Notes on the Jacobi
// iteration style can be seen in GaussSeidelSolver.C // iteration style can be seen in GaussSeidelSolver.C
typedef CoeffField<Type> TypeCoeffField;
typedef Field<Type> TypeField;
typedef typename TypeCoeffField::scalarTypeField scalarTypeField;
typedef typename TypeCoeffField::linearTypeField linearTypeField;
typedef typename TypeCoeffField::squareTypeField squareTypeField;
for (label sweep = 0; sweep < nSweeps_; sweep++) for (label sweep = 0; sweep < nSweeps_; sweep++)
{ {
@ -172,12 +166,6 @@ void Foam::BlockGaussSeidelPrecon<Type>::BlockSweep
// Klas Jareteg: 2013-02-10: // Klas Jareteg: 2013-02-10:
// Must transfer data between the different CPUs. Notes on the Jacobi // Must transfer data between the different CPUs. Notes on the Jacobi
// iteration style can be seen in GaussSeidelSolver.C // iteration style can be seen in GaussSeidelSolver.C
typedef CoeffField<Type> TypeCoeffField;
typedef Field<Type> TypeField;
typedef typename TypeCoeffField::scalarTypeField scalarTypeField;
typedef typename TypeCoeffField::linearTypeField linearTypeField;
typedef typename TypeCoeffField::squareTypeField squareTypeField;
for (label sweep = 0; sweep < nSweeps_; sweep++) for (label sweep = 0; sweep < nSweeps_; sweep++)
{ {

View file

@ -56,9 +56,7 @@ Foam::tmp<Foam::CoeffField<Type> > Foam::GAMGInterface::agglomerateBlockCoeffs
CoeffField<Type>& coarseCoeffs = tcoarseCoeffs(); CoeffField<Type>& coarseCoeffs = tcoarseCoeffs();
typedef CoeffField<Type> TypeCoeffField; typedef CoeffField<Type> TypeCoeffField;
typedef Field<Type> TypeField;
typedef typename TypeCoeffField::scalarTypeField scalarTypeField;
typedef typename TypeCoeffField::linearTypeField linearTypeField; typedef typename TypeCoeffField::linearTypeField linearTypeField;
typedef typename TypeCoeffField::squareTypeField squareTypeField; typedef typename TypeCoeffField::squareTypeField squareTypeField;

View file

@ -27,7 +27,7 @@ License
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
template<class T> template<class T>
const Foam::Xfer<T> Foam::Xfer<T>::zero = Foam::Xfer<T>(); const Foam::Xfer<T> Foam::Xfer<T>::zero;
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //

View file

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

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