Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2008-12-11 15:51:31 +00:00
109 changed files with 1450 additions and 744 deletions

View File

@ -9,8 +9,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \
-I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/turbulenceModels/RAS/compressible/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/laminarFlameSpeed/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/laminarFlameSpeed/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
basicSubGrid Foam::XiEqModels::basicSubGrid
Description Description
Basic sub-grid obstacle flame-wrinking enhancement factor model. Basic sub-grid obstacle flame-wrinking enhancement factor model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
basicSubGrid Foam::XiGModel::basicSubGrid
Description Description

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
PDRDragModel Foam::PDRDragModel
Description Description
Base-class for sub-grid obstacle drag models. Base-class for sub-grid obstacle drag models.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
basic Foam::PDRDragModels::basic
Description Description
Basic sub-grid obstacle drag model. Basic sub-grid obstacle drag model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
PDRkEpsilon Foam::compressible::RASModels::PDRkEpsilon
Description Description
Standard k-epsilon turbulence model with additional source terms Standard k-epsilon turbulence model with additional source terms

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Gulder Foam::XiEqModels::Gulder
Description Description
Simple Gulder model for XiEq based on Gulders correlation Simple Gulder model for XiEq based on Gulders correlation

View File

@ -23,10 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
SCOPEBlend Foam::XiEqModels::SCOPEBlend
Description Description
SourceFiles SourceFiles
SCOPEBlend.C SCOPEBlend.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
SCOPEXiEq Foam::XiEqModel::SCOPEXiEq
Description Description
Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
XiEqModel Foam::XiEqModel
Description Description
Base-class for all XiEq models used by the b-XiEq combustion model. Base-class for all XiEq models used by the b-XiEq combustion model.

View File

@ -23,10 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
instability Foam::XiEqModels::instability
Description Description
SourceFiles SourceFiles
instability.C instability.C

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
KTS Foam::XiGModels::KTS
Description Description
Simple Kolmogorov time-scale model for the flame-wrinling generation rate. Simple Kolmogorov time-scale model for the flame-wrinling generation rate.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
XiGModel Foam::XiGModel
Description Description
Base-class for all Xi generation models used by the b-Xi combustion model. Base-class for all Xi generation models used by the b-Xi combustion model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
instabilityG Foam::XiGModels::instabilityG
Description Description
Flame-surface instabilityG flame-wrinking generation rate coefficient model. Flame-surface instabilityG flame-wrinking generation rate coefficient model.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
XiModel Foam::XiModel
Description Description
Base-class for all Xi models used by the b-Xi combustion model. Base-class for all Xi models used by the b-Xi combustion model.
@ -102,8 +102,6 @@ namespace Foam
Class XiModel Declaration Class XiModel Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class XiModel class XiModel
{ {

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
algebraic Foam::XiModels::algebraic
Description Description
Simple algebraic model for Xi based on Gulders correlation Simple algebraic model for Xi based on Gulders correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
fixed Foam::XiModels::fixed
Description Description
Fixed value model for Xi. Fixed value model for Xi.

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
transport Foam::XiModels::transport
Description Description
Simple transport model for Xi based on Gulders correlation Simple transport model for Xi based on Gulders correlation

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
SCOPE Foam::laminarFlameSpeedModels::SCOPE
Description Description
Laminar flame speed obtained from the SCOPE correlation. Laminar flame speed obtained from the SCOPE correlation.

View File

@ -74,24 +74,26 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
// Do any mesh changes
mesh.update();
if (mesh.changing())
{ {
Info<< "Execution time for mesh.update() = " // Store divU from the previous mesh for the correctPhi
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate volScalarField divU = fvc::div(phi);
<< " s" << endl;
gh = g & mesh.C(); scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
ghf = g & mesh.Cf();
}
if (mesh.changing() && correctPhi) // Do any mesh changes
{ mesh.update();
//***HGW#include "correctPhi.H"
if (mesh.changing())
{
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
}
if (mesh.changing() && correctPhi)
{
#include "correctPhi.H"
}
} }
// Make the fluxes relative to the mesh motion // Make the fluxes relative to the mesh motion
@ -102,6 +104,12 @@ int main(int argc, char *argv[])
#include "meshCourantNo.H" #include "meshCourantNo.H"
} }
if (mesh.changing())
{
gh = g & mesh.C();
ghf = g & mesh.Cf();
}
turbulence->correct(); turbulence->correct();
// --- Outer-corrector loop // --- Outer-corrector loop

View File

@ -0,0 +1,39 @@
{
#include "continuityErrs.H"
volScalarField pcorr
(
IOobject
(
"pcorr",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("pcorr", pd.dimensions(), 0.0),
pcorrTypes
);
dimensionedScalar rAUf("(1|A(U))", dimTime/rho.dimensions(), 1.0);
adjustPhi(phi, U, pcorr);
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pcorrEqn
(
fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU
);
pcorrEqn.solve();
if (nonOrth == nNonOrthCorr)
{
phi -= pcorrEqn.flux();
}
}
#include "continuityErrs.H"
}

View File

@ -150,3 +150,14 @@
( (
incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) incompressible::turbulenceModel::New(U, phi, twoPhaseProperties)
); );
wordList pcorrTypes(pd.boundaryField().types());
for (label i=0; i<pd.boundaryField().size(); i++)
{
if (pd.boundaryField()[i].fixesValue())
{
pcorrTypes[i] = fixedValueFvPatchScalarField::typeName;
}
}

View File

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

View File

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

View File

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

View File

@ -30,6 +30,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "IOstreams.H" #include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H" #include "IFstream.H"
#include "dictionary.H" #include "dictionary.H"
@ -40,18 +41,12 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
IFstream dictStream("testDict"); Info<< dictionary(IFstream("testDict")()) << endl;
dictionary testDict(dictStream);
Info<< testDict << endl; IOobject::writeDivider(Info);
{ {
dictionary someDict; dictionary dict(IFstream("testDictRegex")());
someDict.add(keyType("a.*", true), "subdictValue");
dictionary dict;
dict.add("someDict", someDict);
dict.add(keyType(".*", true), "parentValue");
Info<< "dict:" << dict << endl; Info<< "dict:" << dict << endl;
@ -64,6 +59,18 @@ int main(int argc, char *argv[])
Info<< "Recursive wildcard find \"def\" in sub directory : " Info<< "Recursive wildcard find \"def\" in sub directory : "
<< dict.subDict("someDict").lookup("def", true) << dict.subDict("someDict").lookup("def", true)
<< endl; << endl;
Info<< "Recursive wildcard find \"foo\" in sub directory : "
<< dict.subDict("someDict").lookup("foo", true)
<< endl;
Info<< "Recursive wildcard find \"fooz\" in sub directory : "
<< dict.subDict("someDict").lookup("fooz", true)
<< endl;
Info<< "Recursive wildcard find \"bar\" in sub directory : "
<< dict.subDict("someDict").lookup("bar", true)
<< endl;
Info<< "Recursive wildcard find \"xxx\" in sub directory : "
<< dict.subDict("someDict").lookup("xxx", true)
<< endl;
} }
return 0; return 0;

View File

@ -0,0 +1,34 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDictRegex;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#inputMode merge
".*" parentValue1;
"[n-z].*" parentValue2;
"f.*" parentValue3;
someDict
{
foo subdictValue0;
bar $f.*; // should this really match 'foo'?
// result is dependent on insert order!
"a.*c" subdictValue3;
"ab.*" subdictValue2;
"a.*" subdictValue1;
abcd subdictValue4;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,6 +28,7 @@ Description
#include "argList.H" #include "argList.H"
#include "Time.H" #include "Time.H"
#include "timeSelector.H"
using namespace Foam; using namespace Foam;
@ -36,13 +37,19 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel();
// timeSelector::addOptions();
timeSelector::addOptions(true, true);
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
Info<< runTime.times() << endl; Info<< "Times found:" << runTime.times() << endl;
Info << "End\n" << endl; instantList timeDirs = timeSelector::select0(runTime, args);
Info<< "Times selected:" << timeDirs << endl;
Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

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

View File

@ -0,0 +1,3 @@
EXE_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "regExp.H"
#include "List.H"
#include "Tuple2.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
List<Tuple2<string, string> > rawList(IFstream("testRegexps")());
Info<< "input list:" << rawList << endl;
IOobject::writeDivider(Info);
Info<< endl;
List<string> groups;
// report matches:
forAll(rawList, elemI)
{
const string& pat = rawList[elemI].first();
const string& str = rawList[elemI].second();
regExp re(pat);
Info<< str << " =~ m/" << pat.c_str() << "/ == ";
if (re.match(str, groups))
{
Info<< "true";
if (re.ngroups())
{
Info<< groups;
}
}
else
{
Info<< "false";
if (re.match(str, true))
{
Info<< " partial match";
}
}
Info << endl;
}
Info<< endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*-------------------------------*- C++ -*---------------------------------*\
| ========= |
| \\ / OpenFOAM |
| \\ / |
| \\ / The Open Source CFD Toolbox |
| \\/ http://www.OpenFOAM.org |
\*-------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// pattern, string
(
( "a.*" "abc" )
( "a.*" "bac" )
( "a.*" "abcd" )
( "a.*" "def" )
( "d(.*)f" "def" )
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,7 +26,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "stringList.H" #include "stringListOps.H"
#include "IOstreams.H" #include "IOstreams.H"
using namespace Foam; using namespace Foam;

View File

@ -1,4 +1,3 @@
xferListTest.C xferListTest.C
/* EXE = $(FOAM_USER_APPBIN)/xferListTest */ EXE = $(FOAM_USER_APPBIN)/xferListTest
EXE = ./xferListTest

View File

@ -45,8 +45,10 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// enable -constant ... if someone really wants it
// enable -zeroTime to prevent accidentally trashing the initial fields
timeSelector::addOptions(true, true);
argList::noParallel(); argList::noParallel();
timeSelector::addOptions();
# include "addRegionOption.H" # include "addRegionOption.H"
argList::validOptions.insert("fields", "\"(list of fields)\""); argList::validOptions.insert("fields", "\"(list of fields)\"");

View File

@ -74,7 +74,9 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// with -constant and -zeroTime // enable -constant
// probably don't need -zeroTime though, since the fields are vetted
// afterwards anyhow
timeSelector::addOptions(true, false); timeSelector::addOptions(true, false);
argList::noParallel(); argList::noParallel();
argList::validOptions.insert("ascii", ""); argList::validOptions.insert("ascii", "");

View File

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

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
foamUpgradeFvSolution
Description
Simple tool to upgrade the syntax of system/fvSolution::solvers
Usage
- foamUpgradeFvSolution [OPTION]
@param -test \n
Suppress writing the updated fvSolution file
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "IOdictionary.H"
#include "solution.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("test", "");
# include "setRootCase.H"
# include "createTime.H"
IOdictionary solutionDict
(
IOobject
(
"fvSolution",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
label nChanged = 0;
entry* e = solutionDict.lookupEntryPtr("solvers", false, false);
if (e && e->isDict())
{
nChanged = solution::upgradeSolverDict(e->dict(), true);
}
Info<< nChanged << " solver settings changed" << nl << endl;
if (nChanged)
{
if (args.options().found("test"))
{
Info<< "-test option: no changes made" << nl << endl;
}
else
{
mv
(
solutionDict.objectPath(),
solutionDict.objectPath() + ".old"
);
solutionDict.writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
Info<< "Backup to " << (solutionDict.objectPath() + ".old") << nl
<< "Write to " << solutionDict.objectPath() << nl << endl;
}
}
return 0;
}
// ************************************************************************* //

View File

@ -31,19 +31,19 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: ${0##*/} [OPTION] usage: ${0##*/} [OPTION]
options: options:
-case dir specify alternative case directory -case dir specify alternative case directory
-region name specify mesh region name -region name specify mesh region name
-touch create the .OpenFOAM file only and exit -touch only create the .OpenFOAM file
* start paraview $ParaView_VERSION with the OpenFOAM libraries * start paraview $ParaView_VERSION with the OpenFOAM libraries
USAGE USAGE
exit 1 exit 1
} }
unset regionName touchOnly unset regionName touchOnly
@ -51,81 +51,83 @@ unset regionName touchOnly
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-case) -case)
[ "$#" -ge 2 ] || usage "'-case' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
caseDir=$2 cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
shift 2 shift 2
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" ;;
;; -region)
-region) [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
[ "$#" -ge 2 ] || usage "'-region' option requires an argument" regionName=$2
regionName=$2 shift 2
shift 2 ;;
;; -touch)
-touch) touchOnly=true
touchOnly=1 shift
shift ;;
;; *)
*) usage "unknown option/argument: '$*'"
usage "unknown option/argument: '$*'" ;;
;; esac
esac
done done
# get a sensible caseName # get a sensible caseName
caseName=${PWD##*/} caseName=${PWD##*/}
caseFile="$caseName.OpenFOAM" caseFile="$caseName.OpenFOAM"
fvControls="system"
if [ -n "$regionName" ] if [ -n "$regionName" ]
then then
caseFile="$caseName{$regionName}.OpenFOAM" caseFile="$caseName{$regionName}.OpenFOAM"
fvControls="$fvControls/$regionName"
fi fi
if [ -n "$touchOnly" ]; if [ -n "$touchOnly" ]
then then
touch "$caseFile" touch "$caseFile"
echo "created '$caseFile'" echo "created '$caseFile'"
exit 0 exit 0
fi fi
# parent directory for normal or parallel results # parent directory for normal or parallel results
case "$caseName" in case "$caseName" in
processor*) parentDir=".." ;; processor*) parentDir=".." ;;
*) parentDir="." ;; *) parentDir="." ;;
esac esac
# check existence of essential files # check existence of essential files
for check in system/controlDict system/fvSchemes system/fvSolution for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution
do do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done done
case "$ParaView_VERSION" in case "$ParaView_VERSION" in
2*) 2*)
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch $caseFile touch "$caseFile"
# since we are now in the cwd, %CASE% is '$PWD/$caseFile' # since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \ sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs $WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs
paraview paraFoam.pvs paraview paraFoam.pvs
;; ;;
*) *)
# only create/remove caseFile if it doesn't exist # only create/remove caseFile if it didn't already exist
[ -e $caseFile ] || { [ -e $caseFile ] || {
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch "$caseFile" touch "$caseFile"
echo "created temporary '$caseFile'" echo "created temporary '$caseFile'"
} }
paraview --data="$caseFile" paraview --data="$caseFile"
;; ;;
esac esac
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -1,2 +1,2 @@
Misc. tools for building applications, etc that are useful to have Misc. tools, scripts, templates that are useful (eg, for building applications)
but which don't really need to be in the PATH. but don't need to be in the PATH.

