40 namespace incompressible
55 sensitivityVolBSplinesFI::sensitivityVolBSplinesFI
76 derivativesFolder_(
"optimisation"/
type() +
"Derivatives")
120 distanceSensPtr.reset
122 createZeroFieldPtr<tensor>
137 const label nb(boxes[iNURB].getControlPoints().size());
140 vectorField dxdbSens = boxes[iNURB].computeControlPointSensitivities
143 sensitivityPatchIDs_.toc()
146 vectorField bcSens = boxes[iNURB].computeControlPointSensitivities
149 sensitivityPatchIDs_.toc()
152 for (label cpI = 0; cpI < nb; cpI++)
154 label globalCP = passedCPs + cpI;
159 volPointInter.interpolate(boxes[iNURB].getDxDb(cpI))
171 for (label idir = 0; idir < pTraits<vector>::nComponents; ++idir)
195 (gradDxDbMultInt && gradDxDb.primitiveField())
202 distanceSensPtr().primitiveField();
206 (distSensInt && gradDxDb.primitiveField())
216 for (
const label patchI : sensitivityPatchIDs_)
220 boxes[iNURB].dndbBasedSensitivities(patchI, cpI)
225 boxes[iNURB].dndbBasedSensitivities(patchI, cpI,
false)
236 *
fvc::div(
T(volDxDbI))().primitiveField()
248 bcSens_[globalCP] = bcSens[cpI];
250 boxSensitivities[cpI] =
262 boxes[iNURB].boundControlPointMovement(boxSensitivities);
265 for (label cpI = 0; cpI < nb; cpI++)
267 label globalCP = passedCPs + cpI;
269 derivatives_[3*globalCP + 1] = boxSensitivities[cpI].y();
270 derivatives_[3*globalCP + 2] = boxSensitivities[cpI].z();
309 Info<<
"Writing control point sensitivities to file" <<
endl;
323 <<
setw(widthDV) <<
"#cp" <<
" " 324 <<
setw(width) <<
"total::x" <<
" " 325 <<
setw(width) <<
"total::y" <<
" " 326 <<
setw(width) <<
"total::z" <<
" " 327 <<
setw(width) <<
"flow::x" <<
" " 328 <<
setw(width) <<
"flow::y" <<
" " 329 <<
setw(width) <<
"flow::z" <<
" " 330 <<
setw(width) <<
"dSdb::x" <<
" " 331 <<
setw(width) <<
"dSdb::y" <<
" " 332 <<
setw(width) <<
"dSdb::z" <<
" " 333 <<
setw(width) <<
"dndb::x" <<
" " 334 <<
setw(width) <<
"dndb::y" <<
" " 335 <<
setw(width) <<
"dndb::z" <<
" " 336 <<
setw(width) <<
"dxdbDirect::x" <<
" " 337 <<
setw(width) <<
"dxdbDirect::y" <<
" " 338 <<
setw(width) <<
"dxdbDirect::z" <<
" " 339 <<
setw(width) <<
"dVdb::x" <<
" " 340 <<
setw(width) <<
"dVdb::y" <<
" " 341 <<
setw(width) <<
"dVdb::z" <<
" " 342 <<
setw(width) <<
"distance::x" <<
" " 343 <<
setw(width) <<
"distance::y" <<
" " 344 <<
setw(width) <<
"distance::z" <<
" " 345 <<
setw(width) <<
"options::x" <<
" " 346 <<
setw(width) <<
"options::y" <<
" " 347 <<
setw(width) <<
"options::z" <<
" " 348 <<
setw(width) <<
"dvdb::x" <<
" " 349 <<
setw(width) <<
"dvdb::y" <<
" " 350 <<
setw(width) <<
"dvdb::z" <<
endl;
353 label lastActive(-1);
357 label nb = boxes[iNURB].getControlPoints().
size();
358 const boolList& activeCPs = boxes[iNURB].getActiveCPs();
359 for (label iCP = 0; iCP < nb; iCP++)
363 label globalCP = passedCPs + iCP;
364 if (globalCP!=lastActive + 1) derivFile <<
"\n";
365 lastActive = globalCP;
368 <<
setw(widthDV) << globalCP <<
" " autoPtr< adjointEikonalSolver > eikonalSolver_
Adjoint eikonal equation solver.
autoPtr< boundaryVectorField > dxdbDirectMult_
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
void size(const label n)
Older name for setAddressableSize.
autoPtr< boundaryVectorField > dSfdbMult_
Fields related to direct sensitivities.
defineTypeNameAndDebug(adjointEikonalSolver, 0)
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
volTensorField gradDxDbMult_
grad(dx/db) multiplier
A list of keyword definitions, which are a keyword followed by a number of values (eg...
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
vectorField optionsSens_
Term depending on fvOptions.
Output to file stream, using an OSstream.
void read()
Read options and update solver pointers if necessary.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
static unsigned int defaultPrecision() noexcept
Return the default precision.
Base class for adjoint solvers.
Ignore writing from objectRegistry::writeObject()
vectorField distanceSens_
Term depending on distance differentiation.
const dimensionSet dimless
Dimensionless.
const Time & time() const
Return the top-level database.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
addToRunTimeSelectionTable(adjointSensitivity, sensitivityBezier, dictionary)
Macros for easy insertion into run-time selection tables.
vectorField bcSens_
Term depending on the differentiation of boundary conditions.
Base class for incompressibleAdjoint solvers.
#define forAll(list, i)
Loop across all elements in list.
scalarField divDxDbMult_
div(dx/db) multiplier
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Type gSum(const FieldField< Field, Type > &f)
autoPtr< boundaryVectorField > dnfdbMult_
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label size() const noexcept
The number of elements in the list.
volBSplinesBase & volBSplinesBase_
Reference to underlaying volumetric B-Splines morpher.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
virtual void assembleSensitivities()
Assemble sensitivities.
vectorField flowSens_
Flow related term.
const word & solverName() const
Return solver name.
bool includeDistance_
Include distance variation in sens computation.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
void boundControlPointMovement(vectorField &controlPointsMovement) const
Bound control points movement.
Istream and Ostream manipulators taking arguments.
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
virtual void write(const word &baseName=word::null)
Write sensitivities to file.
vectorField dVdbSens_
Term depending on delta(V)/delta b.
void unzipCol(const FieldField< Field, SymmTensor< Cmpt >> &input, const direction idx, FieldField< Field, Vector< Cmpt >> &result)
Extract a symmTensor field field column (x,y,z) == (0,1,2)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
vectorField optionsDxDbMult_
dx/db multiplier coming from fvOptions
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
label getTotalControlPointsNumber() const
Get cumulative number of control points from all boxes.
PtrList< NURBS3DVolume > & boxesRef()
Get non-const reference to the vol. B-splines boxes.
vectorField dSdbSens_
Term depending on delta(n dS)/delta b.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Mesh data needed to do the Finite Volume discretisation.
static bool master(const label communicator=worldComm)
Am I the master rank.
vectorField dxdbDirectSens_
Term depending on delta(x)/delta b for objectives that directly depend on x.
autoPtr< boundaryVectorField > bcDxDbMult_
messageStream Info
Information stream (stdout output on master, null elsewhere)
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
components
Component labeling enumeration.
fileName derivativesFolder_
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Omanip< int > setw(const int i)
vectorField dndbSens_
Term depending on delta(n)/delta b.
A class for managing temporary objects.
incompressibleAdjointVars & adjointVars_
Calculation of adjoint based sensitivities at vol B-Splines control points using the FI approach...
Defines the attributes of an object for which implicit objectRegistry management is supported...
Base class for Field Integral-based sensitivity derivatives.
Class constructing a number of volumetric B-Splines boxes, read from dynamicMeshDict. Useful for various sensitivities and optMeshMovement classes.
static constexpr const zero Zero
Global zero (0)