59 const word& adjointSolverName,
60 const word& primalSolverName
63 objectiveIncompressible(
mesh,
dict, adjointSolverName, primalSolverName),
74 extendedVariableName(
"Ua")
98 mesh_.time().timeName(),
126 volZone_[zI] =
gSum(VZone);
127 UMean_[zI] =
gSum(UZone*VZone)/volZone_[zI];
128 UVar_[zI] =
gSum(
magSqr(UZone - UMean_[zI])*VZone)/volZone_[zI];
144 for (
const label cellI : cz)
146 dJdvPtr_()[cellI] = (
U[cellI] - UMean_[zI])/volZone_[zI];
160 for (
const label cellI : cz)
163 0.5*(
magSqr(
U[cellI] - UMean_[zI]) - UVar_[zI])/volZone_[zI];
166 divDxDbMult.correctBoundaryConditions();
173 for (
const label zI : zones_)
176 file<<
setw(
width_) << word(zoneName +
"-" +
"UMean") <<
" ";
Istream and Ostream manipulators taking arguments.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label size() const noexcept
The number of elements in list.
void correctBoundaryConditions()
Correct boundary field.
@ 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.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Mesh data needed to do the Finite Volume discretisation.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
const volVectorField & UInst() const
Return const reference to velocity.
const volVectorField & U() const
Return const reference to velocity.
Abstract base class for objective functions in incompressible flows.
const incompressibleVars & vars_
void checkCellZonesSize(const labelList &zoneIDs) const
Check if cellZones provided include at least one cell.
autoPtr< volVectorField > dJdvPtr_
const word objectiveName_
autoPtr< OFstream > objFunctionFilePtr_
File to keep the objective values after the end of the primal solver.
wordList fieldNames_
List of adjoint fields for which this objective will contribute sources to their equations.
unsigned int width_
Default width of entries when writing in the objective files.
autoPtr< volScalarField > divDxDbMultPtr_
Multiplier of d(Volume)/db.
scalar J_
Objective function value and weight.
const dictionary & dict() const
Return objective dictionary.
const word adjointSolverName_
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
A List of wordRe with additional matching capabilities.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Type gSum(const FieldField< Field, Type > &f)
GeometricField< vector, fvPatchField, volMesh > volVectorField
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
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.
Omanip< int > setw(const int i)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
autoPtr< GeometricField< Type, fvPatchField, volMesh > > createZeroFieldPtr(const fvMesh &mesh, const word &name, const dimensionSet dims, bool printAllocation=false)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.