View File

@ -2,6 +2,7 @@ signals/sigFpe.C
signals/sigSegv.C signals/sigSegv.C
signals/sigInt.C signals/sigInt.C
signals/sigQuit.C signals/sigQuit.C
regExp.C
timer.C timer.C
fileStat.C fileStat.C
Unix.C Unix.C

View File

@ -0,0 +1,196 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include <sys/types.h>
#include "regExp.H"
#include "label.H"
#include "string.H"
#include "List.H"
#include "IOstreams.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::regExp::compile(const char* pat) const
{
clear();
preg_ = new regex_t;
if (regcomp(preg_, pat, REG_EXTENDED) != 0)
{
FatalErrorIn
(
"regExp::compile(const char*)"
) << "Failed to compile regular expression '" << pat << "'"
<< exit(FatalError);
}
}
void Foam::regExp::clear() const
{
if (preg_)
{
regfree(preg_);
delete preg_;
preg_ = 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regExp::regExp()
:
preg_(0)
{}
Foam::regExp::regExp(const string& pat)
:
preg_(0)
{
compile(pat.c_str());
}
Foam::regExp::regExp(const char* pat)
:
preg_(0)
{
compile(pat);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regExp::~regExp()
{
clear();
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
int Foam::regExp::ngroups() const
{
return preg_ ? preg_->re_nsub : 0;
}
bool Foam::regExp::match
(
const string& str,
bool partialMatch
) const
{
if (preg_ && str.size())
{
size_t nmatch = 1;
regmatch_t pmatch[1];
// match and also verify that the entire string was matched
if
(
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
&&
(
partialMatch
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
)
)
{
return true;
}
}
return false;
}
bool Foam::regExp::match
(
const string& str,
List<string>& groups,
bool partialMatch
) const
{
if (preg_ && str.size())
{
size_t nmatch = ngroups() + 1;
regmatch_t pmatch[nmatch];
// match and also verify that the entire string was matched
if
(
regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0
&&
(
partialMatch
|| (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size()))
)
)
{
groups.setSize(ngroups());
label groupI = 0;
for (size_t matchI = 1; matchI < nmatch; matchI++)
{
if (pmatch[matchI].rm_so != -1 && pmatch[matchI].rm_eo != -1)
{
groups[groupI] = str.substr
(
pmatch[matchI].rm_so,
pmatch[matchI].rm_eo - pmatch[matchI].rm_so
);
}
else
{
groups[groupI].clear();
}
groupI++;
}
return true;
}
}
groups.clear();
return false;
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::regExp::operator=(const string& pat)
{
compile(pat.c_str());
}
void Foam::regExp::operator=(const char* pat)
{
compile(pat);
}
// ************************************************************************* //

View File

@ -23,94 +23,108 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::regularExpression Foam::regExp
Description Description
Wrapper around regular expressions. Wrapper around POSIX extended regular expressions.
The beginning-of-line (^) and the end-of-line ($) anchors are implicit
by default.
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
These differ somewhat from @c Perl and @c sed regular expressions.
SourceFiles SourceFiles
regExp.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef regularExpression_H #ifndef regExp_H
#define regularExpression_H #define regExp_H
#include <sys/types.h>
#include <regex.h> #include <regex.h>
#include "string.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of classes
class string;
template<class T> class List;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class regularExpression Declaration Class regExp Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class regularExpression class regExp
{ {
// Private data // Private data
//- Precompiled regular expression //- Precompiled regular expression
regex_t* preg_; mutable regex_t* preg_;
// Private member functions // Private member functions
//- release allocated space
void clear() const;
//- compile into a regular expression
void compile(const char*) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
regularExpression(const regularExpression&); regExp(const regExp&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const regularExpression&); void operator=(const regExp&);
public: public:
// Constructors // Constructors
//- Construct null
regExp();
//- Construct from string //- Construct from string
inline regularExpression(const string& s) regExp(const string&);
{
preg_ = new regex_t;
if (regcomp(preg_, s.c_str(), REG_EXTENDED) != 0)
{
FatalErrorIn
(
"regularExpression::regularExpression(const char*)"
) << "Failed to compile regular expression " << s
<< exit(FatalError);
}
}
//- Construct from character array
regExp(const char*);
// Destructor // Destructor
//- Construct from string ~regExp();
inline ~regularExpression()
{
if (preg_)
{
regfree(preg_);
delete preg_;
}
}
// Member functions // Member functions
//- Matches? //- Return the number of (groups)
inline bool matches(const string& s) const int ngroups() const;
{
size_t nmatch = 1;
regmatch_t pmatch[1];
int errVal = regexec(preg_, s.c_str(), nmatch, pmatch, 0); //- Return true if it matches, partial matches are optional
bool match
(
const string&,
bool partialMatch=false
) const;
//- Return true if it matches and sets the sub-groups matched,
// partial matches are optional
bool match
(
const string&,
List<string>& groups,
bool partialMatch=false
) const;
// Member Operators
//- Assign from a string
void operator=(const string&);
//- Assign from a character array
void operator=(const char*);
return (errVal == 0 && pmatch[0].rm_eo == label(s.size()));
}
}; };

View File

@ -131,7 +131,7 @@ void Foam::timeSelector::addOptions
argList::validOptions.insert("zeroTime", ""); argList::validOptions.insert("zeroTime", "");
} }
argList::validOptions.insert("noZero", ""); argList::validOptions.insert("noZero", "");
argList::validOptions.insert("time", "time"); argList::validOptions.insert("time", "ranges");
argList::validOptions.insert("latestTime", ""); argList::validOptions.insert("latestTime", "");
} }
@ -167,28 +167,40 @@ Foam::List<Foam::instant> Foam::timeSelector::select
} }
} }
// determine latestTime selection (if any)
// this must appear before the -time option processing
label latestIdx = -1;
if (args.options().found("latestTime"))
{
selectTimes = false;
latestIdx = timeDirs.size() - 1;
// avoid false match on constant/
if (latestIdx == constantIdx)
{
latestIdx = -1;
}
}
if (args.options().found("time")) if (args.options().found("time"))
{ {
// can match 0/, but can never match constant/
selectTimes = timeSelector selectTimes = timeSelector
( (
IStringStream(args.options()["time"])() IStringStream(args.options()["time"])()
).selected(timeDirs); ).selected(timeDirs);
} }
else if (args.options().found("latestTime"))
{
selectTimes = false;
const label latestIdx = timeDirs.size() - 1;
// avoid false match on constant/ or 0/
if (latestIdx != constantIdx && latestIdx != zeroIdx) // add in latestTime (if selected)
{ if (latestIdx >= 0)
selectTimes[latestIdx] = true; {
} selectTimes[latestIdx] = true;
} }
// special treatment for constant/
if (constantIdx >= 0) if (constantIdx >= 0)
{ {
// only add constant/ if specifically requested
selectTimes[constantIdx] = args.options().found("constant"); selectTimes[constantIdx] = args.options().found("constant");
} }
@ -197,10 +209,12 @@ Foam::List<Foam::instant> Foam::timeSelector::select
{ {
if (args.options().found("noZero")) if (args.options().found("noZero"))
{ {
// exclude 0/ if specifically requested
selectTimes[zeroIdx] = false; selectTimes[zeroIdx] = false;
} }
else if (argList::validOptions.found("zeroTime")) else if (argList::validOptions.found("zeroTime"))
{ {
// with -zeroTime enabled, drop 0/ unless specifically requested
selectTimes[zeroIdx] = args.options().found("zeroTime"); selectTimes[zeroIdx] = args.options().found("zeroTime");
} }
} }

View File

@ -60,8 +60,9 @@ Description
@endverbatim @endverbatim
The first argument avoids adding the @b -constant option. The second The first argument avoids adding the @b -constant option. The second
argument adds an additional @b -zeroTime option and prevents the @c 0/ argument adds an additional @b -zeroTime option and also prevents the
directory from being included in the default time range. @c 0/ directory from being included in the default time range and in the
@b -latestTime selection.
SourceFiles SourceFiles
timeSelector.C timeSelector.C
@ -121,14 +122,17 @@ public:
// //
// @param constant // @param constant
// Add the @b -constant option to include the @c constant/ directory // Add the @b -constant option to include the @c constant/ directory
//
// @param zeroTime // @param zeroTime
// Additional to the @b -noZero option (explicitly exclude the // Enable the @b -zeroTime option and alter the normal time selection
// @c 0/ directory), add the @b -zeroTime option to include the // behaviour (and @b -latestTime behaviour) to exclude the @c 0/
// @c 0/ directory. The @b -noZero option has precedence. // directory. The @c 0/ directory will only be included when
// @b -zeroTime is specified.
// The @b -noZero option has precedence over the @b -zeroTime option.
static void addOptions static void addOptions
( (
const bool constant = true, const bool constant=true,
const bool zeroTime = false const bool zeroTime=false
); );
//- Return the set of times selected based on the argList options //- Return the set of times selected based on the argList options

View File

