54 auto tresGrad = tmp<Field<GradType>>
::New(patch_.size(),
Zero);
55 auto& resGrad = tresGrad.ref();
57 const labelList& faceCells = patch_.faceCells();
63 const GeometricField<Type2, fvPatchField, volMesh>&
field =
80 const word surfFieldName(
"interpolated" +
name +
"ForBoundaryGrad");
81 typedef GeometricField<Type2, fvsPatchField, surfaceMesh> surfFieldType;
82 surfFieldType* surfFieldPtr =
83 mesh.objectRegistry::template getObjectPtr<surfFieldType>(surfFieldName);
93 )().interpolate(
field).ptr();
94 surfFieldPtr->rename(surfFieldName);
99 if (surfFieldPtr->upToDate(
field))
112 )().interpolate(
field).ptr();
113 surfFieldPtr->rename(surfFieldName);
117 surfFieldType& surfField = *surfFieldPtr;
121 tmp<vectorField> tnf = patch_.nf();
129 const label cI = faceCells[fI];
130 const cell& cellI =
cells[cI];
131 for (
const label faceI : cellI)
136 const label own = owner[faceI];
152 const label boundaryFaceI = faceI - patchForFlux.start();
156 *surfField.boundaryField()[
patchID][boundaryFaceI];
160 resGrad[fI] /= V[cI];
165 const fvPatchField<Type2>& bField =
field.boundaryField()[patch_.index()];
166 resGrad = nf*bField.snGrad() + (resGrad - nf*(nf & resGrad));
175 if (!addATCUaGradUTerm_.good())
177 addATCUaGradUTerm_ = bool(isA<ATCUaGradU>(getATC()));
179 return addATCUaGradUTerm_;
191 patch_(adjointBC.patch_),
192 managerName_(adjointBC.managerName_),
193 adjointSolverName_(adjointBC.adjointSolverName_),
194 simulationType_(adjointBC.simulationType_),
199 adjointBC.managerName_,
200 adjointBC.adjointSolverName_,
201 adjointBC.simulationType_,
205 addATCUaGradUTerm_(
Switch::INVALID)
216 const word& solverName
220 managerName_(
"objectiveManager" + solverName),
221 adjointSolverName_(solverName),
222 simulationType_(
"incompressible"),
223 boundaryContrPtr_(nullptr),
224 addATCUaGradUTerm_(
Switch::INVALID)
243 return adjointSolverName_;
250 return simulationType_;
264 boundaryContrPtr_.
reset 278 <<
"No objectiveManager " << managerName_ <<
" available." <<
nl 279 <<
"Setting boundaryAdjointContributionPtr to nullptr. " <<
nl 280 <<
"OK for decomposePar." 287 boundaryAdjointContribution&
290 return boundaryContrPtr_();
298 patch_.boundaryMesh().mesh().template
299 lookupObject<ATCModel>(
"ATCModel" + adjointSolverName_);
tmp< Field< typename Foam::outerProduct< Foam::vector, Type2 >::type > > computePatchGrad(word name)
Get gradient of field on a specific boundary.
adjointBoundaryCondition(const fvPatch &p, const DimensionedField< Type, volMesh > &iF, const word &solverName)
Construct from field and base name.
virtual void updatePrimalBasedQuantities()
Update the primal based quantities related to the adjoint boundary conditions.
const word & simulationType() const
Return the simulationType.
const word & adjointSolverName() const
Return adjointSolverName.
const surfaceVectorField & Sf() const
Return cell face area vectors.
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...
List< cell > cellList
List of cell.
static autoPtr< boundaryAdjointContribution > New(const word &managerName, const word &adjointSolverName, const word &simulationType, const fvPatch &patch)
Return a reference to the selected turbulence model.
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
constexpr char nl
The newline '\n' character (0x0a)
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
bool store()
Register object with its registry and transfer ownership to the registry.
void setBoundaryContributionPtr()
Set the ptr to the correct boundaryAdjointContribution.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
const cellList & cells() const
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
GeometricField< vector, fvPatchField, volMesh > volVectorField
bool addATCUaGradUTerm()
Whether to add the extra term from the UaGradU formulation.
UList< label > labelUList
A UList of labels.
ITstream & interpolationScheme(const word &name) const
Get interpolation scheme for given name, or default.
#define forAll(list, i)
Loop across all elements in list.
virtual tmp< Field< typename Foam::outerProduct< Foam::vector, Type >::type > > dxdbMult() const
Return contribution to sensitivity derivatives.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const polyMesh & mesh() const noexcept
Return the mesh reference.
const ATCModel & getATC() const
ATC type might be useful for a number of BCs. Return here.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Base class for selecting the adjoint transpose convection model. Inherits from regIOobject to add loo...
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
Abstract base class for computing contributions of the objective functions to the adjoint boundary co...
boundaryAdjointContribution & getBoundaryAdjContribution()
Get boundaryContribution.
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
#define WarningInFunction
Report a warning using Foam::Warning.
Base class for solution control classes.
Mesh data needed to do the Finite Volume discretisation.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Field< vector > vectorField
Specialisation of Field<T> for vector.
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
List< label > labelList
A List of labels.
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
const word & objectiveManagerName() const
Return objectiveManager name.
static constexpr const zero Zero
Global zero (0)