78 contErr.weightedAverage(mesh_.V()).value();
96Foam::adjointSimple::adjointSimple
99 const word& managerType,
101 const word& primalSolverName,
102 const word& solverName
114 adjointVars_(allocateVars()),
115 cumulativeContErr_(
Zero)
124 dict.subDict(
"ATCModel")
143 solverControl_().incrementIter();
144 if (solverControl_().performIter())
169 adjointVars_.adjointTurbulence();
170 const label& paRefCell = solverControl_().pRefCell();
171 const scalar& paRefValue = solverControl_().pRefValue();
180 + adjointTurbulence->divDevReff(Ua)
181 + adjointTurbulence->adjointMeanFlowSource()
191 objectiveManager_.addSource(UaEqn);
194 ATCModel_->addATC(UaEqn);
197 addMomentumSource(UaEqn);
220 tmp<volScalarField> rAtUa(rAUa);
222 if (solverControl_().consistent())
224 rAtUa = 1.0/(1.0/rAUa - UaEqn.
H1());
236 while (solverControl_().correctNonOrthogonal())
245 addPressureSource(
paEqn);
252 if (solverControl_().finalNonOrthogonalIter())
270 adjointTurbulence->correct();
272 if (solverControl_().printMaxMags())
276 Info<<
"Max mag (" << Ua.
name() <<
") = " << maxUa.value() <<
endl;
284 solverControl_().write();
300 while (solverControl_().loop())
348 adjointVars_.adjointTurbulence();
350 adjointTurbulence().getAdjointTMVariablesBaseNames();
351 label nTurbVars(turbVarNames.
size());
352 if (adjointTurbulence().includeDistance())
360 names[varID++] = adjointVars_.UaInst().name();
361 for (
const word& turbName : turbVarNames)
363 names[varID++] = turbName;
365 if (adjointTurbulence().includeDistance())
368 word(useSolverNameForFields() ?
"da" + solverName_ :
"da");
374 optionDict.add<
word>(
"type",
"topOSource");
376 optionDict.add<
word>(
"function",
"linear");
377 optionDict.add<
word>(
"interpolationField",
"beta");
387 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....
static autoPtr< ATCModel > New(const fvMesh &mesh, const incompressibleVars &primalVars, const incompressibleAdjointVars &adjointVars, const dictionary &dict)
Return a reference to the selected turbulence model.
void relax(const scalar alpha)
Relax field (for steady-state solution).
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
const word & name() const noexcept
Return the object name.
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.
void size(const label n)
Older name for setAddressableSize.
Solution of the adjoint PDEs for incompressible, steady-state flows.
virtual void postIter()
Steps to be executed before each main SIMPLE iteration.
autoPtr< SIMPLEControl > solverControl_
Solver control.
scalar cumulativeContErr_
Cumulative continuity error.
virtual void preIter()
Steps to be executed before each main SIMPLE iteration.
virtual bool writeData(Ostream &os) const
Write average iteration.
virtual void addMomentumSource(fvVectorMatrix &matrix)
Source terms for the momentum equations.
incompressibleAdjointVars & allocateVars()
Allocate incompressibleAdjointVars and return reference to be used for convenience in the rest of the...
virtual void mainIter()
The main SIMPLE iter.
virtual void addTopOFvOptions() const
Add fvOptions for TopO.
virtual void updatePrimalBasedQuantities()
Update primal based quantities related to the objective functions.
virtual void preCalculateSensitivities()
Accumulate the sensitivities integrand before calculating them.
incompressibleAdjointVars & adjointVars_
Reference to incompressibleAdjointVars.
virtual void preLoop()
Functions to be called before loop.
void continuityErrors()
Compute continuity errors.
virtual bool loop()
Looper (advances iters, time step).
virtual void solveIter()
Execute one iteration of the solution algorithm.
virtual void solve()
Main control loop.
virtual void addPressureSource(fvScalarMatrix &matrix)
Source terms for the continuity equation.
objectiveManager objectiveManager_
Object to manage objective functions.
void allocateSensitivities()
Allocate the sensitivity derivatives.
virtual bool writeData(Ostream &os) const
Write the sensitivity derivatives.
autoPtr< adjointSensitivity > adjointSensitivity_
Sensitivity Derivatives engine.
const word & primalSolverName() const
Return the primal solver name.
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,...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
const Type & value() const noexcept
Return const reference to value.
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
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.
tmp< volScalarField > A() const
Return the central coefficient.
tmp< volScalarField > H1() const
Return H(1).
void setReference(const label celli, const Type &value, const bool forceReference=false)
Set reference level for solution.
void boundaryManipulate(typename GeometricField< Type, fvPatchField, volMesh >::Boundary &values)
Manipulate based on a boundary field.
tmp< GeometricField< Type, fvPatchField, volMesh > > H() const
Return the H operation source.
Mesh data needed to do the Finite Volume discretisation.
List of finite volume options.
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
void constrain(fvMatrix< Type > &eqn)
Apply constraints to equation.
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvOption model.
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.
const volScalarField & paInst() const
Return const reference to pressure.
Base class for incompressibleAdjoint solvers.
autoPtr< ATCModel > ATCModel_
Adjoint Transpose Convection options.
static autoPtr< incompressibleAdjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName, const word &solverName)
Return a reference to the selected incompressible adjoint solver.
virtual const incompressibleAdjointVars & getAdjointVars() const
Access to the incompressible adjoint variables set.
virtual bool includeDistance() const
Should the adjoint to the eikonal equation be solved.
virtual void updatePrimalBasedQuantities()
Update primal based quantities, e.g. the primal fields in adjoint turbulence models.
incompressibleVars & primalVars_
Primal variable set.
Class including all adjoint fields for incompressible flows.
autoPtr< variablesSet > vars_
Base variableSet pointer.
const word & managerType() const
Return the manager type.
bool active_
Solve equations?
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.
virtual void postLoop()
Functions to be called after loop.
A class for managing temporary objects.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
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)
const word dictName("faMeshDefinition")
Find the reference cell nearest (in index) to the given cell but which is not on a cyclic,...
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)
List< word > wordList
List of word.
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)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Type gMax(const FieldField< Field, Type > &f)
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.
fvScalarMatrix paEqn(fvm::d2dt2(pa) - sqr(c0) *fvc::laplacian(pa))
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
const bool momentumPredictor