@ -27,7 +27,7 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "primitiveEntry.H" #include "primitiveEntry.H"
#include "dictionaryEntry.H" #include "dictionaryEntry.H"
#include "regularExpression.H" #include "regExp.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
@ -43,21 +43,18 @@ bool Foam::dictionary::findInWildcards
const bool wildCardMatch, const bool wildCardMatch,
const word& Keyword, const word& Keyword,
DLList<entry*>::const_iterator& wcLink, DLList<entry*>::const_iterator& wcLink,
DLList<autoPtr<regularExpression> >::const_iterator& reLink DLList<autoPtr<regExp> >::const_iterator& reLink
) const ) const
{ {
if (wildCardEntries_.size() > 0) if (wildCardEntries_.size() > 0)
{ {
//wcLink = wildCardEntries_.begin();
//reLink = wildCardRegexps_.end();
while (wcLink != wildCardEntries_.end()) while (wcLink != wildCardEntries_.end())
{ {
if (!wildCardMatch && wcLink()->keyword() == Keyword) if (!wildCardMatch && wcLink()->keyword() == Keyword)
{ {
return true; return true;
} }
else if (wildCardMatch && reLink()->matches(Keyword)) else if (wildCardMatch && reLink()->match(Keyword))
{ {
return true; return true;
} }
@ -76,7 +73,7 @@ bool Foam::dictionary::findInWildcards
const bool wildCardMatch, const bool wildCardMatch,
const word& Keyword, const word& Keyword,
DLList<entry*>::iterator& wcLink, DLList<entry*>::iterator& wcLink,
DLList<autoPtr<regularExpression> >::iterator& reLink DLList<autoPtr<regExp> >::iterator& reLink
) )
{ {
if (wildCardEntries_.size() > 0) if (wildCardEntries_.size() > 0)
@ -87,7 +84,7 @@ bool Foam::dictionary::findInWildcards
{ {
return true; return true;
} }
else if (wildCardMatch && reLink()->matches(Keyword)) else if (wildCardMatch && reLink()->match(Keyword))
{ {
return true; return true;
} }
@ -133,10 +130,7 @@ Foam::dictionary::dictionary
wildCardEntries_.insert(&iter()); wildCardEntries_.insert(&iter());
wildCardRegexps_.insert wildCardRegexps_.insert
( (
autoPtr<regularExpression> autoPtr<regExp>(new regExp(iter().keyword()))
(
new regularExpression(iter().keyword())
)
); );
} }
} }
@ -166,10 +160,7 @@ Foam::dictionary::dictionary
wildCardEntries_.insert(&iter()); wildCardEntries_.insert(&iter());
wildCardRegexps_.insert wildCardRegexps_.insert
( (
autoPtr<regularExpression> autoPtr<regExp>(new regExp(iter().keyword()))
(
new regularExpression(iter().keyword())
)
); );
} }
} }
@ -229,7 +220,7 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
if (wildCardEntries_.size() > 0) if (wildCardEntries_.size() > 0)
{ {
DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin(); DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::const_iterator reLink = DLList<autoPtr<regExp> >::const_iterator reLink =
wildCardRegexps_.begin(); wildCardRegexps_.begin();
// Find in wildcards using regular expressions only // Find in wildcards using regular expressions only
@ -266,7 +257,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
{ {
DLList<entry*>::const_iterator wcLink = DLList<entry*>::const_iterator wcLink =
wildCardEntries_.begin(); wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::const_iterator reLink = DLList<autoPtr<regExp> >::const_iterator reLink =
wildCardRegexps_.begin(); wildCardRegexps_.begin();
// Find in wildcards using regular expressions only // Find in wildcards using regular expressions only
@ -305,7 +296,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
{ {
DLList<entry*>::iterator wcLink = DLList<entry*>::iterator wcLink =
wildCardEntries_.begin(); wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::iterator reLink = DLList<autoPtr<regExp> >::iterator reLink =
wildCardRegexps_.begin(); wildCardRegexps_.begin();
// Find in wildcards using regular expressions only // Find in wildcards using regular expressions only
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink)) if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
@ -487,10 +478,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
wildCardEntries_.insert(entryPtr); wildCardEntries_.insert(entryPtr);
wildCardRegexps_.insert wildCardRegexps_.insert
( (
autoPtr<regularExpression> autoPtr<regExp>(new regExp(entryPtr->keyword()))
(
new regularExpression(entryPtr->keyword())
)
); );
} }
@ -519,10 +507,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
wildCardEntries_.insert(entryPtr); wildCardEntries_.insert(entryPtr);
wildCardRegexps_.insert wildCardRegexps_.insert
( (
autoPtr<regularExpression> autoPtr<regExp>(new regExp(entryPtr->keyword()))
(
new regularExpression(entryPtr->keyword())
)
); );
} }
@ -615,8 +600,7 @@ bool Foam::dictionary::remove(const word& Keyword)
// Delete from wildcards first // Delete from wildcards first
DLList<entry*>::iterator wcLink = DLList<entry*>::iterator wcLink =
wildCardEntries_.begin(); wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::iterator reLink = DLList<autoPtr<regExp> >::iterator reLink = wildCardRegexps_.begin();
wildCardRegexps_.begin();
// Find in wildcards using exact match only // Find in wildcards using exact match only
if (findInWildcards(false, Keyword, wcLink, reLink)) if (findInWildcards(false, Keyword, wcLink, reLink))
@ -683,7 +667,7 @@ bool Foam::dictionary::changeKeyword
// Delete from wildcards first // Delete from wildcards first
DLList<entry*>::iterator wcLink = DLList<entry*>::iterator wcLink =
wildCardEntries_.begin(); wildCardEntries_.begin();
DLList<autoPtr<regularExpression> >::iterator reLink = DLList<autoPtr<regExp> >::iterator reLink =
wildCardRegexps_.begin(); wildCardRegexps_.begin();
// Find in wildcards using exact match only // Find in wildcards using exact match only
@ -697,7 +681,7 @@ bool Foam::dictionary::changeKeyword
IDLList<entry>::replace(iter2(), iter()); IDLList<entry>::replace(iter2(), iter());
delete iter2(); delete iter2();
hashedEntries_.erase(iter2); hashedEntries_.erase(iter2);
} }
else else
{ {
@ -722,10 +706,7 @@ bool Foam::dictionary::changeKeyword
wildCardEntries_.insert(iter()); wildCardEntries_.insert(iter());
wildCardRegexps_.insert wildCardRegexps_.insert
( (
autoPtr<regularExpression> autoPtr<regExp>(new regExp(newKeyword))
(
new regularExpression(newKeyword)
)
); );
} }
@ -789,6 +770,8 @@ void Foam::dictionary::clear()
{ {
IDLList<entry>::clear(); IDLList<entry>::clear();
hashedEntries_.clear(); hashedEntries_.clear();
wildCardEntries_.clear();
wildCardRegexps_.clear();
} }

View File

