49 sensitivitySurfacePoints,
67 extendedPatchIDs[pI++] = patchI;
70 extendedPatchIDs.setSize(pI);
118 const label patchStartIndex =
patch.start();
124 const labelList& pointFaces = patchPointFaces[ppI];
127 label localFaceIndex = pointFaces[pfI];
128 label globalFaceIndex = patchStartIndex + localFaceIndex;
129 const face& faceI = faces[globalFaceIndex];
136 if (faceI[facePointI] == meshPoints[ppI])
142 dBoundary.makeFaceCentresAndAreas_d(
p, p_d);
154 const tensor& deltaCf = deltaNormals[0];
155 pointPatchSens[ppI] += facePatchSens[localFaceIndex] & deltaCf;
163 const tensor& deltaSf = deltaNormals[1];
164 pointPatchSens[ppI] +=
165 dSfdbMult_()[patchI][localFaceIndex] & deltaSf;
171 const tensor& deltaNf = deltaNormals[2];
172 pointPatchSens[ppI] +=
173 dnfdbMult_()[patchI][localFaceIndex] & deltaNf;
189 const fvPatch&
patch =
mesh_.boundary()[patchI];
203 const labelList& pointFaces = patchPointFaces[ppI];
206 const label localFaceIndex = pointFaces[pfI];
209 pointNormals[meshPoints[ppI]] += nf[localFaceIndex];
210 pointMagSf[meshPoints[ppI]] += magSf[localFaceIndex];
237 mesh_.time().timeName(),
250 mesh_.time().timeName(),
258 MagSf.primitiveFieldRef() = pointMagSf;
259 Nf.primitiveFieldRef() = pointNormals;
260 Nf.primitiveFieldRef().normalise();
270 label nTotalPoints(0);
283sensitivitySurfacePoints::sensitivitySurfacePoints
291 writeGeometricInfo_(false),
292 includeSurfaceArea_(false),
295 extendedPatchIDs_(populateExtendedIDs())
299 Info<<
"Extended sensitivity patches " <<
nl;
324 const fvPatch&
pp =
mesh_.boundary()[patchI];
329 const labelList& meshPoints =
pp.patch().meshPoints();
333 const label pointi = meshPoints[pI];
347 dict().getOrDefault<
bool>(
"writeGeometricInfo",
false);
350 dict().getOrDefault<
bool>(
"includeSurfaceArea",
false);
404 const label globaPointI = meshPoints[ppI];
445 mesh_.boundaryMesh()[patchI].meshPoints();
451 const Vector<label>& sd =
mesh_.solutionD();
454 const polyPatch&
patch =
mesh_.boundaryMesh()[patchI];
462 vectorField patchPointNormals(pointNormals, meshPoints);
463 patchPointNormals.normalise();
476 const label gpi = nPassedDVs +
pi;
478 derivatives_[3*gpi ] = scalar(sd[0] == -1 ? 0 : pSens.x());
479 derivatives_[3*gpi + 1] = scalar(sd[1] == -1 ? 0 : pSens.y());
480 derivatives_[3*gpi + 2] = scalar(sd[2] == -1 ? 0 : pSens.z());
482 nPassedDVs +=
patch.nPoints();
548 nfOnPatch.boundaryFieldRef()[patchI] = patch.nf();
549 SfOnPatch.boundaryFieldRef()[patchI] = patch.Sf();
550 CfOnPatch.boundaryFieldRef()[patchI] = patch.Cf();
constexpr scalar pi(M_PI)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
void normalise()
Inplace normalise this field. Generally a no-op except for vector fields.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
void setSize(label n)
Alias for resize().
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
autoPtr< pointBoundaryVectorField > wallPointSensNormalVecPtr_
Normal sens as vectors.
labelHashSet sensitivityPatchIDs_
Patches on which to compute shape sensitivities.
autoPtr< pointBoundaryVectorField > wallPointSensVecPtr_
Wall point sens w.r.t. (x,y.z).
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
autoPtr< pointBoundaryScalarField > wallPointSensNormalPtr_
Wall point sens projected to normal.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
void size(const label n)
Older name for setAddressableSize.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
const Cmpt & x() const noexcept
Access to the vector x component.
const Cmpt & z() const noexcept
Access to the vector z component.
const Cmpt & y() const noexcept
Access to the vector y component.
Abstract base class for adjoint-based sensitivities.
autoPtr< boundaryVectorField > dxdbDirectMult_
Multiplier of dCf/db, found in the objective function.
void setSuffix(const word &suffix)
Set suffix.
autoPtr< boundaryVectorField > bcDxDbMult_
Multiplier of dx/db, coming from boundary conditions that depend on the geometry, like rotatingWallVe...
adjointSolver & adjointSolver_
Reference to the underlaying adjoint solver.
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
autoPtr< boundaryVectorField > dxdbMult_
Multiplier of face dx/db.
scalarField derivatives_
The sensitivity derivative values.
autoPtr< boundaryVectorField > dnfdbMult_
Multiplier of dnf/db.
autoPtr< adjointMeshMovementSolver > adjointMeshMovementSolver_
Adjoint grid displacement solver.
autoPtr< boundaryVectorField > dSfdbMult_
Multiplier of dSf/db.
virtual void assembleSensitivities(autoPtr< designVariables > &designVars)
Assemble sensitivities.
Base class for adjoint solvers.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Differentiation of the mesh data structure.
vectorField makeFaceCentresAndAreas_d(const pointField &p, const pointField &p_d)
Given a face and the points to be moved in the normal direction, find faceArea, faceCentre and unitVe...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A face is a list of labels corresponding to mesh vertices.
pointField points(const UList< point > &pts) const
Return the points corresponding to this face.
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const faceList & faces() const
Return raw faces.
A patch is a list of labels that address the faces in the global face list.
label nPoints() const noexcept
Number of mesh points.
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
Class for computing sensitivity derivatives using the Enhanced Surface Integral (E-SI) formulation,...
void computeDxDbMult()
Compute dxdbMult from its various components.
virtual bool readDict(const dictionary &dict)
Read dict if changed.
Calculation of adjoint-based sensitivities at wall points using the E-SI formulation.
void computePointDerivativesSize()
Allocate the proper size for the point-based sensitivities.
void constructGlobalPointNormalsAndAreas(vectorField &pointNormals, scalarField &pointMagSf)
Construct globally correct point normals and point areas.
void setSuffixName()
Set suffix name for sensitivity fields.
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
virtual bool readDict(const dictionary &dict)
Read dict if changed.
bool includeSurfaceArea_
Include surface area in sens computation.
bool writeGeometricInfo_
Write geometric info for use by external programs.
void read()
Read controls and update solver pointers if necessary.
boolList isSymmetryPoint_
Is point belonging to a symmetry{Plane}.
labelHashSet extendedPatchIDs_
Extended patchIDs.
labelHashSet populateExtendedIDs() const
Set suffix name for sensitivity fields.
vectorField symmPointNormal_
Local point normal per symmetry point.
void finalisePointSensitivities()
Converts face sensitivities to point sensitivities and adds the ones directly computed in points (i....
virtual const labelHashSet & geometryVariationIntegrationPatches() const
Return set of patches on which to compute direct sensitivities.
virtual void assembleSensitivities(autoPtr< designVariables > &designVars)
Assemble sensitivities.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dimensionSet dimless
Dimensionless.
List< labelList > labelListList
List of labelList.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
static const Identity< scalar > I
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
autoPtr< List< Field< Type > > > createZeroBoundaryPointFieldPtr(const fvMesh &mesh, bool printAllocation=false)
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.