44 void Foam::projectEdge::findNearest
48 pointConstraint& constraint
56 List<pointConstraint> boundaryConstraint(1);
67 near = boundaryNear[0];
68 constraint = boundaryConstraint[0];
73 constraint = pointConstraint();
98 if (surfaces_[i] == -1)
101 <<
"Cannot find surface " << names[i] <<
" in geometry"
115 points_[start_] +
lambda*(points_[end_] - points_[start_])
123 findNearest(start, near, constraint);
134 static label eIter = 0;
143 Info<<
"Writing lines from straight-line start points"
144 <<
" to projected points to " << debugStr().name() <<
endl;
151 const point& startPt = points_[start_];
152 const point& endPt = points_[end_];
153 const vector d = endPt-startPt;
158 points[i] = startPt+lambdas[i]*d;
163 const label maxIter = 10;
166 const scalar relTol = 0.1;
167 const scalar absTol = 1
e-4;
169 scalar initialResidual = 0;
171 for (
label iter = 0; iter < maxIter; iter++)
188 if (lambdas[0] < small)
192 if (lambdas.
last() > 1 - small)
197 if (debugStr.
valid())
215 projLambdas /= projLambdas.
last();
226 interpolator.
valueWeights(lambdas[i], indices, weights);
231 predicted += weights[indexi]*
points[indices[indexi]];
233 residual[i] = predicted -
points[i];
236 const scalar scalarResidual =
sum(
mag(residual));
240 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
241 <<
" residual:" << scalarResidual <<
endl;
244 if (scalarResidual < absTol*0.5*lambdas.
size())
250 initialResidual = scalarResidual;
252 else if (scalarResidual/initialResidual < relTol)
257 if (debugStr.
valid())
#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)....
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
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.
Define a curved edge that is parameterised for 0<lambda<1 between the start and end point.
const pointField & points_
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.
Accumulates point constraints through successive applications of the applyConstraint function.
Defines the edge from the projection onto a surface (single surface) or intersection of two surfaces.
projectEdge(const dictionary &dict, const label index, const searchableSurfaces &geometry, const pointField &points, Istream &)
Construct from Istream setting pointsList.
virtual point position(const scalar) const
Return the point positions corresponding to the curve parameters.
static void findNearest(const PtrList< searchableSurface > &, const labelList &surfacesToTest, const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &)
Find nearest. Return -1 (and a miss()) or surface and nearest.
Container for searchableSurfaces.
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
dimensionedScalar lambda(viscosity->lookup("lambda"))
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
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.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout, "Pout")
dimensioned< scalar > magSqr(const dimensioned< Type > &)