49 const word& solverName
59 <<
setw(width) <<
"#varID" <<
" " 60 <<
setw(width) <<
"adjointSensitivity" 66 const label activeVarI = activeVars[varI];
68 <<
setw(width) << activeVarI <<
" " 69 <<
setw(width) << sens[activeVarI] <<
endl;
77 Foam::morphingBoxConstraint::morphingBoxConstraint
80 const dictionary&
dict,
81 volumetricBSplinesDesignVariables& designVariables
86 designVariables_(designVariables),
87 volBSplinesBase_(designVariables.getVolBSplinesBase()),
88 initialCPs_(3*volBSplinesBase_.getTotalControlPointsNumber()),
89 initialiseVars_(true),
90 derivativesFolder_(
"optimisation"/
type() +
"Derivatives")
95 for (
const NURBS3DVolume& boxI : boxes)
98 for (
const vector& cpI : cps)
122 Info<<
"morphingBoxConstraint type : " << modelType <<
endl;
124 auto* ctorPtr = dictionaryConstructorTable(modelType);
132 *dictionaryConstructorTablePtr_
136 return autoPtr<morphingBoxConstraint>
138 ctorPtr(
mesh,
dict, designVariables)
151 if (lowerBounds || upperBounds)
160 autoPtr<scalarField>& lowerBounds,
161 autoPtr<scalarField>& upperBounds
164 if (designVariables_.updateBounds() && (lowerBounds || upperBounds))
174 const word& adjointSolverName
181 computeDVsSensitivities(dvSens, controlPointSens);
182 writeDVSensitivities(dvSens, adjointSolverName);
191 const scalar maxInitChange
195 const scalar maxDisplacement
197 volBSplinesBase_.computeMaxBoundaryDisplacement
200 designVariables_.getPatches().toc()
204 Info<<
"maxAllowedDisplacement/maxDisplacement of boundary\t" 205 << maxInitChange <<
"/" << maxDisplacement <<
endl;
206 const scalar eta(maxInitChange/ maxDisplacement);
virtual scalar computeEta(scalarField &correction, const scalar maxInitChange)
Compute eta if not set in the first step.
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const fvMesh & mesh_
Mesh reference.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
fileName derivativesFolder_
Folder holding the twist sensitivities.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void computeBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds)
Transform bounds from control points to design variables.
static unsigned int defaultPrecision() noexcept
Return the default precision.
virtual bool writeData(Ostream &os) const
Append useful information to the design variables IOdictionary.
const Time & time() const
Return the top-level database.
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
volBSplinesBase & volBSplinesBase_
Easy access to the volBSplinesBase resting in the designVariables_.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual tmp< scalarField > postProcessSens(const scalarField &controlPointSens, const word &adjointSolverName)
Chain rule from control points to design variables.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static autoPtr< morphingBoxConstraint > New(const fvMesh &mesh, const dictionary &dict, volumetricBSplinesDesignVariables &designVariables)
Construct and return the selected morphingBoxConstraint.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const labelList & activeDesignVariables() const
Return list of active design variables.
const PtrList< NURBS3DVolume > & boxes() const
Get const reference to the vol. B-splines boxes.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Volumetric B-Splines design variables for shape optimisation.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Istream and Ostream manipulators taking arguments.
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.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
volumetricBSplinesDesignVariables & designVariables_
Reference to underlaying volumetric B-Splines morpher.
Abstract base class for defining constraints for the control points of volumetric B-Splines morphing ...
Abstract base class for defining design variables.
scalarField initialCPs_
Initial CPs stored in scalarField.
Mesh data needed to do the Finite Volume discretisation.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual void updateBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds)
Update the bounds of the design variables.
Field< vector > vectorField
Specialisation of Field<T> for vector.
virtual void writeDVSensitivities(const scalarField &sens, const word &name)
Write sensitivities w.r.t. the design variables.
Omanip< int > setw(const int i)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for managing temporary objects.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
static constexpr const zero Zero
Global zero (0)