@ -67,7 +67,7 @@ namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class regularExpression; class regExp;
class dictionary; class dictionary;
Istream& operator>>(Istream&, dictionary&); Istream& operator>>(Istream&, dictionary&);
Ostream& operator<<(Ostream&, const dictionary&); Ostream& operator<<(Ostream&, const dictionary&);
@ -95,8 +95,8 @@ class dictionary
//- Wildcard entries //- Wildcard entries
DLList<entry*> wildCardEntries_; DLList<entry*> wildCardEntries_;
//- Wildcard precompiled regex //- Wildcard precompiled regular expressions
DLList<autoPtr<regularExpression> > wildCardRegexps_; DLList<autoPtr<regExp> > wildCardRegexps_;
// Private Member Functions // Private Member Functions
@ -107,7 +107,7 @@ class dictionary
const bool wildCardMatch, const bool wildCardMatch,
const word& Keyword, const word& Keyword,
DLList<entry*>::const_iterator& wcLink, DLList<entry*>::const_iterator& wcLink,
DLList<autoPtr<regularExpression> >::const_iterator& reLink DLList<autoPtr<regExp> >::const_iterator& reLink
) const; ) const;
//- Search wildcard table either for exact match or for regular //- Search wildcard table either for exact match or for regular
@ -117,7 +117,7 @@ class dictionary
const bool wildCardMatch, const bool wildCardMatch,
const word& Keyword, const word& Keyword,
DLList<entry*>::iterator& wcLink, DLList<entry*>::iterator& wcLink,
DLList<autoPtr<regularExpression> >::iterator& reLink DLList<autoPtr<regExp> >::iterator& reLink
); );
@ -163,16 +163,16 @@ public:
dictionary(Istream&); dictionary(Istream&);
//- Construct as copy given the parent dictionary //- Construct as copy given the parent dictionary
dictionary(const dictionary& parentDict, const dictionary& dict); dictionary(const dictionary& parentDict, const dictionary&);
//- Construct top-level dictionary as copy //- Construct top-level dictionary as copy
dictionary(const dictionary& dict); dictionary(const dictionary&);
//- Construct and return clone //- Construct and return clone
Foam::autoPtr<dictionary> clone() const; Foam::autoPtr<dictionary> clone() const;
//- Construct top-level dictionary on freestore from Istream //- Construct top-level dictionary on freestore from Istream
static Foam::autoPtr<dictionary> New(Istream& is); static Foam::autoPtr<dictionary> New(Istream&);
// Destructor // Destructor
@ -211,12 +211,12 @@ public:
//- Search dictionary for given keyword //- Search dictionary for given keyword
// If recursive search parent dictionaries // If recursive search parent dictionaries
bool found(const word& keyword, bool recursive=false) const; bool found(const word&, bool recursive=false) const;
//- Find and return an entry data stream pointer if present //- Find and return an entry data stream pointer if present
// otherwise return NULL. // otherwise return NULL.
// If recursive search parent dictionaries. If wildCardMatch // If recursive search parent dictionaries.
// use wildcards. // If wildCardMatch use wildcards.
const entry* lookupEntryPtr const entry* lookupEntryPtr
( (
const word&, const word&,
@ -226,8 +226,8 @@ public:
//- Find and return an entry data stream pointer for manipulation //- Find and return an entry data stream pointer for manipulation
// if present otherwise return NULL. // if present otherwise return NULL.
// If recursive search parent dictionaries. If wildCardMatch // If recursive search parent dictionaries.
// use wildcards. // If wildCardMatch use wildcards.
entry* lookupEntryPtr entry* lookupEntryPtr
( (
const word&, const word&,
@ -236,8 +236,8 @@ public:
); );
//- Find and return an entry data stream if present otherwise error. //- Find and return an entry data stream if present otherwise error.
// If recursive search parent dictionaries. If wildCardMatch // If recursive search parent dictionaries.
// use wildcards. // If wildCardMatch use wildcards.
const entry& lookupEntry const entry& lookupEntry
( (
const word&, const word&,
@ -331,13 +331,13 @@ public:
//- Add a scalar entry //- Add a scalar entry
// optionally overwrite an existing entry // optionally overwrite an existing entry
void add (const keyType&, const scalar, bool overwrite=false); void add(const keyType&, const scalar, bool overwrite=false);
//- Add a dictionary entry //- Add a dictionary entry
// optionally merge with an existing sub-dictionary // optionally merge with an existing sub-dictionary
void add void add
( (
const keyType& keyword, const keyType&,
const dictionary&, const dictionary&,
bool mergeEntry=false bool mergeEntry=false
); );
@ -345,7 +345,7 @@ public:
//- Add a T entry //- Add a T entry
// optionally overwrite an existing entry // optionally overwrite an existing entry
template<class T> template<class T>
void add(const keyType& keyword, const T&, bool overwrite=false); void add(const keyType&, const T&, bool overwrite=false);
//- Assign a new entry, overwrite any existing entry //- Assign a new entry, overwrite any existing entry
void set(entry*); void set(entry*);
@ -354,14 +354,14 @@ public:
void set(const entry&); void set(const entry&);
//- Assign a dictionary entry, overwrite any existing entry //- Assign a dictionary entry, overwrite any existing entry
void set(const keyType& keyword, const dictionary&); void set(const keyType&, const dictionary&);
//- Assign a T entry, overwrite any existing entry //- Assign a T entry, overwrite any existing entry
template<class T> template<class T>
void set(const keyType& keyword, const T&); void set(const keyType&, const T&);
//- Remove an entry specified by keyword //- Remove an entry specified by keyword
bool remove(const word& keyword); bool remove(const word&);
//- Change the keyword for an entry, //- Change the keyword for an entry,
// optionally forcing overwrite of an existing entry // optionally forcing overwrite of an existing entry
@ -369,7 +369,7 @@ public:
( (
const keyType& oldKeyword, const keyType& oldKeyword,
const keyType& newKeyword, const keyType& newKeyword,
bool forceOverwrite = false bool forceOverwrite=false
); );
//- Merge entries from the given dictionary. //- Merge entries from the given dictionary.
@ -382,7 +382,7 @@ public:
// Write // Write
void write(Ostream& os, bool subDict = true) const; void write(Ostream&, bool subDict=true) const;
// Member Operators // Member Operators

View File

@ -27,7 +27,7 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "IFstream.H" #include "IFstream.H"
#include "inputModeEntry.H" #include "inputModeEntry.H"
#include "regularExpression.H" #include "regExp.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -137,9 +137,6 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
functionEntries::inputModeEntry::clear(); functionEntries::inputModeEntry::clear();
dict.clear(); dict.clear();
dict.hashedEntries_.clear();
dict.wildCardEntries_.clear();
dict.wildCardRegexps_.clear();
dict.read(is); dict.read(is);
return is; return is;

View File

@ -37,19 +37,17 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam Foam::SLList<Foam::string> Foam::argList::validArgs;
{ Foam::HashTable<Foam::string> Foam::argList::validOptions;
SLList<string> argList::validArgs; Foam::HashTable<Foam::string> Foam::argList::validParOptions;
HashTable<string> argList::validOptions; bool Foam::argList::bannerEnabled(true);
HashTable<string> argList::validParOptions;
}
Foam::argList::initValidTables::initValidTables() Foam::argList::initValidTables::initValidTables()
{ {
validOptions.insert("case", "dir"); validOptions.set("case", "dir");
validOptions.insert("parallel", ""); validOptions.set("parallel", "");
validParOptions.insert("parallel", ""); validParOptions.set("parallel", "");
Pstream::addValidParOptions(validParOptions); Pstream::addValidParOptions(validParOptions);
} }
@ -138,7 +136,7 @@ void Foam::argList::getRootCase()
casePath = cwd(); casePath = cwd();
// we could add this back in as '-case'? // we could add this back in as '-case'?
// options_.insert("case", casePath); // options_.set("case", casePath);
} }
rootPath_ = casePath.path(); rootPath_ = casePath.path();
@ -285,7 +283,7 @@ Foam::argList::argList
string timeString = clock::clockTime(); string timeString = clock::clockTime();
// Print the banner once only for parallel runs // Print the banner once only for parallel runs
if (Pstream::master()) if (Pstream::master() && bannerEnabled)
{ {
IOobject::writeBanner(Info, true); IOobject::writeBanner(Info, true);
Info<< "Exec : " << argListString.c_str() << nl Info<< "Exec : " << argListString.c_str() << nl
@ -315,8 +313,6 @@ Foam::argList::argList
// For the master // For the master
if (Pstream::master()) if (Pstream::master())
{ {
fileNameList roots;
// establish rootPath_/globalCase_/case_ for master // establish rootPath_/globalCase_/case_ for master
getRootCase(); getRootCase();
@ -333,45 +329,25 @@ Foam::argList::argList
<< exit(FatalError); << exit(FatalError);
} }
dictionary decompositionDict(decompDictStream); dictionary decompDict(decompDictStream);
Switch distributed(false);
if
(
decompositionDict.readIfPresent("distributed", distributed)
&& distributed
)
{
decompositionDict.lookup("roots") >> roots;
if (roots.size() != Pstream::nProcs()-1)
{
FatalError
<< "number of entries in decompositionDict::roots"
<< " is not equal to the number of slaves "
<< Pstream::nProcs()-1
<< exit(FatalError);
}
}
label dictNProcs label dictNProcs
( (
readLabel readLabel
( (
decompositionDict.lookup("numberOfSubdomains") decompDict.lookup("numberOfSubdomains")
) )
); );
// Check number of processors. We have nProcs(number of // Check number of processors.
// actual processes), dictNProcs(wanted number of processes read // nProcs => number of actual procs
// from decompositionDict) and nProcDirs(number of processor // dictNProcs => number of procs specified in decompositionDict
// directories - n/a when running distributed) // nProcDirs => number of processor directories
// (n/a when running distributed)
// //
// - normal running : nProcs = dictNProcs = nProcDirs // - normal running : nProcs = dictNProcs = nProcDirs
// - decomposition to more processors : nProcs = dictNProcs // - decomposition to more processors : nProcs = dictNProcs
// - decomposition to less processors : nProcs = nProcDirs // - decomposition to fewer processors : nProcs = nProcDirs
if (dictNProcs > Pstream::nProcs()) if (dictNProcs > Pstream::nProcs())
{ {
FatalError FatalError
@ -382,38 +358,23 @@ Foam::argList::argList
<< exit(FatalError); << exit(FatalError);
} }
if (!distributed && dictNProcs < Pstream::nProcs()) // distributed data
if (decompDict.lookupOrDefault<Switch>("distributed", false))
{ {
// Possibly going to fewer processors. fileNameList roots;
// Check if all procDirs are there. decompDict.lookup("roots") >> roots;
label nProcDirs = 0;
while
(
dir
(
rootPath_/globalCase_/"processor"
+ name(++nProcDirs)
)
)
{}
if (nProcDirs != Pstream::nProcs()) if (roots.size() != Pstream::nProcs()-1)
{ {
FatalError FatalError
<< "number of processor directories = " << "number of entries in decompositionDict::roots"
<< nProcDirs << " is not equal to the number of slaves "
<< " is not equal to the number of processors = " << Pstream::nProcs()-1
<< Pstream::nProcs()
<< exit(FatalError); << exit(FatalError);
} }
}
// distributed data
if (roots.size())
{
bool hadOptCase = options_.found("case");
// Distribute the master's argument list (with new root) // Distribute the master's argument list (with new root)
bool hadCaseOpt = options_.found("case");
for for
( (
int slave=Pstream::firstSlave(); int slave=Pstream::firstSlave();
@ -421,8 +382,7 @@ Foam::argList::argList
slave++ slave++
) )
{ {
options_.erase("case"); options_.set
options_.insert
( (
"case", "case",
fileName(roots[slave-1])/globalCase_ fileName(roots[slave-1])/globalCase_
@ -431,17 +391,42 @@ Foam::argList::argList
OPstream toSlave(Pstream::scheduled, slave); OPstream toSlave(Pstream::scheduled, slave);
toSlave << args_ << options_; toSlave << args_ << options_;
} }
options_.erase("case"); options_.erase("case");
// restore [-case dir] // restore [-case dir]
if (hadOptCase) if (hadCaseOpt)
{ {
options_.insert("case", rootPath_/globalCase_); options_.set("case", rootPath_/globalCase_);
} }
} }
else else
{ {
// Possibly going to fewer processors.
// Check if all procDirs are there.
if (dictNProcs < Pstream::nProcs())
{
label nProcDirs = 0;
while
(
dir
(
rootPath_/globalCase_/"processor"
+ name(++nProcDirs)
)
)
{}
if (nProcDirs != Pstream::nProcs())
{
FatalError
<< "number of processor directories = "
<< nProcDirs
<< " is not equal to the number of processors = "
<< Pstream::nProcs()
<< exit(FatalError);
}
}
// Distribute the master's argument list (unaltered) // Distribute the master's argument list (unaltered)
for for
( (
@ -472,7 +457,6 @@ Foam::argList::argList
{ {
// establish rootPath_/globalCase_/case_ // establish rootPath_/globalCase_/case_
getRootCase(); getRootCase();
case_ = globalCase_; case_ = globalCase_;
} }
@ -510,21 +494,21 @@ Foam::argList::argList
} }
if (Pstream::master()) if (Pstream::master() && bannerEnabled)
{ {
Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl
<< "nProcs : " << nProcs << endl; << "nProcs : " << nProcs << endl;
}
if (parRunControl_.parRun() && Pstream::master()) if (parRunControl_.parRun())
{ {
Info<< "Slaves : " << slaveProcs << nl Info<< "Slaves : " << slaveProcs << nl
<< "Pstream initialized with:" << nl << "Pstream initialized with:" << nl
<< " floatTransfer : " << Pstream::floatTransfer << nl << " floatTransfer : " << Pstream::floatTransfer << nl
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl << " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
<< " commsType : " << " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << Pstream::commsTypeNames[Pstream::defaultCommsType]
<< endl; << endl;
}
} }
jobInfo.add("root", rootPath_); jobInfo.add("root", rootPath_);
@ -546,7 +530,7 @@ Foam::argList::argList
sigQuit_.set(); sigQuit_.set();
sigSegv_.set(); sigSegv_.set();
if (Pstream::master()) if (Pstream::master() && bannerEnabled)
{ {
Info<< endl; Info<< endl;
IOobject::writeDivider(Info); IOobject::writeDivider(Info);
@ -564,6 +548,12 @@ Foam::argList::~argList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::argList::noBanner()
{
bannerEnabled = false;
}
void Foam::argList::noParallel() void Foam::argList::noParallel()
{ {
validOptions.erase("parallel"); validOptions.erase("parallel");

View File

@ -92,6 +92,7 @@ namespace Foam
class argList class argList
{ {
// Private data // Private data
static bool bannerEnabled;
stringList args_; stringList args_;
HashTable<string> options_; HashTable<string> options_;
@ -213,6 +214,9 @@ public:
// Edit // Edit
//- Disable emitting the banner information
static void noBanner();
//- Remove the parallel options //- Remove the parallel options
static void noParallel(); static void noParallel();

View File

@ -259,7 +259,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
), ),
( (
fieldName, fieldName,
@ -267,7 +267,7 @@ public:
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
); );
@ -282,7 +282,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
), ),
( (
fieldName, fieldName,
@ -290,7 +290,7 @@ public:
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
); );
@ -304,7 +304,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );
// Selectors // Selectors
@ -317,7 +317,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );
@ -359,7 +359,7 @@ public:
//- Read and reset the solver parameters from the given stream //- Read and reset the solver parameters from the given stream
virtual void read(Istream& solverData); virtual void read(const dictionary&);
virtual solverPerformance solve virtual solverPerformance solve
( (
@ -396,6 +396,9 @@ public:
public: public:
//- Find the smoother name (directly or from a sub-dictionary)
static word getName(const dictionary&);
//- Runtime type information //- Runtime type information
virtual const word& type() const = 0; virtual const word& type() const = 0;
@ -467,7 +470,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& smootherData const dictionary& solverControls
); );
@ -531,6 +534,9 @@ public:
public: public:
//- Find the preconditioner name (directly or from a sub-dictionary)
static word getName(const dictionary&);
//- Runtime type information //- Runtime type information
virtual const word& type() const = 0; virtual const word& type() const = 0;
@ -544,9 +550,9 @@ public:
symMatrix, symMatrix,
( (
const solver& sol, const solver& sol,
Istream& preconditionerData const dictionary& solverControls
), ),
(sol, preconditionerData) (sol, solverControls)
); );
declareRunTimeSelectionTable declareRunTimeSelectionTable
@ -556,9 +562,9 @@ public:
asymMatrix, asymMatrix,
( (
const solver& sol, const solver& sol,
Istream& preconditionerData const dictionary& solverControls
), ),
(sol, preconditionerData) (sol, solverControls)
); );
@ -579,7 +585,7 @@ public:
static autoPtr<preconditioner> New static autoPtr<preconditioner> New
( (
const solver& sol, const solver& sol,
Istream& preconditionerData const dictionary& solverControls
); );
@ -593,7 +599,7 @@ public:
//- Read and reset the preconditioner parameters //- Read and reset the preconditioner parameters
// from the given stream // from the given stream
virtual void read(Istream& preconditionerData) virtual void read(const dictionary&)
{} {}
//- Return wA the preconditioned form of residual rA //- Return wA the preconditioned form of residual rA

View File

@ -37,29 +37,66 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word
Foam::lduMatrix::preconditioner::getName
(
const dictionary& solverControls
)
{
word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
if (e.isDict())
{
e.dict().lookup("preconditioner") >> name;
}
else
{
e.stream() >> name;
}
return name;
}
Foam::autoPtr<Foam::lduMatrix::preconditioner> Foam::autoPtr<Foam::lduMatrix::preconditioner>
Foam::lduMatrix::preconditioner::New Foam::lduMatrix::preconditioner::New
( (
const solver& sol, const solver& sol,
Istream& preconditionerData const dictionary& solverControls
) )
{ {
word preconditionerName(preconditionerData); word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
if (e.isDict())
{
e.dict().lookup("preconditioner") >> name;
}
else
{
e.stream() >> name;
}
const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
if (sol.matrix().symmetric()) if (sol.matrix().symmetric())
{ {
symMatrixConstructorTable::iterator constructorIter = symMatrixConstructorTable::iterator constructorIter =
symMatrixConstructorTablePtr_->find(preconditionerName); symMatrixConstructorTablePtr_->find(name);
if (constructorIter == symMatrixConstructorTablePtr_->end()) if (constructorIter == symMatrixConstructorTablePtr_->end())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::preconditioner::New(const solver&, Istream&)", "lduMatrix::preconditioner::New"
preconditionerData "(const solver&, const dictionary&)",
controls
) << "Unknown symmetric matrix preconditioner " ) << "Unknown symmetric matrix preconditioner "
<< preconditionerName << endl << endl << name << nl << nl
<< "Valid symmetric matrix preconditioners are :" << endl << "Valid symmetric matrix preconditioners :" << endl
<< symMatrixConstructorTablePtr_->toc() << symMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -69,24 +106,25 @@ Foam::lduMatrix::preconditioner::New
constructorIter() constructorIter()
( (
sol, sol,
preconditionerData controls
) )
); );
} }
else if (sol.matrix().asymmetric()) else if (sol.matrix().asymmetric())
{ {
asymMatrixConstructorTable::iterator constructorIter = asymMatrixConstructorTable::iterator constructorIter =
asymMatrixConstructorTablePtr_->find(preconditionerName); asymMatrixConstructorTablePtr_->find(name);
if (constructorIter == asymMatrixConstructorTablePtr_->end()) if (constructorIter == asymMatrixConstructorTablePtr_->end())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::preconditioner::New(const solver&, Istream&)", "lduMatrix::preconditioner::New"
preconditionerData "(const solver&, const dictionary&)",
controls
) << "Unknown asymmetric matrix preconditioner " ) << "Unknown asymmetric matrix preconditioner "
<< preconditionerName << endl << endl << name << nl << nl
<< "Valid asymmetric matrix preconditioners are :" << endl << "Valid asymmetric matrix preconditioners :" << endl
<< asymMatrixConstructorTablePtr_->toc() << asymMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -96,7 +134,7 @@ Foam::lduMatrix::preconditioner::New
constructorIter() constructorIter()
( (
sol, sol,
preconditionerData controls
) )
); );
} }
@ -104,9 +142,10 @@ Foam::lduMatrix::preconditioner::New
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::preconditioner::New(const solver&, Istream&)", "lduMatrix::preconditioner::New"
preconditionerData "(const solver&, const dictionary&)",
) << "cannot preconditione incomplete matrix, " controls
) << "cannot solve incomplete matrix, "
"no diagonal or off-diagonal coefficient" "no diagonal or off-diagonal coefficient"
<< exit(FatalIOError); << exit(FatalIOError);

View File

