40 morphingBoxConstraint,
70 for (label
k = 1;
k < nCPsDir[2] - 1; ++
k)
72 for (label j = 1; j < nCPsDir[1] - 1; ++j)
74 for (label i = 1; i < nCPsDir[0] - 1; ++i)
77 for (label idir = 0; idir < 3; ++idir)
79 label iIncr(idir == 0);
80 label jIncr(idir == 1);
81 label kIncr(idir == 2);
83 (boxI.
getCPID(i - iIncr, j - jIncr,
k - kIncr));
85 (boxI.
getCPID(i + iIncr, j + jIncr,
k + kIncr));
86 lowerBounds()[3*cpID + idir + passed] =
92 upperBounds()[3*cpID + idir + passed] =
107 autoPtr<scalarField>& lowerBounds,
108 autoPtr<scalarField>& upperBounds,
109 const NURBS3DVolume& boxI,
114 const Vector<label> nCPsDir = boxI.nCPsPerDirection();
116 for (label ibound = 0; ibound < 3; ++ibound)
119 Vector<label> minID(1, 1, 1);
121 Vector<label> maxID(nCPsDir[0] - 2, nCPsDir[1] - 2, nCPsDir[2] - 2);
123 Vector<label> incr(1, 1, 1);
127 maxID[ibound] = nCPsDir[ibound];
128 incr[ibound] = nCPsDir[ibound] - 1;
129 Vector<label> indices(
Zero);
130 label& i = indices[0];
131 label& j = indices[1];
132 label&
k = indices[2];
134 for (
k = minID[2];
k < maxID[2];
k += incr[2])
136 for (j = minID[1]; j < maxID[1]; j += incr[1])
138 for (i = minID[0]; i < maxID[0]; i += incr[0])
140 label cpID(boxI.getCPID(i, j,
k));
141 for (label dir = 0; dir < 3; ++dir)
143 Vector<label> incrMinus(dir == 0, dir == 1, dir == 2);
144 Vector<label> incrPlus(dir == 0, dir == 1, dir == 2);
150 && indices[ibound] == nCPsDir[ibound] - 1
153 label(incrMinus[ibound] && indices[ibound] == 0);
168 if (incrMinus[ibound])
170 lowerBounds()[3*cpID + dir + passed] =
173 cps[prevCP].component(dir)
174 + cps[cpID].component(dir)
177 if (incrPlus[ibound])
179 upperBounds()[3*cpID + dir + passed] =
182 cps[nextCP].component(dir)
183 + cps[cpID].component(dir)
196 Foam::noConstraint::noConstraint
199 const dictionary&
dict,
200 volumetricBSplinesDesignVariables& designVariables
203 morphingBoxConstraint(
mesh,
dict, designVariables)
227 if (designVariables_.nonOverlappingCPs() && designVariables_.updateBounds())
230 <<
"Updating bounds for the design variables " <<
endl;
236 updateInternalBounds(lowerBounds, upperBounds, boxI, passed);
239 updateBoundaryBounds(lowerBounds, upperBounds, boxI, passed);
243 <<
"lower bounds " << lowerBounds() <<
endl;
245 <<
"upper bounds " << upperBounds() <<
endl;
255 return activeCPCoors;
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
void size(const label n)
Older name for setAddressableSize.
virtual tmp< scalarField > correctionCPs(const scalarField &correctionDVs)
Convert the correction of the design variables to the correction of the control points.
virtual labelList computeActiveDesignVariables(const labelList &activeCPCoors)
Compute the active design variables based on the IDs of the active control point coordinates.
virtual void updateBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds)
Update the bounds of the design variables.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void updateBoundaryBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds, const NURBS3DVolume &boxI, const label passed)
Update the bounds of the boundary control points.
label k
Boltzmann constant.
NURBS3DVolume morpher. Includes support functions for gradient computations Base class providing supp...
virtual tmp< scalarField > controlPointsToDesignVariables(const scalarField &cps)
Return the design variables corresponding to the given control points.
volBSplinesBase & volBSplinesBase_
Easy access to the volBSplinesBase resting in the designVariables_.
Macros for easy insertion into run-time selection tables.
virtual void computeDVsSensitivities(scalarField &dvSens, const scalarField &cpSens)
Compute sensitivities wrt the design variables (chain rule)
Vector< label > nCPsPerDirection() const
Get number of control points per direction.
void updateInternalBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds, const NURBS3DVolume &boxI, const label passed)
Update the bounds of the internal control points.
void setSize(const label n)
Alias for resize()
virtual tmp< scalarField > designVariablesToControlPoints(const scalarField &designVariables)
Convert design variables to control points, stored in a scalarField.
label getCPID(const label i, const label j, const label k) const
Get control point ID from its I-J-K coordinates.
#define DebugInfo
Report an information message using Foam::Info.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
defineTypeNameAndDebug(combustionModel, 0)
virtual void computeBounds(autoPtr< scalarField > &lowerBounds, autoPtr< scalarField > &upperBounds)
Transform bounds from control points to design variables.
volumetricBSplinesDesignVariables & designVariables_
Reference to underlaying volumetric B-Splines morpher.
label getTotalControlPointsNumber() const
Get cumulative number of control points from all boxes.
Abstract base class for defining design variables.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
List< label > labelList
A List of labels.
A class for managing temporary objects.
const vectorField & getControlPoints() const
Get control points.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)