75 autoPtr<scalarField>& bounds,
80 const label nCPs(bezier_.nBezier());
81 for (label iCP = 0; iCP < nCPs; ++iCP)
83 bounds()[iCP] = cpBounds.x();
85 bounds()[2*nCPs + iCP] = cpBounds.z();
97 dx_.primitiveFieldRef() =
Zero;
101 const label nCPs(bezier_.nBezier());
104 const boolListList& confineMovement = bezier_.confineMovement();
108 if (!confineMovement[0][cpI])
112 if (!confineMovement[1][cpI])
116 if (!confineMovement[2][cpI])
118 cpMovement[cpI].z() =
correction[2*nCPs + cpI];
135 const label nBezier = bezier_.nBezier();
143Foam::BezierDesignVariables::BezierDesignVariables
158 mesh_.time().globalPath()/
"system",
199 displMethodPtr_->setMotionField(dx_);
214 const scalar maxDisplacement(
max(
mag(dx_)).value());
216 Info<<
"maxAllowedDisplacement/maxDisplacement at the boundary\t"
217 << maxInitChange_() <<
"/" << maxDisplacement <<
endl;
219 const scalar eta = maxInitChange_()/maxDisplacement;
239 label cpI(-1), dir(-1);
241 return bezier_.dxdbFace(patchI, cpI, dir);
251 label cpI(-1), dir(-1);
253 return bezier_.dndbBasedSensitivities(patchI, cpI, dir,
false);
263 label cpI(-1), dir(-1);
265 return bezier_.dndbBasedSensitivities(patchI, cpI, dir,
true);
272 label cpI(-1), dir(-1);
273 decomposeVarID(cpI, dir, varID);
277 for (
const label pI : parametertisedPatches_)
280 if (
gSum(
mag(dxdbFace)) > SMALL)
285 return solveMeshMovementEqn(patchI, varID);
Istream and Ostream manipulators taking arguments.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Bezier design variables for shape optimisation.
virtual void update(scalarField &correction)
Update design variables based on a given correction.
virtual tmp< vectorField > dSdb(const label patchI, const label varID) const
Get dSdb for given design variable and patch.
virtual scalar computeEta(scalarField &correction)
Compute eta if not set in the first step.
Bezier bezier_
The Bezier control points and auxiliary functions.
void decomposeVarID(label &cpI, label &dir, const label varID) const
Decompose varID to cpID and direction.
void readBounds(autoPtr< scalar > lowerBoundPtr=nullptr, autoPtr< scalar > upperBoundPtr=nullptr)
Read bounds for design variables, if present.
virtual bool globalSum() const
Whether to use global sum when computing matrix-vector products.
pointVectorField dx_
Boundary movement due to the change in Bezier control points.
tmp< vectorField > computeBoundaryDisplacement(const scalarField &correction)
Transform the correction of design variables to control points' movement.
void setBounds(autoPtr< scalarField > &bounds, const vector &cpBounds)
Set uniform bounds for all control points.
virtual tmp< vectorField > dxdbFace(const label patchI, const label varID) const
Get dxdb for given design variable and patch.
virtual tmp< vectorField > dndb(const label patchI, const label varID) const
Get dndb for given design variable and patch.
virtual tmp< volVectorField > dCdb(const label varID) const
Get dCdb for given design variable.
label nBezier() const
Number of Bezier control points.
const labelList & getActiveDesignVariables() const
Return active design variables.
void operator+=(const UList< scalar > &)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
label size() const noexcept
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
autoPtr< scalarField > upperBounds_
Upper bounds of the design variables.
autoPtr< scalar > maxInitChange_
Maximum design variables' change in the first optimisation cycle.
void readBounds(autoPtr< scalar > lowerBoundPtr=nullptr, autoPtr< scalar > upperBoundPtr=nullptr)
Read bounds for design variables, if present.
virtual const scalarField & getVars() const
Get the design variables.
autoPtr< scalarField > lowerBounds_
Lower bounds of the design variables.
labelList activeDesignVariables_
Which of the design variables will be updated.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Mesh data needed to do the Finite Volume discretisation.
Mesh representing a set of points created from polyMesh.
Abstract base class for defining design variables for shape optimisation.
virtual void moveMesh()
Move mesh based on displacementMethod.
virtual tmp< volVectorField > solveMeshMovementEqn(const label patchI, const label varID) const
Compute dxdb at the mesh cell centers by solving a Laplace PDE.
autoPtr< displacementMethod > displMethodPtr_
Mesh movement mechanism.
static autoPtr< shapeDesignVariables > New(fvMesh &mesh, const dictionary &dict)
Construct and return the selected shapeDesignVariables.
labelHashSet parametertisedPatches_
Patches to be moved by the design variables.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Namespace for bounding specifications. At the moment, mostly for tables.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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.
Type gSum(const FieldField< Field, Type > &f)
const dimensionSet dimless
Dimensionless.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< List< bool > > boolListList
List of boolList.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
#define forAll(list, i)
Loop across all elements in list.