@ -34,9 +34,31 @@ namespace Foam
defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix); defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::word
Foam::lduMatrix::smoother::getName
(
const dictionary& solverControls
)
{
word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("smoother", false, false);
if (e.isDict())
{
e.dict().lookup("smoother") >> name;
}
else
{
e.stream() >> name;
}
return name;
}
Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
( (
const word& fieldName, const word& fieldName,
@ -44,23 +66,37 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& smootherData const dictionary& solverControls
) )
{ {
word smootherName(smootherData); word name;
// handle primitive or dictionary entry
const entry& e = solverControls.lookupEntry("smoother", false, false);
if (e.isDict())
{
e.dict().lookup("smoother") >> name;
}
else
{
e.stream() >> name;
}
// not (yet?) needed:
// const dictionary& controls = e.isDict() ? e.dict() : dictionary::null;
if (matrix.symmetric()) if (matrix.symmetric())
{ {
symMatrixConstructorTable::iterator constructorIter = symMatrixConstructorTable::iterator constructorIter =
symMatrixConstructorTablePtr_->find(smootherName); symMatrixConstructorTablePtr_->find(name);
if (constructorIter == symMatrixConstructorTablePtr_->end()) if (constructorIter == symMatrixConstructorTablePtr_->end())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::smoother::New", smootherData "lduMatrix::smoother::New", solverControls
) << "Unknown symmetric matrix smoother " << smootherName ) << "Unknown symmetric matrix smoother "
<< endl << endl << name << nl << nl
<< "Valid symmetric matrix smoothers are :" << endl << "Valid symmetric matrix smoothers are :" << endl
<< symMatrixConstructorTablePtr_->toc() << symMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError); << exit(FatalIOError);
@ -81,15 +117,15 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
else if (matrix.asymmetric()) else if (matrix.asymmetric())
{ {
asymMatrixConstructorTable::iterator constructorIter = asymMatrixConstructorTable::iterator constructorIter =
asymMatrixConstructorTablePtr_->find(smootherName); asymMatrixConstructorTablePtr_->find(name);
if (constructorIter == asymMatrixConstructorTablePtr_->end()) if (constructorIter == asymMatrixConstructorTablePtr_->end())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::smoother::New", smootherData "lduMatrix::smoother::New", solverControls
) << "Unknown asymmetric matrix smoother " << smootherName ) << "Unknown asymmetric matrix smoother "
<< endl << endl << name << nl << nl
<< "Valid asymmetric matrix smoothers are :" << endl << "Valid asymmetric matrix smoothers are :" << endl
<< asymMatrixConstructorTablePtr_->toc() << asymMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError); << exit(FatalIOError);
@ -111,8 +147,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::smoother::New", smootherData "lduMatrix::smoother::New", solverControls
) << "cannot solve incomplete matrix, no off-diagonal coefficients" ) << "cannot solve incomplete matrix, "
"no diagonal or off-diagonal coefficient"
<< exit(FatalIOError); << exit(FatalIOError);
return autoPtr<lduMatrix::smoother>(NULL); return autoPtr<lduMatrix::smoother>(NULL);

View File

@ -45,10 +45,10 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
{ {
word solverName(solverData); word name(solverControls.lookup("solver"));
if (matrix.diagonal()) if (matrix.diagonal())
{ {
@ -61,22 +61,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
); );
} }
else if (matrix.symmetric()) else if (matrix.symmetric())
{ {
symMatrixConstructorTable::iterator constructorIter = symMatrixConstructorTable::iterator constructorIter =
symMatrixConstructorTablePtr_->find(solverName); symMatrixConstructorTablePtr_->find(name);
if (constructorIter == symMatrixConstructorTablePtr_->end()) if (constructorIter == symMatrixConstructorTablePtr_->end())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::solver::New", solverData "lduMatrix::solver::New", solverControls
) << "Unknown symmetric matrix solver " << solverName ) << "Unknown symmetric matrix solver " << name << nl << nl
<< endl << endl
<< "Valid symmetric matrix solvers are :" << endl << "Valid symmetric matrix solvers are :" << endl
<< symMatrixConstructorTablePtr_->toc() << symMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError); << exit(FatalIOError);
@ -91,22 +90,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
); );
} }
else if (matrix.asymmetric()) else if (matrix.asymmetric())
{ {
asymMatrixConstructorTable::iterator constructorIter = asymMatrixConstructorTable::iterator constructorIter =
asymMatrixConstructorTablePtr_->find(solverName); asymMatrixConstructorTablePtr_->find(name);
if (constructorIter == asymMatrixConstructorTablePtr_->end()) if (constructorIter == asymMatrixConstructorTablePtr_->end())
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::solver::New", solverData "lduMatrix::solver::New", solverControls
) << "Unknown asymmetric matrix solver " << solverName ) << "Unknown asymmetric matrix solver " << name << nl << nl
<< endl << endl
<< "Valid asymmetric matrix solvers are :" << endl << "Valid asymmetric matrix solvers are :" << endl
<< asymMatrixConstructorTablePtr_->toc() << asymMatrixConstructorTablePtr_->toc()
<< exit(FatalIOError); << exit(FatalIOError);
@ -121,7 +119,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
); );
} }
@ -129,7 +127,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New
{ {
FatalIOErrorIn FatalIOErrorIn
( (
"lduMatrix::solver::New", solverData "lduMatrix::solver::New", solverControls
) << "cannot solve incomplete matrix, " ) << "cannot solve incomplete matrix, "
"no diagonal or off-diagonal coefficient" "no diagonal or off-diagonal coefficient"
<< exit(FatalIOError); << exit(FatalIOError);
@ -148,7 +146,7 @@ Foam::lduMatrix::solver::solver
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
: :
fieldName_(fieldName), fieldName_(fieldName),
@ -156,12 +154,7 @@ Foam::lduMatrix::solver::solver
interfaceBouCoeffs_(interfaceBouCoeffs), interfaceBouCoeffs_(interfaceBouCoeffs),
interfaceIntCoeffs_(interfaceIntCoeffs), interfaceIntCoeffs_(interfaceIntCoeffs),
interfaces_(interfaces), interfaces_(interfaces),
controlDict_(solverControls)
controlDict_(solverData),
maxIter_(1000),
tolerance_(1e-6),
relTol_(0)
{ {
readControls(); readControls();
} }
@ -171,16 +164,15 @@ Foam::lduMatrix::solver::solver
void Foam::lduMatrix::solver::readControls() void Foam::lduMatrix::solver::readControls()
{ {
controlDict_.readIfPresent("maxIter", maxIter_); maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000);
controlDict_.readIfPresent("tolerance", tolerance_); tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6);
controlDict_.readIfPresent("relTol", relTol_); relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0);
} }
void Foam::lduMatrix::solver::read(Istream& solverData) void Foam::lduMatrix::solver::read(const dictionary& solverControls)
{ {
word solverName(solverData); controlDict_ = solverControls;
solverData >> controlDict_;
readControls(); readControls();
} }

View File

@ -43,7 +43,7 @@ namespace Foam
Foam::DICPreconditioner::DICPreconditioner Foam::DICPreconditioner::DICPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver& sol,
Istream& const dictionary&
) )
: :
lduMatrix::preconditioner(sol), lduMatrix::preconditioner(sol),

View File

@ -67,11 +67,11 @@ public:
// Constructors // Constructors
//- Construct from matrix components and preconditioner data stream //- Construct from matrix components and preconditioner solver controls
DICPreconditioner DICPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver&,
Istream& preconditionerData const dictionary& solverControlsUnused
); );

View File

@ -43,7 +43,7 @@ namespace Foam
Foam::DILUPreconditioner::DILUPreconditioner Foam::DILUPreconditioner::DILUPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver& sol,
Istream& const dictionary&
) )
: :
lduMatrix::preconditioner(sol), lduMatrix::preconditioner(sol),

View File

@ -67,11 +67,11 @@ public:
// Constructors // Constructors
//- Construct from matrix components and preconditioner data stream //- Construct from matrix components and preconditioner solver controls
DILUPreconditioner DILUPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver&,
Istream& preconditionerData const dictionary& solverControlsUnused
); );
@ -94,8 +94,7 @@ public:
const direction cmpt=0 const direction cmpt=0
) const; ) const;
//- Return wT the transpose-matrix preconditioned form of //- Return wT the transpose-matrix preconditioned form of residual rT.
// residual rT.
virtual void preconditionT virtual void preconditionT
( (
scalarField& wT, scalarField& wT,

View File

@ -43,7 +43,7 @@ namespace Foam
Foam::FDICPreconditioner::FDICPreconditioner Foam::FDICPreconditioner::FDICPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver& sol,
Istream& const dictionary&
) )
: :
lduMatrix::preconditioner(sol), lduMatrix::preconditioner(sol),
@ -164,7 +164,7 @@ void Foam::FDICPreconditioner::precondition
__builtin_prefetch (&uPtr[face+96],0,0); __builtin_prefetch (&uPtr[face+96],0,0);
__builtin_prefetch (&lPtr[face+96],0,0); __builtin_prefetch (&lPtr[face+96],0,0);
__builtin_prefetch (&rDuUpperPtr[face+96],0,0); __builtin_prefetch (&rDuUpperPtr[face+96],0,0);
__builtin_prefetch (&wAPtr[uPtr[face+32]],0,1); __builtin_prefetch (&wAPtr[uPtr[face+32]],0,1);
__builtin_prefetch (&wAPtr[lPtr[face+32]],0,1); __builtin_prefetch (&wAPtr[lPtr[face+32]],0,1);
#endif #endif

View File

@ -80,11 +80,11 @@ public:
// Constructors // Constructors
//- Construct from matrix components and preconditioner data stream //- Construct from matrix components and preconditioner solver controls
FDICPreconditioner FDICPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver&,
Istream& preconditionerData const dictionary& solverControlsUnused
); );

View File

@ -45,7 +45,7 @@ namespace Foam
Foam::GAMGPreconditioner::GAMGPreconditioner Foam::GAMGPreconditioner::GAMGPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver& sol,
Istream& preconditionerData const dictionary& solverControls
) )
: :
GAMGSolver GAMGSolver
@ -55,7 +55,7 @@ Foam::GAMGPreconditioner::GAMGPreconditioner
sol.interfaceBouCoeffs(), sol.interfaceBouCoeffs(),
sol.interfaceIntCoeffs(), sol.interfaceIntCoeffs(),
sol.interfaces(), sol.interfaces(),
preconditionerData solverControls
), ),
lduMatrix::preconditioner(sol), lduMatrix::preconditioner(sol),
nVcycles_(2) nVcycles_(2)
@ -75,13 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner()
void Foam::GAMGPreconditioner::readControls() void Foam::GAMGPreconditioner::readControls()
{ {
GAMGSolver::readControls(); GAMGSolver::readControls();
controlDict_.readIfPresent("nVcycles", nVcycles_); nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2);
}
void Foam::GAMGPreconditioner::read(Istream& solverData)
{
GAMGSolver::read(solverData);
} }

View File

@ -55,17 +55,14 @@ class GAMGPreconditioner
public GAMGSolver, public GAMGSolver,
public lduMatrix::preconditioner public lduMatrix::preconditioner
{ {
// Private data protected:
// Protected data
//- Number of V-cycles to perform //- Number of V-cycles to perform
label nVcycles_; label nVcycles_;
//- Read the control parameters from the controlDict_
// Private member functions virtual void readControls();
//- Read control parameters from the control dictionary
void readControls();
public: public:
@ -75,11 +72,11 @@ public:
// Constructors // Constructors
//- Construct for given solver and preconditioner data stream //- Construct from matrix components and preconditioner solver controls
GAMGPreconditioner GAMGPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver&,
Istream& preconditionerData const dictionary& solverControls
); );
@ -90,9 +87,6 @@ public:
// Member Functions // Member Functions
//- Read and reset the preconditioner parameters from the given stream
virtual void read(Istream& preconditionerData);
//- Return wA the preconditioned form of residual rA //- Return wA the preconditioned form of residual rA
virtual void precondition virtual void precondition
( (

View File

@ -47,7 +47,7 @@ namespace Foam
Foam::diagonalPreconditioner::diagonalPreconditioner Foam::diagonalPreconditioner::diagonalPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver& sol,
Istream& const dictionary&
) )
: :
lduMatrix::preconditioner(sol), lduMatrix::preconditioner(sol),
@ -77,10 +77,6 @@ Foam::diagonalPreconditioner::diagonalPreconditioner
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::diagonalPreconditioner::read(Istream&)
{}
void Foam::diagonalPreconditioner::precondition void Foam::diagonalPreconditioner::precondition
( (
scalarField& wA, scalarField& wA,

View File

@ -56,7 +56,7 @@ class diagonalPreconditioner
{ {
// Private data // Private data
//- The reciprocal diagonal //- The reciprocal diagonal
scalarField rD; scalarField rD;
@ -77,11 +77,11 @@ public:
// Constructors // Constructors
//- Construct from matrix components and preconditioner data stream //- Construct from matrix components and preconditioner solver controls
diagonalPreconditioner diagonalPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver&,
Istream& preconditionerData const dictionary& solverControlsUnused
); );
@ -93,9 +93,6 @@ public:
// Member Functions // Member Functions
//- Read and reset the preconditioner parameters from the given stream
virtual void read(Istream& preconditionerData);
//- Return wA the preconditioned form of residual rA //- Return wA the preconditioned form of residual rA
virtual void precondition virtual void precondition
( (
@ -104,8 +101,7 @@ public:
const direction cmpt=0 const direction cmpt=0
) const; ) const;
//- Return wT the transpose-matrix preconditioned form of //- Return wT the transpose-matrix preconditioned form of residual rT.
// residual rT.
virtual void preconditionT virtual void preconditionT
( (
scalarField& wT, scalarField& wT,
@ -113,7 +109,7 @@ public:
const direction cmpt=0 const direction cmpt=0
) const ) const
{ {
return(precondition(wT, rT, cmpt)); return precondition(wT, rT, cmpt);
} }
}; };

