Go to the documentation of this file.
40 namespace incompressible
66 createZeroBoundaryPointFieldPtr<vector>(
mesh_)
70 createZeroBoundaryPointFieldPtr<vector>(
mesh_)
74 for (
const label patchI : sensitivityPatchIDs_)
88 functions[funcI].weight()
89 *functions[funcI].dSdbMultiplier(patchI);
91 functions[funcI].weight()
92 *functions[funcI].dndbMultiplier(patchI);
103 const label patchStartIndex =
patch.start();
111 const labelList& pointFaces = patchPointFaces[ppI];
114 label localFaceIndex = pointFaces[pfI];
115 label globalFaceIndex = patchStartIndex + localFaceIndex;
116 const face& faceI = faces[globalFaceIndex];
122 if (faceI[facePointI] == meshPoints[ppI])
131 const tensor& deltaSf = deltaNormals[1];
133 dSdbMultiplierTot[localFaceIndex] & deltaSf;
136 const tensor& deltaNf = deltaNormals[2];
138 dndbMultiplierTot[localFaceIndex] & deltaNf;
146 for (
const label patchI : sensitivityPatchIDs_)
152 const label globaPointI = meshPoints[ppI];
153 dSdbGlobal[globaPointI] += pointSensdSdb()[patchI][ppI];
154 dndbGlobal[globaPointI] += pointSensdndb()[patchI][ppI];
167 for (
const label patchI : sensitivityPatchIDs_)
172 pointSensdSdb()[patchI].map(dSdbGlobal, meshPoints);
173 pointSensdndb()[patchI].map(dndbGlobal, meshPoints);
179 patchInter.pointToFaceInterpolate(pointSensdSdb()[patchI])
186 patchInter.pointToFaceInterpolate(pointSensdndb()[patchI]);
190 wallFaceSensVecPtr_()[patchI] += dSdbFace + dndbFace;
219 sensitivitySurface::sensitivitySurface
239 includeSurfaceArea_(
false),
240 includePressureTerm_(
false),
241 includeGradStressTerm_(
false),
242 includeTransposeStresses_(
false),
243 includeDivTerm_(
false),
244 includeDistance_(
false),
245 includeMeshMovement_(
false),
246 includeObjective_(
false),
247 writeGeometricInfo_(
false),
248 eikonalSolver_(
nullptr),
249 meshMovementSolver_(
nullptr),
251 nfOnPatchPtr_(
nullptr),
252 SfOnPatchPtr_(
nullptr),
253 CfOnPatchPtr_(
nullptr)
259 wallFaceSensVecPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
260 wallFaceSensNormalPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
261 wallFaceSensNormalVecPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
264 if (writeGeometricInfo_)
273 mesh.time().timeName(),
290 mesh.time().timeName(),
307 mesh.time().timeName(),
319 computeDerivativesSize();
373 sensitivityPatchIDs_,
405 for (
const label patchI : sensitivityPatchIDs_)
424 Info<<
" Calculating auxiliary quantities " <<
endl;
438 if (isA<wallFvPatch>(
patch))
443 nf*
U.boundaryField()[patchI].snGrad();
452 createZeroFieldPtr<vector>(
mesh_,
"stressX", stress.dimensions())
456 createZeroFieldPtr<vector>(
mesh_,
"stressY", stress.dimensions())
460 createZeroFieldPtr<vector>(
mesh_,
"stressZ", stress.dimensions())
463 stressXPtr().replace(0, stress.
component(0));
464 stressXPtr().replace(1, stress.
component(1));
465 stressXPtr().replace(2, stress.
component(2));
467 stressYPtr().replace(0, stress.
component(3));
468 stressYPtr().replace(1, stress.
component(4));
469 stressYPtr().replace(2, stress.
component(5));
471 stressZPtr().replace(0, stress.
component(6));
472 stressZPtr().replace(1, stress.
component(7));
473 stressZPtr().replace(2, stress.
component(8));
492 adjointTurbulence->wallShapeSensitivities();
495 <<
" Calculating adjoint sensitivity. " <<
endl;
499 for (
const label patchI : sensitivityPatchIDs_)
522 &
U.boundaryField()[patchI].snGrad()
524 * nuEff.boundaryField()[patchI]
532 nuEff.boundaryField()[patchI]
538 &
U.boundaryField()[patchI].snGrad()
546 scalar(1./3.)*nuEff.boundaryField()[patchI]
549 &
U.boundaryField()[patchI].snGrad()
563 gradStressTerm = - ((Uab & nf)*gradp.
boundaryField()[patchI]);
579 &
U.boundaryField()[patchI].snGrad()
593 functions[funcI].weight()
595 functions[funcI].dxdbDirectMultiplier(patchI)
601 wallFaceSensVecPtr_()[patchI] +=
606 + adjointTMsensitivities[patchI]
622 for (
const label patchI : sensitivityPatchIDs_)
642 distanceSensPtr.
reset(createZeroBoundaryPtr<vector>(
mesh_));
645 for (
const label patchI : sensitivityPatchIDs_)
647 distanceSensPtr()[patchI] = sens[patchI];
655 meshMovementSensPtr.
reset(createZeroBoundaryPtr<vector>(
mesh_));
658 for (
const label patchI : sensitivityPatchIDs_)
660 meshMovementSensPtr()[patchI] = sens[patchI];
666 label nPassedFaces(0);
667 for (
const label patchI : sensitivityPatchIDs_)
676 wallFaceSensVecPtr_()[patchI] += distanceSensPtr()[patchI];
682 wallFaceSensVecPtr_()[patchI] += meshMovementSensPtr()[patchI];
687 wallFaceSensVecPtr_()[patchI] *=
patch.magSf();
690 wallFaceSensNormalPtr_()[patchI] = wallFaceSensVecPtr_()[patchI] & nf;
691 wallFaceSensNormalVecPtr_()[patchI] =
692 wallFaceSensNormalPtr_()[patchI] * nf;
697 = wallFaceSensNormalPtr_()[patchI][fI];
699 nPassedFaces +=
patch.size();
const dictionary & dict() const
Return the construction dictionary.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
virtual const pointField & points() const
Return raw points.
class for managing incompressible objective functions.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual void assembleSensitivities()
Assemble sensitivities.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
const word & solverName() const
Return solver name.
bool includePressureTerm_
Include the adjoint pressure term in sens computation.
bool includeObjective_
Include terms directly emerging from the objective function.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Differentiation of the mesh data structure.
pointField points(const UList< point > &points) const
Return the points corresponding to this face.
A class for handling words, derived from Foam::string.
defineTypeNameAndDebug(adjointEikonalSolver, 0)
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
bool read(const char *buf, int32_t &val)
Same as readInt32.
autoPtr< adjointEikonalSolver > eikonalSolver_
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void write(const word &baseName=word::null)
Write sensitivity maps.
A simple single-phase transport model based on viscosityModel.
const volScalarField & p() const
Return const reference to pressure.
Class including all adjoint fields for incompressible flows.
#define forAll(list, i)
Loop across all elements in list.
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
autoPtr< adjointMeshMovementSolver > meshMovementSolver_
Solver of the adjoint to the eikonal PDE.
bool includeGradStressTerm_
Include the term containing the grad of the stress at the boundary.
addToRunTimeSelectionTable(adjointSensitivity, sensitivityBezier, dictionary)
void write()
Write sensitivity fields.
Abstract base class for adjoint-based sensitivities in incompressible flows.
bool includeDivTerm_
Include the term from the deviatoric part of the stresses.
void computeDerivativesSize()
Compute the number of faces on sensitivityPatchIDs_.
virtual bool readDict(const dictionary &dict)
Read dictionary if changed.
messageStream Info
Information stream (uses stdout - output is on the master only)
bool writeGeometricInfo_
Write geometric info for use by external programs.
virtual void accumulateIntegrand(const scalar dt)
Accumulate sensitivity integrands.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const volScalarField & pa() const
Return const reference to pressure.
autoPtr< adjointEikonalSolver > & getAdjointEikonalSolver()
Get adjoint eikonal solver.
const volVectorField & U() const
Return const reference to velocity.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
autoPtr< volVectorField > nfOnPatchPtr_
const volVectorField & Ua() const
Return const reference to velocity.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool includeSurfaceArea_
Include surface area in sens computation.
Macros for easy insertion into run-time selection tables.
vectorField makeFaceCentresAndAreas_d(const pointField &p, const pointField &p_d)
incompressibleAdjointVars & adjointVars_
Mesh data needed to do the Finite Volume discretisation.
bool includeDistance_
Include distance variation in sens computation.
incompressibleVars & primalVars_
bool includeTransposeStresses_
Include the transpose part of the adjoint stresses.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void read()
Read controls and update solver pointers if necessary.
virtual const faceList & faces() const
Return raw faces.
#define DebugInfo
Report an information message using Foam::Info.
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
const std::string patch
OpenFOAM patch number as a std::string.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const autoPtr< incompressibleAdjoint::adjointRASModel > & adjointTurbulence() const
Return const reference to the adjointRASModel.
Solver of the adjoint to the Laplace grid displacement equation.
void clearSensitivities()
Zero sensitivity fields and their constituents.
label nPoints() const
Number of mesh points.
autoPtr< volVectorField > CfOnPatchPtr_
static const word null
An empty word.
static const Vector< scalar > zero
A face is a list of labels corresponding to mesh vertices.
bool includeMeshMovement_
Include mesh movement variation in sens computation.
void setSuffixName()
Set suffix name for sensitivity fields.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
void setSuffix(const word &suffix)
Set suffix.
fv::IOoptionListAdjoint fvOptionsAdjoint(mesh)
virtual bool readDict(const dictionary &dict)
Read dict if changed.
Base class for solution control classes.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
autoPtr< volVectorField > SfOnPatchPtr_
PtrList< objective > & getObjectiveFunctions()
Return reference to objective functions.
objectiveManager & objectiveManager_