Go to the documentation of this file.
49 void Foam::blockEdges::projectEdge::findNearest
53 pointConstraint& constraint
61 List<pointConstraint> boundaryConstraint(1);
72 near = boundaryNear[0];
73 constraint = boundaryConstraint[0];
78 constraint = pointConstraint();
85 Foam::blockEdges::projectEdge::projectEdge
98 surfaces_.setSize(names.size());
101 surfaces_[i] = geometry_.findSurfaceID(names[i]);
103 if (surfaces_[i] == -1)
106 <<
"Cannot find surface " << names[i] <<
" in geometry"
118 const point start(points_[start_] +
lambda*(points_[end_]-points_[start_]));
125 findNearest(start, near, constraint);
136 static label eIter = 0;
145 Info<<
"Writing lines from straight-line start points"
146 <<
" to projected points to " << debugStr().name() <<
endl;
151 auto&
points = tpoints.ref();
153 const point& startPt = points_[start_];
154 const point& endPt = points_[end_];
155 const vector d = endPt-startPt;
160 points[i] = startPt+lambdas[i]*d;
165 constexpr label maxIter = 10;
168 constexpr scalar relTol = 0.1;
169 constexpr scalar absTol = 1
e-4;
171 scalar initialResidual = 0.0;
173 for (label iter = 0; iter < maxIter; iter++)
190 if (lambdas[0] < SMALL)
194 if (lambdas.last() > 1.0-SMALL)
211 projLambdas[0] = 0.0;
212 for (label i = 1; i <
points.size(); i++)
216 projLambdas /= projLambdas.last();
225 for (label i = 1; i <
points.size() - 1; i++)
227 interpolator.
valueWeights(lambdas[i], indices, weights);
232 predicted += weights[indexi]*
points[indices[indexi]];
234 residual[i] = predicted-
points[i];
237 scalar scalarResidual =
sum(
mag(residual));
241 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
242 <<
" residual:" << scalarResidual <<
endl;
245 if (scalarResidual < absTol*0.5*lambdas.size())
251 initialResidual = scalarResidual;
253 else if (scalarResidual/initialResidual < relTol)
int debug
Static debugging option.
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.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
Accumulates point constraints through successive applications of the applyConstraint function.
Ostream & endl(Ostream &os)
Add newline and flush stream.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
#define forAll(list, i)
Loop across all elements in list.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
defineTypeNameAndDebug(arcEdge, 0)
addToRunTimeSelectionTable(blockEdge, arcEdge, Istream)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const pointField & points_
The referenced point field.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
const label start_
Index of the start point.
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.
const label end_
Index of the end point.
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
A 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)
virtual scalar length() const
The length of the edge.
const dimensionedScalar e
Elementary charge.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
virtual point position(const scalar) const
The point position corresponding to the curve parameter.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
vector point
Point is a vector.
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.