45 namespace incompressibleAdjoint
47 namespace adjointRASModels
56 adjointSpalartAllmaras,
194 return pos(fieldSwitch) +
neg(fieldSwitch)*
Cs_;
208 return pos(fieldSwitch)*(dFv2dChi*
nuTilda()*invDenom/
nu() +
fv2*invDenom);
221 return - 2.*
pos(fieldSwitch)*aux/
y_;
233 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
235 tdrdNutilda.ref().boundaryFieldRef() ==
Zero;
249 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
265 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
284 pow6Cw3/(pow6g + pow6Cw3)
285 *
pow((1.0 + pow6Cw3)/(pow6g + pow6Cw3), 1.0/6.0)
341 return -
Cb1_*dStildadNuTilda;
362 if(!isA<coupledFvPatch>(
patch))
379 Info<<
"Updating primal-based fields of the adjoint turbulence " 380 <<
"model ..." <<
endl;
460 adjointSpalartAllmaras::adjointSpalartAllmaras
465 const word& adjointTurbulenceModelName,
466 const word& modelName
475 adjointTurbulenceModelName
515 Cw1_(Cb1_/
sqr(kappa_) + (1.0 + Cb2_)/sigmaNut_),
553 limitAdjointProduction_
555 coeffDict_.getOrDefault(
"limitAdjointProduction", true)
558 y_(primalVars_.RASModelVariables()().d()),
560 mask_(allocateMask()),
562 symmAdjointProductionU_
566 "symmAdjointProductionU",
576 productionDestructionSource_
580 "productionDestructionSource",
650 "momentumSourceMult",
660 gradU_(fvc::
grad(primalVars.
U())),
661 gradNuTilda_(fvc::
grad(nuTilda())),
662 minStilda_(
"SMALL", Stilda_.dimensions(), SMALL)
730 "adjointSpalartAllmaras::addMomentumSource" 782 if (isA<wallFvPatch>(
patch) &&
patch.size() != 0)
784 wallShapeSens[patchI] =
791 return wallShapeSens;
803 wallFloCoSens[patchI] =
808 return wallFloCoSens;
831 auto tadjointEikonalSource =
834 "adjointEikonalSource" +
type(),
844 SAwallFunctionPatchField;
852 forAll(nutBoundary, patchi)
857 isA<SAwallFunctionPatchField>(nutBoundary[patchi])
861 const scalar
kappa_(0.41);
862 const scalar E_(9.8);
891 ((
kappa_/E_)*(
exp(kUu) - 1 - kUu - 0.5*kUu*kUu));
914 adjointEikonalSource[cellI] -=
915 2.*( rt[faceI] + Uap_t[faceI] )
916 *vtau[faceI]*Cwf_d[faceI]*magSf[faceI]
924 return tadjointEikonalSource;
938 tgradNuaTilda.
ref().boundaryFieldRef();
945 if (isA<wallFvPatch>(
patch))
956 gradNuaTildab[patchI] =
966 (gradU & gradU)().
T()
967 - (gradU & gradU.T())
1023 const word& designVarsName
1051 "adjointSpalartAllmaras::correct" 1086 + gradNua*oneOverSigmaNut
1099 nuaTildaEqn.ref().relax();
1113 << maxDeltaNuaTilda.
value()
dictionary coeffDict_
Model coefficients dictionary.
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
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 the turbulence model differentiation.
const Type & value() const noexcept
Return const reference to value.
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...
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
tmp< volScalarField > dP_dNuTilda(const volScalarField &dStildadNuTilda) const
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)
const word & name() const noexcept
Return the object name.
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 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...
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
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.
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.
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 entries 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)
Calculation of adjoint based sensitivities for topology optimisation. This returns just the field par...
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
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.
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &solverControls)
Solve returning the solution statistics given convergence tolerance.
dimensionedScalar minStilda_
const volVectorField & U() const
Return const reference to velocity.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
const uniformDimensionedVectorField & g
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.
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.
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 volScalarField & nutRef() const
static void postProcessSens(scalarField &sens, scalarField &auxSens, fv::options &fvOptions, const word &fieldName, const word &designVariablesName)
Add part of the sensitivities coming from fvOptions.
virtual void addSource(fvVectorMatrix &matrix)
Add contribution to adjoint momentum PDEs.
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
virtual tmp< scalarField > topologySensitivities(const word &designVarsName) const
Term contributing to the computation of topology optimisation sensitivities.
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 turbulence model differentiation.
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()
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
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.
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present.
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.
Do not request registration (bool: false)
tmp< volScalarField > dfw_dDelta(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadDelta) const
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.
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
static constexpr const zero Zero
Global zero (0)