44 incompressibleAdjointSolver,
52 Foam::incompressibleAdjointSolver::incompressibleAdjointSolver
55 const word& managerType,
57 const word& primalSolverName
76 const word& managerType,
78 const word& primalSolverName
82 auto* ctorPtr = dictionaryConstructorTable(solverType);
89 "incompressibleAdjointSolver",
91 *dictionaryConstructorTablePtr_
96 autoPtr<incompressibleAdjointSolver>
117 return getAdjointVars().useSolverNameForFields();
133 refCast<incompressibleAdjointVars>(
const_cast<variablesSet&
>(vars_()));
142 refCast<incompressibleAdjointVars>(
const_cast<variablesSet&
>(vars_()));
165 getAdjointVars().adjointTurbulence()->setChangedPrimalSolution();
166 ATCModel_().updatePrimalBasedQuantities();
167 getAdjointVars().updatePrimalBasedQuantities();
182 autoPtr<incompressibleAdjoint::adjointRASModel>& adjointRAS
184 getAdjointVars().adjointTurbulence()
199 tmp<volTensorField> tgradU =
206 forAll(mesh_.boundary(), patchI)
208 const fvPatch&
patch = mesh_.boundary()[patchI];
209 if (isA<wallFvPatch>(
patch))
211 tmp<vectorField> tnf = mesh_.boundary()[patchI].nf();
212 gradUbf[patchI] = tnf*
U.boundaryField()[patchI].snGrad();
216 tmp<volScalarField> tnuEff = adjointRAS->nuEff();
217 tmp<volSymmTensorField> stress = tnuEff()*
twoSymm(gradU);
228 tmp<volTensorField> tgradUa =
fvc::grad(Ua);
233 - tnuEff*(gradU &
twoSymm(tgradUa()))
239 - (tgradUa & stress())
244 for (label idir = 0; idir < pTraits<vector>::nComponents; ++idir)
246 autoPtr<volVectorField> stressDirPtr
248 createZeroFieldPtr<vector>
249 (mesh_,
"stressDir", stress().dimensions())
253 unzipRow(stress(), idir, stressDirPtr());
255 forAll(mesh_.boundary(), pI)
257 if (!isA<coupledFvPatch>(mesh_.boundary()[pI]))
259 flowTerm.boundaryFieldRef()[pI] +=
260 Ua.component(idir)().boundaryField()[pI]
261 *gradStressDir.boundaryField()[pI];
271 ATCModel_->getFISensitivityTerm()
276 flowTerm += pa*tgradU;
279 flowTerm +=
T(adjointRAS->FISensitivityTerm());
282 PtrList<objective>& functions
283 (objectiveManagerPtr_->getObjectiveFunctions());
285 for (objective& objI : functions)
287 if (objI.hasGradDxDbMult())
289 flowTerm += objI.weight()*objI.gradDxDbMultiplier();
293 flowTerm.correctBoundaryConditions();
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual void additionalSensitivityMapTerms(boundaryVectorField &sensitivityMap, const labelHashSet &patchIDs, const scalar dt)
Terms to be added to the sensitivity map, depending on the adjoint solver.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual const incompressibleAdjointVars & getAdjointVars() const
Access to the incompressible adjoint variables set.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
const fvMesh & mesh() const
Return the solver mesh.
virtual bool readDict(const dictionary &dict)
Read dict if updated.
const incompressibleVars & getPrimalVars() const
Access to the incompressible primal variables set.
virtual void updatePrimalBasedQuantities()
Update primal based quantities, e.g. the primal fields in adjoint turbulence models.
void unzipRow(const FieldField< Field, SymmTensor< Cmpt >> &input, const direction idx, FieldField< Field, Vector< Cmpt >> &result)
Extract a symmTensor field field row (x,y,z) == (0,1,2)
Base class for adjoint solvers.
GeometricBoundaryField< tensor, fvPatchField, volMesh > Boundary
Type of boundary fields.
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.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Macros for easy insertion into run-time selection tables.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Class including all adjoint fields for incompressible flows.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
static tmp< GeometricField< tensor, fvPatchField, volMesh > > New(const word &name, const Mesh &mesh, const dimensionSet &ds, const word &patchFieldType=fvPatchField< tensor >::calculatedType())
Return tmp field from name, mesh, dimensions and patch type.
Base class for solution control classes.
A class for handling words, derived from Foam::string.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
virtual const dictionary & dict() const
Return the solver dictionary.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const autoPtr< ATCModel > & getATCModel() const
Access to the ATC model.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Base class for creating a set of variables.
Mesh data needed to do the Finite Volume discretisation.
const std::string patch
OpenFOAM patch number as a std::string.
virtual tmp< volTensorField > computeGradDxDbMultiplier()
Compute the multiplier for grad(dxdb)
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
virtual bool readDict(const dictionary &dict)
Base class for primal incompressible solvers.
A class for managing temporary objects.
static autoPtr< incompressibleAdjointSolver > New(fvMesh &mesh, const word &managerType, const dictionary &dict, const word &primalSolverName)
Return a reference to the selected incompressible adjoint solver.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
const word & primalSolverName() const
Return the primal solver name.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
virtual bool useSolverNameForFields() const
Should solver name be appended to fields.