122 tr.ref().boundaryFieldRef() ==
Zero;
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)
251 tdrdStilda.ref().boundaryFieldRef() ==
Zero;
265 *(scalar(10) -
r_)/(scalar(10) -
r_ + SMALL)
267 tdrdDelta.ref().boundaryFieldRef() ==
Zero;
284 pow6Cw3/(pow6g + pow6Cw3)
285 *
pow((1.0 + pow6Cw3)/(pow6g + pow6Cw3), 1.0/6.0)
341 return -
Cb1_*dStildadNuTilda;
379 Info<<
"Updating primal-based fields of the adjoint turbulence "
380 <<
"model ..." <<
endl;
460adjointSpalartAllmaras::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"
784 wallShapeSens[patchI] =
791 return wallShapeSens;
803 wallFloCoSens[patchI] =
808 return wallFloCoSens;
831 auto tadjointEikonalSource =
834 "adjointEikonalSource" +
type(),
840 volScalarField& adjointEikonalSource = tadjointEikonalSource.ref();
844 SAwallFunctionPatchField;
852 forAll(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();
956 gradNuaTildab[patchI] =
966 (gradU & gradU)().
T()
967 - (gradU & gradU.T())
990 mesh_.time().timeName(),
1023 const word& designVarsName
1051 "adjointSpalartAllmaras::correct"
1086 + gradNua*oneOverSigmaNut
1099 nuaTildaEqn.ref().relax();
1113 << maxDeltaNuaTilda.
value()
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const uniformDimensionedVectorField & g
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...
label size() const noexcept
The number of elements in list.
const dimensionSet & dimensions() const noexcept
Return dimensions.
void relax(const scalar alpha)
Relax field (for steady-state solution).
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())
tmp< GeometricField< Type, PatchField, GeoMesh > > T() const
Return transpose (only if it is a tensor field).
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef().
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
void storePrevIter() const
Store the field as the previous iteration value.
void correctBoundaryConditions()
Correct boundary field.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
void setSize(label n)
Alias for resize().
label size() const noexcept
The number of entries in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
static autoPtr< boundaryAdjointContribution > New(const word &managerName, const word &adjointSolverName, const word &simulationType, const fvPatch &patch)
Return a reference to the selected turbulence model.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Generic dimensioned Type class.
bool readIfPresent(const dictionary &dict)
Update the value of dimensioned<Type> if found in the dictionary, lookup in dictionary with the name(...
const Type & value() const noexcept
Return const reference to value.
Smooth ATC in cells next to a set of patches supplied by type.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Finite-volume options, which is an IOdictionary of values and a fv::optionList.
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present otherwise lookup and return.
Manages the adjoint mean flow fields and their mean values.
const volVectorField & Ua() const
Return const reference to velocity.
const volVectorField & UaInst() const
Return const reference to velocity.
const solverControl & getSolverControl() const
Return const reference to solverControl.
Abstract base class for incompressible turbulence models.
dictionary coeffDict_
Model coefficients dictionary.
bool includeDistance_
Does the turbulence model include distances and should the adjoint to the distance field be computed.
autoPtr< boundaryVectorField > wallShapeSensitivitiesPtr_
Wall sensitivity term for shape optimisation.
Switch adjointTurbulence_
Turbulence on/off flag.
bool changedPrimalSolution_
Has the primal solution changed?
autoPtr< boundaryVectorField > adjMomentumBCSourcePtr_
Source to the adjoint momentum BC emerging from differentiating the turbulence model.
const nearWallDist & y() const
Return the near wall distances.
autoPtr< volScalarField > adjointTMVariable1Ptr_
Adjoint turbulence model variable 1.
objectiveManager & objectiveManager_
Reference to the objectiveManager.
wordList adjointTMVariablesBaseNames_
Base names of the adjoint fields.
autoPtr< boundaryVectorField > wallFloCoSensitivitiesPtr_
Wall sensitivity term for flow control optimisation.
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
void setMeanFields()
Set mean fields.
virtual bool read()
Read adjointRASProperties dictionary.
Continuous adjoint to the Spalart-Allmaras one-eqn mixing-length model for incompressible flows.
tmp< volScalarField > dfw_dNuTilda(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadNuTilda) const
virtual tmp< fvVectorMatrix > divDevReff(volVectorField &U) const
Return the diffusion term for the momentum equation.
virtual tmp< scalarField > diffusionCoeffVar1(label patchI) const
Diffusion coefficient of the first primal and adjoint turbulence model equation. Needed for some adjo...
const volScalarField & nuTilda() const
References to the primal turbulence model variables.
tmp< volScalarField > dStilda_dNuTilda(const volScalarField &Omega, const volScalarField &fv2, const volScalarField &dFv2dChi) const
virtual tmp< volTensorField > FISensitivityTerm()
Term contributing to the computation of FI-based sensitivities.
tmp< volScalarField > chi() const
tmp< volScalarField > dfw_dOmega(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadOmega) const
tmp< volScalarField > dFv2_dChi(const volScalarField &chi, const volScalarField &fv1, const volScalarField &dFv1dChi) const
tmp< volScalarField > fw(const volScalarField &Stilda) const
volVectorField gradNuTilda_
tmp< volScalarField > dStilda_dDelta(const volScalarField &Omega, const volScalarField &fv2) const
virtual void correct()
Solve the adjoint turbulence equations.
tmp< volVectorField > conservativeMomentumSource()
Conservative source term for the adjoint momentum equations.
tmp< volScalarField > DnuTildaEff() const
tmp< volScalarField > dStilda_dOmega(const volScalarField &Omega, const volScalarField &fv2) const
void updatePrimalRelatedFields()
Update the constant primal-related fields.
virtual const boundaryVectorField & adjointMomentumBCSource() const
Source for the outlet adjoint momentum BC coming from differentiating the turbulence model.
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor including the laminar stress.
tmp< volScalarField > dP_dNuTilda(const volScalarField &dStildadNuTilda) const
volTensorField momentumSourceMult_
virtual void nullify()
Nullify all adjoint turbulence model fields and their old times.
tmp< volScalarField > dr_dNuTilda(const volScalarField &Stilda) const
tmp< volScalarField > fv1(const volScalarField &chi) const
virtual tmp< volScalarField > nutJacobianTMVar1() const
Jacobian of nut wrt the first turbulence model variable.
tmp< volScalarField > Stilda(const volScalarField &chi, const volScalarField &fv1) const
volScalarField & nuaTilda()
Access to the adjoint Spalart - Allmaras field.
tmp< volScalarField > dfw_dDelta(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadDelta) const
dimensionedScalar minStilda_
bool limitAdjointProduction_
Whether to limit the adjoint production term to enhance stability.
volScalarField productionDestructionSource_
tmp< volScalarField > dfw_dr(const volScalarField &Stilda) const
virtual const boundaryVectorField & wallShapeSensitivities()
Sensitivity terms for shape optimisation, emerging from the turbulence model differentiation.
tmp< volScalarField > allocateMask()
Allocate the mask field.
const volScalarField & y_
Wall distance.
virtual tmp< volVectorField > adjointMeanFlowSource()
Source terms to the adjoint momentum equation due to the differentiation of the turbulence model.
virtual const boundaryVectorField & wallFloCoSensitivities()
Sensitivity terms for flow control, emerging from the turbulence model differentiation.
dimensionedScalar sigmaNut_
tmp< volScalarField > dD_dNuTilda(const volScalarField &fw, const volScalarField &dfwdNuTilda) const
virtual tmp< volScalarField > distanceSensitivities()
Sensitivity terms resulting from the differentiation of the distance field. Misses dxdb,...
tmp< volScalarField > dr_dStilda(const volScalarField &Stilda) const
tmp< volScalarField > dnut_dNuTilda(const volScalarField &fv1, const volScalarField &dFv1dChi) const
tmp< volScalarField > dr_dDelta(const volScalarField &Stilda) const
const volScalarField & nutRef() const
tmp< volScalarField > fv2(const volScalarField &chi, const volScalarField &fv1) const
volScalarField mask_
Field for masking (convergence enhancement).
volSymmTensorField symmAdjointProductionU_
virtual tmp< scalarField > topologySensitivities(const word &designVarsName) const
Term contributing to the computation of topology optimisation sensitivities.
virtual bool read()
Read adjointRASProperties dictionary.
tmp< volScalarField > dFv1_dChi(const volScalarField &chi) const
tmp< volScalarField > r(const volScalarField &Stilda) const
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
incompressibleAdjointMeanFlowVars & adjointVars_
tmp< volScalarField > nu() const
Return the laminar viscosity.
virtual void correct()=0
Solve the adjoint turbulence equations.
incompressibleVars & primalVars_
Base class for solution control classes.
const volVectorField & U() const
Return const reference to velocity.
const surfaceScalarField & phi() const
Return const reference to volume flux.
This boundary condition provides a wall function for the turbulent viscosity (i.e....
Class for managing objective functions.
const word & adjointSolverName() const
Return name of the adjointSolver.
virtual void addSource(fvVectorMatrix &matrix)
Add contribution to adjoint momentum PDEs.
static void postProcessSens(scalarField &sens, scalarField &auxSens, fv::options &fvOptions, const word &fieldName, const word &designVariablesName)
Add part of the sensitivities coming from fvOptions.
bool printMaxMags() const
Print max mags of solver fields.
A class for managing temporary objects.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
static void setField(autoPtr< GeometricField< Type, fvPatchField, volMesh > > &fieldPtr, const fvMesh &mesh, const word &baseName, const word &solverName, const bool useSolverNameForFields)
Read vol fields.
const word & solverName() const
Return solver name.
bool useSolverNameForFields() const
Append solver name to fields?
static void nullifyField(GeometricField< Type, PatchField, GeoMesh > &fieldPtr)
Nullify field and old times, if present.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Namespace of functions to calculate explicit derivatives.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
zeroField SuSp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
Namespace for incompressible adjoint turbulence models.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar pow6(const dimensionedScalar &ds)
dimensionedScalar pos(const dimensionedScalar &ds)
dimensionedScalar pow5(const dimensionedScalar &ds)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedScalar exp(const dimensionedScalar &ds)
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dimensionSet dimless
Dimensionless.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< symmTensor > dimensionedSymmTensor
Dimensioned tensor obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensionedScalar neg(const dimensionedScalar &ds)
static constexpr const zero Zero
Global zero (0).
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
volVectorField::Boundary boundaryVectorField
UList< label > labelUList
A UList of labels.
fvPatchField< vector > fvPatchVectorField
dimensionedTensor skew(const dimensionedTensor &dt)
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
fvPatchField< scalar > fvPatchScalarField
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
Calculation of adjoint based sensitivities for topology optimisation. This returns just the field par...
#define forAll(list, i)
Loop across all elements in list.