View File

@ -47,7 +47,7 @@ namespace Foam
Foam::noPreconditioner::noPreconditioner Foam::noPreconditioner::noPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver& sol,
Istream& const dictionary&
) )
: :
lduMatrix::preconditioner(sol) lduMatrix::preconditioner(sol)
@ -56,10 +56,6 @@ Foam::noPreconditioner::noPreconditioner
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::noPreconditioner::read(Istream&)
{}
void Foam::noPreconditioner::precondition void Foam::noPreconditioner::precondition
( (
scalarField& wA, scalarField& wA,

View File

@ -68,11 +68,11 @@ public:
// Constructors // Constructors
//- Construct from matrix components and preconditioner data stream //- Construct from matrix components and preconditioner solver controls
noPreconditioner noPreconditioner
( (
const lduMatrix::solver& sol, const lduMatrix::solver&,
Istream& preconditionerData const dictionary& solverControlsUnused
); );
@ -84,9 +84,6 @@ public:
// Member Functions // Member Functions
//- Read and reset the preconditioner parameters from the given stream
virtual void read(Istream& preconditionerData);
//- Return wA the preconditioned form of residual rA //- Return wA the preconditioned form of residual rA
virtual void precondition virtual void precondition
( (
@ -95,8 +92,7 @@ public:
const direction cmpt=0 const direction cmpt=0
) const; ) const;
//- Return wT the transpose-matrix preconditioned form of //- Return wT the transpose-matrix preconditioned form of residual rT.
// residual rT.
virtual void preconditionT virtual void preconditionT
( (
scalarField& wT, scalarField& wT,
@ -104,7 +100,7 @@ public:
const direction cmpt=0 const direction cmpt=0
) const ) const
{ {
return(precondition(wT, rT, cmpt)); return precondition(wT, rT, cmpt);
} }
}; };

View File

@ -27,8 +27,10 @@ Class
Description Description
Simplified diagonal-based incomplete Cholesky smoother for symmetric Simplified diagonal-based incomplete Cholesky smoother for symmetric
matrices. In order to improve efficiency the residual is evaluated after matrices.
every nSweeps sweeps.
To improve efficiency, the residual is evaluated after every nSweeps
sweeps.
SourceFiles SourceFiles
DICSmoother.C DICSmoother.C

View File

@ -26,9 +26,9 @@ Class
Foam::DICGaussSeidelSmoother Foam::DICGaussSeidelSmoother
Description Description
Combined DIC/GaussSeidel smoother for symmetric Combined DIC/GaussSeidel smoother for symmetric matrices in which DIC
matrices in which DIC smoothing is followed by GaussSeidel to ensure that smoothing is followed by GaussSeidel to ensure that any "spikes" created
any "spikes" created by the DIC sweeps are smoothed-out. by the DIC sweeps are smoothed-out.
SourceFiles SourceFiles
DICGaussSeidelSmoother.C DICGaussSeidelSmoother.C
@ -47,7 +47,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class DICGaussSeidelSmoother Declaration Class DICGaussSeidelSmoother Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class DICGaussSeidelSmoother class DICGaussSeidelSmoother
@ -57,6 +57,7 @@ class DICGaussSeidelSmoother
// Private data // Private data
DICSmoother dicSmoother_; DICSmoother dicSmoother_;
GaussSeidelSmoother gsSmoother_; GaussSeidelSmoother gsSmoother_;

View File

@ -27,8 +27,9 @@ Class
Description Description
Simplified diagonal-based incomplete LU smoother for asymmetric matrices. Simplified diagonal-based incomplete LU smoother for asymmetric matrices.
In order to improve efficiency the residual is evaluated after every
nSweeps sweeps. To improve efficiency, the residual is evaluated after every nSweeps
sweeps.
SourceFiles SourceFiles
DILUSmoother.C DILUSmoother.C
@ -46,7 +47,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class DILUSmoother Declaration Class DILUSmoother Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class DILUSmoother class DILUSmoother

View File

@ -26,9 +26,9 @@ Class
Foam::DILUGaussSeidelSmoother Foam::DILUGaussSeidelSmoother
Description Description
Combined DILU/GaussSeidel smoother for asymmetric Combined DILU/GaussSeidel smoother for asymmetric matrices in which
matrices in which DILU smoothing is followed by GaussSeidel to ensure that DILU smoothing is followed by GaussSeidel to ensure that any "spikes"
any "spikes" created by the DILU sweeps are smoothed-out. created by the DILU sweeps are smoothed-out.
SourceFiles SourceFiles
DILUGaussSeidelSmoother.C DILUGaussSeidelSmoother.C
@ -47,7 +47,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class DILUGaussSeidelSmoother Declaration Class DILUGaussSeidelSmoother Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class DILUGaussSeidelSmoother class DILUGaussSeidelSmoother
@ -57,6 +57,7 @@ class DILUGaussSeidelSmoother
// Private data // Private data
DILUSmoother diluSmoother_; DILUSmoother diluSmoother_;
GaussSeidelSmoother gsSmoother_; GaussSeidelSmoother gsSmoother_;

View File

@ -37,36 +37,31 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::IStringStream Foam::BICCG::solverDataStream Foam::dictionary Foam::BICCG::solverDict
( (
const scalar tolerance, const scalar tol,
const scalar relTol const scalar relTol
) const )
{ {
return IStringStream dictionary dict(IStringStream("solver PBiCG; preconditioner DILU;")());
( dict.add("tolerance", tol);
"{ preconditioner DILU;" dict.add("relTol", relTol);
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
); return dict;
} }
Foam::IStringStream Foam::BICCG::solverDataStream Foam::dictionary Foam::BICCG::solverDict
( (
const word& solverName, Istream& is
Istream& solverData )
) const
{ {
scalar tolerance(readScalar(solverData)); scalar tol(readScalar(is));
scalar relTol(readScalar(solverData)); scalar relTol(readScalar(is));
return IStringStream return solverDict(tol, relTol);
(
solverName + "{ preconditioner DILU;"
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
);
} }
@ -79,8 +74,7 @@ Foam::BICCG::BICCG
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
const scalar tolerance, const dictionary& solverControls
const scalar relTol
) )
: :
PBiCG PBiCG
@ -90,7 +84,7 @@ Foam::BICCG::BICCG
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverDataStream(tolerance, relTol)() solverControls
) )
{} {}
@ -102,7 +96,8 @@ Foam::BICCG::BICCG
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const scalar tolerance,
const scalar relTol
) )
: :
PBiCG PBiCG
@ -112,18 +107,8 @@ Foam::BICCG::BICCG
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverDataStream(word::null, solverData)() solverDict(tolerance, relTol)
) )
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::BICCG::read(Istream& solverData)
{
word solverName(solverData);
PBiCG::read(solverDataStream(solverName, solverData)());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -32,7 +32,7 @@ Description
Deprecated Deprecated
This solver is present for backward-compatibility and the PBiCG solver This solver is present for backward-compatibility and the PBiCG solver
should be used for preference. should be used instead.
SourceFiles SourceFiles
BICCG.C BICCG.C
@ -65,31 +65,39 @@ class BICCG
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const BICCG&); void operator=(const BICCG&);
//- Return the dictionary data-stream constructed from the components.
// Needed for backward compatibility
IStringStream solverDataStream
(
const scalar tolerance,
const scalar relTol
) const;
//- Return the dictionary data-stream constructed from the old-style
// data-stream. Needed for backward compatibility
IStringStream solverDataStream
(
const word& solverName,
Istream& solverData
) const;
public: public:
//- Return the dictionary constructed from the components.
// Needed for backward compatibility
static dictionary solverDict
(
const scalar tol,
const scalar relTol
);
//- Return the dictionary constructed from the old-style data-stream.
// Needed for backward compatibility
static dictionary solverDict(Istream&);
//- Runtime type information //- Runtime type information
TypeName("BICCG"); TypeName("BICCG");
// Constructors // Constructors
//- Construct from matrix components and solver data stream
BICCG
(
const word& fieldName,
const lduMatrix& matrix,
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
const dictionary& solverControls
);
//- Construct from matrix components and tolerances //- Construct from matrix components and tolerances
BICCG BICCG
( (
@ -102,28 +110,11 @@ public:
const scalar relTol = 0.0 const scalar relTol = 0.0
); );
//- Construct from matrix components and solver data stream
BICCG
(
const word& fieldName,
const lduMatrix& matrix,
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
);
// Destructor // Destructor
virtual ~BICCG() virtual ~BICCG()
{} {}
// Member Functions
//- Read and reset the solver parameters from the given stream
void read(Istream& solverData);
}; };

View File

@ -49,7 +49,7 @@ Foam::GAMGSolver::GAMGSolver
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
: :
lduMatrix::solver lduMatrix::solver
@ -59,7 +59,7 @@ Foam::GAMGSolver::GAMGSolver
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
), ),
// Default values for all controls // Default values for all controls
@ -112,7 +112,7 @@ Foam::GAMGSolver::GAMGSolver
"const FieldField<Field, scalar>& interfaceBouCoeffs," "const FieldField<Field, scalar>& interfaceBouCoeffs,"
"const FieldField<Field, scalar>& interfaceIntCoeffs," "const FieldField<Field, scalar>& interfaceIntCoeffs,"
"const lduInterfaceFieldPtrsList& interfaces," "const lduInterfaceFieldPtrsList& interfaces,"
"Istream& solverData" "const dictionary& solverControls"
")" ")"
) << "No coarse levels created, either matrix too small for GAMG" ) << "No coarse levels created, either matrix too small for GAMG"
" or nCellsInCoarsestLevel too large.\n" " or nCellsInCoarsestLevel too large.\n"
@ -154,6 +154,7 @@ void Foam::GAMGSolver::readControls()
{ {
lduMatrix::solver::readControls(); lduMatrix::solver::readControls();
// we could also consider supplying defaults here too
controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_); controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_);
controlDict_.readIfPresent("nPreSweeps", nPreSweeps_); controlDict_.readIfPresent("nPreSweeps", nPreSweeps_);
controlDict_.readIfPresent("nPostSweeps", nPostSweeps_); controlDict_.readIfPresent("nPostSweeps", nPostSweeps_);

View File

@ -212,7 +212,7 @@ public:
// Constructors // Constructors
//- Construct from lduMatrix //- Construct from lduMatrix and solver controls
GAMGSolver GAMGSolver
( (
const word& fieldName, const word& fieldName,
@ -220,7 +220,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );

View File

@ -374,7 +374,7 @@ void Foam::GAMGSolver::initVcycle
interfaceBouCoeffs_, interfaceBouCoeffs_,
interfaceIntCoeffs_, interfaceIntCoeffs_,
interfaces_, interfaces_,
controlDict_.lookup("smoother") controlDict_
) )
); );
@ -408,7 +408,7 @@ void Foam::GAMGSolver::initVcycle
interfaceLevelsBouCoeffs_[leveli], interfaceLevelsBouCoeffs_[leveli],
interfaceLevelsIntCoeffs_[leveli], interfaceLevelsIntCoeffs_[leveli],
interfaceLevels_[leveli], interfaceLevels_[leveli],
controlDict_.lookup("smoother") controlDict_
) )
); );
} }

View File

