objectRegistry, regIOobject: Added support for automatic re-reading of dependent class
Now with the addition of the optional dependenciesModified() function classes which depend on other classes which are re-read from file when modified are also automatically updated via their read() function called by objectRegistry::readModifiedObjects. This significantly simplifies the update of the solutionControls and modular solvers when either the controlDict or fvSolution dictionaries are modified at run-time.
This commit is contained in:
@ -40,41 +40,44 @@ namespace solvers
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::solvers::fluidSolver::readControls(const bool construct)
|
||||
bool Foam::solvers::fluidSolver::dependenciesModified() const
|
||||
{
|
||||
if (construct || runTime.controlDict().modified())
|
||||
{
|
||||
maxCo =
|
||||
runTime.controlDict().lookupOrDefault<scalar>("maxCo", vGreat);
|
||||
|
||||
maxDeltaT_ =
|
||||
runTime.controlDict().found("maxDeltaT")
|
||||
? runTime.userTimeToTime
|
||||
(
|
||||
runTime.controlDict().lookup<scalar>("maxDeltaT")
|
||||
)
|
||||
: vGreat;
|
||||
}
|
||||
|
||||
if (construct || mesh.solution().modified())
|
||||
{
|
||||
correctPhi = pimple.dict().lookupOrDefault
|
||||
(
|
||||
"correctPhi",
|
||||
mesh.dynamic()
|
||||
);
|
||||
|
||||
checkMeshCourantNo = pimple.dict().lookupOrDefault
|
||||
(
|
||||
"checkMeshCourantNo",
|
||||
false
|
||||
);
|
||||
}
|
||||
return runTime.controlDict().modified() || mesh.solution().modified();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::solvers::fluidSolver::read()
|
||||
{
|
||||
solver::read();
|
||||
|
||||
maxCo =
|
||||
runTime.controlDict().lookupOrDefault<scalar>("maxCo", vGreat);
|
||||
|
||||
maxDeltaT_ =
|
||||
runTime.controlDict().found("maxDeltaT")
|
||||
? runTime.userTimeToTime
|
||||
(
|
||||
runTime.controlDict().lookup<scalar>("maxDeltaT")
|
||||
)
|
||||
: vGreat;
|
||||
|
||||
correctPhi = pimple.dict().lookupOrDefault
|
||||
(
|
||||
"correctPhi",
|
||||
mesh.dynamic()
|
||||
);
|
||||
|
||||
checkMeshCourantNo = pimple.dict().lookupOrDefault
|
||||
(
|
||||
"checkMeshCourantNo",
|
||||
false
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Foam::solvers::fluidSolver::meshCourantNo() const
|
||||
{
|
||||
if (checkMeshCourantNo)
|
||||
@ -210,7 +213,7 @@ Foam::solvers::fluidSolver::fluidSolver(fvMesh& mesh)
|
||||
CoNum(CoNum_)
|
||||
{
|
||||
// Read the controls
|
||||
readControls(true);
|
||||
read();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -92,15 +92,18 @@ class fluidSolver
|
||||
|
||||
protected:
|
||||
|
||||
//- Return true if the solver's dependencies have been modified
|
||||
virtual bool dependenciesModified() const;
|
||||
|
||||
//- Read controls
|
||||
virtual bool read();
|
||||
|
||||
//- Switch to correct the flux after mesh change
|
||||
bool correctPhi;
|
||||
|
||||
//- Current maximum Courant number for time-step control
|
||||
scalar CoNum_;
|
||||
|
||||
//- Read controls
|
||||
void readControls(const bool construct = false);
|
||||
|
||||
//- Check mesh Courant numbers for moving mesh cases
|
||||
void meshCourantNo() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user