ENH: replaced fragile dict interactions by meshState functions

This commit is contained in:
Andrew Heather
2023-11-30 17:17:24 +00:00
parent 79cd147de0
commit 0ff86ee2e7
11 changed files with 22 additions and 38 deletions

View File

@ -1,6 +1,6 @@
if (finalIter) if (finalIter)
{ {
mesh.data().add("finalIteration", true); mesh.data().setFinalIteration(true);
} }
if (frozenFlow) if (frozenFlow)
@ -35,5 +35,5 @@ else
if (finalIter) if (finalIter)
{ {
mesh.data().remove("finalIteration"); mesh.data().setFinalIteration(false);
} }

View File

@ -1,6 +1,6 @@
if (finalIter) if (finalIter)
{ {
mesh.data().add("finalIteration", true); mesh.data().setFinalIteration(true);
} }
{ {
@ -35,5 +35,5 @@ if (finalIter)
if (finalIter) if (finalIter)
{ {
mesh.data().remove("finalIteration"); mesh.data().setFinalIteration(false);
} }

View File

@ -1,6 +1,6 @@
if (finalIter) if (finalIter)
{ {
mesh.data().add("finalIteration", true); mesh.data().setFinalIteration(true);
} }
if (frozenFlow) if (frozenFlow)
@ -36,5 +36,5 @@ else
if (finalIter) if (finalIter)
{ {
mesh.data().remove("finalIteration"); mesh.data().setFinalIteration(false);
} }

View File

@ -25,7 +25,7 @@
if (finalIter) if (finalIter)
{ {
mesh.data().add("finalIteration", true); mesh.data().setFinalIteration(true);
} }
hEqn.solve(mesh.solver(h.select(finalIter))); hEqn.solve(mesh.solver(h.select(finalIter)));
@ -39,7 +39,7 @@
if (finalIter) if (finalIter)
{ {
mesh.data().remove("finalIteration"); mesh.data().setFinalIteration(false);
} }
} }
} }

View File

@ -1153,14 +1153,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::relax()
{ {
word name = this->name(); word name = this->name();
if if (this->mesh().data().isFinalIteration())
(
this->mesh().data().template getOrDefault<bool>
(
"finalIteration",
false
)
)
{ {
name += "Final"; name += "Final";
} }

View File

@ -32,6 +32,7 @@ License
#include "objectRegistry.H" #include "objectRegistry.H"
#include "scalarIOField.H" #include "scalarIOField.H"
#include "Time.H" #include "Time.H"
#include "meshState.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -351,12 +352,11 @@ void Foam::lduMatrix::setResidualField
if (residualPtr) if (residualPtr)
{ {
const IOdictionary* dataPtr = const auto* dataPtr = mesh().thisDb().findObject<meshState>("data");
mesh().thisDb().findObject<IOdictionary>("data");
if (dataPtr) if (dataPtr)
{ {
if (initial && dataPtr->found("firstIteration")) if (initial && dataPtr->isFirstIteration())
{ {
*residualPtr = residual; *residualPtr = residual;
DebugInfo DebugInfo

View File

@ -219,7 +219,7 @@ bool Foam::pimpleControl::loop()
} }
corr_ = 0; corr_ = 0;
mesh_.data().remove("finalIteration"); mesh_.data().setFinalIteration(false);
return false; return false;
} }
@ -231,7 +231,7 @@ bool Foam::pimpleControl::loop()
Info<< algorithmName_ << ": converged in " << corr_ - 1 Info<< algorithmName_ << ": converged in " << corr_ - 1
<< " iterations" << endl; << " iterations" << endl;
mesh_.data().remove("finalIteration"); mesh_.data().setFinalIteration(false);
corr_ = 0; corr_ = 0;
converged_ = false; converged_ = false;
@ -242,7 +242,7 @@ bool Foam::pimpleControl::loop()
Info<< algorithmName_ << ": iteration " << corr_ << endl; Info<< algorithmName_ << ": iteration " << corr_ << endl;
storePrevIterFields(); storePrevIterFields();
mesh_.data().add("finalIteration", true); mesh_.data().setFinalIteration(true);
converged_ = true; converged_ = true;
} }
} }
@ -250,7 +250,7 @@ bool Foam::pimpleControl::loop()
{ {
if (finalIter()) if (finalIter())
{ {
mesh_.data().add("finalIteration", true); mesh_.data().setFinalIteration(true);
} }
if (corr_ <= nCorrPIMPLE_) if (corr_ <= nCorrPIMPLE_)

View File

@ -42,7 +42,7 @@ Foam::pisoControl::pisoControl(fvMesh& mesh, const word& dictName)
: :
pimpleControl(mesh, dictName) pimpleControl(mesh, dictName)
{ {
// mesh_.data::add("finalIteration", true); // mesh_.data().setFinalIteration(true);
} }

View File

@ -193,12 +193,12 @@ void Foam::solutionControl::setFirstIterFlag
if (force || (check && corr_ <= 1 && corrNonOrtho_ == 0)) if (force || (check && corr_ <= 1 && corrNonOrtho_ == 0))
{ {
DebugInfo<< "solutionControl: set firstIteration flag" << endl; DebugInfo<< "solutionControl: set firstIteration flag" << endl;
mesh_.data().set("firstIteration", true); mesh_.data().setFirstIteration(true);
} }
else else
{ {
DebugInfo<< "solutionControl: remove firstIteration flag" << endl; DebugInfo<< "solutionControl: remove firstIteration flag" << endl;
mesh_.data().remove("firstIteration"); mesh_.data().setFirstIteration(false);
} }
} }

View File

@ -1257,8 +1257,7 @@ void Foam::fvMatrix<Type>::relax()
{ {
word name = psi_.select word name = psi_.select
( (
psi_.mesh().data().template getOrDefault<bool> psi_.mesh().data().isFinalIteration()
("finalIteration", false)
); );
if (psi_.mesh().relaxEquation(name)) if (psi_.mesh().relaxEquation(name))
@ -1532,11 +1531,7 @@ const Foam::dictionary& Foam::fvMatrix<Type>::solverDict() const
{ {
return psi_.mesh().solverDict return psi_.mesh().solverDict
( (
psi_.select psi_.select(psi_.mesh().data().isFinalIteration())
(
psi_.mesh().data().template getOrDefault<bool>
("finalIteration", false)
)
); );
} }

View File

@ -935,11 +935,7 @@ void Foam::radiation::viewFactor::calculate()
const dictionary& solverControls = const dictionary& solverControls =
qr_.mesh().solverDict qr_.mesh().solverDict
( (
qr_.select qr_.select(qr_.mesh().data().isFinalIteration())
(
qr_.mesh().data::template getOrDefault<bool>
("finalIteration", false)
)
); );
// Solver call // Solver call