49 objectiveIncompressible,
50 objectivePowerDissipation,
57 void objectivePowerDissipation::populateFieldNames()
61 const incompressibleAdjointSolver& adjSolver =
63 const autoPtr<incompressibleAdjoint::adjointRASModel>& adjointRAS =
64 adjSolver.getAdjointVars().adjointTurbulence();
66 adjointRAS().getAdjointTMVariablesBaseNames();
70 (adjSolver.extendedVariableName(baseNames[nI]));
82 const word& adjointSolverName,
83 const word& primalSolverName
94 extendedVariableName(
"Ua")
106 createZeroFieldPtr<vector>
133 createZeroFieldPtr<tensor>
136 (
"gradDxdbMult" +
type()),
142 dJdbPtr_.reset(createZeroFieldPtr<scalar>(
mesh_,
"dJdb",
dimless));
159 for (
const label zI : zones_)
163 scalarField integrandZone(integrand.primitiveField(), zoneI);
165 J_ += 0.5*
gSum(integrandZone*VZone);
171 scalar porosityContr =
Zero;
172 for (
const label cellI : zoneI)
174 porosityContr +=
beta[cellI]*
magSqr(
U[cellI])*V[cellI];
196 const incompressibleAdjointSolver& adjSolver =
199 const autoPtr<incompressibleAdjoint::adjointRASModel>& adjointRAS =
200 adjSolver.getAdjointVars().adjointTurbulence();
201 tmp<volScalarField> dnutdUMult = 0.5*
magSqr(S());
202 tmp<volVectorField> dnutdU = adjointRAS->nutJacobianU(dnutdUMult);
205 for (
const label zI : zones_)
208 for (
const label cellI : zoneI)
210 dJdvPtr_()[cellI] = dnutdU()[cellI];
218 for (
const label zI : zones_)
221 for (
const label cellI : zoneI)
223 dJdvPtr_()[cellI] += integrand[cellI];
230 const topOVariablesBase& vars =
233 const scalar betaMax = vars.getBetaMax();
234 for (
const label zI : zones_)
237 for (
const label cellI : zoneI)
282 for (
const label zI : zones_)
285 for (
const label cellI : zoneI)
287 divDxDbMult[cellI] = integrand[cellI];
303 for (
const label zI : zones_)
306 for (
const label cellI : zoneI)
308 gradDxDbMult[cellI] = integrand[cellI];
311 gradDxDbMult.correctBoundaryConditions();
322 const topOVariablesBase& vars =
324 const scalar betaMax = vars.getBetaMax();
325 for (
const label zI : zones_)
328 for (
const label cellI : zoneI)
341 populateFieldNames();
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
objectivePowerDissipation(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName)
Construct from components.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void size(const label n)
Older name for setAddressableSize.
fvMatrix< scalar > fvScalarMatrix
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
const word adjointSolverName_
scalar getBetaMax() const
Get betaMax value.
autoPtr< volScalarField > dJdTMvar2Ptr_
Second turbulence model variable.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
GeometricField< tensor, fvPatchField, volMesh > volTensorField
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void update_dJdTMvar(autoPtr< volScalarField > &dJdTMvarPtr, tmp< volScalarField >(incompressibleAdjoint::adjointRASModel::*JacobianFunc)() const, const volScalarField &JacobianMultiplier, const labelList &zones)
Compute dJdTMVar{1,2}.
compressible::turbulenceModel & turb
void checkCellZonesSize(const labelList &zoneIDs) const
Check if cellZones provided include at least one cell.
virtual void update_dJdv()
Update values to be added to the adjoint outlet velocity.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
GeometricField< vector, fvPatchField, volMesh > volVectorField
void push_back(const T &val)
Append an element at the end of the list.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Macros for easy insertion into run-time selection tables.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
const word objectiveName_
#define forAll(list, i)
Loop across all elements in list.
wordList fieldNames_
List of adjoint fields for which this objective will contribute sources to their equations.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual scalar J()
Return the objective function value.
void setSize(const label n)
Alias for resize()
Type gSum(const FieldField< Field, Type > &f)
const volScalarField & dJdb() const
Contribution to field sensitivities.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
autoPtr< volVectorField > dJdvPtr_
defineTypeNameAndDebug(objectivePartialVolume, 1)
A List of wordRe with additional matching capabilities.
virtual void update_dJdTMvar1()
Update field to be added to the first adjoint turbulence model PDE.
virtual const volScalarField & beta() const =0
Get field used for physical interpolations.
virtual void addSource(fvScalarMatrix &matrix)
Add source terms to the adjoint turbulence model equations.
scalar J_
Objective function value and weight.
label find(const T &val) const
Find index of the first occurrence of the value.
const volVectorField & U() const
Return const reference to velocity.
virtual scalar weight() const
Return the objective function weight.
Istream and Ostream manipulators taking arguments.
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.
Base class for selecting the betaMax value, i.e. the value multiplying the Brinkman penalisation term...
virtual void update_divDxDbMultiplier()
Update div(dx/db multiplier). Volume-based sensitivity term.
virtual void update_dJdTMvar2()
Update field to be added to the second adjoint turbulence model PDE.
addToRunTimeSelectionTable(objectiveGeometric, objectivePartialVolume, dictionary)
void allocatedJdTurbulence()
Allocate fields related to the differentiation of turbulence models, if necessary.
autoPtr< volScalarField > divDxDbMultPtr_
Multiplier of d(Volume)/db.
virtual void update_gradDxDbMultiplier()
Update grad(dx/db multiplier). Volume-based sensitivity term.
const incompressibleVars & vars_
List< word > wordList
List of word.
dimensionedScalar pow3(const dimensionedScalar &ds)
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
virtual void update_dJdb()
Contribution to field sensitivities.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
void correctBoundaryConditions()
Correct boundary field.
autoPtr< volTensorField > gradDxDbMultPtr_
Emerging from volume objectives that include spatial derivatives.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
const autoPtr< incompressible::turbulenceModel > & turbulence() const
Return const reference to the turbulence model.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
const volVectorField & UInst() const
Return const reference to velocity.
autoPtr< volScalarField > dJdTMvar1Ptr_
First turbulence model variable.
Base class for all design variables related to topology optimisation (topO). Provides the lookup func...
Defines the attributes of an object for which implicit objectRegistry management is supported...
virtual tmp< volScalarField > nutJacobianTMVar2() const
Jacobian of nut wrt the second turbulence model variable.
Abstract base class for objective functions in incompressible flows.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
virtual tmp< volScalarField > nutJacobianTMVar1() const
Jacobian of nut wrt the first turbulence model variable.
static constexpr const zero Zero
Global zero (0)