43 namespace incompressibleAdjoint
45 namespace adjointRASModels
54 adjointSpalartAllmaras,
192 return pos(fieldSwitch) +
neg(fieldSwitch)*
Cs_;
206 return pos(fieldSwitch)*(dFv2dChi*
nuTilda()*invDenom/
nu() +
fv2*invDenom);
219 return - 2.*
pos(fieldSwitch)*aux/
y_;
231 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
233 tdrdNutilda.ref().boundaryFieldRef() ==
Zero;
247 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
263 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
282 pow6Cw3/(pow6g + pow6Cw3)
283 *
pow((1.0 + pow6Cw3)/(pow6g + pow6Cw3), 1.0/6.0)
339 return -
Cb1_*dStildadNuTilda;
360 if(!isA<coupledFvPatch>(
patch))
377 Info<<
"Updating primal-based fields of the adjoint turbulence " 378 <<
"model ..." <<
endl;
472 adjointSpalartAllmaras::adjointSpalartAllmaras
477 const word& adjointTurbulenceModelName,
478 const word& modelName
487 adjointTurbulenceModelName
527 Cw1_(Cb1_/
sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
565 limitAdjointProduction_
567 coeffDict_.getOrDefault(
"limitAdjointProduction", true)
570 y_(primalVars_.RASModelVariables()().d()),
572 mask_(allocateMask()),
574 symmAdjointProductionU_
578 "symmAdjointProductionU",
588 productionDestructionSource_
592 "productionDestructionSource",
662 "momentumSourceMult",
672 gradU_(fvc::
grad(primalVars.
U())),
673 gradNuTilda_(fvc::
grad(nuTilda())),
674 minStilda_(
"SMALL", Stilda_.dimensions(), SMALL)
800 if (isA<wallFvPatch>(
patch) &&
patch.size() != 0)
802 wallShapeSens[patchI] =
809 return wallShapeSens;
821 wallFloCoSens[patchI] =
826 return wallFloCoSens;
849 auto tadjointEikonalSource =
852 "adjointEikonalSource" +
type(),
862 SAwallFunctionPatchField;
870 forAll(nutBoundary, patchi)
875 isA<SAwallFunctionPatchField>(nutBoundary[patchi])
879 const scalar
kappa_(0.41);
880 const scalar E_(9.8);
909 ((
kappa_/E_)*(
exp(kUu) - 1 - kUu - 0.5*kUu*kUu));
932 adjointEikonalSource[cellI] -=
933 2.*( rt[faceI] + Uap_t[faceI] )
934 *vtau[faceI]*Cwf_d[faceI]*magSf[faceI]
942 return tadjointEikonalSource;
956 tgradNuaTilda.
ref().boundaryFieldRef();
963 if (isA<wallFvPatch>(
patch))
974 gradNuaTildab[patchI] =
984 (gradU & gradU)().
T()
985 - (gradU & gradU.T())
1061 + gradNua*oneOverSigmaNut
1073 nuaTildaEqn.ref().relax();
1080 scalar maxDeltaNuaTilda =
1083 Info<<
"Max mag of nuaTilda = " << maxNuaTilda.
value() <<
endl;
1084 Info<<
"Max mag of delta nuaTilda = " << maxDeltaNuaTilda <<
endl;
dictionary coeffDict_
Model coefficients dictionary.
void updatePrimalRelatedFields()
Update the constant primal-related fields.
tmp< volScalarField > dfw_dNuTilda(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadNuTilda) const
virtual const boundaryVectorField & wallShapeSensitivities()
Sensitivity terms for shape optimisation, emerging from.
const Type & value() const noexcept
Return const reference to value.
virtual void addTMEqn1Source(fvScalarMatrix &adjTMEqn1)=0
Add contribution to first adjoint turbulence model PDE.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< volScalarField > DnuTildaEff() const
bool includeDistance_
Does the turbulence model include distances and should the adjoint to the distance field be computed...
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
tmp< volScalarField > dP_dNuTilda(const volScalarField &dStildadNuTilda) const
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
virtual tmp< scalarField > diffusionCoeffVar1(label patchI) const
Diffusion coefficient of the first primal and adjoint turbulence model equation. Needed for some adjo...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static autoPtr< boundaryAdjointContribution > New(const word &managerName, const word &adjointSolverName, const word &simulationType, const fvPatch &patch)
Return a reference to the selected turbulence model.
dimensionedTensor skew(const dimensionedTensor &dt)
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
volVectorField gradNuTilda_
bool readIfPresent(const dictionary &dict)
Update the value of dimensioned<Type> if found in the dictionary, lookup in dictionary with the name(...
virtual tmp< volVectorField > adjointMeanFlowSource()
Source terms to the adjoint momentum equation due to the differentiation of the turbulence model...
const volScalarField & nuTilda() const
References to the primal turbulence model variables.
class for managing incompressible objective functions.
virtual bool read()
Read adjointRASProperties dictionary.
tmp< volScalarField > dStilda_dNuTilda(const volScalarField &Omega, const volScalarField &fv2, const volScalarField &dFv2dChi) const
dimensionedScalar sigmaNut_
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
tmp< volScalarField > Stilda(const volScalarField &chi, const volScalarField &fv1) const
tmp< volScalarField > dFv2_dChi(const volScalarField &chi, const volScalarField &fv1, const volScalarField &dFv1dChi) const
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Continuous adjoint to the Spalart-Allmaras one-eqn mixing-length model for incompressible flows...
volScalarField mask_
Field for masking (convergence enhancement)
virtual const boundaryVectorField & adjointMomentumBCSource() const
Source for the outlet adjoint momentum BC coming from differentiating the turbulence model...
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
static void nullifyField(GeometricField< Type, PatchField, GeoMesh > &fieldPtr)
Nullify field and old times, if present.
autoPtr< boundaryVectorField > adjMomentumBCSourcePtr_
Source to the adjoint momentum BC emerging from differentiating the turbulence model.
virtual void correct()=0
Solve the adjoint turbulence equations.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
autoPtr< boundaryVectorField > wallShapeSensitivitiesPtr_
Wall sensitivity term for shape optimisation.
Smooth ATC in cells next to a set of patches supplied by type.
const Time & time() const
Return the top-level database.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
incompressibleAdjointMeanFlowVars & adjointVars_
tmp< volScalarField > dD_dNuTilda(const volScalarField &fw, const volScalarField &dfwdNuTilda) const
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
incompressibleVars & primalVars_
tmp< volScalarField > r(const volScalarField &Stilda) const
dimensionedScalar neg(const dimensionedScalar &ds)
dimensionedScalar pow5(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
tmp< volScalarField > nu() const
Return the laminar viscosity.
#define forAll(list, i)
Loop across all elements in list.
Switch adjointTurbulence_
Turbulence on/off flag.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
autoPtr< boundaryVectorField > wallFloCoSensitivitiesPtr_
Wall sensitivity term for flow control optimisation.
volScalarField productionDestructionSource_
dimensionedScalar pos(const dimensionedScalar &ds)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const surfaceScalarField & phi() const
Return const reference to volume flux.
Base class for solution control classes.
bool changedPrimalSolution_
Has the primal solution changed?
tmp< volScalarField > dStilda_dDelta(const volScalarField &Omega, const volScalarField &fv2) const
tmp< volScalarField > dr_dNuTilda(const volScalarField &Stilda) const
This boundary condition provides a wall function for the turbulent viscosity (i.e. nut) based on velocity (i.e. U). Using Spalding's law gives a continuous nut profile to the wall.
void setSize(const label n)
Alias for resize()
tmp< volScalarField > chi() const
tmp< volScalarField > dr_dDelta(const volScalarField &Stilda) const
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar exp(const dimensionedScalar &ds)
bool useSolverNameForFields() const
Append solver name to fields?
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual tmp< volScalarField > nutJacobianTMVar1() const
Jacobian of nut wrt the first turbulence model variable.
Abstract base class for incompressible turbulence models.
label size() const noexcept
The number of elements in the list.
bool printMaxMags() const
Print max mags of solver fields.
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
const volVectorField & Ua() const
Return const reference to velocity.
virtual bool read()
Read adjointRASProperties dictionary.
volScalarField & nuaTilda()
Access to the adjoint Spalart - Allmaras field.
static tmp< volScalarField > createLimiter(const fvMesh &mesh, const dictionary &dict)
Return a limiter based on given cells. For use with classes other than ATC which employ the same smoo...
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
zeroField SuSp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
wordList adjointTMVariablesBaseNames_
Base names of the adjoint fields.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
addToRunTimeSelectionTable(adjointRASModel, adjointkOmegaSST, dictionary)
autoPtr< volScalarField > adjointTMVariable1Ptr_
Adjoint turbulence model variable 1.
const word & solverName() const
Return solver name.
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor including the laminar stress.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
dimensionedScalar minStilda_
const volVectorField & U() const
Return const reference to velocity.
const uniformDimensionedVectorField & g
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
volTensorField momentumSourceMult_
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Type gMax(const FieldField< Field, Type > &f)
tmp< volScalarField > dStilda_dOmega(const volScalarField &Omega, const volScalarField &fv2) const
virtual void correct()
Solve the adjoint turbulence equations.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
tmp< volScalarField > dFv1_dChi(const volScalarField &chi) const
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const solverControl & getSolverControl() const
Return const reference to solverControl.
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
tmp< volScalarField > dnut_dNuTilda(const volScalarField &fv1, const volScalarField &dFv1dChi) const
void setMeanFields()
Set mean fields.
const word & adjointSolverName() const
Return name of the adjointSolver.
volSymmTensorField symmAdjointProductionU_
Manages the adjoint mean flow fields and their mean values.
const volScalarField & y_
Wall distance.
const volVectorField & UaInst() const
Return const reference to velocity.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar pow3(const dimensionedScalar &ds)
tmp< volScalarField > dfw_dOmega(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadOmega) const
void relax(const scalar alpha)
Relax field (for steady-state solution).
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
virtual tmp< fvVectorMatrix > divDevReff(volVectorField &U) const
Return the diffusion term for the momentum equation.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
virtual const boundaryVectorField & wallFloCoSensitivities()
Sensitivity terms for flow control, emerging from the.
tmp< volScalarField > fw(const volScalarField &Stilda) const
tmp< volScalarField > fv2(const volScalarField &chi, const volScalarField &fv1) const
const std::string patch
OpenFOAM patch number as a std::string.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
tmp< volScalarField > dfw_dr(const volScalarField &Stilda) const
void correctBoundaryConditions()
Correct boundary field.
virtual void nullify()
Nullify all adjoint turbulence model fields and their old times.
dimensionedScalar pow6(const dimensionedScalar &ds)
messageStream Info
Information stream (stdout output on master, null elsewhere)
objectiveManager & objectiveManager_
Reference to the objectiveManager.
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
tmp< volScalarField > dr_dStilda(const volScalarField &Stilda) const
void storePrevIter() const
Store the field as the previous iteration value.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
virtual tmp< volScalarField > distanceSensitivities()
Sensitivity terms resulting from the differentiation of the distance field. Misses dxdb...
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
tmp< volScalarField > fv1(const volScalarField &chi) const
defineTypeNameAndDebug(adjointkOmegaSST, 0)
A class for managing temporary objects.
tmp< volScalarField > allocateMask()
Allocate the mask field.
virtual tmp< volTensorField > FISensitivityTerm()
Term contributing to the computation of FI-based sensitivities.
tmp< volVectorField > conservativeMomentumSource()
Conservative source term for the adjoint momentum equations.
Defines the attributes of an object for which implicit objectRegistry management is supported...
const nearWallDist & y() const
Return the near wall distances.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
tmp< volScalarField > dfw_dDelta(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadDelta) const
const volScalarField & nut() const
Return the turbulence viscosity.
bool limitAdjointProduction_
Whether to limit the adjoint production term to enhance stability.
static void setField(autoPtr< GeometricField< Type, fvPatchField, volMesh >> &fieldPtr, const fvMesh &mesh, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Read vol fields.
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh >> grad(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
const dimensionSet & dimensions() const noexcept
Return dimensions.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
static constexpr const zero Zero
Global zero (0)