Go to the documentation of this file.
41 namespace incompressible
50 sensitivityVolBSplinesFI,
56 sensitivityVolBSplinesFI::sensitivityVolBSplinesFI
88 derivativesFolder_(
"optimisation"/
type() +
"Derivatives")
92 label nCPs = volBSplinesBase_.getTotalControlPointsNumber();
104 mkDir(derivativesFolder_);
125 distanceSensPtr.
reset
127 createZeroFieldPtr<tensor>
142 const label nb(boxes[iNURB].getControlPoints().size());
145 vectorField dxdbSens = boxes[iNURB].computeControlPointSensitivities
148 sensitivityPatchIDs_.toc()
151 vectorField bcSens = boxes[iNURB].computeControlPointSensitivities
154 sensitivityPatchIDs_.toc()
157 for (label cpI = 0; cpI < nb; cpI++)
159 label globalCP = passedCPs + cpI;
188 temp.
replace(0, volDxDbI.component(0));
189 temp.
replace(1, volDxDbI.component(3));
190 temp.
replace(2, volDxDbI.component(6));
193 temp.
replace(0, volDxDbI.component(1));
194 temp.
replace(1, volDxDbI.component(4));
195 temp.
replace(2, volDxDbI.component(7));
198 temp.
replace(0, volDxDbI.component(2));
199 temp.
replace(1, volDxDbI.component(5));
200 temp.
replace(2, volDxDbI.component(8));
225 for (
const label patchI : sensitivityPatchIDs_)
229 boxes[iNURB].dndbBasedSensitivities(patchI, cpI)
234 boxes[iNURB].dndbBasedSensitivities(patchI, cpI,
false)
245 *
fvc::div(
T(volDxDbI))().primitiveField()
253 distanceSensPtr().primitiveField();
279 bcSens_[globalCP] = bcSens[cpI];
281 boxSensitivities[cpI] =
293 boxes[iNURB].boundControlPointMovement(boxSensitivities);
296 for (label cpI = 0; cpI < nb; cpI++)
298 label globalCP = passedCPs + cpI;
300 derivatives_[3*globalCP + 1] = boxSensitivities[cpI].y();
301 derivatives_[3*globalCP + 2] = boxSensitivities[cpI].z();
338 Info<<
"Writing control point sensitivities to file" <<
endl;
352 <<
setw(widthDV) <<
"#cp" <<
" "
353 <<
setw(width) <<
"total::x" <<
" "
354 <<
setw(width) <<
"total::y" <<
" "
355 <<
setw(width) <<
"total::z" <<
" "
356 <<
setw(width) <<
"flow::x" <<
" "
357 <<
setw(width) <<
"flow::y" <<
" "
358 <<
setw(width) <<
"flow::z" <<
" "
359 <<
setw(width) <<
"dSdb::x" <<
" "
360 <<
setw(width) <<
"dSdb::y" <<
" "
361 <<
setw(width) <<
"dSdb::z" <<
" "
362 <<
setw(width) <<
"dndb::x" <<
" "
363 <<
setw(width) <<
"dndb::y" <<
" "
364 <<
setw(width) <<
"dndb::z" <<
" "
365 <<
setw(width) <<
"dxdbDirect::x" <<
" "
366 <<
setw(width) <<
"dxdbDirect::y" <<
" "
367 <<
setw(width) <<
"dxdbDirect::z" <<
" "
368 <<
setw(width) <<
"dVdb::x" <<
" "
369 <<
setw(width) <<
"dVdb::y" <<
" "
370 <<
setw(width) <<
"dVdb::z" <<
" "
371 <<
setw(width) <<
"distance::x" <<
" "
372 <<
setw(width) <<
"distance::y" <<
" "
373 <<
setw(width) <<
"distance::z" <<
" "
374 <<
setw(width) <<
"options::x" <<
" "
375 <<
setw(width) <<
"options::y" <<
" "
376 <<
setw(width) <<
"options::z" <<
" "
377 <<
setw(width) <<
"dvdb::x" <<
" "
378 <<
setw(width) <<
"dvdb::y" <<
" "
379 <<
setw(width) <<
"dvdb::z" <<
endl;
382 label lastActive(-1);
386 label nb = boxes[iNURB].getControlPoints().size();
387 const boolList& activeCPs = boxes[iNURB].getActiveCPs();
388 for (label iCP = 0; iCP < nb; iCP++)
392 label globalCP = passedCPs + iCP;
393 if (globalCP!=lastActive + 1) derivFile <<
"\n";
394 lastActive = globalCP;
397 <<
setw(widthDV) << globalCP <<
" "
vectorField optionsDxDbMult_
dx/db multiplier coming from fvOptions
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
class for managing incompressible objective functions.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & solverName() const
Return solver name.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
autoPtr< boundaryVectorField > bcDxDbMult_
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
A class for handling words, derived from Foam::string.
vectorField bcSens_
Term depending on the differentiation of boundary conditions.
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
defineTypeNameAndDebug(adjointEikonalSolver, 0)
Class constructing a number of volumetric B-Splines boxes, read from dynamicMeshDict....
A class for managing temporary objects.
vectorField dSdbSens_
Term depending on delta(n dS)/delta b.
static constexpr const zero Zero
Global zero (0)
vectorField flowSens_
Flow related term.
vectorField dndbSens_
Term depending on delta(n)/delta b.
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
volTensorField gradDxDbMult_
grad(dx/db) multiplier
static const volBSplinesBase & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
static word timeName(const scalar t, const int precision=precision_)
void read()
Read options and update solver pointers if necessary.
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
scalarField divDxDbMult_
div(dx/db) multiplier
Ostream & endl(Ostream &os)
Add newline and flush stream.
Type gSum(const FieldField< Field, Type > &f)
Dimension set for the base types.
vectorField dVdbSens_
Term depending on delta(V)/delta b.
Class including all adjoint fields for incompressible flows.
vectorField dxdbDirectSens_
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
autoPtr< adjointEikonalSolver > eikonalSolver_
Adjoint eikonal equation solver.
autoPtr< boundaryVectorField > dSfdbMult_
Fields related to direct sensitivities.
addToRunTimeSelectionTable(adjointSensitivity, sensitivityBezier, dictionary)
void interpolate(const GeometricField< Type, pointPatchField, pointMesh > &, GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate from pointField to volField.
vectorField optionsSens_
Term depending on fvOptions.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void boundControlPointMovement(vectorField &controlPointsMovement)
Bound control points movement.
Istream and Ostream manipulators taking arguments.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
PtrList< NURBS3DVolume > & boxesRef()
Get non-const reference to the vol. B-splines boxes.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
autoPtr< boundaryVectorField > dxdbDirectMult_
Macros for easy insertion into run-time selection tables.
incompressibleAdjointVars & adjointVars_
Mesh data needed to do the Finite Volume discretisation.
Omanip< int > setw(const int i)
Output to file stream, using an OSstream.
static bool master(const label communicator=0)
Am I the master process.
virtual void write(const word &baseName=word::null)
Write sensitivities to file.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Base class for Field Integral-based sensitivity derivatives.
static unsigned int defaultPrecision()
Return the default precision.
bool includeDistance_
Include distance variation in sens computation.
virtual void assembleSensitivities()
Assemble sensitivities.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
const Time & time() const
Return the top-level database.
static const Vector< scalar > zero
autoPtr< boundaryVectorField > dnfdbMult_
fileName derivativesFolder_
fv::IOoptionListAdjoint fvOptionsAdjoint(mesh)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
volBSplinesBase & volBSplinesBase_
Reference to underlaying volumetric B-Splines morpher.
vectorField distanceSens_
Term depending on distance differentiation.
Base class for solution control classes.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.