15 #if !defined(KRATOS_NURBS_CURVE_GEOMETRY_H_INCLUDED )
16 #define KRATOS_NURBS_CURVE_GEOMETRY_H_INCLUDED
31 template <
int TWorkingSpaceDimension,
class TContainerPo
intType>
38 typedef typename TContainerPointType::value_type
NodeType;
68 :
BaseType(rThisPoints, &msGeometryData)
72 CheckAndFitKnotVectors();
81 :
BaseType(rThisPoints, &msGeometryData)
86 CheckAndFitKnotVectors();
89 <<
"Number of control points and weights do not match!" << std::endl;
93 :
BaseType(ThisPoints, &msGeometryData)
100 , mPolynomialDegree(rOther.mPolynomialDegree)
101 , mKnots(rOther.mKnots)
102 , mWeights(rOther.mWeights)
110 , mPolynomialDegree(rOther.mPolynomialDegree)
111 , mKnots(rOther.mKnots)
112 , mWeights(rOther.mWeights)
127 mPolynomialDegree = rOther.mPolynomialDegree;
128 mKnots = rOther.mKnots;
129 mWeights = rOther.mWeights;
134 template<
class TOtherContainerPo
intType>
139 mPolynomialDegree = rOther.mPolynomialDegree;
140 mKnots = rOther.mKnots;
141 mWeights = rOther.mWeights;
152 return Kratos::make_shared<NurbsCurveGeometry>(ThisPoints);
162 if (LocalDirectionIndex == 0) {
165 KRATOS_ERROR <<
"Possible direction index in NurbsCurveGeometry is 0. Given direction index: "
166 << LocalDirectionIndex << std::endl;
177 <<
"Trying to access polynomial degree in direction " << LocalDirectionIndex
178 <<
" from NurbsCurveGeometry #" << this->
Id() <<
". However, nurbs curves have only one direction."
181 return mPolynomialDegree;
204 return mKnots.size();
214 return mPolynomialDegree + 1;
224 return mWeights.size() != 0;
252 const IndexType first_span = mPolynomialDegree - 1;
255 const IndexType number_of_spans = last_span - first_span + 1;
257 std::vector<NurbsInterval> result(number_of_spans);
260 const double t0 = mKnots[first_span +
i];
261 const double t1 = mKnots[first_span +
i + 1];
274 if (std::abs(mKnots[
i] - mKnots[
i + 1]) > 1
e-6) {
278 return knot_span_counter;
289 rSpans[0] = mKnots[0];
293 if (std::abs(mKnots[
i] - mKnots[
i + 1]) > 1
e-6) {
311 const double Tolerance = std::numeric_limits<double>::epsilon()
314 const double min_parameter =
315 std::min(mKnots[mPolynomialDegree - 1],
317 if (rPointLocalCoordinates[0] < min_parameter) {
321 const double max_parameter =
322 std::max(mKnots[mPolynomialDegree - 1],
324 if (rPointLocalCoordinates[0] > max_parameter) {
346 const double Tolerance = std::numeric_limits<double>::epsilon()
349 const double min_parameter =
std::min(mKnots[mPolynomialDegree - 1], mKnots[
NumberOfKnots() - mPolynomialDegree]);
350 if (rPointLocalCoordinates[0] < min_parameter) {
351 rClosestPointLocalCoordinates[0] = min_parameter;
353 }
else if (rPointLocalCoordinates[0] == min_parameter) {
354 rClosestPointLocalCoordinates[0] = rPointLocalCoordinates[0];
358 const double max_parameter =
std::max(mKnots[mPolynomialDegree - 1], mKnots[
NumberOfKnots() - mPolynomialDegree]);
359 if (rPointLocalCoordinates[0] > max_parameter) {
360 rClosestPointLocalCoordinates[0] = max_parameter;
362 }
else if (rPointLocalCoordinates[0] == max_parameter) {
363 rClosestPointLocalCoordinates[0] = rPointLocalCoordinates[0];
367 rClosestPointLocalCoordinates[0] = rPointLocalCoordinates[0];
386 const double Tolerance = std::numeric_limits<double>::epsilon()
392 rProjectedPointLocalCoordinates,
393 rPointGlobalCoordinates,
394 point_global_coordinates,
411 for (
IndexType i = 0;
i < integration_points.size(); ++
i) {
413 length += integration_points[
i].Weight() * determinant_jacobian;
428 if (rResult.size1() != working_space_dimension || rResult.size2() != 1) {
429 rResult.
resize(working_space_dimension, 1,
false);
447 for (
IndexType k = 0;
k < working_space_dimension; ++
k) {
448 rResult(
k, 0) += r_coordinates[
k] * shape_function_container(
i, 1);
462 mPolynomialDegree + 1,
477 std::vector<double> spans;
481 rIntegrationPoints, spans, rIntegrationInfo);
500 IndexType NumberOfShapeFunctionDerivatives,
506 mPolynomialDegree, NumberOfShapeFunctionDerivatives);
509 if (rResultGeometries.
size() != rIntegrationPoints.size())
510 rResultGeometries.
resize(rIntegrationPoints.size());
517 for (
IndexType i = 0;
i < NumberOfShapeFunctionDerivatives - 1;
i++) {
518 shape_function_derivatives[
i].
resize(num_nonzero_cps, 1);
521 for (
IndexType i = 0;
i < rIntegrationPoints.size(); ++
i)
525 mKnots, mWeights, rIntegrationPoints[
i][0]);
529 mKnots, rIntegrationPoints[
i][0]);
536 nonzero_control_points(
j) =
pGetPoint(first_cp_index +
j);
541 N(0,
j) = shape_function_container(
j, 0);
545 if (NumberOfShapeFunctionDerivatives > 0) {
546 for (
IndexType n = 0;
n < NumberOfShapeFunctionDerivatives - 1;
n++) {
548 shape_function_derivatives[
n](
j, 0) = shape_function_container(
j,
n + 1);
554 default_method, rIntegrationPoints[
i],
555 N, shape_function_derivatives);
592 rResult += (*this)[index] * shape_function_container(
i, 0);
607 std::vector<CoordinatesArrayType>& rGlobalSpaceDerivatives,
609 const SizeType DerivativeOrder)
const override
620 if (rGlobalSpaceDerivatives.size() != DerivativeOrder + 1) {
621 rGlobalSpaceDerivatives.resize(DerivativeOrder + 1);
627 rGlobalSpaceDerivatives[order] = (*this)[index_0] * shape_function_container(0, order);
628 for (
IndexType u = 1;
u < shape_function_container.NumberOfNonzeroControlPoints();
u++) {
629 IndexType index = shape_function_container.GetFirstNonzeroControlPoint() +
u;
631 rGlobalSpaceDerivatives[order] += (*this)[index] * shape_function_container(
u, order);
664 rResult[
i] = shape_function_container(
i, 0);
691 if (rResult.size1() != 1
696 rResult(0,
i) = shape_function_container(
i, 1);
721 std::string
Info()
const override
723 return std::to_string(TWorkingSpaceDimension) +
" dimensional nurbs curve.";
729 rOStream << TWorkingSpaceDimension <<
" dimensional nurbs curve.";
764 void CheckAndFitKnotVectors()
777 <<
"Number of controls points, polynomial degree and number of knots do not match! " << std::endl
778 <<
" P: " << mPolynomialDegree <<
", size of knot vector: " << mKnots.size()
779 <<
", number of control points: " << num_control_points <<
"." << std::endl
780 <<
"Following condition must be achieved: Knots.size() = (ControlPoints.size() + PolynomialDegree - 1)."
792 void save(
Serializer& rSerializer)
const override
795 rSerializer.
save(
"PolynomialDegree", mPolynomialDegree);
796 rSerializer.
save(
"Knots", mKnots);
797 rSerializer.
save(
"Weights", mWeights);
803 rSerializer.
load(
"PolynomialDegree", mPolynomialDegree);
804 rSerializer.
load(
"Knots", mKnots);
805 rSerializer.
load(
"Weights", mWeights);
814 template<
int TWorkingSpaceDimension,
class TContainerPo
intType>
815 const GeometryData NurbsCurveGeometry<TWorkingSpaceDimension, TContainerPointType>::msGeometryData(
820 template<
int TWorkingSpaceDimension,
class TContainerPo
intType>
static GeometryPointerType CreateQuadraturePoint(SizeType WorkingSpaceDimension, SizeType LocalSpaceDimension, GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, GeometryType *pGeometryParent)
Definition: quadrature_points_utility.h:159
Definition: geometry_data.h:60
KratosGeometryType
Definition: geometry_data.h:110
KratosGeometryFamily
Definition: geometry_data.h:91
Definition: geometry_dimension.h:42
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
SizeType size() const
Definition: geometry.h:518
Geometry & operator=(const Geometry &rOther)
Definition: geometry.h:400
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
std::size_t SizeType
Definition: geometry.h:144
const TPointType::Pointer pGetPoint(const int Index) const
Definition: geometry.h:1790
std::size_t IndexType
Definition: geometry.h:137
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
Vector & DeterminantOfJacobian(Vector &rResult) const
Definition: geometry.h:3154
virtual void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo)
Definition: geometry.h:2331
IntegrationMethod GetDefaultIntegrationMethod() const
Definition: geometry.h:2004
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
TPointType const & GetPoint(const int Index) const
Definition: geometry.h:1816
Definition: geometry_shape_function_container.h:60
Integration information for the creation of integration points.
Definition: integration_info.h:35
static void CreateIntegrationPoints1D(IntegrationPointsArrayType &rIntegrationPoints, const std::vector< double > &rSpansLocalSpace, const IntegrationInfo &rIntegrationInfo)
Definition: integration_point_utilities.cpp:18
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
void clear()
Definition: amatrix_interface.h:284
Definition: nurbs_curve_geometry.h:33
BaseType::IndexType IndexType
Definition: nurbs_curve_geometry.h:43
void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) override
Definition: nurbs_curve_geometry.h:498
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: nurbs_curve_geometry.h:647
NurbsCurveGeometry< TWorkingSpaceDimension, TContainerPointType > GeometryType
Definition: nurbs_curve_geometry.h:41
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: nurbs_curve_geometry.h:733
int IsInsideLocalSpace(const CoordinatesArrayType &rPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Checks if given point in local space coordinates of this geometry is inside the geometry boundaries.
Definition: nurbs_curve_geometry.h:309
const Vector & Knots() const
Definition: nurbs_curve_geometry.h:193
NurbsCurveGeometry & operator=(const NurbsCurveGeometry &rOther)
Assignment operator.
Definition: nurbs_curve_geometry.h:124
NurbsCurveGeometry(const PointsArrayType &rThisPoints, const SizeType PolynomialDegree, const Vector &rKnots, const Vector &rWeights)
Conctructor for NURBS curves.
Definition: nurbs_curve_geometry.h:76
void SpansLocalSpace(std::vector< double > &rSpans, IndexType DirectionIndex=0) const override
Definition: nurbs_curve_geometry.h:285
TContainerPointType::value_type NodeType
Definition: nurbs_curve_geometry.h:38
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: nurbs_curve_geometry.h:46
bool IsRational() const
Definition: nurbs_curve_geometry.h:222
SizeType PolynomialDegree(IndexType LocalDirectionIndex) const override
Return polynomial degree of the curve.
Definition: nurbs_curve_geometry.h:174
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: nurbs_curve_geometry.h:711
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: nurbs_curve_geometry.h:678
std::string Info() const override
Turn back information as a string.
Definition: nurbs_curve_geometry.h:721
SizeType NumberOfKnotSpans(IndexType DirectionIndex=0) const
Returns the number of spans.
Definition: nurbs_curve_geometry.h:270
Geometry< NodeType > BaseType
Definition: nurbs_curve_geometry.h:40
BaseType::GeometriesArrayType GeometriesArrayType
Definition: nurbs_curve_geometry.h:48
const TPointType::Pointer pGetPoint(const int Index) const
Definition: geometry.h:1790
NurbsCurveGeometry(const PointsArrayType &rThisPoints, const SizeType PolynomialDegree, const Vector &rKnots)
Conctructor for B-Spline curves.
Definition: nurbs_curve_geometry.h:64
NurbsCurveGeometry(NurbsCurveGeometry< TWorkingSpaceDimension, TOtherContainerPointType > const &rOther)
Copy constructor from a geometry with different point type.
Definition: nurbs_curve_geometry.h:107
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: nurbs_curve_geometry.h:49
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: nurbs_curve_geometry.h:727
double Length() const override
Computes the length of a nurbs curve.
Definition: nurbs_curve_geometry.h:404
const Vector & Weights() const
Definition: nurbs_curve_geometry.h:233
SizeType PointsNumberInDirection(IndexType LocalDirectionIndex) const override
Returns number of points per direction.
Definition: nurbs_curve_geometry.h:160
~NurbsCurveGeometry() override=default
Destructor.
BaseType::PointsArrayType PointsArrayType
Definition: nurbs_curve_geometry.h:47
IntegrationInfo GetDefaultIntegrationInfo() const override
Provides the default integration dependent on the polynomial degree.
Definition: nurbs_curve_geometry.h:459
void GlobalSpaceDerivatives(std::vector< CoordinatesArrayType > &rGlobalSpaceDerivatives, const CoordinatesArrayType &rLocalCoordinates, const SizeType DerivativeOrder) const override
This method maps from dimension space to working space and computes the number of derivatives at the ...
Definition: nurbs_curve_geometry.h:606
std::vector< NurbsInterval > KnotSpanIntervals() const
Definition: nurbs_curve_geometry.h:250
NurbsCurveGeometry(const PointsArrayType &ThisPoints)
Definition: nurbs_curve_geometry.h:92
SizeType NumberOfKnots() const
Definition: nurbs_curve_geometry.h:202
SizeType NumberOfNonzeroControlPoints() const
Definition: nurbs_curve_geometry.h:212
virtual int ClosestPointLocalToLocalSpace(const CoordinatesArrayType &rPointLocalCoordinates, CoordinatesArrayType &rClosestPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Calculates the closes point projection This method calculates the closest point projection of a point...
Definition: nurbs_curve_geometry.h:343
int ProjectionPointGlobalToLocalSpace(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rProjectedPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Projects a point onto the geometry Projects a certain point on the geometry, or finds the closest poi...
Definition: nurbs_curve_geometry.h:383
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: nurbs_curve_geometry.h:706
NurbsCurveGeometry & operator=(NurbsCurveGeometry< TWorkingSpaceDimension, TOtherContainerPointType > const &rOther)
Assignment operator for geometries with different point type.
Definition: nurbs_curve_geometry.h:135
BaseType::SizeType SizeType
Definition: nurbs_curve_geometry.h:44
BaseType::Pointer Create(PointsArrayType const &ThisPoints) const override
Definition: nurbs_curve_geometry.h:149
Matrix & Jacobian(Matrix &rResult, const CoordinatesArrayType &rCoordinates) const override
Computes the Jacobian with coordinates.
Definition: nurbs_curve_geometry.h:423
NurbsCurveGeometry(NurbsCurveGeometry< TWorkingSpaceDimension, TContainerPointType > const &rOther)
Copy constructor.
Definition: nurbs_curve_geometry.h:98
NurbsInterval DomainInterval() const
Definition: nurbs_curve_geometry.h:241
void CreateIntegrationPoints(IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) const override
Definition: nurbs_curve_geometry.h:473
CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rLocalCoordinates) const override
Definition: nurbs_curve_geometry.h:574
KRATOS_CLASS_POINTER_DEFINITION(NurbsCurveGeometry)
Counted pointer of NurbsCurveGeometry.
NurbsCurveShapeFunction.
Definition: nurbs_curve_shape_functions.h:34
IndexType GetFirstNonzeroControlPoint() const
Definition: nurbs_curve_shape_functions.h:141
SizeType NumberOfNonzeroControlPoints() const
Definition: nurbs_curve_shape_functions.h:108
SizeType NumberOfShapeFunctionRows() const
Definition: nurbs_curve_shape_functions.h:117
void ComputeNurbsShapeFunctionValues(const Vector &rKnots, const Vector &rWeights, const double ParameterT)
Definition: nurbs_curve_shape_functions.h:284
void ComputeBSplineShapeFunctionValues(const Vector &rKnots, const double ParameterT)
Definition: nurbs_curve_shape_functions.h:172
Class for optimized use of intervals.
Definition: nurbs_interval.h:36
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
size_type size() const
Definition: pointer_vector.h:255
void resize(size_type dim)
Definition: pointer_vector.h:314
static bool NewtonRaphsonCurve(CoordinatesArrayType &rProjectedPointLocalCoordinates, const CoordinatesArrayType &rPointGlobalCoordinatesCoordinates, CoordinatesArrayType &rProjectedPointGlobalCoordinates, const Geometry< TPointType > &rGeometry, const int MaxIterations=20, const double Accuracy=1e-6)
Definition: projection_nurbs_geometry_utilities.h:51
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
Short class definition.
Definition: array_1d.h:61
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
SizeType GetNumberOfKnots(const SizeType PolynomialDegree, const SizeType NumberOfControlPoints)
Definition: nurbs_utilities.h:89
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
const GeometryData BrepCurve< TContainerPointType, TContainerPointEmbeddedType >::msGeometryData & msGeometryDimension
Definition: brep_curve.h:483
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
u
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:30
string t0
Definition: kernel_approximation_error.py:61
def load(f)
Definition: ode_solve.py:307
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31