@ -36,40 +36,33 @@ namespace Foam
addICCGSymMatrixConstructorToTable_; addICCGSymMatrixConstructorToTable_;
} }
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::dictionary Foam::ICCG::solverDict
Foam::IStringStream Foam::ICCG::solverDataStream
( (
const scalar tolerance, const scalar tol,
const scalar relTol const scalar relTol
) const )
{ {
return IStringStream dictionary dict(IStringStream("solver PCG; preconditioner DIC;")());
( dict.add("tolerance", tol);
"{ preconditioner DIC;" dict.add("relTol", relTol);
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
); return dict;
} }
Foam::IStringStream Foam::ICCG::solverDataStream Foam::dictionary Foam::ICCG::solverDict
( (
const word& solverName, Istream& is
Istream& solverData )
) const
{ {
scalar tolerance(readScalar(solverData)); scalar tol(readScalar(is));
scalar relTol(readScalar(solverData)); scalar relTol(readScalar(is));
return IStringStream return solverDict(tol, relTol);
(
solverName + "{ preconditioner DIC;"
" tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }"
);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ICCG::ICCG Foam::ICCG::ICCG
@ -79,8 +72,7 @@ Foam::ICCG::ICCG
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
const scalar tolerance, const dictionary& solverControls
const scalar relTol
) )
: :
PCG PCG
@ -90,7 +82,7 @@ Foam::ICCG::ICCG
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverDataStream(tolerance, relTol)() solverControls
) )
{} {}
@ -102,7 +94,8 @@ Foam::ICCG::ICCG
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const scalar tolerance,
const scalar relTol
) )
: :
PCG PCG
@ -112,18 +105,8 @@ Foam::ICCG::ICCG
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverDataStream(word::null, solverData)() solverDict(tolerance, relTol)
) )
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ICCG::read(Istream& solverData)
{
word solverName(solverData);
PCG::read(solverDataStream(solverName, solverData)());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -65,31 +65,38 @@ class ICCG
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ICCG&); void operator=(const ICCG&);
//- Return the dictionary data-stream constructed from the components.
// Needed for backward compatibility
IStringStream solverDataStream
(
const scalar tolerance,
const scalar relTol
) const;
//- Return the dictionary data-stream constructed from the old-style
// data-stream. Needed for backward compatibility
IStringStream solverDataStream
(
const word& solverName,
Istream& solverData
) const;
public: public:
//- Return the dictionary constructed from the components.
// Needed for backward compatibility
static dictionary solverDict
(
const scalar tol,
const scalar relTol
);
//- Return the dictionary constructed from the old-style data-stream.
// Needed for backward compatibility
static dictionary solverDict(Istream&);
//- Runtime type information //- Runtime type information
TypeName("ICCG"); TypeName("ICCG");
// Constructors // Constructors
//- Construct from matrix components and solver data stream
ICCG
(
const word& fieldName,
const lduMatrix& matrix,
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
const dictionary& solverControls
);
//- Construct from matrix components and tolerances //- Construct from matrix components and tolerances
ICCG ICCG
( (
@ -102,28 +109,11 @@ public:
const scalar relTol = 0.0 const scalar relTol = 0.0
); );
//- Construct from matrix components and solver data stream
ICCG
(
const word& fieldName,
const lduMatrix& matrix,
const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData
);
// Destructor // Destructor
virtual ~ICCG() virtual ~ICCG()
{} {}
// Member Functions
//- Read and reset the solver parameters from the given stream
void read(Istream& solverData);
}; };

View File

@ -46,7 +46,7 @@ Foam::PBiCG::PBiCG
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
: :
lduMatrix::solver lduMatrix::solver
@ -56,7 +56,7 @@ Foam::PBiCG::PBiCG
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
{} {}
@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve
const direction cmpt const direction cmpt
) const ) const
{ {
word preconditionerName(controlDict_.lookup("preconditioner"));
// --- Setup class containing solver performance data // --- Setup class containing solver performance data
lduMatrix::solverPerformance solverPerf lduMatrix::solverPerformance solverPerf
( (
preconditionerName + typeName, lduMatrix::preconditioner::getName(controlDict_) + typeName,
fieldName_ fieldName_
); );
@ -128,7 +126,7 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve
lduMatrix::preconditioner::New lduMatrix::preconditioner::New
( (
*this, *this,
controlDict_.lookup("preconditioner") controlDict_
); );
// --- Solver iteration // --- Solver iteration

View File

@ -77,7 +77,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );

View File

@ -46,7 +46,7 @@ Foam::PCG::PCG
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
: :
lduMatrix::solver lduMatrix::solver
@ -56,7 +56,7 @@ Foam::PCG::PCG
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
{} {}
@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve
const direction cmpt const direction cmpt
) const ) const
{ {
word preconditionerName(controlDict_.lookup("preconditioner"));
// --- Setup class containing solver performance data // --- Setup class containing solver performance data
lduMatrix::solverPerformance solverPerf lduMatrix::solverPerformance solverPerf
( (
preconditionerName + typeName, lduMatrix::preconditioner::getName(controlDict_) + typeName,
fieldName_ fieldName_
); );
@ -119,7 +117,7 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve
lduMatrix::preconditioner::New lduMatrix::preconditioner::New
( (
*this, *this,
controlDict_.lookup("preconditioner") controlDict_
); );
// --- Solver iteration // --- Solver iteration

View File

@ -27,7 +27,7 @@ Class
Description Description
Preconditioned conjugate gradient solver for symmetric lduMatrices Preconditioned conjugate gradient solver for symmetric lduMatrices
using a run-time selectable preconditiioner. using a run-time selectable preconditioner.
SourceFiles SourceFiles
PCG.C PCG.C
@ -69,7 +69,7 @@ public:
// Constructors // Constructors
//- Construct from matrix components and solver data stream //- Construct from matrix components and solver controls
PCG PCG
( (
const word& fieldName, const word& fieldName,
@ -77,7 +77,7 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );

View File

@ -43,7 +43,7 @@ Foam::diagonalSolver::diagonalSolver
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
: :
lduMatrix::solver lduMatrix::solver
@ -53,19 +53,13 @@ Foam::diagonalSolver::diagonalSolver
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
) )
{} {}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::diagonalSolver::read(Istream& solverData)
{
word solverName(solverData);
}
Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve
( (
scalarField& psi, scalarField& psi,

View File

@ -68,7 +68,7 @@ public:
// Constructors // Constructors
//- Construct from matrix //- Construct from matrix and solver controls
diagonalSolver diagonalSolver
( (
const word& fieldName, const word& fieldName,
@ -76,14 +76,15 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );
// Member Functions // Member Functions
//- Read and reset the solver parameters from the given stream //- Read and reset the solver parameters from the given stream
void read(Istream& solverData); void read(const dictionary&)
{}
//- Solve the matrix with this solver //- Solve the matrix with this solver
lduMatrix::solverPerformance solve lduMatrix::solverPerformance solve

View File

@ -49,7 +49,7 @@ Foam::smoothSolver::smoothSolver
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
) )
: :
lduMatrix::solver lduMatrix::solver
@ -59,9 +59,8 @@ Foam::smoothSolver::smoothSolver
interfaceBouCoeffs, interfaceBouCoeffs,
interfaceIntCoeffs, interfaceIntCoeffs,
interfaces, interfaces,
solverData solverControls
), )
nSweeps_(1)
{ {
readControls(); readControls();
} }
@ -72,7 +71,7 @@ Foam::smoothSolver::smoothSolver
void Foam::smoothSolver::readControls() void Foam::smoothSolver::readControls()
{ {
lduMatrix::solver::readControls(); lduMatrix::solver::readControls();
controlDict_.readIfPresent("nSweeps", nSweeps_); nSweeps_ = controlDict_.lookupOrDefault<label>("nSweeps", 1);
} }
@ -96,7 +95,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve
interfaceBouCoeffs_, interfaceBouCoeffs_,
interfaceIntCoeffs_, interfaceIntCoeffs_,
interfaces_, interfaces_,
controlDict_.lookup("smoother") controlDict_
); );
smootherPtr->smooth smootherPtr->smooth
@ -144,7 +143,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve
interfaceBouCoeffs_, interfaceBouCoeffs_,
interfaceIntCoeffs_, interfaceIntCoeffs_,
interfaces_, interfaces_,
controlDict_.lookup("smoother") controlDict_
); );
// Smoothing loop // Smoothing loop

View File

@ -66,7 +66,6 @@ protected:
//- Read the control parameters from the controlDict_ //- Read the control parameters from the controlDict_
virtual void readControls(); virtual void readControls();
public: public:
//- Runtime type information //- Runtime type information
@ -75,7 +74,7 @@ public:
// Constructors // Constructors
//- Construct from matrix components and solver data stream //- Construct from matrix components and solver controls
smoothSolver smoothSolver
( (
const word& fieldName, const word& fieldName,
@ -83,10 +82,15 @@ public:
const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceBouCoeffs,
const FieldField<Field, scalar>& interfaceIntCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs,
const lduInterfaceFieldPtrsList& interfaces, const lduInterfaceFieldPtrsList& interfaces,
Istream& solverData const dictionary& solverControls
); );
// Destructor
virtual ~smoothSolver()
{}
// Member Functions // Member Functions
//- Solve the matrix with this solver //- Solve the matrix with this solver

View File

