61 const word& adjointSolverName,
62 const word& primalSolverName
97 <<
"No patches provided to PtLosses. "
98 <<
"Choosing them according to the patch mass flows" <<
nl;
107 const scalar mass =
gSum(phiPatch);
108 if (
mag(mass) > SMALL)
110 objectiveReportPatches.
append(patchI);
114 patches_.
transfer(objectiveReportPatches);
118 if (patches_.
empty())
121 <<
"No valid patch name on which to minimize " <<
type() <<
endl
126 Info<<
"Minimizing " <<
type() <<
" in patches:" <<
endl;
146 const label patchI = patches_[oI];
150 (
U.boundaryField()[patchI] & Sf)
153 + 0.5*
magSqr(
U.boundaryField()[patchI])
156 patchPt_[oI] =
mag(pt);
170 const label patchI = patches_[oI];
175 bdJdpPtr_()[patchI] = -(
U.boundaryField()[patchI] & nf)*nf;
187 const label patchI = patches_[oI];
207 const label patchI = patches_[oI];
214 - 0.5*
magSqr(
U.boundaryField()[patchI])
215 -
sqr(
U.boundaryField()[patchI] & nf);
226 const label patchI = patches_[oI];
232 bdJdvtPtr_()[patchI] = -Un*(
U.boundaryField()[patchI] - Un*nf);
239 for (
const label patchI : patches_)
249 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 append(const T &val)
Copy append an element to the end of this list.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
void transfer(List< T > &list)
void setSize(const label n)
Alias for resize()
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements 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
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const
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.
void initialize()
Return the objectiveReportPatches.
virtual void addHeaderColumns() const
Write headers for additional columns.
void update_boundarydJdvn()
Update values to be added to the adjoint outlet pressure.
scalar J()
Return the objective function value.
void update_boundarydJdv()
Update values to be added to the adjoint outlet velocity.
virtual void addColumnValues() const
Write information to additional columns.
void update_boundarydJdp()
Update values to be added to the adjoint inlet velocity.
void update_boundarydJdvt()
Update values to be added to the adjoint outlet tangential velocity.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
const polyBoundaryMesh & boundaryMesh() const
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.
Type gSum(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.