#includeModel, #includeConstraint: New dictionary directives

#includeModel includes an fvModel configuration file into the fvModels file
 #includeConstraint includes an fvModel configuration file into the fvConstraints file

These operate in the same manner as #includeFunc does for functionObjects and
search the etc/caseDicts/fvModels and etc/caseDicts/fvConstraints directories
for configuration files and apply optional argument substitution.

Class
    Foam::functionEntries::includeFvModelEntry

Description
    Specify a fvModel dictionary file to include, expects the
    fvModel name to follow with option arguments (without quotes).

    Searches for fvModel dictionary file in user/group/shipped
    directories allowing for version-specific and version-independent files
    using the following hierarchy:
    - \b user settings:
      - ~/.OpenFOAM/\<VERSION\>/caseDicts/fvModels
      - ~/.OpenFOAM/caseDicts/fvModels
    - \b group (site) settings (when $WM_PROJECT_SITE is set):
      - $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/fvModels
      - $WM_PROJECT_SITE/etc/caseDicts/fvModels
    - \b group (site) settings (when $WM_PROJECT_SITE is not set):
      - $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/caseDicts/fvModels
      - $WM_PROJECT_INST_DIR/site/etc/caseDicts/fvModels
    - \b other (shipped) settings:
      - $WM_PROJECT_DIR/etc/caseDicts/fvModels

    The optional field arguments included in the name are inserted in 'field' or
    'fields' entries in the fvModel dictionary and included in the name
    of the fvModel entry to avoid conflict.

    Examples:
    \verbatim
        #includeModel clouds
        #includeModel surfaceFilms
    \endverbatim

    Other dictionary entries may also be specified using named arguments.

See also
    Foam::includeFvConstraintEntry
    Foam::includeFuncEntry

Class
    Foam::functionEntries::includeFvConstraintEntry

Description
    Specify a fvConstraint dictionary file to include, expects the
    fvConstraint name to follow with option arguments (without quotes).

    Searches for fvConstraint dictionary file in user/group/shipped
    directories allowing for version-specific and version-independent files
    using the following hierarchy:
    - \b user settings:
      - ~/.OpenFOAM/\<VERSION\>/caseDicts/fvConstraints
      - ~/.OpenFOAM/caseDicts/fvConstraints
    - \b group (site) settings (when $WM_PROJECT_SITE is set):
      - $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/fvConstraints
      - $WM_PROJECT_SITE/etc/caseDicts/fvConstraints
    - \b group (site) settings (when $WM_PROJECT_SITE is not set):
      - $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/caseDicts/fvConstraints
      - $WM_PROJECT_INST_DIR/site/etc/caseDicts/fvConstraints
    - \b other (shipped) settings:
      - $WM_PROJECT_DIR/etc/caseDicts/fvConstraints

    The optional field arguments included in the name are inserted in 'field' or
    'fields' entries in the fvConstraint dictionary and included in the name
    of the fvConstraint entry to avoid conflict.

    Examples:
    \verbatim
        #includeConstraint limitPressure(minFactor=0.1, maxFactor=2)
        #includeConstraint limitTemperature(min=101, max=1000)
    \endverbatim
    or for a multiphase case:
    \verbatim
        #includeConstraint limitLowPressure(min=1e4)
        #includeConstraint limitTemperature(phase=steam, min=270, max=2000)
        #includeConstraint limitTemperature(phase=water, min=270, max=2000)
    \endverbatim

    Other dictionary entries may also be specified using named arguments.

See also
    Foam::includeFvModelEntry
    Foam::includeFuncEntry
This commit is contained in:
Henry Weller
2023-01-30 18:59:07 +00:00
parent 6614c7ad05
commit 3a269eb3d7
26 changed files with 1065 additions and 682 deletions

View File

@ -1 +1,2 @@
EXE_INC =
EXE_LIBS = -lfiniteVolume

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -217,7 +217,10 @@ int main(int argc, char *argv[])
{
Info<< nl
<< "Available configured functionObjects:"
<< functionObjectList::list()
<< listAllConfigFiles
(
functionEntries::includeFuncEntry::functionObjectDictPath
)
<< endl;
return 0;
}

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object limitPressure;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type limitPressure;
selectionMode all;
min <1e4>;
//************************************************************************** //

View File

@ -13,17 +13,16 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
limitp
{
type limitPressure;
selectionMode all;
// limits can be specified absolute
// min 200;
// max 500;
// min <200>;
// max <500>;
// ... or as multipliers on initial min/max values
minFactor 0.1;
maxFactor 1.5;
}
minFactor <0.1>;
maxFactor <1.5>;
//************************************************************************** //

View File

@ -13,12 +13,11 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
limitT
{
type limitTemperature;
min 200;
max 6000;
selectionMode all;
}
min <200>;
max <6000>;
//************************************************************************** //

View File

@ -13,14 +13,12 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
clouds
{
type clouds;
libs
(
"liblagrangianParcel.so"
"liblagrangianParcelTurbulence.so"
);
}
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object porousZone;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type explicitPorositySource;
explicitPorositySourceCoeffs
{
type DarcyForchheimer;
selectionMode cellZone;
cellZone <cellZoneName>; // Specify the name of the cellZone
DarcyForchheimerCoeffs
{
// Negative coeffs are multiplied by largest positive coeff,
// taking the magnitude, e.g. for -1000, coeff = |1e7*-1000| = 1e10
d [0 -2 0 0 0 0 0] (1e7 -1000 -1000);
f [0 -1 0 0 0 0 0] (0 0 0);
coordinateSystem // Cartesian coordinates for the cellZone
{
x (1 0 0);
y (0 1 0);
#includeEtc "caseDicts/general/coordinateSystem/cartesianXY"
}
}
fixedCoeffCoeffs
{
alpha [0 0 -1 0 0 0 0] (100 -1000 -1000);
beta [0 -1 0 0 0 0 0] (0 0 0);
rhoRef 1.205;
coordinateSystem // Cylindrical coordinates for the cellZone
{
origin (0 0 0);
axis (0 0 1);
#includeEtc "caseDicts/general/coordinateSystem/cylindrical"
}
}
}
//************************************************************************** //

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object surfaceFilms;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
type surfaceFilms;
libs ("libsurfaceFilmModels.so");
// ************************************************************************* //