@ -27,9 +27,22 @@ License
#include "solution.H" #include "solution.H"
#include "Time.H" #include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // these are for old syntax compatibility:
#include "BICCG.H"
#include "ICCG.H"
#include "IStringStream.H"
int Foam::solution::debug(Foam::debug::debugSwitch("solution", false)); // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::solution::debug(::Foam::debug::debugSwitch("solution", 0));
// list of sub-dictionaries to rewrite
//! @cond localScope
static const Foam::List<Foam::word> subDictNames
(
Foam::IStringStream("(preconditioner smoother)")()
);
//! @endcond localScope
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -55,6 +68,84 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::solution::upgradeSolverDict
(
dictionary& dict,
const bool verbose
)
{
label nChanged = 0;
// backward compatibility:
// recast primitive entries into dictionary entries
forAllIter(dictionary, dict, iter)
{
if (!iter().isDict())
{
Istream& is = iter().stream();
word name(is);
dictionary subdict;
if (name == "BICCG")
{
// special treatment for very old syntax
subdict = BICCG::solverDict(is);
}
else if (name == "ICCG")
{
// special treatment for very old syntax
subdict = ICCG::solverDict(is);
}
else
{
subdict.add("solver", name);
subdict <<= dictionary(is);
// preconditioner and smoother entries can be
// 1) primitiveEntry w/o settings,
// 2) or a dictionaryEntry.
// transform primitiveEntry with settings -> dictionaryEntry
forAll(subDictNames, dictI)
{
const word& dictName = subDictNames[dictI];
entry* ePtr = subdict.lookupEntryPtr(dictName,false,false);
if (ePtr && !ePtr->isDict())
{
Istream& is = ePtr->stream();
is >> name;
if (!is.eof())
{
dictionary newDict;
newDict.add(dictName, name);
newDict <<= dictionary(is);
subdict.set(dictName, newDict);
}
}
}
}
// write out information to help people adjust to the new syntax
if (verbose)
{
Info<< "// using new solver syntax:\n"
<< iter().keyword() << subdict << endl;
}
// overwrite with dictionary entry
dict.set(iter().keyword(), subdict);
nChanged++;
}
}
return nChanged;
}
bool Foam::solution::read() bool Foam::solution::read()
{ {
if (regIOobject::read()) if (regIOobject::read())
@ -69,6 +160,7 @@ bool Foam::solution::read()
if (dict.found("solvers")) if (dict.found("solvers"))
{ {
solvers_ = dict.subDict("solvers"); solvers_ = dict.subDict("solvers");
upgradeSolverDict(solvers_);
} }
return true; return true;
@ -97,7 +189,7 @@ bool Foam::solution::relax(const word& name) const
{ {
if (debug) if (debug)
{ {
Info<< "Lookup relax for " << name << endl; Info<< "Find relax for " << name << endl;
} }
return relaxationFactors_.found(name); return relaxationFactors_.found(name);
@ -127,7 +219,7 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const
} }
Foam::ITstream& Foam::solution::solver(const word& name) const const Foam::dictionary& Foam::solution::solver(const word& name) const
{ {
if (debug) if (debug)
{ {
@ -135,7 +227,7 @@ Foam::ITstream& Foam::solution::solver(const word& name) const
<< "Lookup solver for " << name << endl; << "Lookup solver for " << name << endl;
} }
return solvers_.lookup(name); return solvers_.subDict(name);
} }

View File

@ -44,7 +44,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class solution Declaration Class solution Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class solution class solution
@ -59,7 +59,6 @@ class solution
//- Dictionary of solver parameters for all the fields //- Dictionary of solver parameters for all the fields
dictionary solvers_; dictionary solvers_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct and assignment //- Disallow default bitwise copy construct and assignment
@ -69,6 +68,11 @@ class solution
public: public:
//- Update from older solver controls syntax
// Usually verbose, since we want to know about the changes
// Returns the number of settings changed
static label upgradeSolverDict(dictionary& dict, const bool verbose=true);
//- Debug switch //- Debug switch
static int debug; static int debug;
@ -84,7 +88,7 @@ public:
// Access // Access
//- Return the selected sub-dictionary of solvers if the "select" //- Return the selected sub-dictionary of solvers if the "select"
// keyword is given othewise return the complete dictionary // keyword is given, otherwise return the complete dictionary
const dictionary& solutionDict() const; const dictionary& solutionDict() const;
//- Return true if the relaxation factor is given for the field //- Return true if the relaxation factor is given for the field
@ -93,13 +97,11 @@ public:
//- Return the relaxation factor for the given field //- Return the relaxation factor for the given field
scalar relaxationFactor(const word& name) const; scalar relaxationFactor(const word& name) const;
//- Return the dictionary of solver parameters for the given field //- Return the solver controls dictionary for the given field
const dictionary& solverDict(const word& name) const; const dictionary& solverDict(const word& name) const;
//- Return the stream of solver parameters for the given field //- Return the solver controls dictionary for the given field
// @deprecated Backward compatibility only - should use solverDict const dictionary& solver(const word& name) const;
ITstream& solver(const word& name) const;
// Read // Read

View File

@ -28,6 +28,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -420,13 +421,13 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet
forAll(patchNames, i) forAll(patchNames, i)
{ {
// Treat the diven patch names as wild-cards and search the set // Treat the given patch names as wild-cards and search the set
// of all patch names for matches // of all patch names for matches
labelList patchIDs = findStrings(patchNames[i], allPatchNames); labelList patchIDs = findStrings(patchNames[i], allPatchNames);
if (patchIDs.size() == 0) if (patchIDs.size() == 0)
{ {
WarningIn("polyBoundaryMesh::patchSet(const wordList& patchNames)") WarningIn("polyBoundaryMesh::patchSet(const wordList&)")
<< "Cannot find any patch names matching " << patchNames[i] << "Cannot find any patch names matching " << patchNames[i]
<< endl; << endl;
} }

View File

@ -34,27 +34,15 @@ Description
#define stringList_H #define stringList_H
#include "string.H" #include "string.H"
#include "labelList.H" #include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
typedef List<string> stringList; typedef List<string> stringList;
//- Return the indices of the strings in the list
// that match the given regular expression
template<class StringList>
labelList findStrings(const string& regexp, const StringList&);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "stringListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif

View File

@ -0,0 +1,70 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InNamspace
Foam
Description
Operations on lists of strings.
SourceFiles
stringListOpsTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef stringListOps_H
#define stringListOps_H
#include "labelList.H"
#include "stringList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
//- Return the indices of the strings in the list
// that match the given regular expression
// partial matches are optional
template<class StringType>
labelList findStrings
(
const string& regexpPattern,
const UList<StringType>&,
bool partialMatch=false
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "stringListOpsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -25,7 +25,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "labelList.H" #include "labelList.H"
#include "regularExpression.H" #include "regExp.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -34,25 +34,28 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class StringList> template<class StringType>
labelList findStrings(const string& regexp, const StringList& sl) labelList findStrings
(
const string& pattern,
const UList<StringType>& lst,
bool partialMatch
)
{ {
labelList matches(sl.size()); regExp re(pattern);
labelList matched(lst.size());
regularExpression re(regexp); label matchI = 0;
forAll(lst, elemI)
label matchi = 0;
forAll(sl, i)
{ {
if (re.matches(sl[i])) if (re.match(lst[elemI], partialMatch))
{ {
matches[matchi++] = i; matched[matchI++] = elemI;
} }
} }
matched.setSize(matchI);
matches.setSize(matchi); return matched;
return matches;
} }

View File

@ -336,8 +336,8 @@ Foam::fvMatrix<Type>::fvMatrix
{ {
if (debug) if (debug)
{ {
Info<< "fvMatrix<Type>(GeometricField<Type, fvPatchField, volMesh>&," Info<< "fvMatrix<Type>"
" Istream&) : " "(GeometricField<Type, fvPatchField, volMesh>&, Istream&) : "
"constructing fvMatrix<Type> for field " << psi_.name() "constructing fvMatrix<Type> for field " << psi_.name()
<< endl; << endl;
} }
@ -1257,7 +1257,7 @@ template<class Type>
Foam::lduMatrix::solverPerformance Foam::solve Foam::lduMatrix::solverPerformance Foam::solve
( (
fvMatrix<Type>& fvm, fvMatrix<Type>& fvm,
Istream& solverControls const dictionary& solverControls
) )
{ {
return fvm.solve(solverControls); return fvm.solve(solverControls);
@ -1267,7 +1267,7 @@ template<class Type>
Foam::lduMatrix::solverPerformance Foam::solve Foam::lduMatrix::solverPerformance Foam::solve
( (
const tmp<fvMatrix<Type> >& tfvm, const tmp<fvMatrix<Type> >& tfvm,
Istream& solverControls const dictionary& solverControls
) )
{ {
lduMatrix::solverPerformance solverPerf = lduMatrix::solverPerformance solverPerf =

View File

@ -220,8 +220,8 @@ public:
// Member functions // Member functions
//- Solve returning the solution statistics. //- Solve returning the solution statistics.
// Solver controls read from Istream // Use the given solver controls
lduMatrix::solverPerformance solve(Istream&); lduMatrix::solverPerformance solve(const dictionary&);
//- Solve returning the solution statistics. //- Solve returning the solution statistics.
// Solver controls read from fvSolution // Solver controls read from fvSolution
@ -359,16 +359,16 @@ public:
); );
//- Construct and return the solver //- Construct and return the solver
// Solver controls read from Istream // Use the given solver controls
autoPtr<fvSolver> solver(Istream&); autoPtr<fvSolver> solver(const dictionary&);
//- Construct and return the solver //- Construct and return the solver
// Solver controls read from fvSolution // Solver controls read from fvSolution
autoPtr<fvSolver> solver(); autoPtr<fvSolver> solver();
//- Solve returning the solution statistics. //- Solve returning the solution statistics.
// Solver controls read from Istream // Use the given solver controls
lduMatrix::solverPerformance solve(Istream&); lduMatrix::solverPerformance solve(const dictionary&);
//- Solve returning the solution statistics. //- Solve returning the solution statistics.
// Solver controls read from fvSolution // Solver controls read from fvSolution
@ -518,16 +518,20 @@ void checkMethod
//- Solve returning the solution statistics given convergence tolerance //- Solve returning the solution statistics given convergence tolerance
// Solver controls read Istream // Use the given solver controls
template<class Type> template<class Type>
lduMatrix::solverPerformance solve(fvMatrix<Type>&, Istream&); lduMatrix::solverPerformance solve(fvMatrix<Type>&, const dictionary&);
//- Solve returning the solution statistics given convergence tolerance, //- Solve returning the solution statistics given convergence tolerance,
// deleting temporary matrix after solution. // deleting temporary matrix after solution.
// Solver controls read Istream // Use the given solver controls
template<class Type> template<class Type>
lduMatrix::solverPerformance solve(const tmp<fvMatrix<Type> >&, Istream&); lduMatrix::solverPerformance solve
(
const tmp<fvMatrix<Type> >&,
const dictionary&
);
//- Solve returning the solution statistics given convergence tolerance //- Solve returning the solution statistics given convergence tolerance

View File

@ -53,12 +53,12 @@ void Foam::fvMatrix<Type>::setComponentReference
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
( (
Istream& solverControls const dictionary& solverControls
) )
{ {
if (debug) if (debug)
{ {
Info<< "fvMatrix<Type>::solve(Istream& solverControls) : " Info<< "fvMatrix<Type>::solve(const dictionary& solverControls) : "
"solving fvMatrix<Type>" "solving fvMatrix<Type>"
<< endl; << endl;
} }
@ -108,7 +108,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
internalCoeffs_.component(cmpt) internalCoeffs_.component(cmpt)
); );
lduInterfaceFieldPtrsList interfaces = lduInterfaceFieldPtrsList interfaces =
psi_.boundaryField().interfaces(); psi_.boundaryField().interfaces();
// Use the initMatrixInterfaces and updateMatrixInterfaces to correct // Use the initMatrixInterfaces and updateMatrixInterfaces to correct
@ -142,7 +142,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
bouCoeffsCmpt, bouCoeffsCmpt,
intCoeffsCmpt, intCoeffsCmpt,
interfaces, interfaces,
solverControls.rewind() solverControls
)->solve(psiCmpt, sourceCmpt, cmpt); )->solve(psiCmpt, sourceCmpt, cmpt);
solverPerf.print(); solverPerf.print();
@ -170,20 +170,20 @@ template<class Type>
Foam::autoPtr<typename Foam::fvMatrix<Type>::fvSolver> Foam::autoPtr<typename Foam::fvMatrix<Type>::fvSolver>
Foam::fvMatrix<Type>::solver() Foam::fvMatrix<Type>::solver()
{ {
return solver(psi_.mesh().solver(psi_.name())); return solver(psi_.mesh().solverDict(psi_.name()));
} }
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve() Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve()
{ {
return solve(psi_.mesh().solver(psi_.name())); return solve(psi_.mesh().solverDict(psi_.name()));
} }
template<class Type> template<class Type>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve() Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve()
{ {
return solve(psi_.mesh().solver(psi_.name())); return solve(psi_.mesh().solverDict(psi_.name()));
} }

View File

@ -45,7 +45,7 @@ void Foam::fvMatrix<Foam::scalar>::setComponentReference
internalCoeffs_[patchi][facei] += internalCoeffs_[patchi][facei] +=
diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]; diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]];
boundaryCoeffs_[patchi][facei] += boundaryCoeffs_[patchi][facei] +=
diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]] diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]
*value; *value;
} }
@ -57,12 +57,12 @@ template<>
Foam::autoPtr<Foam::fvMatrix<Foam::scalar>::fvSolver> Foam::autoPtr<Foam::fvMatrix<Foam::scalar>::fvSolver>
Foam::fvMatrix<Foam::scalar>::solver Foam::fvMatrix<Foam::scalar>::solver
( (
Istream& solverControls const dictionary& solverControls
) )
{ {
if (debug) if (debug)
{ {
Info<< "fvMatrix<scalar>::solver(Istream& solverControls) : " Info<< "fvMatrix<scalar>::solver(const dictionary& solverControls) : "
"solver for fvMatrix<scalar>" "solver for fvMatrix<scalar>"
<< endl; << endl;
} }
@ -96,7 +96,7 @@ Foam::fvMatrix<Foam::scalar>::solver
template<> template<>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
( (
Istream& solverControls const dictionary& solverControls
) )
{ {
scalarField saveDiag = fvMat_.diag(); scalarField saveDiag = fvMat_.diag();
@ -105,8 +105,10 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
scalarField totalSource = fvMat_.source(); scalarField totalSource = fvMat_.source();
fvMat_.addBoundarySource(totalSource, false); fvMat_.addBoundarySource(totalSource, false);
// assign new solver controls
solver_->read(solverControls); solver_->read(solverControls);
lduMatrix::solverPerformance solverPerf =
lduMatrix::solverPerformance solverPerf =
solver_->solve(fvMat_.psi().internalField(), totalSource); solver_->solve(fvMat_.psi().internalField(), totalSource);
solverPerf.print(); solverPerf.print();
@ -122,12 +124,12 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
template<> template<>
Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve
( (
Istream& solverControls const dictionary& solverControls
) )
{ {
if (debug) if (debug)
{ {
Info<< "fvMatrix<scalar>::solve(Istream& solverControls) : " Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : "
"solving fvMatrix<scalar>" "solving fvMatrix<scalar>"
<< endl; << endl;
} }

View File

@ -23,9 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass InClass
Foam::fvScalarMatrix Foam::fvMatrix
Description Description
A scalar instance of fvMatrix
SourceFiles SourceFiles
fvScalarMatrix.C fvScalarMatrix.C
@ -56,13 +57,22 @@ void fvMatrix<scalar>::setComponentReference
); );
template<> template<>
autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver(Istream&); autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver
(
const dictionary&
);
template<> template<>
lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve(Istream&); lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve
(
const dictionary&
);
template<> template<>
lduMatrix::solverPerformance fvMatrix<scalar>::solve(Istream&); lduMatrix::solverPerformance fvMatrix<scalar>::solve
(
const dictionary&
);
template<> template<>
tmp<scalarField> fvMatrix<scalar>::residual() const; tmp<scalarField> fvMatrix<scalar>::residual() const;

View File

@ -142,8 +142,8 @@ void Foam::MULES::implicitSolve
{ {
const fvMesh& mesh = psi.mesh(); const fvMesh& mesh = psi.mesh();
dictionary MULESSolver(mesh.solver(psi.name())); const dictionary& MULEScontrols =
const dictionary& MULEScontrols = MULESSolver.subDict("MULESImplicit"); mesh.solverDict(psi.name()).subDict("MULESImplicit");
label maxIter label maxIter
( (

View File

@ -55,7 +55,7 @@ namespace Foam
Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver
( (
const polyMesh& mesh, const polyMesh& mesh,
Istream& msData Istream&
) )
: :
fvMotionSolver(mesh), fvMotionSolver(mesh),

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