54 objectiveIncompressible::objectiveIncompressible
58 const word& adjointSolverName,
59 const word& primalSolverName
78 dJdTMvar1Ptr_(nullptr),
79 dJdTMvar2Ptr_(nullptr),
87 bdJdTMvar1Ptr_(nullptr),
88 bdJdTMvar2Ptr_(nullptr),
90 bdJdGradUPtr_(nullptr)
102 const word& adjointSolverName,
103 const word& primalSolverName
109 <<
" of type " << modelType <<
endl;
111 auto* ctorPtr = dictionaryConstructorTable(modelType);
118 "objectiveIncompressible",
120 *dictionaryConstructorTablePtr_
124 return autoPtr<objectiveIncompressible>
126 ctorPtr(
mesh,
dict, adjointSolverName, primalSolverName)
141 dJdvPtr_().primitiveFieldRef() *= oneOverNorm;
145 dJdpPtr_().primitiveFieldRef() *= oneOverNorm;
149 dJdTPtr_().primitiveFieldRef() *= oneOverNorm;
311 const incompressiblePrimalSolver& primSolver =
313 const autoPtr<incompressible::RASModelVariables>& rasVars =
314 primSolver.getIncoVars().RASModelVariables();
316 if (rasVars().hasTMVar1())
318 const dimensionSet primalVarDims = rasVars->TMVar1Inst().dimensions();
322 createZeroFieldPtr<scalar>
330 if (rasVars().hasTMVar2())
332 const dimensionSet primalVarDims = rasVars->TMVar2Inst().dimensions();
336 createZeroFieldPtr<scalar>
357 reduce(nCells, sumOp<label>());
361 <<
"Provided cellZones include no cells" 369 autoPtr<volScalarField>& dJdTMvarPtr,
371 (incompressibleAdjoint::adjointRASModel::*JacobianFunc)()
const,
376 if (dJdTMvarPtr.good())
384 const incompressibleAdjointSolver& adjSolver =
387 const autoPtr<incompressibleAdjoint::adjointRASModel>& adjointRAS =
388 adjSolver.getAdjointVars().adjointTurbulence();
390 tmp<volScalarField> tnutJacobian = (adjointRAS->*JacobianFunc)();
395 for (
const label zI : zones)
398 for (
const label cellI : zoneI)
401 JacobianMultiplier[cellI]*nutJacobian[cellI];
408 <<
"Skipping the computation of nutJacobian until " 409 <<
"the adjoint solver is complete" bool hasdJdTMVar2() const noexcept
word dictName() const
The local dictionary name (final part of scoped name)
bool hasBoundarydJdv() const noexcept
virtual void update_meanValues()
Some objectives need to store some auxiliary values. If averaging is enabled, update these mean value...
virtual void update_boundarydJdp()
virtual void doNormalization()
Normalize all fields allocated by the objective.
static autoPtr< objectiveIncompressible > New(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName)
Return a reference to the selected turbulence model.
const labelIOList & zoneIDs
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
virtual void update_boundarydJdnut()
const word adjointSolverName_
const dictionary & dict() const
Return objective dictionary.
autoPtr< volScalarField > dJdpPtr_
errorManipArg< error, int > exit(error &err, const int errNo=1)
autoPtr< volScalarField > dJdTMvar2Ptr_
Second turbulence model variable.
autoPtr< boundaryScalarField > bdJdTMvar2Ptr_
Adjoint outlet turbulence model var 2.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool hasBoundarydJdTMVar1() const noexcept
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool hasBoundarydJdGradU() const noexcept
virtual void update()
Update objective function derivatives.
autoPtr< volScalarField > dJdTPtr_
autoPtr< scalar > normFactor_
Normalization factor.
bool hasBoundarydJdvn() const noexcept
void update_dJdTMvar(autoPtr< volScalarField > &dJdTMvarPtr, tmp< volScalarField >(incompressibleAdjoint::adjointRASModel::*JacobianFunc)() const, const volScalarField &JacobianMultiplier, const labelList &zones)
Compute dJdTMVar{1,2}.
virtual void doNormalization()
Normalize all fields allocated by the objective.
bool hasdJdv() const noexcept
Inline functions for checking whether pointers are set or not.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
Same as contains()
void checkCellZonesSize(const labelList &zoneIDs) const
Check if cellZones provided include at least one cell.
bool hasBoundarydJdp() const noexcept
virtual void update_boundarydJdv()
autoPtr< boundaryTensorField > bdJdGradUPtr_
Term multiplying gradU variations.
virtual void update_boundarydJdvn()
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
bool hasBoundarydJdT() const noexcept
virtual void update_boundarydJdvt()
Macros for easy insertion into run-time selection tables.
wordList fieldNames_
List of adjoint fields for which this objective will contribute sources to their equations.
bool hasBoundarydJdnut() const noexcept
GeometricField< scalar, fvPatchField, volMesh > volScalarField
autoPtr< boundaryScalarField > bdJdnutPtr_
Jacobian wrt to nut.
virtual bool write(const bool valid=true) const
Write objective function history.
virtual void update_dJdT()
A class for handling words, derived from Foam::string.
virtual void nullify()
Update objective function derivatives.
autoPtr< volVectorField > dJdvPtr_
label size() const noexcept
The number of entries in the list.
virtual void update_boundarydJdT()
const volVectorField & dJdv()
Contribution to field adjoint momentum eqs.
bool computed_
Whether the objective is computed or not.
virtual void update_dJdp()
bool hasdJdTMVar1() const noexcept
autoPtr< boundaryVectorField > bdJdvPtr_
virtual bool write(const bool valid=true) const
Write objective function history.
virtual scalar weight() const
Return the objective function weight.
Abstract base class for objective functions. No point in making this runTime selectable since its chi...
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
virtual void update_boundarydJdTMvar1()
autoPtr< boundaryVectorField > bdJdpPtr_
Adjoint (intlet,wall) velocity.
defineTypeNameAndDebug(combustionModel, 0)
bool hasBoundarydJdTMVar2() const noexcept
const word primalSolverName_
bool hasdJdp() const noexcept
autoPtr< boundaryScalarField > bdJdTPtr_
Adjoint outlet temperature.
void allocatedJdTurbulence()
Allocate fields related to the differentiation of turbulence models, if necessary.
void computeMeanFields()
Compute mean fields on the fly.
const incompressibleVars & vars_
virtual void addSource(fvVectorMatrix &matrix)
Vector sources can be given only to the adjoint momentum equations. Implemented in base objectiveInco...
dimensionedScalar pow3(const dimensionedScalar &ds)
virtual void nullify()
Nullify adjoint contributions.
#define WarningInFunction
Report a warning using Foam::Warning.
bool hasBoundarydJdvt() const noexcept
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
virtual void update_dJdTMvar2()
Mesh data needed to do the Finite Volume discretisation.
virtual void update_dJdv()
Update vol and boundary fields and derivatives.
fvMatrix< vector > fvVectorMatrix
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
autoPtr< boundaryVectorField > bdJdvtPtr_
Adjoint outlet velocity.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual void update()=0
Update objective function derivatives.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
autoPtr< boundaryScalarField > bdJdTMvar1Ptr_
Adjoint outlet turbulence model var 1.
Base class for primal incompressible solvers.
List< label > labelList
A List of labels.
autoPtr< boundaryScalarField > bdJdvnPtr_
Adjoint outlet pressure.
virtual void update_boundarydJdGradU()
autoPtr< volScalarField > dJdTMvar1Ptr_
First turbulence model variable.
virtual void update_boundarydJdTMvar2()
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Abstract base class for objective functions in incompressible flows.
bool hasdJdT() const noexcept
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
virtual void update_dJdTMvar1()
const dimensionSet dimArea(sqr(dimLength))
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)