View File

@ -1,58 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object porousZone;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
porousZone // Change to something more descriptive
{
type explicitPorositySource;
explicitPorositySourceCoeffs
{
type DarcyForchheimer;
selectionMode cellZone;
cellZone <cellZoneName>; // Specify the name of the cellZone
DarcyForchheimerCoeffs
{
// Negative coeffs are multiplied by largest positive coeff,
// taking the magnitude, e.g. for -1000, coeff = |1e7*-1000| = 1e10
d [0 -2 0 0 0 0 0] (1e7 -1000 -1000);
f [0 -1 0 0 0 0 0] (0 0 0);
coordinateSystem // Cartesian coordinates for the cellZone
{
x (1 0 0);
y (0 1 0);
#includeEtc "caseDicts/general/coordinateSystem/cartesianXY"
}
}
fixedCoeffCoeffs
{
alpha [0 0 -1 0 0 0 0] (100 -1000 -1000);
beta [0 -1 0 0 0 0 0] (0 0 0);
rhoRef 1.205;
coordinateSystem // Cylindrical coordinates for the cellZone
{
origin (0 0 0);
axis (0 0 1);
#includeEtc "caseDicts/general/coordinateSystem/cylindrical"
}
}
}
}
//************************************************************************** //

View File

@ -24,14 +24,10 @@ License
\*---------------------------------------------------------------------------*/
#include "dictionary.H"
#include "primitiveEntry.H"
#include "dictionaryEntry.H"
#include "regExp.H"
#include "OSHA1stream.H"
#include "DynamicList.H"
#include "inputSyntaxEntry.H"
#include "fileOperation.H"
#include "stringOps.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
@ -1655,13 +1651,13 @@ Foam::dictionary Foam::operator|
void Foam::dictArgList
(
const string& funcArgs,
const string& argString,
word& funcName,
wordReList& args,
List<Tuple2<word, string>>& namedArgs
)
{
funcName = funcArgs;
funcName = argString;
int argLevel = 0;
bool namedArg = false;
@ -1672,8 +1668,8 @@ void Foam::dictArgList
for
(
word::const_iterator iter = funcArgs.begin();
iter != funcArgs.end();
word::const_iterator iter = argString.begin();
iter != argString.end();
++iter
)
{
@ -1683,7 +1679,7 @@ void Foam::dictArgList
{
if (argLevel == 0)
{
funcName = funcArgs(start, i - start);
funcName = argString(start, i - start);
start = i+1;
}
++argLevel;
@ -1699,14 +1695,14 @@ void Foam::dictArgList
Tuple2<word, string>
(
argName,
funcArgs(start, i - start)
argString(start, i - start)
)
);
namedArg = false;
}
else
{
args.append(wordRe(funcArgs(start, i - start)));
args.append(wordRe(argString(start, i - start)));
}
start = i+1;
}
@ -1722,7 +1718,7 @@ void Foam::dictArgList
}
else if (c == '=')
{
argName = funcArgs(start, i - start);
argName = argString(start, i - start);
string::stripInvalid<variable>(argName);
start = i+1;
namedArg = true;
@ -1738,7 +1734,7 @@ void Foam::dictArgList
void Foam::dictArgList
(
const string& funcArgs,
const string& argString,
wordReList& args,
List<Tuple2<word, string>>& namedArgs
)
@ -1752,8 +1748,8 @@ void Foam::dictArgList
for
(
word::const_iterator iter = funcArgs.begin();
iter != funcArgs.end();
word::const_iterator iter = argString.begin();
iter != argString.end();
++iter
)
{
@ -1763,9 +1759,9 @@ void Foam::dictArgList
{
++argLevel;
}
else if (c == ',' || std::next(iter) == funcArgs.end())
else if (c == ',' || std::next(iter) == argString.end())
{
if (std::next(iter) == funcArgs.end())
if (std::next(iter) == argString.end())
{
if (c == ')')
{
@ -1784,21 +1780,21 @@ void Foam::dictArgList
Tuple2<word, string>
(
argName,
funcArgs(start, i - start)
argString(start, i - start)
)
);
namedArg = false;
}
else
{
args.append(wordRe(funcArgs(start, i - start)));
args.append(wordRe(argString(start, i - start)));
}
start = i+1;
}
}
else if (c == '=')
{
argName = funcArgs(start, i - start);
argName = argString(start, i - start);
string::stripInvalid<variable>(argName);
start = i+1;
namedArg = true;

View File

@ -53,7 +53,7 @@ SourceFiles
#include "entry.H"
#include "IDLList.H"
#include "DLList.H"
#include "HashTable.H"
#include "HashSet.H"
#include "ITstream.H"
#include "wordReList.H"
#include "Pair.H"
@ -750,7 +750,7 @@ dictionary operator|(const dictionary& dict1, const dictionary& dict2);
//- Parse dictionary substitution argument list
void dictArgList
(
const string& funcArgs,
const string& argString,
word& funcName,
wordReList& args,
List<Tuple2<word, string>>& namedArgs
@ -759,7 +759,7 @@ void dictArgList
//- Parse dictionary substitution argument list
void dictArgList
(
const string& funcArgs,
const string& argString,
wordReList& args,
List<Tuple2<word, string>>& namedArgs
);
@ -767,6 +767,81 @@ void dictArgList
//- Extracts dict name and keyword
Pair<word> dictAndKeyword(const word& scopedName);
//- Return the list of configuration files in
// user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
// - \b user settings:
// - ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
// - ~/.OpenFOAM/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
// - $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/postProcessing
// - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/
// caseDicts/postProcessing
// - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
// - \b other (shipped) settings:
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
wordList listAllConfigFiles
(
const fileName& configFilesPath
);
//- Search for configuration file for given region
// and if not present also search the case directory as well as the
// user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
// - \b user settings:
// - ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
// - ~/.OpenFOAM/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
// - $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/postProcessing
// - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/
// caseDicts/postProcessing
// - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
// - \b other (shipped) settings:
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
//
// \return The path of the configuration file if found
// otherwise null
fileName findConfigFile
(
const word& funcName,
const fileName& configFilesPath,
const word& region = word::null
);
//- Read the specified configuration file
// parsing the optional arguments included in the string
// 'argString', inserting 'field' or 'fields' entries as required
// and merging the resulting configuration dictionary into
// 'parentDict'.
//
// Parses the optional arguments:
// 'Q(U)' -> funcName = Q; args = (U)
// -> field U;
//
// Supports named arguments:
// 'patchAverage(patch=inlet, p,U)'
// or
// 'patchAverage(patch=inlet, field=(p U))'
// -> funcName = patchAverage;
// args = (patch=inlet, p,U)
// -> patch inlet;
// fields (p U);
bool readConfigFile
(
const string& argString,
dictionary& parentDict,
const fileName& configFilesPath,
const Pair<string>& contextTypeAndValue,
const word& region = word::null
);
//- Write a dictionary entry
void writeEntry(Ostream& os, const dictionary& dict);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,6 +27,10 @@ License
#include "IOobject.H"
#include "inputSyntaxEntry.H"
#include "inputModeEntry.H"
#include "stringOps.H"
#include "etcFiles.H"
#include "wordAndDictionary.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -176,13 +180,6 @@ bool Foam::dictionary::substituteKeyword(const word& keyword)
}
// * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * //
void Foam::writeEntry(Ostream& os, const dictionary& value)
{
os << value;
}
// * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * //
@ -248,4 +245,414 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const dictionary& dict)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::List<Foam::Tuple2<Foam::word, Foam::string>>
unsetConfigEntries(const dictionary& configDict)
{
const wordRe unsetPattern("<.*>");
unsetPattern.compile();
List<Tuple2<word, string>> unsetArgs;
forAllConstIter(IDLList<entry>, configDict, iter)
{
if (iter().isStream())
{
ITstream& its = iter().stream();
OStringStream oss;
bool isUnset = false;
forAll(its, i)
{
oss << its[i];
if (its[i].isWord() && unsetPattern.match(its[i].wordToken()))
{
isUnset = true;
}
}
if (isUnset)
{
unsetArgs.append
(
Tuple2<word, string>
(
iter().keyword(),
oss.str()
)
);
}
}
else
{
List<Tuple2<word, string>> subUnsetArgs =
unsetConfigEntries(iter().dict());
forAll(subUnsetArgs, i)
{
unsetArgs.append
(
Tuple2<word, string>
(
iter().keyword() + '/' + subUnsetArgs[i].first(),
subUnsetArgs[i].second()
)
);
}
}
}
return unsetArgs;
}
void listConfigFiles
(
const fileName& dir,
HashSet<word>& foMap
)
{
// Search specified directory for configuration files
{
fileNameList foFiles(fileHandler().readDir(dir));
forAll(foFiles, f)
{
if (foFiles[f].ext().empty())
{
foMap.insert(foFiles[f]);
}
}
}
// Recurse into sub-directories
{
fileNameList foDirs(fileHandler().readDir(dir, fileType::directory));
forAll(foDirs, fd)
{
listConfigFiles(dir/foDirs[fd], foMap);
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::fileName Foam::findConfigFile
(
const word& funcName,
const fileName& configFilesPath,
const word& region
)
{
// First check if there is a configuration file in the
// region system directory
{
const fileName dictFile
(
stringOps::expand("$FOAM_CASE")/"system"/region/funcName
);
if (isFile(dictFile))
{
return dictFile;
}
}
// Next, if the region is specified, check if there is a configuration file
// in the global system directory
if (region != word::null)
{
const fileName dictFile
(
stringOps::expand("$FOAM_CASE")/"system"/funcName
);
if (isFile(dictFile))
{
return dictFile;
}
}
// Finally, check etc directories
{
const fileNameList etcDirs(findEtcDirs(configFilesPath));
forAll(etcDirs, i)
{
const fileName dictFile(search(funcName, etcDirs[i]));
if (!dictFile.empty())
{
return dictFile;
}
}
}
return fileName::null;
}
Foam::wordList Foam::listAllConfigFiles
(
const fileName& configFilesPath
)
{
HashSet<word> foMap;
fileNameList etcDirs(findEtcDirs(configFilesPath));
forAll(etcDirs, ed)
{
listConfigFiles(etcDirs[ed], foMap);
}
return foMap.sortedToc();
}
bool Foam::readConfigFile
(
const string& argString,
dictionary& parentDict,
const fileName& configFilesPath,
const Pair<string>& contextTypeAndValue,
const word& region
)
{
word funcType;
wordReList args;
List<Tuple2<word, string>> namedArgs;
dictArgList(argString, funcType, args, namedArgs);
// Search for the configuration file
fileName path = findConfigFile(funcType, configFilesPath, region);
if (path == fileName::null)
{
if (funcType == word::null)
{
FatalIOErrorInFunction(parentDict)
<< "configuration file name not specified"
<< nl << nl
<< "Available configured objects:"
<< listAllConfigFiles(configFilesPath)
<< exit(FatalIOError);
}
else
{
FatalIOErrorInFunction(parentDict)
<< "Cannot find configuration file "
<< funcType << nl << nl
<< "Available configured objects:"
<< listAllConfigFiles(configFilesPath)
<< exit(FatalIOError);
}
return false;
}
// Read the configuration file
autoPtr<ISstream> fileStreamPtr(fileHandler().NewIFstream(path));
ISstream& fileStream = fileStreamPtr();
// Delay processing the functionEntries
// until after the function argument entries have been added
entry::disableFunctionEntries = true;
dictionary funcsDict(funcType, parentDict, fileStream);
entry::disableFunctionEntries = false;
dictionary* funcDictPtr = &funcsDict;
if (funcsDict.found(funcType) && funcsDict.isDict(funcType))
{
funcDictPtr = &funcsDict.subDict(funcType);
}
dictionary& funcDict = *funcDictPtr;
// Store the funcDict as read for error reporting context
const dictionary funcDict0(funcDict);
// Insert the 'field' and/or 'fields' and 'objects' entries corresponding
// to both the arguments and the named arguments
DynamicList<wordAndDictionary> fieldArgs;
forAll(args, i)
{
fieldArgs.append(wordAndDictionary(args[i], dictionary::null));
}
forAll(namedArgs, i)
{
if (namedArgs[i].first() == "field")
{
IStringStream iss(namedArgs[i].second());
fieldArgs.append(wordAndDictionary(iss));
}
if
(
namedArgs[i].first() == "fields"
|| namedArgs[i].first() == "objects"
)
{
IStringStream iss(namedArgs[i].second());
fieldArgs.append(List<wordAndDictionary>(iss));
}
}
if (fieldArgs.size() == 1)
{
funcDict.set("field", fieldArgs[0].first());
funcDict.merge(fieldArgs[0].second());
}
if (fieldArgs.size() >= 1)
{
funcDict.set("fields", fieldArgs);
funcDict.set("objects", fieldArgs);
}
// Insert non-field arguments
forAll(namedArgs, i)
{
if
(
namedArgs[i].first() != "field"
&& namedArgs[i].first() != "fields"
&& namedArgs[i].first() != "objects"
)
{
const Pair<word> dAk(dictAndKeyword(namedArgs[i].first()));
dictionary& subDict(funcDict.scopedDict(dAk.first()));
IStringStream entryStream
(
dAk.second() + ' ' + namedArgs[i].second() + ';'
);
subDict.set(entry::New(entryStream).ptr());
}
}
// Insert the region name if specified
if (region != word::null)
{
funcDict.set("region", region);
}
// Set the name of the function entry to that specified by the optional
// funcName argument otherwise automatically generate a unique name
// from the function type and arguments
const word funcName
(
funcDict.lookupOrDefault("funcName", string::validate<word>(argString))
);
// Check for anything in the configuration that has not been set
List<Tuple2<word, string>> unsetArgs = unsetConfigEntries(funcDict);
bool hasUnsetError = false;
forAll(unsetArgs, i)
{
if
(
unsetArgs[i].first() != "fields"
&& unsetArgs[i].first() != "objects"
)
{
hasUnsetError = true;
}
}
if (!hasUnsetError)
{
forAll(unsetArgs, i)
{
funcDict.set(unsetArgs[i].first(), wordList());
}
}
else
{
FatalIOErrorInFunction(funcDict0)
<< nl;
forAll(unsetArgs, i)
{
FatalIOErrorInFunction(funcDict0)
<< "Essential value for keyword '" << unsetArgs[i].first()
<< "' not set" << nl;
}
FatalIOErrorInFunction(funcDict0)
<< nl << "In function entry:" << nl
<< " " << argString.c_str() << nl
<< nl << "In " << contextTypeAndValue.first().c_str() << ":" << nl
<< " " << contextTypeAndValue.second().c_str() << nl;
word funcType;
wordReList args;
List<Tuple2<word, string>> namedArgs;
dictArgList(argString, funcType, args, namedArgs);
string argList;
forAll(args, i)
{
args[i].strip(" \n");
argList += (argList.size() ? ", " : "") + args[i];
}
forAll(namedArgs, i)
{
namedArgs[i].second().strip(" \n");
argList +=
(argList.size() ? ", " : "")
+ namedArgs[i].first() + " = " + namedArgs[i].second();
}
forAll(unsetArgs, i)
{
unsetArgs[i].second().strip(" \n");
argList +=
(argList.size() ? ", " : "")
+ unsetArgs[i].first() + " = " + unsetArgs[i].second();
}
FatalIOErrorInFunction(funcDict0)
<< nl << "The function entry should be:" << nl
<< " " << funcType << '(' << argList.c_str() << ')'
<< exit(FatalIOError);
}
// Re-parse the funcDict to execute the functionEntries
// now that the function argument entries have been added
dictionary funcArgsDict;
funcArgsDict.add(funcName, funcDict);
{
OStringStream os;
funcArgsDict.write(os);
funcArgsDict = dictionary
(
funcType,
parentDict,
IStringStream(os.str())()
);
}
// Merge this configuration dictionary into parentDict
parentDict.merge(funcArgsDict);
parentDict.subDict(funcName).name() = funcDict.name();
return true;
}
// * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * //
void Foam::writeEntry(Ostream& os, const dictionary& value)
{
os << value;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,8 +24,6 @@ License
\*---------------------------------------------------------------------------*/
#include "includeFuncEntry.H"
#include "functionObjectList.H"
#include "stringOps.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -47,6 +45,12 @@ namespace functionEntries
}
Foam::fileName Foam::functionEntries::includeFuncEntry::functionObjectDictPath
(
"caseDicts/postProcessing"
);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeFuncEntry::execute
@ -58,10 +62,11 @@ bool Foam::functionEntries::includeFuncEntry::execute
// Read line containing the function name and the optional arguments
const string fNameArgs(readFuncNameArgs(is));
return functionObjectList::readFunctionObject
return readConfigFile
(
fNameArgs,
parentDict,
functionObjectDictPath,
{"file", is.name() + " at line " + Foam::name(is.lineNumber())}
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,9 +57,6 @@ Description
Other dictionary entries may also be specified using named arguments.
See also
Foam::functionObjectList
SourceFiles
includeFuncEntry.C
@ -92,6 +89,13 @@ public:
ClassName("includeFunc");
// Static Data Members
//- Default relative path to the directory structure
// containing the functionObject dictionary files
static fileName functionObjectDictPath;
// Member Functions
//- Execute the functionEntry in a sub-dict context

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,17 +27,6 @@ License
#include "argList.H"
#include "timeControlFunctionObject.H"
#include "dictionaryEntry.H"
#include "stringOps.H"
#include "etcFiles.H"
#include "wordAndDictionary.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
Foam::fileName Foam::functionObjectList::functionObjectDictPath
(
"caseDicts/postProcessing"
);
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
@ -69,391 +58,6 @@ Foam::functionObject* Foam::functionObjectList::remove
}
void Foam::functionObjectList::listDir
(
const fileName& dir,
HashSet<word>& foMap
)
{
// Search specified directory for functionObject configuration files
{
fileNameList foFiles(fileHandler().readDir(dir));
forAll(foFiles, f)
{
if (foFiles[f].ext().empty())
{
foMap.insert(foFiles[f]);
}
}
}
// Recurse into sub-directories
{
fileNameList foDirs(fileHandler().readDir(dir, fileType::directory));
forAll(foDirs, fd)
{
listDir(dir/foDirs[fd], foMap);
}
}
}
Foam::wordList Foam::functionObjectList::list()
{
HashSet<word> foMap;
fileNameList etcDirs(findEtcDirs(functionObjectDictPath));
forAll(etcDirs, ed)
{
listDir(etcDirs[ed], foMap);
}
return foMap.sortedToc();
}
Foam::fileName Foam::functionObjectList::findDict
(
const word& funcName,
const word& region
)
{
// First check if there is a functionObject dictionary file in the
// region system directory
{
const fileName dictFile
(
stringOps::expand("$FOAM_CASE")/"system"/region/funcName
);
if (isFile(dictFile))
{
return dictFile;
}
}
// Next, if the region is specified, check if there is a functionObject
// dictionary file in the global system directory
if (region != word::null)
{
const fileName dictFile
(
stringOps::expand("$FOAM_CASE")/"system"/funcName
);
if (isFile(dictFile))
{
return dictFile;
}
}
// Finally, check etc directories
{
const fileNameList etcDirs(findEtcDirs(functionObjectDictPath));
forAll(etcDirs, i)
{
const fileName dictFile(search(funcName, etcDirs[i]));
if (!dictFile.empty())
{
return dictFile;
}
}
}
return fileName::null;
}
Foam::List<Foam::Tuple2<Foam::word, Foam::string>>
Foam::functionObjectList::unsetEntries(const dictionary& funcDict)
{
const wordRe unsetPattern("<.*>");
unsetPattern.compile();
List<Tuple2<word, string>> unsetArgs;
forAllConstIter(IDLList<entry>, funcDict, iter)
{
if (iter().isStream())
{
ITstream& its = iter().stream();
OStringStream oss;
bool isUnset = false;
forAll(its, i)
{
oss << its[i];
if (its[i].isWord() && unsetPattern.match(its[i].wordToken()))
{
isUnset = true;
}
}
if (isUnset)
{
unsetArgs.append
(
Tuple2<word, string>
(
iter().keyword(),
oss.str()
)
);
}
}
else
{
List<Tuple2<word, string>> subUnsetArgs =
unsetEntries(iter().dict());
forAll(subUnsetArgs, i)
{
unsetArgs.append
(
Tuple2<word, string>
(
iter().keyword() + '/' + subUnsetArgs[i].first(),
subUnsetArgs[i].second()
)
);
}
}
}
return unsetArgs;
}
bool Foam::functionObjectList::readFunctionObject
(
const string& funcArgs,
dictionary& functionsDict,
const Pair<string>& contextTypeAndValue,
const word& region
)
{
word funcType;
wordReList args;
List<Tuple2<word, string>> namedArgs;
dictArgList(funcArgs, funcType, args, namedArgs);
// Search for the functionObject dictionary
fileName path = findDict(funcType, region);
if (path == fileName::null)
{
if (funcType == word::null)
{
FatalIOErrorInFunction(functionsDict)
<< "functionObject configuration file name not specified"
<< nl << nl
<< "Available configured functionObjects:"
<< list()
<< exit(FatalIOError);
}
else
{
FatalIOErrorInFunction(functionsDict)
<< "Cannot find functionObject configuration file "
<< funcType << nl << nl
<< "Available configured functionObjects:"
<< list()
<< exit(FatalIOError);
}
return false;
}
// Read the functionObject dictionary
// IFstream fileStream(path);
autoPtr<ISstream> fileStreamPtr(fileHandler().NewIFstream(path));
ISstream& fileStream = fileStreamPtr();
// Delay processing the functionEntries
// until after the function argument entries have been added
entry::disableFunctionEntries = true;
dictionary funcsDict(funcType, functionsDict, fileStream);
entry::disableFunctionEntries = false;
dictionary* funcDictPtr = &funcsDict;
if (funcsDict.found(funcType) && funcsDict.isDict(funcType))
{
funcDictPtr = &funcsDict.subDict(funcType);
}
dictionary& funcDict = *funcDictPtr;
// Store the funcDict as read for error reporting context
const dictionary funcDict0(funcDict);
// Insert the 'field' and/or 'fields' and 'objects' entries corresponding
// to both the arguments and the named arguments
DynamicList<wordAndDictionary> fieldArgs;
forAll(args, i)
{
fieldArgs.append(wordAndDictionary(args[i], dictionary::null));
}
forAll(namedArgs, i)
{
if (namedArgs[i].first() == "field")
{
IStringStream iss(namedArgs[i].second());
fieldArgs.append(wordAndDictionary(iss));
}
if
(
namedArgs[i].first() == "fields"
|| namedArgs[i].first() == "objects"
)
{
IStringStream iss(namedArgs[i].second());
fieldArgs.append(List<wordAndDictionary>(iss));
}
}
if (fieldArgs.size() == 1)
{
funcDict.set("field", fieldArgs[0].first());
funcDict.merge(fieldArgs[0].second());
}
if (fieldArgs.size() >= 1)
{
funcDict.set("fields", fieldArgs);
funcDict.set("objects", fieldArgs);
}
// Insert non-field arguments
forAll(namedArgs, i)
{
if
(
namedArgs[i].first() != "field"
&& namedArgs[i].first() != "fields"
&& namedArgs[i].first() != "objects"
)
{
const Pair<word> dAk(dictAndKeyword(namedArgs[i].first()));
dictionary& subDict(funcDict.scopedDict(dAk.first()));
IStringStream entryStream
(
dAk.second() + ' ' + namedArgs[i].second() + ';'
);
subDict.set(entry::New(entryStream).ptr());
}
}
// Insert the region name if specified
if (region != word::null)
{
funcDict.set("region", region);
}
// Set the name of the function entry to that specified by the optional
// funcName argument otherwise automatically generate a unique name
// from the function type and arguments
const word funcName
(
funcDict.lookupOrDefault("funcName", string::validate<word>(funcArgs))
);
// Check for anything in the configuration that has not been set
List<Tuple2<word, string>> unsetArgs = unsetEntries(funcDict);
bool hasUnsetError = false;
forAll(unsetArgs, i)
{
if
(
unsetArgs[i].first() != "fields"
&& unsetArgs[i].first() != "objects"
)
{
hasUnsetError = true;
}
}
if (!hasUnsetError)
{
forAll(unsetArgs, i)
{
funcDict.set(unsetArgs[i].first(), wordList());
}
}
else
{
FatalIOErrorInFunction(funcDict0)
<< nl;
forAll(unsetArgs, i)
{
FatalIOErrorInFunction(funcDict0)
<< "Essential value for keyword '" << unsetArgs[i].first()
<< "' not set" << nl;
}
FatalIOErrorInFunction(funcDict0)
<< nl << "In function entry:" << nl
<< " " << funcArgs.c_str() << nl
<< nl << "In " << contextTypeAndValue.first().c_str() << ":" << nl
<< " " << contextTypeAndValue.second().c_str() << nl;
word funcType;
wordReList args;
List<Tuple2<word, string>> namedArgs;
dictArgList(funcArgs, funcType, args, namedArgs);
string argList;
forAll(args, i)
{
args[i].strip(" \n");
argList += (argList.size() ? ", " : "") + args[i];
}
forAll(namedArgs, i)
{
namedArgs[i].second().strip(" \n");
argList +=
(argList.size() ? ", " : "")
+ namedArgs[i].first() + " = " + namedArgs[i].second();
}
forAll(unsetArgs, i)
{
unsetArgs[i].second().strip(" \n");
argList +=
(argList.size() ? ", " : "")
+ unsetArgs[i].first() + " = " + unsetArgs[i].second();
}
FatalIOErrorInFunction(funcDict0)
<< nl << "The function entry should be:" << nl
<< " " << funcType << '(' << argList.c_str() << ')'
<< exit(FatalIOError);
}
// Re-parse the funcDict to execute the functionEntries
// now that the function argument entries have been added
dictionary funcArgsDict;
funcArgsDict.add(funcName, funcDict);
{
OStringStream os;
funcArgsDict.write(os);
funcArgsDict = dictionary
(
funcType,
functionsDict,
IStringStream(os.str())()
);
}
// Merge this functionObject dictionary into functionsDict
functionsDict.merge(funcArgsDict);
functionsDict.subDict(funcName).name() = funcDict.name();
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjectList::functionObjectList
@ -538,10 +142,11 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
if (args.optionFound("func"))
{
readFunctionObject
readConfigFile
(
args["func"],
functionsDict,
functionEntries::includeFuncEntry::functionObjectDictPath,
{"command", args.commandLine()},
region
);
@ -553,10 +158,11 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
forAll(funcs, i)
{
readFunctionObject
readConfigFile
(
funcs[i],
functionsDict,
functionEntries::includeFuncEntry::functionObjectDictPath,
{"command", args.commandLine()},
region
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,9 +43,8 @@ SourceFiles
#include "PtrList.H"
#include "functionObject.H"
#include "SHA1Digest.H"
#include "HashTable.H"
#include "HashSet.H"
#include "dictionary.H"
#include "includeFuncEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -94,26 +93,9 @@ class functionObjectList
// Returns a nullptr (and index -1) if it didn't exist
functionObject* remove(const word&, label& oldIndex);
//- Search the specified directory for functionObject
// configuration files, add to the given map and recurse
static void listDir(const fileName& dir, HashSet<word>& foMap);
//- Return unset entries and their placeholder values
static List<Tuple2<word, string>> unsetEntries
(
const dictionary& funcDict
);
public:
// Static Data Members
//- Default relative path to the directory structure
// containing the functionObject dictionary files
static fileName functionObjectDictPath;
// Constructors
//- Construct from Time and the execution setting.
@ -179,75 +161,6 @@ public:
//- Find the ID of a given function object by name
label findObjectID(const word& name) const;
//- Return the list of functionObject configuration files in
// user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
// - \b user settings:
// - ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
// - ~/.OpenFOAM/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
// - $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/postProcessing
// - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/
// caseDicts/postProcessing
// - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
// - \b other (shipped) settings:
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
static wordList list();
//- Search for functionObject dictionary file for given region
// and if not present also search the case directory as well as the
// user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
// - \b user settings:
// - ~/.OpenFOAM/\<VERSION\>/caseDicts/postProcessing
// - ~/.OpenFOAM/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is set):
// - $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/postProcessing
// - $WM_PROJECT_SITE/etc/caseDicts/postProcessing
// - \b group (site) settings (when $WM_PROJECT_SITE is not set):
// - $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/
// caseDicts/postProcessing
// - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
// - \b other (shipped) settings:
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
//
// \return The path of the functionObject dictionary file if found
// otherwise null
static fileName findDict
(
const word& funcName,
const word& region = word::null
);
//- Read the specified functionObject configuration dictionary
// parsing the optional arguments included in the string 'funcArgs',
// inserting 'field' or 'fields' entries as required and merging the
// resulting functionObject dictionary into 'functionsDict'.
//
// Parses the optional functionObject arguments:
// 'Q(U)' -> funcName = Q; args = (U)
// -> field U;
//
// Supports named arguments:
// 'patchAverage(patch=inlet, p,U)'
// or
// 'patchAverage(patch=inlet, field=(p U))'
// -> funcName = patchAverage;
// args = (patch=inlet, p,U)
// -> patch inlet;
// fields (p U);
static bool readFunctionObject
(
const string& funcArgs,
dictionary& functionsDict,
const Pair<string>& contextTypeAndValue,
const word& region = word::null
);
//- Read and set the function objects if their data have changed
bool read();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -78,7 +78,10 @@ if (argList::postProcess(argc, argv))
{
Info<< nl
<< "Available configured functionObjects:"
<< functionObjectList::list()
<< listAllConfigFiles
(
functionEntries::includeFuncEntry::functionObjectDictPath
)
<< endl;
return 0;
}

View File

@ -500,10 +500,12 @@ $(MRF)/derivedFvPatchFields/MRFFreestreamVelocity/MRFFreestreamVelocityFvPatchVe
fvModels = $(general)/fvModels
$(fvModels)/fvModel.C
$(fvModels)/fvModels.C
$(fvModels)/includeFvModelEntry/includeFvModelEntry.C
fvConstraints = $(general)/fvConstraints
$(fvConstraints)/fvConstraint.C
$(fvConstraints)/fvConstraints.C
$(fvConstraints)/includeFvConstraintEntry/includeFvConstraintEntry.C
cellSources = sets/cellSources
$(cellSources)/fieldToCell/fieldToCell.C

View File

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "includeFvConstraintEntry.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
defineTypeNameAndDebug(includeFvConstraintEntry, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
includeFvConstraintEntry,
execute,
dictionaryIstream
);
}
}
Foam::fileName
Foam::functionEntries::includeFvConstraintEntry::fvConstraintDictPath
(
"caseDicts/fvConstraints"
);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeFvConstraintEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
// Read line containing the function name and the optional arguments
const string fNameArgs(readFuncNameArgs(is));
return readConfigFile
(
fNameArgs,
parentDict,
fvConstraintDictPath,
{"file", is.name() + " at line " + Foam::name(is.lineNumber())}
);
}
// ************************************************************************* //

View File

@ -0,0 +1,123 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionEntries::includeFvConstraintEntry
Description
Specify a fvConstraint dictionary file to include, expects the
fvConstraint name to follow with option arguments (without quotes).
Searches for fvConstraint dictionary file in user/group/shipped
directories allowing for version-specific and version-independent files
using the following hierarchy:
- \b user settings:
- ~/.OpenFOAM/\<VERSION\>/caseDicts/fvConstraints
- ~/.OpenFOAM/caseDicts/fvConstraints
- \b group (site) settings (when $WM_PROJECT_SITE is set):
- $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/fvConstraints
- $WM_PROJECT_SITE/etc/caseDicts/fvConstraints
- \b group (site) settings (when $WM_PROJECT_SITE is not set):
- $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/caseDicts/fvConstraints
- $WM_PROJECT_INST_DIR/site/etc/caseDicts/fvConstraints
- \b other (shipped) settings:
- $WM_PROJECT_DIR/etc/caseDicts/fvConstraints
The optional field arguments included in the name are inserted in 'field' or
'fields' entries in the fvConstraint dictionary and included in the name
of the fvConstraint entry to avoid conflict.
Examples:
\verbatim
#includeConstraint limitPressure(minFactor=0.1, maxFactor=2)
#includeConstraint limitTemperature(min=101, max=1000)
\endverbatim
or for a multiphase case:
\verbatim
#includeConstraint limitLowPressure(min=1e4)
#includeConstraint limitTemperature(phase=steam, min=270, max=2000)
#includeConstraint limitTemperature(phase=water, min=270, max=2000)
\endverbatim
Other dictionary entries may also be specified using named arguments.
See also
Foam::includeFvModelEntry
Foam::includeFuncEntry
SourceFiles
includeFvConstraintEntry.C
\*---------------------------------------------------------------------------*/
#ifndef includeFvConstraintEntry_H
#define includeFvConstraintEntry_H
#include "functionEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class includeFvConstraintEntry Declaration
\*---------------------------------------------------------------------------*/
class includeFvConstraintEntry
:
public functionEntry
{
public:
//- Runtime type information
ClassName("includeConstraint");
// Static Data Members
//- Default relative path to the directory structure
// containing the fvConstraint dictionary files
static fileName fvConstraintDictPath;
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,75 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "includeFvModelEntry.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
defineTypeNameAndDebug(includeFvModelEntry, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
includeFvModelEntry,
execute,
dictionaryIstream
);
}
}
Foam::fileName Foam::functionEntries::includeFvModelEntry::fvModelDictPath
(
"caseDicts/fvModels"
);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionEntries::includeFvModelEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
// Read line containing the function name and the optional arguments
const string fNameArgs(readFuncNameArgs(is));
return readConfigFile
(
fNameArgs,
parentDict,
fvModelDictPath,
{"file", is.name() + " at line " + Foam::name(is.lineNumber())}
);
}
// ************************************************************************* //

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionEntries::includeFvModelEntry
Description
Specify a fvModel dictionary file to include, expects the
fvModel name to follow with option arguments (without quotes).
Searches for fvModel dictionary file in user/group/shipped
directories allowing for version-specific and version-independent files
using the following hierarchy:
- \b user settings:
- ~/.OpenFOAM/\<VERSION\>/caseDicts/fvModels
- ~/.OpenFOAM/caseDicts/fvModels
- \b group (site) settings (when $WM_PROJECT_SITE is set):
- $WM_PROJECT_SITE/\<VERSION\>/etc/caseDicts/fvModels
- $WM_PROJECT_SITE/etc/caseDicts/fvModels
- \b group (site) settings (when $WM_PROJECT_SITE is not set):
- $WM_PROJECT_INST_DIR/site/\<VERSION\>/etc/caseDicts/fvModels
- $WM_PROJECT_INST_DIR/site/etc/caseDicts/fvModels
- \b other (shipped) settings:
- $WM_PROJECT_DIR/etc/caseDicts/fvModels
The optional field arguments included in the name are inserted in 'field' or
'fields' entries in the fvModel dictionary and included in the name
of the fvModel entry to avoid conflict.
Examples:
\verbatim
#includeModel clouds
#includeModel surfaceFilms
\endverbatim
Other dictionary entries may also be specified using named arguments.
See also
Foam::includeFvConstraintEntry
Foam::includeFuncEntry
SourceFiles
includeFvModelEntry.C
\*---------------------------------------------------------------------------*/
#ifndef includeFvModelEntry_H
#define includeFvModelEntry_H
#include "functionEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionEntries
{
/*---------------------------------------------------------------------------*\
Class includeFvModelEntry Declaration
\*---------------------------------------------------------------------------*/
class includeFvModelEntry
:
public functionEntry
{
public:
//- Runtime type information
ClassName("includeModel");
// Static Data Members
//- Default relative path to the directory structure
// containing the fvModel dictionary files
static fileName fvModelDictPath;
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionEntries
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -13,22 +13,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
limitp
{
type limitPressure;
minFactor 0.1;
maxFactor 2;
}
limitT
{
type limitTemperature;
min 101;
max 1000;
selectionMode all;
}
#includeConstraint limitPressure(minFactor=0.1, maxFactor=2)
#includeConstraint limitTemperature(min=101, max=1000)
//************************************************************************** //

View File

@ -13,20 +13,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
limitp
{
type limitPressure;
minFactor 0.1;
maxFactor 2;
}
limitT
{
type limitTemperature;
min 101;
max 1000;
selectionMode all;
}
#includeConstraint limitPressure(minFactor=0.1, maxFactor=2)
#includeConstraint limitTemperature(min=101, max=1000)
// ************************************************************************* //

View File

@ -14,16 +14,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
clouds
{
type clouds;
libs ("liblagrangianParcel.so");
}
surfaceFilms
{
type surfaceFilms;
libs ("libsurfaceFilmModels.so");
}
#includeModel clouds
#includeModel surfaceFilms
// ************************************************************************* //

View File

@ -14,29 +14,8 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
limitp
{
type limitPressure;
min 1e4;
}
limitTsteam
{
type limitTemperature;
selectionMode all;
min 270;
max 2000;
phase steam;
}
limitTwater
{
type limitTemperature;
selectionMode all;
min 270;
max 2000;
phase water;
}
#includeConstraint limitLowPressure(min=1e4)
#includeConstraint limitTemperature(phase=steam, min=270, max=2000)
#includeConstraint limitTemperature(phase=water, min=270, max=2000)
// ************************************************************************* //