38 namespace incompressibleAdjoint
47 adjointTurbulenceModel,
87 if (solControl.average())
132 adjointRASModel::adjointRASModel
138 const word& adjointTurbulenceModelName
141 adjointTurbulenceModel
146 adjointTurbulenceModelName
152 "adjointRASProperties",
153 primalVars.
U().time().constant(),
160 objectiveManager_(objManager),
162 adjointTurbulence_(
get<
word>(
"adjointTurbulence")),
163 printCoeffs_(getOrDefault<
Switch>(
"printCoeffs", false)),
164 coeffDict_(subOrEmptyDict(
type +
"Coeffs")),
168 adjointTMVariable1Ptr_(nullptr),
169 adjointTMVariable2Ptr_(nullptr),
170 adjointTMVariablesBaseNames_(0),
171 adjointTMVariable1MeanPtr_(nullptr),
172 adjointTMVariable2MeanPtr_(nullptr),
176 includeDistance_(false),
177 changedPrimalSolution_(true)
188 const word& adjointTurbulenceModelName
195 "adjointRASProperties",
204 const word modelType(
dict.get<
word>(
"adjointRASModel"));
206 Info<<
"Selecting adjointRAS turbulence model " << modelType <<
endl;
208 auto* ctorPtr = dictionaryConstructorTable(modelType);
217 *dictionaryConstructorTablePtr_
228 adjointTurbulenceModelName
257 IOdictionary::readStream
293 "adjointTMVariable1" +
type(),
320 "adjointTMVariable2" +
type(),
395 "nutJacobianTMVar1"+
type(),
421 "nutJacobianTMVar2"+
type(),
483 if (solControl.doAverageIter())
485 const label iAverageIter = solControl.
averageIter();
486 scalar avIter(iAverageIter);
487 scalar oneOverItP1 = 1./(avIter+1);
488 scalar mult = avIter*oneOverItP1;
dictionary coeffDict_
Model coefficients dictionary.
virtual tmp< scalarField > diffusionCoeffVar1(label patchI) const
Diffusion coefficient of the first primal and adjoint turbulence model equation. Needed for some adjo...
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
defineTypeNameAndDebug(adjointRASModel, 0)
bool includeDistance_
Does the turbulence model include distances and should the adjoint to the distance field be computed...
autoPtr< volScalarField > adjointTMVariable1MeanPtr_
Adjoint turbulence model variable 1, mean value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
nearWallDist y_
Near wall distance boundary field.
void computeMeanFields()
Average adjoint fields on the fly.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
defineRunTimeSelectionTable(adjointRASModel, dictionary)
Switch printCoeffs_
Flag to print the model coeffs at run-time.
static autoPtr< adjointRASModel > New(incompressibleVars &primalVars, incompressibleAdjointMeanFlowVars &adjointVars, objectiveManager &objManager, const word &adjointTurbulenceModelName=adjointTurbulenceModel::typeName)
Return a reference to the selected adjointRAS model.
Class for managing objective functions.
virtual bool read()
Read adjointRASProperties dictionary.
const dimensionSet dimViscosity
Ostream & endl(Ostream &os)
Add newline and flush stream.
volScalarField & getAdjointTMVariable2()
Return non-constant reference to adjoint turbulence model variable 2.
virtual tmp< volVectorField > nutJacobianU(tmp< volScalarField > &dNutdUMult) const
Jacobian of nut wrt the flow velocity.
volScalarField & getAdjointTMVariable1()
Return non-constant reference to adjoint turbulence model variable 1.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
void restoreInitValues()
Restore field values to the initial ones.
virtual void correct()=0
Solve the adjoint turbulence equations.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
incompressibleAdjointMeanFlowVars & adjointVars_
Macros for easy insertion into run-time selection tables.
autoPtr< volScalarField > adjointTMVariable2MeanPtr_
Adjoint turbulence model variable 2, mean value.
autoPtr< volScalarField > & getAdjointTMVariable2InstPtr()
Return non-constant autoPtr to adjoint turbulence model variable 2.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Switch adjointTurbulence_
Turbulence on/off flag.
void setChangedPrimalSolution()
Set flag of changed primal solution to true.
bool includeDistance() const
Should the adjoint to the eikonal equation be computed.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Base class for solution control classes.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
bool changedPrimalSolution_
Has the primal solution changed?
virtual void correct()
Solve the adjoint turbulence equations.
autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > createZeroBoundaryPtr(const fvMesh &mesh, bool printAllocation=false)
void close()
Close Istream.
A class for handling words, derived from Foam::string.
Abstract base class for incompressible turbulence models.
virtual tmp< scalarField > diffusionCoeffVar2(label patchI) const
Diffusion coefficient of the second primal and adjoint turbulence model equation. Needed for some adj...
label size() const noexcept
The number of entries in the list.
volScalarField & getAdjointTMVariable1Inst()
Return non-constant reference to adjoint turbulence model variable 1.
Base class for solver control classes.
Reading is optional [identical to LAZY_READ].
const objectRegistry & db() const noexcept
Return the local objectRegistry.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
volScalarField & getAdjointTMVariable2Inst()
Return non-constant reference to adjoint turbulence model variable 2.
wordList adjointTMVariablesBaseNames_
Base names of the adjoint fields.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
autoPtr< volScalarField > adjointTMVariable1Ptr_
Adjoint turbulence model variable 1.
autoPtr< volScalarField > adjointTMVariable2Ptr_
Adjoint turbulence model variable 2.
const Time & time() const noexcept
Return Time associated with the objectRegistry.
const volVectorField & U() const
Return const reference to velocity.
const wordList & getAdjointTMVariablesBaseNames() const
Return reference to the adjoint turbulence model variables base names.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
const word & constant() const noexcept
Return constant name.
void resetMeanFields()
Reset mean fields to zero.
Abstract base class for incompressible adjoint turbulence models (RAS, LES and laminar).
const solverControl & getSolverControl() const
Return const reference to solverControl.
bool changing() const noexcept
Is mesh changing (topology changing and/or moving)
void setMeanFields()
Set mean fields.
Manages the adjoint mean flow fields and their mean values.
addToRunTimeSelectionTable(adjointTurbulenceModel, adjointRASModel, adjointTurbulenceModel)
bool average() const
Whether averaging is enabled or not.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Automatically write from objectRegistry::writeObject()
messageStream Info
Information stream (stdout output on master, null elsewhere)
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
label & averageIter()
Return average iteration index reference.
A class for managing temporary objects.
bool useAveragedFields() const
Use averaged fields? For solving the adjoint equations or computing sensitivities based on averaged f...
bool storeInitValues() const
Re-initialize.
Defines the attributes of an object for which implicit objectRegistry management is supported...
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
virtual tmp< volScalarField > nutJacobianTMVar2() const
Jacobian of nut wrt the second turbulence model variable.
virtual bool readData(Istream &)
The readData function required by regIOobject read operation.
virtual void correct()
Correct for mesh geom/topo changes.
Do not request registration (bool: false)
autoPtr< volScalarField > & getAdjointTMVariable1InstPtr()
Return non-constant autoPtr to adjoint turbulence model variable 1.
const dimensionSet & dimensions() const noexcept
Return dimensions.
virtual tmp< volScalarField > nutJacobianTMVar1() const
Jacobian of nut wrt the first turbulence model variable.
virtual void printCoeffs()
Print model coefficients.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
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)