Go to the documentation of this file.
47 void Foam::projectEdge::findNearest
51 pointConstraint& constraint
59 List<pointConstraint> boundaryConstraint(1);
70 near = boundaryNear[0];
71 constraint = boundaryConstraint[0];
76 constraint = pointConstraint();
83 Foam::projectEdge::projectEdge
96 surfaces_.setSize(names.size());
99 surfaces_[i] = geometry_.findSurfaceID(names[i]);
101 if (surfaces_[i] == -1)
104 <<
"Cannot find surface " << names[i] <<
" in geometry"
116 const point start(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;
165 const scalar relTol = 0.1;
166 const scalar absTol = 1
e-4;
168 scalar initialResidual = 0.0;
170 for (label iter = 0; iter < maxIter; iter++)
187 if (lambdas[0] < SMALL)
191 if (lambdas.last() > 1.0-SMALL)
196 if (debugStr.
valid())
208 projLambdas[0] = 0.0;
209 for (label i = 1; i <
points.size(); i++)
213 projLambdas /= projLambdas.last();
222 for (label i = 1; i <
points.size() - 1; i++)
224 interpolator.
valueWeights(lambdas[i], indices, weights);
229 predicted += weights[indexi]*
points[indices[indexi]];
231 residual[i] = predicted-
points[i];
234 scalar scalarResidual =
sum(
mag(residual));
238 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
239 <<
" residual:" << scalarResidual <<
endl;
242 if (scalarResidual < absTol*0.5*lambdas.size())
248 initialResidual = scalarResidual;
250 else if (scalarResidual/initialResidual < relTol)
256 if (debugStr.
valid())
int debug
Static debugging option.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vectorField pointField
pointField is a vectorField.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
OFstream that keeps track of vertices.
virtual point position(const scalar) const
Return the point positions corresponding to the curve parameters.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
Accumulates point constraints through successive applications of the applyConstraint function.
Unit conversion functions.
bool valid() const noexcept
True if the managed pointer is non-null.
Ostream & endl(Ostream &os)
Add newline and flush stream.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Define a curved edge that is parameterized for 0<lambda<1 between the start and end point.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const pointField & points_
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const
Calculate weights and indices to calculate t from samples.
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
Macros for easy insertion into run-time selection tables.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
line< point, const point & > linePointRef
Line using referred points.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const dimensionedScalar e
Elementary charge.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
vector point
Point is a vector.
defineTypeNameAndDebug(combustionModel, 0)
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.