mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: harmomize schemes-lookup and solution internal accessor names
FIX: correct the schemes internal dictionary name
- change from '.' to '/' delimiter as per 886ba89ddb (#1073)
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -102,6 +102,19 @@ void Foam::schemesLookup::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::schemesLookup::selectedDict() const
|
||||
{
|
||||
word select;
|
||||
|
||||
if (readIfPresent("select", select, keyType::LITERAL))
|
||||
{
|
||||
return subDict(select);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::schemesLookup::schemesLookup
|
||||
@ -136,7 +149,7 @@ Foam::schemesLookup::schemesLookup
|
||||
snGradSchemes_("snGradSchemes", objectPath()),
|
||||
laplacianSchemes_("laplacianSchemes", objectPath()),
|
||||
|
||||
fluxRequired_(objectPath() + ".fluxRequired"),
|
||||
fluxRequired_(objectPath() / "fluxRequired"),
|
||||
fluxRequiredDefault_(false),
|
||||
steady_(false)
|
||||
{
|
||||
@ -153,7 +166,7 @@ Foam::schemesLookup::schemesLookup
|
||||
|
||||
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
|
||||
{
|
||||
read(schemesDict());
|
||||
read(selectedDict());
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +190,7 @@ bool Foam::schemesLookup::read()
|
||||
{
|
||||
clear(); // Clear current settings except fluxRequired
|
||||
|
||||
read(schemesDict());
|
||||
read(selectedDict());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -186,68 +199,58 @@ bool Foam::schemesLookup::read()
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::schemesLookup::schemesDict() const
|
||||
{
|
||||
if (found("select"))
|
||||
{
|
||||
return subDict(word(lookup("select")));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::ddtScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup ddtScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup ddt scheme for " << name << endl;
|
||||
return ddtSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::d2dt2Scheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup d2dt2Scheme for " << name << endl;
|
||||
DebugInfo<< "Lookup d2dt2 scheme for " << name << endl;
|
||||
return d2dt2Schemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::interpolationScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup interpolationScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup interpolation scheme for " << name << endl;
|
||||
return interpSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::divScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup divScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup div scheme for " << name << endl;
|
||||
return divSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::gradScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup gradScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup grad scheme for " << name << endl;
|
||||
return gradSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::lnGradScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup lnGradScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup lnGrad scheme for " << name << endl;
|
||||
return lnGradSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::snGradScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup snGradScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup snGrad scheme for " << name << endl;
|
||||
return snGradSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::ITstream& Foam::schemesLookup::laplacianScheme(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup laplacianScheme for " << name << endl;
|
||||
DebugInfo<< "Lookup laplacian scheme for " << name << endl;
|
||||
return laplacianSchemes_.lookup(name);
|
||||
}
|
||||
|
||||
@ -266,6 +269,12 @@ bool Foam::schemesLookup::fluxRequired(const word& name) const
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::schemesLookup::schemesDict() const
|
||||
{
|
||||
return selectedDict();
|
||||
}
|
||||
|
||||
|
||||
void Foam::schemesLookup::writeDicts(Ostream& os) const
|
||||
{
|
||||
ddtSchemes_.writeEntryOptional(os);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,10 +30,29 @@ Class
|
||||
Description
|
||||
Selector class for finite area/finite volume differencing schemes.
|
||||
|
||||
The schemes data are treated as MUST_READ_IF_MODIFIED even if
|
||||
the requested readOption is nominally MUST_READ or READ_IF_PRESENT.
|
||||
This allows run-time modifications to behave as expected.
|
||||
The file will contain these types of entries:
|
||||
\table
|
||||
Name | Description | Type | Reqd | Default
|
||||
ddtSchemes | ddt | dict | no | none
|
||||
d2dt2Schemes | d2dt2 (currently only finite-area) | dict | no | none
|
||||
interpolationSchemes | interpolation | dict | no | linear
|
||||
divSchemes | div | dict | yes | -
|
||||
gradSchemes | grad | dict | yes | -
|
||||
lnGradSchemes | line-normal grad (finite-area) | dict | no | corrected
|
||||
snGradSchemes | surface-normal grad | dict | no | corrected
|
||||
laplacianSchemes | laplacian | dict | yes | -
|
||||
fluxRequired | | dict | no | -
|
||||
\endtable
|
||||
|
||||
\par select
|
||||
This is a rarely used feature to select between different groups of
|
||||
settings within the file. If unspecified, the file contents are used
|
||||
directly.
|
||||
|
||||
Note
|
||||
The schemes data are treated as \c READ_MODIFIED even if the
|
||||
requested \p readOption is nominally MUST_READ or READ_IF_PRESENT.
|
||||
This allows run-time modifications to behave as expected. <br>
|
||||
The optional fallback dictionary content for constructors is used
|
||||
when a file is missing or for a NO_READ, with a null pointer being
|
||||
treated like an empty dictionary.
|
||||
@ -154,6 +173,12 @@ class schemesLookup
|
||||
//- Read settings from the dictionary
|
||||
void read(const dictionary& dict);
|
||||
|
||||
//- The entire dictionary or the optional "select" sub-dictionary.
|
||||
const dictionary& selectedDict() const;
|
||||
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- No copy construct
|
||||
schemesLookup(const schemesLookup&) = delete;
|
||||
|
||||
@ -190,21 +215,15 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The current schemes dictionary, respects the "select" keyword
|
||||
//- True if default ddt scheme is steady-state
|
||||
bool steady() const noexcept { return steady_; }
|
||||
|
||||
//- True if default ddt scheme is not steady-state
|
||||
bool transient() const noexcept { return !steady_; }
|
||||
|
||||
//- The entire dictionary or the optional "select" sub-dictionary.
|
||||
const dictionary& schemesDict() const;
|
||||
|
||||
//- True if default ddtScheme is steady-state
|
||||
bool steady() const noexcept
|
||||
{
|
||||
return steady_;
|
||||
}
|
||||
|
||||
//- True if default ddtScheme is not steady-state
|
||||
bool transient() const noexcept
|
||||
{
|
||||
return !steady_;
|
||||
}
|
||||
|
||||
|
||||
// Lookup Access
|
||||
|
||||
@ -232,10 +251,10 @@ public:
|
||||
//- Get laplacian scheme for given name, or default
|
||||
ITstream& laplacianScheme(const word& name) const;
|
||||
|
||||
//- Get flux-required for given name, or default
|
||||
//- Set flux-required for given name (mutable)
|
||||
void setFluxRequired(const word& name) const;
|
||||
|
||||
//- Set flux-required for given name (mutable)
|
||||
//- Get flux-required for given name, or default
|
||||
bool fluxRequired(const word& name) const;
|
||||
|
||||
|
||||
@ -289,7 +308,7 @@ public:
|
||||
return laplacianSchemes_.dict_;
|
||||
}
|
||||
|
||||
//- Access to flux required dictionary
|
||||
//- Access flux-required dictionary
|
||||
const dictionary& fluxRequired() const noexcept
|
||||
{
|
||||
return fluxRequired_;
|
||||
@ -346,7 +365,7 @@ public:
|
||||
return laplacianSchemes_.dict_;
|
||||
}
|
||||
|
||||
//- Access to flux required dictionary
|
||||
//- Access flux-required dictionary
|
||||
dictionary& fluxRequired() noexcept
|
||||
{
|
||||
return fluxRequired_;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -50,9 +50,9 @@ Foam::schemesLookup::lookupDetail::lookupDetail
|
||||
}
|
||||
else
|
||||
{
|
||||
dict_.name() = parentDictPath + "." + name_;
|
||||
dict_.name() = fileName::concat(parentDictPath, name_, '/');
|
||||
}
|
||||
default_.name() = dict_.name() + ".default";
|
||||
default_.name() = fileName::concat(dict_.name(), "default", '/');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,7 +41,8 @@ namespace Foam
|
||||
// List of sub-dictionaries to rewrite
|
||||
static const Foam::List<Foam::word> subDictNames
|
||||
({
|
||||
"preconditioner", "smoother"
|
||||
"preconditioner",
|
||||
"smoother"
|
||||
});
|
||||
|
||||
|
||||
@ -142,6 +143,19 @@ void Foam::solution::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::solution::selectedDict() const
|
||||
{
|
||||
word select;
|
||||
|
||||
if (readIfPresent("select", select, keyType::LITERAL))
|
||||
{
|
||||
return subDict(select);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::solution::solution
|
||||
@ -183,7 +197,7 @@ Foam::solution::solution
|
||||
|
||||
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
|
||||
{
|
||||
read(solutionDict());
|
||||
read(selectedDict());
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +215,7 @@ Foam::solution::solution
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
// A non-default destructor since we had incomplete types in the header
|
||||
// No default destructor in header (incomplete types)
|
||||
Foam::solution::~solution()
|
||||
{}
|
||||
|
||||
@ -283,6 +297,17 @@ bool Foam::solution::cache(const word& name) const
|
||||
}
|
||||
|
||||
|
||||
// void Foam::solution::enableCache(const word& name) const
|
||||
// {
|
||||
// if (!cache_.found(name))
|
||||
// {
|
||||
// DebugInfo<< "Cache: enable cache for " << name << endl;
|
||||
// cache_.add(name, true);
|
||||
// caching_ = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
bool Foam::solution::relaxField(const word& name) const
|
||||
{
|
||||
DebugInfo
|
||||
@ -358,12 +383,20 @@ Foam::scalar Foam::solution::equationRelaxationFactor(const word& name) const
|
||||
|
||||
const Foam::dictionary& Foam::solution::solutionDict() const
|
||||
{
|
||||
if (found("select"))
|
||||
{
|
||||
return subDict(get<word>("select"));
|
||||
}
|
||||
return selectedDict();
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
const Foam::dictionary& Foam::solution::solutionDict(const word& name) const
|
||||
{
|
||||
DebugInfo<< "Lookup subDict : " << name << endl;
|
||||
return selectedDict().subDict(name);
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::solution::solversDict() const
|
||||
{
|
||||
return solvers_;
|
||||
}
|
||||
|
||||
|
||||
@ -385,7 +418,7 @@ bool Foam::solution::read()
|
||||
{
|
||||
if (regIOobject::read())
|
||||
{
|
||||
read(solutionDict());
|
||||
read(selectedDict());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,10 +30,43 @@ Class
|
||||
Description
|
||||
Selector class for relaxation factors, solver type and solution.
|
||||
|
||||
The solution data are treated as MUST_READ_IF_MODIFIED even if
|
||||
the requested readOption is nominally MUST_READ or READ_IF_PRESENT.
|
||||
This allows run-time modifications to behave as expected.
|
||||
The file will contain these types of entries:
|
||||
|
||||
\par solvers { }
|
||||
A sub-dictionary listing of linear solver settings. For example,
|
||||
\verbatim
|
||||
solvers
|
||||
{
|
||||
p
|
||||
{
|
||||
solver PCG;
|
||||
preconditioner DIC;
|
||||
tolerance 1e-06;
|
||||
relTol 0.05;
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\par select
|
||||
This is a rarely used feature to select between different groups of
|
||||
settings within the file. If unspecified, the file contents are used
|
||||
directly.
|
||||
|
||||
There are currently no other specified entries, but the file will
|
||||
often also contain other solution specifications. For example,
|
||||
\verbatim
|
||||
PIMPLE
|
||||
{
|
||||
nOuterCorrectors 2;
|
||||
nCorrectors 1;
|
||||
nNonOrthogonalCorrectors 0;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The solution data are treated as \c READ_MODIFIED even if the
|
||||
requested \p readOption is nominally MUST_READ or READ_IF_PRESENT.
|
||||
This allows run-time modifications to behave as expected. <br>
|
||||
The optional fallback dictionary content for constructors is used
|
||||
when a file is missing or for a NO_READ, with a null pointer being
|
||||
treated like an empty dictionary.
|
||||
@ -100,6 +133,12 @@ class solution
|
||||
//- Read settings from the dictionary
|
||||
void read(const dictionary&);
|
||||
|
||||
//- The entire dictionary or the optional "select" sub-dictionary.
|
||||
const dictionary& selectedDict() const;
|
||||
|
||||
|
||||
// Generated Methods
|
||||
|
||||
//- No copy construct
|
||||
solution(const solution&) = delete;
|
||||
|
||||
@ -114,7 +153,7 @@ public:
|
||||
// Returns the number of settings changed
|
||||
static label upgradeSolverDict(dictionary& dict, const bool verbose=true);
|
||||
|
||||
//- Debug switch
|
||||
//- Debug switch (registered name: "solution")
|
||||
static int debug;
|
||||
|
||||
|
||||
@ -139,56 +178,64 @@ public:
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
//- Destructor. Non-default in header (incomplete types)
|
||||
virtual ~solution();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Return true if the given field should be cached
|
||||
bool cache(const word& name) const;
|
||||
//- True if the given field should be cached
|
||||
bool cache(const word& name) const;
|
||||
|
||||
//- Return true if the relaxation factor is given for the field
|
||||
bool relaxField(const word& name) const;
|
||||
//- True if the relaxation factor is given for the field
|
||||
bool relaxField(const word& name) const;
|
||||
|
||||
//- Return true if the relaxation factor is given for the equation
|
||||
bool relaxEquation(const word& name) const;
|
||||
//- True if the relaxation factor is given for the equation
|
||||
bool relaxEquation(const word& name) const;
|
||||
|
||||
//- Return the relaxation factor for the given field
|
||||
scalar fieldRelaxationFactor(const word& name) const;
|
||||
//- The relaxation factor for the given field
|
||||
scalar fieldRelaxationFactor(const word& name) const;
|
||||
|
||||
//- Return the relaxation factor for the given equation
|
||||
scalar equationRelaxationFactor(const word& name) const;
|
||||
//- The relaxation factor for the given equation
|
||||
scalar equationRelaxationFactor(const word& name) const;
|
||||
|
||||
//- Return the selected sub-dictionary of solvers if the "select"
|
||||
//- keyword is given, otherwise return the complete dictionary
|
||||
const dictionary& solutionDict() const;
|
||||
//- The entire dictionary or the optional "select" sub-dictionary.
|
||||
const dictionary& solutionDict() const;
|
||||
|
||||
//- Return the solver controls dictionary for the given field
|
||||
const dictionary& solverDict(const word& name) const;
|
||||
//- Return \p name sub-dictionary within the solutionDict().
|
||||
// Same as \c solutionDict().subDict(...)
|
||||
const dictionary& solutionDict(const word& name) const;
|
||||
|
||||
//- Return the solver controls dictionary for the given field
|
||||
const dictionary& solver(const word& name) const;
|
||||
//- The solver controls dictionary (all fields)
|
||||
const dictionary& solversDict() const;
|
||||
|
||||
//- The solver controls dictionary for the given field.
|
||||
//- Same as \c solversDict().subDict(...)
|
||||
const dictionary& solverDict(const word& name) const;
|
||||
|
||||
//- The solver controls dictionary for the given field.
|
||||
//- Same as solverDict(...)
|
||||
const dictionary& solver(const word& name) const;
|
||||
|
||||
|
||||
// Read
|
||||
// Read
|
||||
|
||||
//- Read the solution dictionary
|
||||
bool read();
|
||||
//- Read the solution dictionary
|
||||
bool read();
|
||||
|
||||
|
||||
// Other
|
||||
// Other
|
||||
|
||||
//- Helper for printing cache message
|
||||
template<class FieldType>
|
||||
static void cachePrintMessage
|
||||
(
|
||||
const char* message,
|
||||
const word& name,
|
||||
const FieldType& vf
|
||||
);
|
||||
//- Helper for printing cache message
|
||||
template<class FieldType>
|
||||
static void cachePrintMessage
|
||||
(
|
||||
const char* message,
|
||||
const word& name,
|
||||
const FieldType& fld
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -34,15 +34,14 @@ void Foam::solution::cachePrintMessage
|
||||
(
|
||||
const char* message,
|
||||
const word& name,
|
||||
const FieldType& vf
|
||||
const FieldType& fld // == regIOobject
|
||||
)
|
||||
{
|
||||
if (solution::debug)
|
||||
if (Foam::solution::debug)
|
||||
{
|
||||
Info<< "Cache: " << message << token::SPACE << name
|
||||
<< ", originating from " << vf.name()
|
||||
<< " event No. " << vf.eventNo()
|
||||
<< endl;
|
||||
Info<< "Cache: " << message << ' ' << name
|
||||
<< ", originating from " << fld.name()
|
||||
<< " event:" << fld.eventNo() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user