60 if (geom.name() ==
name)
67 <<
"Cannot find surface " <<
name <<
" in geometry" 74 Foam::label Foam::blockFaces::projectFace::index
80 return coord.first() + coord.second()*
n.first();
84 void Foam::blockFaces::projectFace::calcLambdas
92 lambdaI.setSize(
points.size());
94 lambdaJ.setSize(
points.size());
97 for (label i = 1; i <
n.first(); i++)
99 for (label j = 1; j <
n.second(); j++)
110 for (label i = 1; i <
n.first(); i++)
112 label ijLast = index(
n,
labelPair(i,
n.second()-1));
113 for (label j = 1; j <
n.second(); j++)
116 lambdaJ[ij] /= lambdaJ[ijLast];
119 for (label j = 1; j <
n.second(); j++)
121 label iLastj = index(
n,
labelPair(
n.first()-1, j));
122 for (label i = 1; i <
n.first(); i++)
125 lambdaI[ij] /= lambdaI[iLastj];
133 Foam::blockFaces::projectFace::projectFace
142 surface_(lookupSurface(geometry, is))
151 const label blockFacei,
156 static label fIter = 0;
166 <<
" with verts:" << desc.
vertices()
167 <<
" writing lines from start points" 168 <<
" to projected points to " << debugStr().name() <<
endl;
205 calcLambdas(
n,
points, lambdaI, lambdaJ);
209 const label maxIter = 10;
211 const scalar relTol = 0.1;
213 scalar initialResidual = 0.0;
214 scalar iResidual = 0.0;
215 scalar jResidual = 0.0;
217 for (label iter = 0; iter < maxIter; iter++)
221 List<pointIndexHit> hits;
227 surface_.findNearest(
points, nearestDistSqr, hits);
237 points[i] = hits[i].point();
244 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
245 <<
" iResidual+jResidual:" << iResidual+jResidual <<
endl;
253 initialResidual < ROOTVSMALL
254 || ((iResidual+jResidual)/initialResidual < relTol)
268 for (label j = 1; j <
n.second()-1; j++)
272 projLambdas[0] = 0.0;
273 for (label i = 1; i <
n.first(); i++)
281 projLambdas /= projLambdas.last();
283 linearInterpolationWeights interpolator(projLambdas);
285 for (label i = 1; i <
n.first()-1; i++)
289 interpolator.valueWeights(lambdaI[ij], indices, weights);
294 label ptIndex = index(
n,
labelPair(indices[indexi], j));
295 predicted += weights[indexi]*
points[ptIndex];
297 residual[ij] = predicted-
points[ij];
306 debugStr().writeLine(
points[i], predicted);
310 iResidual =
sum(
mag(residual));
318 residual = vector::zero;
319 for (label i = 1; i <
n.first()-1; i++)
323 projLambdas[0] = 0.0;
324 for (label j = 1; j <
n.second(); j++)
333 projLambdas /= projLambdas.last();
335 linearInterpolationWeights interpolator(projLambdas);
337 for (label j = 1; j <
n.second()-1; j++)
341 interpolator.valueWeights(lambdaJ[ij], indices, weights);
346 label ptIndex = index(
n,
labelPair(i, indices[indexi]));
347 predicted += weights[indexi]*
points[ptIndex];
349 residual[ij] = predicted-
points[ij];
358 debugStr().writeLine(
points[i], predicted);
362 jResidual =
sum(
mag(residual));
366 initialResidual = iResidual + jResidual;
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
defineTypeNameAndDebug(projectFace, 0)
Unit conversion functions.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Takes the description of the block and the list of curved edges and creates a list of points on edges...
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Cmpt & y() const noexcept
Access to the vector y component.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const cellShape & blockShape() const noexcept
Return the block shape.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
virtual void project(const blockDescriptor &, const label blockFacei, pointField &points) const
Project the given points onto the surface.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
const labelVector & density() const noexcept
The mesh density (number of cells) in the i,j,k directions.
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
const Cmpt & x() const noexcept
Access to the vector x component.
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
const Cmpt & z() const noexcept
Access to the vector z component.
vector point
Point is a vector.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Projects the given set of face points onto the selected surface of the geometry provided as a searcha...
messageStream Info
Information stream (stdout output on master, null elsewhere)
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.
addToRunTimeSelectionTable(blockFace, projectFace, Istream)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)