52Foam::blockEdges::projectCurveEdge::projectCurveEdge
70 if (surfaces_[i] == -1)
73 <<
"Cannot find surface " <<
names[i] <<
" in geometry"
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 scalar distSqr =
Foam::magSqr(lastPoint()-firstPoint());
132 const searchableExtrudedCircle&
s =
135 geometry_[surfaces_[i]]
137 List<pointIndexHit> nearInfo;
138 s.findParametricNearest
148 if (nearInfo[i].hit())
150 points[i] = nearInfo[i].point();
161 constexpr label maxIter = 10;
164 constexpr scalar relTol = 0.1;
165 constexpr scalar absTol = 1
e-4;
167 scalar initialResidual = 0.0;
169 for (label iter = 0; iter < maxIter; iter++)
173 List<pointConstraint> constraints(lambdas.
size());
186 if (lambdas[0] < SMALL)
190 if (lambdas.
last() > 1.0-SMALL)
192 points.last() = lastPoint();
199 debugStr().writeLine(start[i],
points[i]);
207 projLambdas[0] = 0.0;
208 for (label i = 1; i <
points.size(); i++)
212 projLambdas /= projLambdas.last();
214 linearInterpolationWeights interpolator(projLambdas);
221 for (label i = 1; i <
points.size() - 1; i++)
223 interpolator.valueWeights(lambdas[i], indices, weights);
228 predicted += weights[indexi]*
points[indices[indexi]];
230 residual[i] = predicted-
points[i];
233 scalar scalarResidual =
sum(
mag(residual));
237 Pout<<
"Iter:" << iter <<
" initialResidual:" << initialResidual
238 <<
" residual:" << scalarResidual <<
endl;
241 if (scalarResidual < absTol*0.5*lambdas.
size())
247 initialResidual = scalarResidual;
249 else if (scalarResidual/initialResidual < relTol)
260 debugStr().writeLine(
points[i], predicted);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
blockEdge(const pointField &points, const label from, const label to)
Construct from components.
point linearPosition(const scalar lambda) const
The point position in the straight line.
const point & lastPoint() const
The location of the last point.
label start() const noexcept
Index of start (first) point.
const point & firstPoint() const
The location of the first point.
Defines the edge from the projection onto a surface (single surface) or intersection of two surfaces.
virtual scalar length() const
The length of the curve.
virtual point position(const scalar) const
The point position corresponding to the curve parameter.
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.
Searching on edgeMesh with constant radius.
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. The collection is specified as a dictionary. For example,...
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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))
A namespace for various blockEdge types.
Namespace for handling debugging switches.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< word > wordList
List of word.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
vector point
Point is a vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< scalar > scalarList
List of scalar.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.