48 const searchableSurfaces& geometry,
63 <<
"Cannot find surface " <<
name <<
" in geometry"
76 return coord.first() + coord.second()*
n.first();
80 void Foam::blockFaces::projectFace::calcLambdas
88 lambdaI.setSize(
points.size());
90 lambdaJ.setSize(
points.size());
93 for (
label i = 1; i <
n.first(); i++)
95 for (
label j = 1; j <
n.second(); j++)
106 for (
label i = 1; i <
n.first(); i++)
109 for (
label j = 1; j <
n.second(); j++)
112 lambdaJ[ij] /= lambdaJ[ijLast];
115 for (
label j = 1; j <
n.second(); j++)
118 for (
label i = 1; i <
n.first(); i++)
121 lambdaI[ij] /= lambdaI[iLastj];
138 surface_(lookupSurface(geometry, is))
147 const label blockFacei,
152 static label fIter = 0;
162 <<
" with verts:" << desc.
vertices()
163 <<
" writing lines from start points"
164 <<
" to projected points to " << debugStr().name() <<
endl;
201 calcLambdas(
n,
points, lambdaI, lambdaJ);
205 const label maxIter = 10;
208 const scalar relTol = 0.1;
209 const scalar absTol = 1
e-4;
211 scalar initialResidual = 0;
213 for (
label iter = 0; iter < maxIter; iter++)
223 surface_.findNearest(
points, nearestDistSqr, hits);
229 const point& hitPt = hits[i].hitPoint();
230 if (debugStr.
valid())
245 for (
label j = 1; j <
n.second()-1; j++)
250 for (
label i = 1; i <
n.first(); i++)
258 projLambdas /= projLambdas.
last();
262 for (
label i = 1; i <
n.first()-1; i++)
266 interpolator.
valueWeights(lambdaI[ij], indices, weights);
271 const label ptIndex =
273 predicted += weights[indexi]*
points[ptIndex];
275 residual[ij] = predicted -
points[ij];
279 if (debugStr.
valid())
288 scalar scalarResidual =
sum(
mag(residual));
297 for (
label i = 1; i <
n.first()-1; i++)
302 for (
label j = 1; j <
n.second(); j++)
311 projLambdas /= projLambdas.
last();
315 for (
label j = 1; j <
n.second()-1; j++)
319 interpolator.
valueWeights(lambdaJ[ij], indices, weights);
324 const label ptIndex =
326 predicted += weights[indexi]*
points[ptIndex];
328 residual[ij] = predicted -
points[ij];
332 if (debugStr.
valid())
341 scalarResidual +=
sum(
mag(residual));
345 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
346 <<
" scalarResidual:" << scalarResidual <<
endl;
349 if (scalarResidual < absTol*lambdaI.
size())
355 initialResidual = scalarResidual;
357 else if (scalarResidual/initialResidual < relTol)
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
OFstream which keeps track of vertices.
T & last()
Return the last element of the list.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
Takes the description of the block and the list of curved edges and creates a list of points on edges...
const cellShape & blockShape() const
Return the block shape.
const pointField & vertices() const
Reference to point field defining the block mesh.
const Vector< label > & density() const
Return the mesh density (number of cells) in the i,j,k directions.
Projects the given set of face points onto the selected surface of the geometry provided as a searcha...
virtual void project(const blockDescriptor &, const label blockFacei, pointField &points) const
Project the given points onto the surface.
projectFace(const dictionary &dict, const label index, const searchableSurfaces &geometry, Istream &)
Construct from Istream setting pointsList.
A list of keyword definitions, which are a keyword followed by any number of values (e....
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const
Calculate weights and indices to calculate t from samples.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Container for searchableSurfaces.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
defineTypeNameAndDebug(projectFace, 0)
addToRunTimeSelectionTable(blockFace, projectFace, Istream)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pair< label > labelPair
Label pair.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
line< point, const point & > linePointRef
Line using referred points.
word name(const bool)
Return a word representation of a bool.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< scalar > mag(const dimensioned< Type > &)
prefixOSstream Pout(cout, "Pout")
dimensioned< scalar > magSqr(const dimensioned< Type > &)