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
103 if (surfaces_[i] == -1)
106 <<
"Cannot find surface " <<
names[i] <<
" in geometry" 124 pointConstraint constraint;
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 scalar distSqr =
Foam::magSqr(lastPoint()-firstPoint());
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++)
175 List<pointConstraint> constraints(lambdas.
size());
188 if (lambdas[0] < SMALL)
192 if (lambdas.
last() > 1.0-SMALL)
194 points.last() = lastPoint();
201 debugStr().writeLine(start[i],
points[i]);
209 projLambdas[0] = 0.0;
210 for (label i = 1; i <
points.size(); i++)
214 projLambdas /= projLambdas.last();
216 linearInterpolationWeights interpolator(projLambdas);
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)
262 debugStr().writeLine(
points[i], predicted);
void size(const label n)
Older name for setAddressableSize.
virtual scalar length() const
The length of the edge.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void resize(const label len)
Adjust allocated size of list.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
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.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Ostream & endl(Ostream &os)
Add newline and flush stream.
label findSurfaceID(const word &name) const
Find index of surface. Return -1 if not found.
point linearPosition(const scalar lambda) const
The point position in the straight line.
Macros for easy insertion into run-time selection tables.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define forAll(list, i)
Loop across all elements in list.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
const point & lastPoint() const
The location of the last point.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files...
int debug
Static debugging option.
T & last()
Access last element of the list, position [size()-1].
defineTypeNameAndDebug(arcEdge, 0)
addToRunTimeSelectionTable(blockEdge, arcEdge, Istream)
Define a curved edge that is parameterized for 0<lambda<1 between the start/end points.
vector point
Point is a vector.
virtual point position(const scalar) const
The point position corresponding to the curve parameter.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
const point & firstPoint() const
The location of the first point.
List< label > labelList
A List of labels.
A class for managing temporary objects.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)