18 #if !defined(KRATOS_CURVE_TESSELLATION_H_INCLUDED )
19 #define KRATOS_CURVE_TESSELLATION_H_INCLUDED
30 template <
class TContainerPo
intType>
70 const int PolynomialDegree,
72 const std::vector<NurbsInterval>& rKnotSpanIntervals,
73 const double Tolerance)
96 const double Tolerance,
97 const int NumberOfGuessesPerInterval = 1,
98 bool ToSurfaceParameter =
false)
100 std::vector<double> span_intervals;
106 NumberOfGuessesPerInterval,
126 const std::vector<double>& rSpanIntervals,
127 const double Tolerance,
128 const int NumberOfGuessesPerInterval = 1,
129 bool ToSurfaceParameter =
false)
131 NurbsInterval this_interval(rSpanIntervals[0], rSpanIntervals[rSpanIntervals.size() - 1]);
133 std::vector<NurbsInterval> KnotSpanIntervals(rSpanIntervals.size() - 1);
135 for (
IndexType i = 0;
i < rSpanIntervals.size() - 1; ++
i) {
136 KnotSpanIntervals[
i] =
NurbsInterval(rSpanIntervals[
i], rSpanIntervals[
i + 1]);
141 NumberOfGuessesPerInterval,
164 const int PolynomialDegree,
166 const std::vector<NurbsInterval>& rKnotSpanIntervals,
167 const double Tolerance,
168 bool ToSurfaceParameter =
false
177 for (
const auto&
span : rKnotSpanIntervals) {
184 const double t = normalized_span.
GetT0();
189 point,
t0, rGeometry, ToSurfaceParameter);
191 sample_points.emplace_back(
t, point);
198 point, t_at_normalized, rGeometry, ToSurfaceParameter);
200 sample_points.emplace_back(1.0, point);
202 std::sort(std::begin(sample_points),
std::end(sample_points),
203 [](std::pair<double, Vector>
const&
lhs, std::pair<double, Vector>
const&
rhs) {
204 return std::get<0>(
lhs) > std::get<0>(
rhs);
210 const int n = PolynomialDegree * 2 + 1;
213 const auto parameter_point_a = sample_points.back();
215 const auto t_a = std::get<0>(parameter_point_a);
216 const auto point_a = std::get<1>(parameter_point_a);
218 sample_points.pop_back();
222 if (sample_points.size() == 0) {
227 const auto parameter_point_b = sample_points.back();
229 const auto t_b = std::get<0>(parameter_point_b);
230 const auto point_b = std::get<1>(parameter_point_b);
232 double max_distance{ 0 };
233 std::pair<double, Vector> max_point;
235 for (
int i = 1;
i <=
n;
i++) {
237 t_b,
i / (
double(
n) + 1.0));
242 point, t_at_normalized, rGeometry, ToSurfaceParameter);
244 const double distance = DistanceToLine(point, point_a,
247 if (distance > max_distance) {
248 max_distance = distance;
249 max_point = {
t, point };
253 if (max_distance < Tolerance) {
257 sample_points.push_back(max_point);
268 bool to_surface_parameter =
false
271 if (!to_surface_parameter) {
273 rGlobalCoordinates, crLocaCoordinates);
276 rGlobalCoordinates = crLocaCoordinates;
277 rGeometry.
Calculate(PARAMETER_2D_COORDINATES, rGlobalCoordinates);
296 double length = End - Start;
297 double delta_length = length / (NumberOfPoints - 1);
301 parameter[0] = Start + delta_length *
i;
304 points[
i] = { parameter[0], result };
328 new_distance =
norm_2(rPointGlobalCoordinates - std::get<1>(rTesselation[
i]));
329 if (new_distance < distance)
331 distance = new_distance;
332 rClosestPointGlobalCoordinates = std::get<1>(rTesselation[
i]);
333 rClosestPointLocalCoordinates[0] = std::get<0>(rTesselation[
i]);
352 rPointGlobalCoordinates,
353 rClosestPointGlobalCoordinates,
354 rClosestPointLocalCoordinates,
375 static double DistanceToLine(
Definition: curve_tessellation.h:32
Geometry< typename TContainerPointType::value_type > GeometryType
Definition: curve_tessellation.h:38
std::vector< std::pair< double, CoordinatesArrayType > > TessellationType
Definition: curve_tessellation.h:40
static TessellationType ComputeTessellation(const GeometryType &rGeometry, const int PolynomialDegree, const NurbsInterval DomainInterval, const std::vector< NurbsInterval > &rKnotSpanIntervals, const double Tolerance, bool ToSurfaceParameter=false)
Definition: curve_tessellation.h:162
void Tessellate(const GeometryType &rGeometry, const std::vector< double > &rSpanIntervals, const double Tolerance, const int NumberOfGuessesPerInterval=1, bool ToSurfaceParameter=false)
Definition: curve_tessellation.h:124
GeometryType::CoordinatesArrayType CoordinatesArrayType
Definition: curve_tessellation.h:39
GeometryType::SizeType SizeType
Definition: curve_tessellation.h:42
CurveTessellation()
Conctructor for tessellation of a nurbs curve.
Definition: curve_tessellation.h:49
void Tessellate(const GeometryType &rGeometry, const double Tolerance, const int NumberOfGuessesPerInterval=1, bool ToSurfaceParameter=false)
Definition: curve_tessellation.h:94
void Tessellate(const GeometryType &rGeometry, const int PolynomialDegree, const NurbsInterval DomainInterval, const std::vector< NurbsInterval > &rKnotSpanIntervals, const double Tolerance)
Definition: curve_tessellation.h:68
static void GetClosestPoint(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rClosestPointGlobalCoordinates, CoordinatesArrayType &rClosestPointLocalCoordinates, const TessellationType &rTesselation)
Definition: curve_tessellation.h:318
static void ComputeGlobalCoordinates(CoordinatesArrayType &rGlobalCoordinates, const CoordinatesArrayType &crLocaCoordinates, const GeometryType &rGeometry, bool to_surface_parameter=false)
Definition: curve_tessellation.h:264
TessellationType GetTessellation()
Definition: curve_tessellation.h:361
static TessellationType ComputePolygon(const GeometryType &rGeometry, const SizeType NumberOfPoints, const double Start, const double End)
Definition: curve_tessellation.h:286
void GetClosestPoint(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rClosestPointGlobalCoordinates, CoordinatesArrayType &rClosestPointLocalCoordinates) const
Definition: curve_tessellation.h:346
GeometryType::IndexType IndexType
Definition: curve_tessellation.h:41
Geometry base class.
Definition: geometry.h:71
virtual CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, CoordinatesArrayType const &LocalCoordinates) const
Definition: geometry.h:2377
virtual void Calculate(const Variable< bool > &rVariable, bool &rOutput) const
Calculate with bool.
Definition: geometry.h:693
std::size_t SizeType
Definition: geometry.h:144
std::size_t IndexType
Definition: geometry.h:137
virtual void SpansLocalSpace(std::vector< double > &rSpans, IndexType LocalDirectionIndex=0) const
Definition: geometry.h:1972
Various mathematical utilitiy functions.
Definition: math_utils.h:62
static double Norm(const Vector &a)
Calculates the norm of vector "a".
Definition: math_utils.h:703
Class for optimized use of intervals.
Definition: nurbs_interval.h:36
double GetLength() const
Definition: nurbs_interval.h:95
NurbsInterval GetNormalizedInterval(const double T0, const double T1) const
Definition: nurbs_interval.h:120
double GetT0() const
Definition: nurbs_interval.h:60
double GetParameterAtNormalized(const double Parameter) const
Definition: nurbs_interval.h:109
Short class definition.
Definition: array_1d.h:61
end
Definition: DEM_benchmarks.py:180
static double max(double a, double b)
Definition: GeometryFunctions.h:79
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
float span
Definition: angle_finder.py:9
rhs
Definition: generate_frictional_mortar_condition.py:297
lhs
Definition: generate_frictional_mortar_condition.py:297
string t0
Definition: kernel_approximation_error.py:61
int t
Definition: ode_solve.py:392
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31