Go to the documentation of this file.
43 namespace incompressibleAdjoint
45 namespace adjointRASModels
54 adjointSpalartAllmaras,
82 return 1.0 - chi/(1.0 + chi*fv1);
99 + fv2(chi, fv1)*nuTilda()/
sqr(kappa_*y_),
117 nuTilda()/(
max(Stilda, minStilda_)*
sqr(kappa_*y_)),
122 tr.ref().boundaryFieldRef() ==
Zero;
180 return (chi*chi*dFv1dChi - 1.)/
sqr(1. + chi*fv1);
192 Omega + fv2*nuTilda()/
sqr(kappa_*y_) - Cs_*Omega
195 return pos(fieldSwitch) +
neg(fieldSwitch)*Cs_;
207 volScalarField fieldSwitch(Omega + fv2*nuTilda()*invDenom - Cs_*Omega);
209 return pos(fieldSwitch)*(dFv2dChi*nuTilda()*invDenom/
nu() + fv2*invDenom);
222 return - 2.*
pos(fieldSwitch)*aux/y_;
233 1./(
max(Stilda, minStilda_)*
sqr(kappa_*y_))
234 *(scalar(10) - r_)/(scalar(10) - r_ + SMALL)
236 tdrdNutilda.
ref().boundaryFieldRef() ==
Zero;
249 - nuTilda()/
sqr(
max(Stilda, minStilda_)*kappa_*y_)
250 *(scalar(10) - r_)/(scalar(10) - r_ + SMALL)
252 tdrdStilda.
ref().boundaryFieldRef() ==
Zero;
265 -2.*nuTilda()/(
max(Stilda, minStilda_)*
sqr(kappa_*y_)*y_)
266 *(scalar(10) - r_)/(scalar(10) - r_ + SMALL)
268 tdrdDelta.
ref().boundaryFieldRef() ==
Zero;
284 return pow6Cw3/(pow6g + pow6Cw3)
285 *
pow((1.0 + pow6Cw3)/(pow6g + pow6Cw3), 1.0/6.0)
286 *(1.0 + Cw2_*(6.0*
pow5(r_) - 1.0));
300 dfwdr*(dr_dNuTilda(Stilda) + dr_dStilda(Stilda)*dStildadNuTilda);
311 return dfwdr*dr_dStilda(Stilda)*dStildadOmega;
322 return dfwdr*(dr_dDelta(Stilda) + dr_dStilda(Stilda)*dStildadDelta);
332 return Cw1_*(nuTilda()*dfwdNuTilda + fw)/
sqr(y_);
341 return - Cb1_*dStildadNuTilda;
351 return dFv1dChi*nuTilda()/
nu() + fv1;
362 if(!isA<coupledFvPatch>(
patch))
379 Info<<
"Updating primal-based fields of the adjoint turbulence "
380 <<
"model ..." <<
endl;
474 adjointSpalartAllmaras::adjointSpalartAllmaras
479 const word& adjointTurbulenceModelName,
480 const word& modelName
489 adjointTurbulenceModelName
529 Cw1_(Cb1_/
sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
567 limitAdjointProduction_
569 coeffDict_.getOrDefault(
"limitAdjointProduction",
true)
572 y_(primalVars_.RASModelVariables()().d()),
574 mask_(allocateMask()),
576 symmAdjointProductionU_
580 "symmAdjointProductionU",
590 productionDestructionSource_
594 "productionDestructionSource",
664 "momentumSourceMult",
676 minStilda_(
"SMALL", Stilda_.dimensions(), SMALL)
682 adjointTMVariable1Ptr_,
693 includeDistance_ =
true;
697 updatePrimalRelatedFields();
799 if (isA<wallFvPatch>(
patch) &&
patch.size() != 0)
801 wallShapeSens[patchI] =
808 return wallShapeSens;
821 wallFloCoSens[patchI] =
826 return wallFloCoSens;
854 "adjointEikonalSource" +
type(),
865 SAwallFunctionPatchField;
873 forAll(nutBoundary, patchi)
878 isA<SAwallFunctionPatchField>(nutBoundary[patchi])
882 const scalar
kappa_(0.41);
883 const scalar E_(9.8);
912 ((
kappa_/E_)*(
exp(kUu) - 1 - kUu - 0.5*kUu*kUu));
935 adjointEikonalSource[cellI] -=
936 2.*( rt[faceI] + Uap_t[faceI] )
937 * vtau[faceI]*Cwf_d[faceI]*magSf[faceI]
945 return tadjointEikonalSource;
962 if (isA<wallFvPatch>(
patch))
983 (gradU & gradU)().
T()
984 - (gradU & gradU.T())
1020 return tvolSensTerm;
1062 + gradNua*oneOverSigmaNut
1074 nuaTildaEqn.
ref().relax();
1081 scalar maxDeltaNuaTilda =
1084 Info<<
"Max mag of nuaTilda = " << maxNuaTilda.
value() <<
endl;
1085 Info<<
"Max mag of delta nuaTilda = " << maxDeltaNuaTilda <<
endl;
bool useSolverNameForFields() const
Append solver name to fields?
Manages the adjoint mean flow fields and their mean values.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
class for managing incompressible objective functions.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & solverName() const
Return solver name.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
tmp< volScalarField > fv1(const volScalarField &chi) const
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
volVectorField gradNuTilda_
tmp< volScalarField > r(const volScalarField &Stilda) const
autoPtr< boundaryVectorField > wallShapeSensitivitiesPtr_
Wall sensitivity term for shape optimisation.
const nearWallDist & y() const
Return the near wall distances.
A class for handling words, derived from Foam::string.
dimensionedTensor skew(const dimensionedTensor &dt)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< symmTensor > dimensionedSymmTensor
Dimensioned tensor obtained from generic dimensioned type.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
dictionary coeffDict_
Model coefficients dictionary.
tmp< volScalarField > dStilda_dNuTilda(const volScalarField &Omega, const volScalarField &fv2, const volScalarField &dFv2dChi) const
dimensionedScalar sigmaNut_
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
tmp< volScalarField > fv2(const volScalarField &chi, const volScalarField &fv1) const
static word timeName(const scalar t, const int precision=precision_)
virtual tmp< volVectorField > adjointMeanFlowSource()
tmp< volScalarField > dStilda_dOmega(const volScalarField &Omega, const volScalarField &fv2) const
const surfaceScalarField & phi() const
Return const reference to volume flux.
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< volScalarField > dnut_dNuTilda(const volScalarField &fv1, const volScalarField &dFv1dChi) const
tmp< volScalarField > dfw_dOmega(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadOmega) const
virtual const boundaryVectorField & adjointMomentumBCSource() const
autoPtr< boundaryVectorField > wallFloCoSensitivitiesPtr_
Wall sensitivity term for flow control optimisation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< volScalarField > dfw_dDelta(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadDelta) const
const Type & value() const
Return const reference to value.
tmp< volScalarField > dr_dNuTilda(const volScalarField &Stilda) const
bool changedPrimalSolution_
Has the primal solution changed?
dimensionedScalar exp(const dimensionedScalar &ds)
tmp< volScalarField > dFv2_dChi(const volScalarField &chi, const volScalarField &fv1, const volScalarField &dFv1dChi) const
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
virtual tmp< volScalarField > distanceSensitivities()
#define forAll(list, i)
Loop across all elements in list.
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
virtual bool read()
Read adjointRASProperties dictionary.
tmp< volScalarField > dr_dDelta(const volScalarField &Stilda) const
volScalarField & nuaTilda()
Access to the adjoint Spalart - Allmaras field.
tmp< volScalarField > dfw_dNuTilda(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadNuTilda) const
tmp< volScalarField > dfw_dr(const volScalarField &Stilda) const
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
static void nullifyField(GeometricField< Type, PatchField, GeoMesh > &fieldPtr)
Nullify field and old times, if present.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
virtual bool read()
Read adjointRASProperties dictionary.
tmp< fvMatrix< Type > > SuSp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
dimensionedScalar pow6(const dimensionedScalar &ds)
volSymmTensorField symmAdjointProductionU_
bool printMaxMags() const
Print max mags of solver fields.
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
bool readIfPresent(const dictionary &dict)
tmp< volVectorField > conservativeMomentumSource()
Conservative source term for the adjoint momentum equations.
tmp< volScalarField > dD_dNuTilda(const volScalarField &fw, const volScalarField &dfwdNuTilda) const
dimensionedScalar pow3(const dimensionedScalar &ds)
messageStream Info
Information stream (stdout output on master, null elsewhere)
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
autoPtr< boundaryVectorField > adjMomentumBCSourcePtr_
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
virtual tmp< volTensorField > FISensitivityTerm()
Term contributing to the computation of FI-based sensitivities.
SolverPerformance< Type > solve(faMatrix< Type > &, Istream &)
Solve returning the solution statistics given convergence tolerance.
const volScalarField & nuTilda() const
References to the primal turbulence model variables.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const volVectorField & U() const
Return const reference to velocity.
virtual void nullify()
Nullify all adjoint turbulence model fields and their old times.
virtual tmp< scalarField > diffusionCoeffVar1(label patchI) const
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const volScalarField & nut() const
Return the turbulence viscosity.
const volVectorField & Ua() const
Return const reference to velocity.
Switch adjointTurbulence_
Turbulence on/off flag.
const volScalarField & y_
Wall distance.
static void setField(autoPtr< GeometricField< Type, fvPatchField, volMesh >> &fieldPtr, const fvMesh &mesh, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Read vol fields.
This boundary condition provides a wall constraint on the turbulent viscosity, i.e....
dimensionedScalar pow5(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
virtual void correct()=0
Solve the adjoint turbulence equations.
Abstract base class for incompressible turbulence models.
const uniformDimensionedVectorField & g
const solverControl & getSolverControl() const
Return const reference to solverControl.
objectiveManager & objectiveManager_
Reference to the objectiveManager.
tmp< volScalarField > dFv1_dChi(const volScalarField &chi) const
tmp< volScalarField > allocateMask()
Allocate the mask field.
void correctBoundaryConditions()
Correct boundary field.
tmp< volScalarField > dr_dStilda(const volScalarField &Stilda) const
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
tmp< volScalarField > Stilda(const volScalarField &chi, const volScalarField &fv1) const
virtual tmp< volScalarField > nutJacobianTMVar1() const
Jacobian of nut wrt the first turbulence model variable.
tmp< volScalarField > fw(const volScalarField &Stilda) const
void storePrevIter() const
Store the field as the previous iteration value.
addToRunTimeSelectionTable(adjointRASModel, adjointLaminar, dictionary)
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
volTensorField momentumSourceMult_
defineTypeNameAndDebug(adjointLaminar, 0)
void updatePrimalRelatedFields()
Update the constant primal-related fields.
const std::string patch
OpenFOAM patch number as a std::string.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
dimensionedScalar sqrt(const dimensionedScalar &ds)
tmp< volScalarField > chi() const
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static tmp< volScalarField > createLimiter(const fvMesh &mesh, const dictionary &dict)
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
incompressibleAdjointMeanFlowVars & adjointVars_
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
void relax(const scalar alpha)
Relax field (for steady-state solution).
incompressibleVars & primalVars_
bool limitAdjointProduction_
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor including the laminar stress.
tmp< volScalarField > dP_dNuTilda(const volScalarField &dStildadNuTilda) const
volScalarField mask_
Field for masking (convergence enhancement)
virtual void addTMEqn1Source(fvScalarMatrix &adjTMEqn1)=0
Add contribution to first adjoint turbulence model PDE.
const Time & time() const
Return the top-level database.
virtual tmp< fvVectorMatrix > divDevReff(volVectorField &U) const
Return the diffusion term for the momentum equation.
tmp< volScalarField > nu() const
Return the laminar viscosity.
tmp< volScalarField > dStilda_dDelta(const volScalarField &Omega, const volScalarField &fv2) const
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
virtual const boundaryVectorField & wallShapeSensitivities()
Sensitivity terms for shape optimisation, emerging from.
virtual void correct()
Solve the adjoint turbulence equations.
volScalarField productionDestructionSource_
tmp< volScalarField > DnuTildaEff() const
const word & adjointSolverName() const
Return name of the adjointSolver.
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
dimensionedScalar neg(const dimensionedScalar &ds)
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Smooth ATC in cells next to a set of patches supplied by type.
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
const volVectorField & UaInst() const
Return const reference to velocity.
Type gMax(const FieldField< Field, Type > &f)
Base class for solution control classes.
static autoPtr< boundaryAdjointContribution > New(const word &managerName, const word &adjointSolverName, const word &simulationType, const fvPatch &patch)
Return a reference to the selected turbulence model.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const dimensionSet dimless
Dimensionless.
virtual const boundaryVectorField & wallFloCoSensitivities()
Sensitivity terms for flow control, emerging from the.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar pos(const dimensionedScalar &ds)