Go to the documentation of this file.
52 Foam::blockEdges::projectCurveEdge::projectCurveEdge
65 surfaces_.resize(names.size());
68 surfaces_[i] = geometry_.findSurfaceID(names[i]);
70 if (surfaces_[i] == -1)
73 <<
"Cannot find surface " << names[i] <<
" in geometry"
77 if (isA<searchableExtrudedCircle>(geometry_[surfaces_[i]]))
79 Info<<
type() <<
" : Using curved surface "
80 << geometry_[surfaces_[i]].name()
81 <<
" to predict starting points." <<
endl;
101 static label eIter = 0;
110 Info<<
"Writing lines from straight-line start points"
111 <<
" to projected points to " << debugStr().name() <<
endl;
116 auto&
points = tpoints.ref();
118 const point& startPt = points_[start_];
119 const point& endPt = points_[end_];
120 const vector d = endPt-startPt;
125 points[i] = startPt+lambdas[i]*d;
132 if (isA<searchableExtrudedCircle>(geometry_[surfaces_[i]]))
135 refCast<const searchableExtrudedCircle>
137 geometry_[surfaces_[i]]
140 s.findParametricNearest
150 if (nearInfo[i].hit())
152 points[i] = nearInfo[i].hitPoint();
163 constexpr label maxIter = 10;
166 constexpr scalar relTol = 0.1;
167 constexpr scalar absTol = 1
e-4;
169 scalar initialResidual = 0.0;
171 for (label iter = 0; iter < maxIter; iter++)
188 if (lambdas[0] < SMALL)
192 if (lambdas.last() > 1.0-SMALL)
209 projLambdas[0] = 0.0;
210 for (label i = 1; i <
points.size(); i++)
214 projLambdas /= projLambdas.last();
223 for (label i = 1; i <
points.size() - 1; i++)
225 interpolator.
valueWeights(lambdas[i], indices, weights);
230 predicted += weights[indexi]*
points[indices[indexi]];
232 residual[i] = predicted-
points[i];
235 scalar scalarResidual =
sum(
mag(residual));
239 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
240 <<
" residual:" << scalarResidual <<
endl;
243 if (scalarResidual < absTol*0.5*lambdas.size())
249 initialResidual = scalarResidual;
251 else if (scalarResidual/initialResidual < relTol)
int debug
Static debugging option.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
OFstream that keeps track of vertices.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
Searching on edgeMesh with constant radius.
Unit conversion functions.
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.
virtual point position(const scalar) const
The point position corresponding to the curve parameter.
defineTypeNameAndDebug(arcEdge, 0)
addToRunTimeSelectionTable(blockEdge, arcEdge, Istream)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
virtual scalar length() const
The length of the curve.
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.
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
A line using referred points.
static const Vector< Cmpt > max
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.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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.