57void objectivePtLosses::initialize()
72 <<
"No patches provided to PtLosses. "
73 <<
"Choosing them according to the patch mass flows" <<
nl;
82 const scalar mass =
gSum(phiPatch);
83 if (
mag(mass) > SMALL)
89 patches_.
transfer(objectiveReportPatches);
96 <<
"No valid patch name on which to minimize " <<
type() <<
endl
101 Info<<
"Minimizing " <<
type() <<
" in patches:" <<
endl;
116 const word& adjointSolverName,
117 const word& primalSolverName
120 objectiveIncompressible(
mesh,
dict, adjointSolverName, primalSolverName),
148 const label patchI = patches_[oI];
152 (
U.boundaryField()[patchI] & Sf)
154 p.boundaryField()[patchI]
155 + 0.5*
magSqr(
U.boundaryField()[patchI])
158 patchPt_[oI] =
mag(pt);
172 const label patchI = patches_[oI];
177 bdJdpPtr_()[patchI] = -(
U.boundaryField()[patchI] & nf)*nf;
189 const label patchI = patches_[oI];
196 - (
p.boundaryField()[patchI] + 0.5*
magSqr(Ub))*nf
209 const label patchI = patches_[oI];
215 -
p.boundaryField()[patchI]
216 - 0.5*
magSqr(
U.boundaryField()[patchI])
217 -
sqr(
U.boundaryField()[patchI] & nf);
228 const label patchI = patches_[oI];
234 bdJdvtPtr_()[patchI] = -Un*(
U.boundaryField()[patchI] - Un*nf);
241 for (
const label patchI : patches_)
251 for (
const scalar pt : patchPt_)
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.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void setSize(label n)
Alias for resize().
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of entries in the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
const volVectorField & UInst() const
Return const reference to velocity.
const volVectorField & U() const
Return const reference to velocity.
const volScalarField & p() const
Return const reference to pressure.
const surfaceScalarField & phiInst() const
Return const reference to volume flux.
const volScalarField & pInst() const
Return const reference to pressure.
Abstract base class for objective functions in incompressible flows.
autoPtr< boundaryScalarField > bdJdvnPtr_
Adjoint outlet pressure.
autoPtr< boundaryVectorField > bdJdpPtr_
Adjoint (intlet,wall) velocity.
autoPtr< boundaryVectorField > bdJdvtPtr_
Adjoint outlet velocity.
const incompressibleVars & vars_
autoPtr< boundaryVectorField > bdJdvPtr_
autoPtr< OFstream > objFunctionFilePtr_
File to keep the objective values after the end of the primal solver.
unsigned int width_
Default width of entries when writing in the objective files.
scalar J_
Objective function value and weight.
const dictionary & dict() const
Return objective dictionary.
objectivePtLosses(const fvMesh &mesh, const dictionary &dict, const word &adjointSolverName, const word &primalSolverName)
from components
virtual void addHeaderColumns() const
Write headers for additional columns.
virtual void update_boundarydJdvn()
Update values to be added to the adjoint outlet pressure.
virtual scalar J()
Return the objective function value.
virtual void update_boundarydJdv()
Update values to be added to the adjoint outlet velocity.
virtual void addColumnValues() const
Write information to additional columns.
virtual void update_boundarydJdp()
Update values to be added to the adjoint inlet velocity.
virtual void update_boundarydJdvt()
Update values to be added to the adjoint outlet tangential velocity.
labelHashSet patchSet(const UList< wordRe > &select, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for managing temporary objects.
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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for handling debugging switches.
Type gSum(const FieldField< Field, Type > &f)
GeometricField< vector, fvPatchField, volMesh > volVectorField
dimensionedSymmTensor sqr(const dimensionedVector &dv)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
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.
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
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).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > createZeroBoundaryPtr(const fvMesh &mesh, bool printAllocation=false)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
fvPatchField< vector > fvPatchVectorField
fvsPatchField< scalar > fvsPatchScalarField
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.