58 if (incoVars_.useSolverNameForFields())
61 <<
"useSolverNameForFields is set to true for primalSolver "
62 << solverName() <<
nl <<
tab
63 <<
"Appending variable names with the solver name" <<
nl <<
tab
64 <<
"Please adjust the necessary entries in fvSchemes and fvSolution"
79 contErr.weightedAverage(mesh_.V()).value();
94 const word& managerType,
96 const word& solverName
107 incoVars_(allocateVars()),
108 MRF_(
mesh,
word(useSolverNameForFields() ? solverName_ :
word::null)),
109 cumulativeContErr_(
Zero),
111 allowFunctionObjects_(
dict.getOrDefault(
"allowFunctionObjects", false))
157 incoVars_.turbulence();
158 label&
pRefCell = solverControl_().pRefCell();
159 scalar&
pRefValue = solverControl_().pRefValue();
165 MRF_.correctBoundaryVelocity(
U);
199 if (solverControl_().consistent())
213 while (solverControl_().correctNonOrthogonal())
224 if (solverControl_().finalNonOrthogonalIter())
237 U.correctBoundaryConditions();
241 incoVars_.laminarTransport().correct();
250 if (managerType_ ==
"steadyOptimisation" && allowFunctionObjects_)
252 const_cast<Time&
>(mesh_.time()).functionObjects().execute(
false);
255 solverControl_().write();
259 for (
auto& obj : objectives_)
261 Info<< obj.objectiveName() <<
" : " << obj.J() <<
endl;
262 obj.accumulateJMean(solverControl_());
263 obj.writeInstantaneousValue();
280 while (solverControl_().loop())
304 if (objectives_.empty())
306 objectives_ = getObjectiveFunctions();
320 for (
auto& obj : objectives_)
322 obj.writeInstantaneousSeparator();
332 os.writeEntry(
"averageIter", solverControl_().averageIter());
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
For cases which do no have a pressure boundary adjust the balance of fluxes to obey continuity....
void relax(const scalar alpha)
Relax field (for steady-state solution).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
SIMPLE control class to supply convergence information/checks for the SIMPLE loop.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const functionObjectList & functionObjects() const noexcept
Return the list of function objects.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
bool execute(bool writeProperties=true)
Called at each ++ or += of the time-loop.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux() const
Return the face-flux field from the matrix.
SolverPerformance< Type > solve(const dictionary &)
Solve returning the solution statistics.
void setReference(const label celli, const Type &value, const bool forceReference=false)
Set reference level for solution.
Mesh data needed to do the Finite Volume discretisation.
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
Finite-volume options, which is an IOdictionary of values and a fv::optionList.
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present otherwise lookup and return.
Base class for primal incompressible solvers.
static autoPtr< incompressiblePrimalSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &solverName)
Return a reference to the selected incompressible primal solver.
const incompressibleVars & getIncoVars() const
Access to the incompressible variables set.
virtual bool readDict(const dictionary &dict)
Read dict if updated.
UPtrList< objective > getObjectiveFunctions() const
Return the list of objectives assodicated with this solver.
Base class for solution control classes.
const volScalarField & pInst() const
Return const reference to pressure.
Base class for solution control classes.
virtual void postIter()
Steps to be executed before each main SIMPLE iteration.
autoPtr< SIMPLEControl > solverControl_
Solver control.
UPtrList< objective > objectives_
List of objectives related to this primal solver.
scalar cumulativeContErr_
Cumulative continuity error.
virtual void preIter()
Steps to be executed before each main SIMPLE iteration.
virtual void restoreInitValues()
Restore initial field values if necessary.
virtual bool writeData(Ostream &os) const
Write average iteration.
incompressibleVars & allocateVars()
Protected Member Functions.
virtual bool readDict(const dictionary &dict)
Read dict if updated.
virtual void mainIter()
The main SIMPLE iter.
bool allowFunctionObjects_
Allow the execution of function objects in optimisation mode.
void addExtraSchemes()
In case variable names are different than the base ones, add extra schemes and relaxation factors to ...
incompressibleVars & incoVars_
Reference to incompressibleVars.
virtual void preLoop()
Functions to be called before loop.
void continuityErrors()
Compute continuity errors.
IOMRFZoneList MRF_
MRF zones.
virtual void postLoop()
Functions to be called after loop.
virtual bool loop()
Looper (advances iters, time step).
virtual void solveIter()
Execute one iteration of the solution algorithm.
virtual void solve()
Main control loop.
autoPtr< variablesSet > vars_
Base variableSet pointer.
const word & managerType() const
Return the manager type.
bool active_
Solve equations?
const word managerType_
The optimisation type.
bool useSolverNameForFields() const
Use solver name as a suffix to the involved fields.
const dictionary & dict() const
Return the solver dictionary.
const word solverName_
Solver name.
const fvMesh & mesh() const
Return the solver mesh.
const word & solverName() const
Return the solver name.
fvMesh & mesh_
Reference to the mesh database.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
tmp< fvVectorMatrix > tUEqn(fvm::ddt(rho, U)+fvm::div(phi, U)+MRF.DDt(rho, U)+turbulence->divDevRhoReff(U)==fvOptions(rho, U))
volScalarField rAtU(1.0/(1.0/rAU - UEqn.H1()))
volScalarField::Internal contErr((fvc::ddt(rho)+fvc::div(rhoPhi) -(fvOptions(alpha1, mixture.thermo1().rho())&rho1) -(fvOptions(alpha2, mixture.thermo2().rho())&rho2))())
OBJstream os(runTime.globalPath()/outputName)
Find the reference cell nearest (in index) to the given cell but which is not on a cyclic,...
tmp< volScalarField > rAU
#define WarningInFunction
Report a warning using Foam::Warning.
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
void constrainPressure(volScalarField &p, const RhoType &rho, const volVectorField &U, const surfaceScalarField &phiHbyA, const RAUType &rhorAU, const MRFType &MRF)
bool adjustPhi(surfaceScalarField &phi, const volVectorField &U, volScalarField &p)
Adjust the balance of fluxes to obey continuity.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
GeometricField< vector, fvPatchField, volMesh > volVectorField
fvMatrix< scalar > fvScalarMatrix
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
Type weightedAverage(const UList< scalar > &weights, const UList< Type > &fld)
The local weighted average of a field, using the mag() of the weights.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fvMatrix< vector > fvVectorMatrix
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &solverControls)
Solve returning the solution statistics given convergence tolerance.
static constexpr const zero Zero
Global zero (0).
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
bool setRefCell(const volScalarField &field, const volScalarField &fieldRef, const dictionary &dict, label &refCelli, scalar &refValue, const bool forceReference=false)
If the field fieldRef needs referencing find the reference cell nearest.
constexpr char nl
The newline '\n' character (0x0a).
constexpr char tab
The tab '\t' character(0x09).
const bool momentumPredictor