38 namespace incompressibleAdjoint
47 adjointTurbulenceModel,
112 adjointRASModel::adjointRASModel
118 const word& adjointTurbulenceModelName
121 adjointTurbulenceModel
126 adjointTurbulenceModelName
132 "adjointRASProperties",
133 primalVars.
U().time().constant(),
140 objectiveManager_(objManager),
142 adjointTurbulence_(
get<
word>(
"adjointTurbulence")),
143 printCoeffs_(getOrDefault<
Switch>(
"printCoeffs", false)),
144 coeffDict_(subOrEmptyDict(
type +
"Coeffs")),
148 adjointTMVariable1Ptr_(nullptr),
149 adjointTMVariable2Ptr_(nullptr),
150 adjointTMVariablesBaseNames_(0),
151 adjointTMVariable1MeanPtr_(nullptr),
152 adjointTMVariable2MeanPtr_(nullptr),
156 includeDistance_(false),
157 changedPrimalSolution_(true)
168 const word& adjointTurbulenceModelName
175 "adjointRASProperties",
184 const word modelType(
dict.get<
word>(
"adjointRASModel"));
186 Info<<
"Selecting adjointRAS turbulence model " << modelType <<
endl;
188 auto* ctorPtr = dictionaryConstructorTable(modelType);
197 *dictionaryConstructorTablePtr_
208 adjointTurbulenceModelName
237 IOdictionary::readStream
273 "adjointTMVariable1" +
type(),
300 "adjointTMVariable2" +
type(),
368 "nutJacobianTMVar1"+
type(),
391 "nutJacobianTMVar2"+
type(),
457 if (solControl.doAverageIter())
459 const label iAverageIter = solControl.
averageIter();
460 scalar avIter(iAverageIter);
461 scalar oneOverItP1 = 1./(avIter+1);
462 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 incompressible objective functions.
virtual bool read()
Read adjointRASProperties dictionary.
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.
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.
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.
Reading required, file watched for runTime modification.
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 elements in the list.
volScalarField & getAdjointTMVariable1Inst()
Return non-constant reference to adjoint turbulence model variable 1.
Base class for solver control classes.
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 wordList & getAdjointTMVariablesBaseNames()
Return reference to the adjoint turbulence model variables base names.
const volVectorField & U() const
Return const reference to velocity.
virtual const volScalarField & nut() const
Return the turbulence viscosity.
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 time name of given scalar time 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.
const Time & time() const
Return Time associated with the objectRegistry.
IOobject(const IOobject &)=default
Copy construct.
Automatically write from objectRegistry::writeObject()
messageStream Info
Information stream (stdout output on master, null elsewhere)
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...
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.
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 a sub-dictionary) otherwise return nullptr...
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
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)