17 #if !defined(KRATOS_NURBS_CURVE_ON_SURFACE_H_INCLUDED )
18 #define KRATOS_NURBS_CURVE_ON_SURFACE_H_INCLUDED
34 template <
int TWorkingSpaceDimension,
class TCurveContainerPo
intType,
class TSurfaceContainerPo
intType>
41 typedef typename TSurfaceContainerPointType::value_type
NodeType;
75 typename NurbsSurfaceType::Pointer pSurface,
76 typename NurbsCurveType::Pointer pCurve)
78 , mpNurbsSurface(pSurface)
79 , mpNurbsCurve(pCurve)
91 , mpNurbsSurface(rOther.mpNurbsSurface)
92 , mpNurbsCurve(rOther.mpNurbsCurve)
100 , mpNurbsSurface(rOther.mpNurbsSurface)
101 , mpNurbsCurve(rOther.mpNurbsCurve)
116 mpNurbsSurface = rOther.mpNurbsSurface;
117 mpNurbsCurve = rOther.mpNurbsCurve;
122 template<
class TOtherCurveContainerPo
intType,
class TOtherSurfaceContainerPo
intType>
127 mpNurbsSurface = rOther.mpNurbsSurface;
128 mpNurbsCurve = rOther.mpNurbsCurve;
137 TSurfaceContainerPointType
const& ThisPoints)
const override
139 KRATOS_ERROR <<
"NurbsCurveOnSurfaceGeometry cannot be created with 'PointsArrayType const& ThisPoints'. "
140 <<
"'Create' is not allowed as it would not contain the required pointers to the surface and the curve."
158 const auto& const_this = *
this;
159 return std::const_pointer_cast<GeometryType>(
160 const_this.pGetGeometryPart(
Index));
174 return mpNurbsSurface;
177 << this->
Id() << std::endl;
200 if (rVariable == PARAMETER_2D_COORDINATES) {
202 mpNurbsCurve->GlobalCoordinates(rOutput, local_parameter);
213 return mpNurbsSurface->PolynomialDegree(0) + mpNurbsSurface->PolynomialDegree(1);
238 return mpNurbsCurve->PointsNumberInDirection(LocalDirectionIndex);
248 auto interval = mpNurbsCurve->DomainInterval();
256 double Start,
double End)
const
258 std::vector<double> surface_spans_u;
259 std::vector<double> surface_spans_v;
260 mpNurbsSurface->SpansLocalSpace(surface_spans_u, 0);
261 mpNurbsSurface->SpansLocalSpace(surface_spans_v, 1);
265 *(mpNurbsCurve.get()), Start, End,
266 surface_spans_u, surface_spans_v,
275 return mpNurbsCurve->DomainInterval();
293 const double Tolerance = std::numeric_limits<double>::epsilon()
299 rProjectedPointLocalCoordinates,
300 rPointGlobalCoordinates,
301 point_global_coordinates,
317 const double Tolerance = std::numeric_limits<double>::epsilon()
320 return mpNurbsCurve->IsInsideLocalSpace(rPointLocalCoordinates, Tolerance);
338 const double Tolerance = std::numeric_limits<double>::epsilon()
341 return mpNurbsCurve->ClosestPointLocalToLocalSpace(rPointLocalCoordinates, rClosestPointLocalCoordinates, Tolerance);
352 return mpNurbsSurface->Center();
363 for (
IndexType i = 0;
i < integration_points.size(); ++
i) {
365 length += integration_points[
i].Weight() * determinant_jacobian;
377 std::vector<CoordinatesArrayType> global_space_derivatives(2);
379 global_space_derivatives, rPoint, 1);
380 return norm_2(global_space_derivatives[1]);
390 IndexType p = mpNurbsSurface->PolynomialDegreeU() + mpNurbsSurface->PolynomialDegreeV() + 1;
406 std::vector<double> spans;
410 rIntegrationPoints, spans, rIntegrationInfo);
430 IndexType NumberOfShapeFunctionDerivatives,
436 mpNurbsSurface->PolynomialDegreeU(), mpNurbsSurface->PolynomialDegreeV(),
437 NumberOfShapeFunctionDerivatives);
440 if (rResultGeometries.
size() != rIntegrationPoints.size())
441 rResultGeometries.
resize(rIntegrationPoints.size());
448 for (
IndexType i = 0;
i < NumberOfShapeFunctionDerivatives - 1;
i++) {
449 shape_function_derivatives[
i].
resize(num_nonzero_cps,
i + 2);
452 for (
IndexType i = 0;
i < rIntegrationPoints.size(); ++
i)
454 std::vector<CoordinatesArrayType> global_space_derivatives(2);
455 mpNurbsCurve->GlobalSpaceDerivatives(
456 global_space_derivatives,
457 rIntegrationPoints[
i],
460 if (mpNurbsSurface->IsRational()) {
462 mpNurbsSurface->KnotsU(), mpNurbsSurface->KnotsV(), mpNurbsSurface->Weights(),
463 global_space_derivatives[0][0], global_space_derivatives[0][1]);
467 mpNurbsSurface->KnotsU(), mpNurbsSurface->KnotsV(),
468 global_space_derivatives[0][0], global_space_derivatives[0][1]);
474 mpNurbsSurface->NumberOfControlPointsU(), mpNurbsSurface->NumberOfControlPointsV());
476 nonzero_control_points(
j) = mpNurbsSurface->pGetPoint(cp_indices[
j]);
480 N(0,
j) = shape_function_container(
j, 0);
484 if (NumberOfShapeFunctionDerivatives > 0) {
486 for (
IndexType n = 0;
n < NumberOfShapeFunctionDerivatives - 1;
n++) {
489 shape_function_derivatives[
n](
j,
k) = shape_function_container(
j, shape_derivative_index +
k);
492 shape_derivative_index +=
n + 2;
497 default_method, rIntegrationPoints[
i],
498 N, shape_function_derivatives);
501 data_container, nonzero_control_points,
502 global_space_derivatives[1][0], global_space_derivatives[1][1],
this);
524 CoordinatesArrayType result_local = mpNurbsCurve->GlobalCoordinates(rResult, rLocalCoordinates);
527 return mpNurbsSurface->GlobalCoordinates(rResult, result_local);
540 std::vector<CoordinatesArrayType>& rGlobalSpaceDerivatives,
542 const SizeType DerivativeOrder)
const override
545 if (rGlobalSpaceDerivatives.size() != DerivativeOrder + 1) {
546 rGlobalSpaceDerivatives.resize(DerivativeOrder + 1);
550 std::vector<array_1d<double, 3>> curve_derivatives;
551 mpNurbsCurve->GlobalSpaceDerivatives(curve_derivatives, rCoordinates, DerivativeOrder);
555 surface_coordinates[0] = curve_derivatives[0][0];
556 surface_coordinates[1] = curve_derivatives[0][1];
557 std::vector<array_1d<double, 3>> surface_derivatives;
558 mpNurbsSurface->GlobalSpaceDerivatives(surface_derivatives, surface_coordinates, DerivativeOrder);
560 std::function<array_1d<double, 3>(
int,
int,
int)>
c;
562 if (DerivativeOrder > 0) {
565 for (
int a = 1;
a <= DerivativeOrder;
a++) {
567 c(DerivativeOrder -
a,
i + 1,
j) * curve_derivatives[
a][0] +
568 c(DerivativeOrder -
a,
i,
j + 1) * curve_derivatives[
a][1]
576 return surface_derivatives[index];
580 rGlobalSpaceDerivatives[
i] =
c(
i, 0, 0);
603 std::string
Info()
const override
605 return "2 dimensional nurbs curve on 3D surface.";
611 rOStream <<
"2 dimensional nurbs curve on 3D surface.";
632 typename NurbsSurfaceType::Pointer mpNurbsSurface;
633 typename NurbsCurveType::Pointer mpNurbsCurve;
641 void save(
Serializer& rSerializer)
const override
644 rSerializer.
save(
"pNurbsSurface", mpNurbsSurface);
645 rSerializer.
save(
"pNurbsCurve", mpNurbsCurve);
651 rSerializer.
load(
"pNurbsSurface", mpNurbsSurface);
652 rSerializer.
load(
"pNurbsCurve", mpNurbsCurve);
659 template<
int TWorkingSpaceDimension,
class TCurveContainerPo
intType,
class TSurfaceContainerPo
intType>
660 const GeometryData NurbsCurveOnSurfaceGeometry<TWorkingSpaceDimension, TCurveContainerPointType, TSurfaceContainerPointType>::msGeometryData(
665 template<
int TWorkingSpaceDimension,
class TCurveContainerPo
intType,
class TSurfaceContainerPo
intType>
static GeometryPointerType CreateQuadraturePointCurveOnSurface(GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, double LocalTangentU, double LocalTangentV, GeometryType *pGeometryParent)
Definition: quadrature_points_utility.h:103
static void ComputeAxisIntersection(std::vector< double > &rIntersectionParameters, const GeometryType &rGeometry, double Start, double End, const std::vector< double > &rAxis1, const std::vector< double > &rAxis2, const double Tolerance)
Definition: curve_axis_intersection.h:146
Definition: geometry_data.h:60
KratosGeometryType
Definition: geometry_data.h:110
@ Kratos_Nurbs_Curve_On_Surface
KratosGeometryFamily
Definition: geometry_data.h:91
Definition: geometry_dimension.h:42
Geometry base class.
Definition: geometry.h:71
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
virtual void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo)
Definition: geometry.h:2331
static constexpr IndexType BACKGROUND_GEOMETRY_INDEX
Definition: geometry.h:220
IntegrationMethod GetDefaultIntegrationMethod() const
Definition: geometry.h:2004
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
Definition: nurbs_curve_geometry.h:33
Definition: nurbs_curve_on_surface_geometry.h:36
void GlobalSpaceDerivatives(std::vector< CoordinatesArrayType > &rGlobalSpaceDerivatives, const CoordinatesArrayType &rCoordinates, 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_on_surface_geometry.h:539
NurbsCurveType::Pointer NurbsCurvePointerType
Definition: nurbs_curve_on_surface_geometry.h:54
BaseType::Pointer Create(TSurfaceContainerPointType const &ThisPoints) const override
Definition: nurbs_curve_on_surface_geometry.h:136
~NurbsCurveOnSurfaceGeometry() override=default
Destructor.
NurbsCurveOnSurfaceGeometry(NurbsCurveOnSurfaceGeometry const &rOther)
Copy constructor.
Definition: nurbs_curve_on_surface_geometry.h:89
NurbsCurveOnSurfaceGeometry & operator=(NurbsCurveOnSurfaceGeometry< TWorkingSpaceDimension, TOtherCurveContainerPointType, TOtherSurfaceContainerPointType > const &rOther)
Assignment operator for geometries with different point type.
Definition: nurbs_curve_on_surface_geometry.h:123
void Calculate(const Variable< array_1d< double, 3 >> &rVariable, array_1d< double, 3 > &rOutput) const override
Calculate with array_1d<double, 3>
Definition: nurbs_curve_on_surface_geometry.h:195
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: nurbs_curve_on_surface_geometry.h:588
const GeometryPointer pGetGeometryPart(const IndexType Index) const override
This function returns the pointer of the geometry which is corresponding to the trim index....
Definition: nurbs_curve_on_surface_geometry.h:171
GeometryPointer pGetGeometryPart(const IndexType Index) override
This function returns the pointer of the geometry which is corresponding to the trim index....
Definition: nurbs_curve_on_surface_geometry.h:156
TCurveContainerPointType::value_type CurveNodeType
Definition: nurbs_curve_on_surface_geometry.h:42
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_on_surface_geometry.h:315
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_on_surface_geometry.h:290
TSurfaceContainerPointType::value_type NodeType
Definition: nurbs_curve_on_surface_geometry.h:41
BaseType::IndexType IndexType
Definition: nurbs_curve_on_surface_geometry.h:49
BaseType::SizeType SizeType
Definition: nurbs_curve_on_surface_geometry.h:50
NurbsCurveGeometry< 2, TCurveContainerPointType > NurbsCurveType
Definition: nurbs_curve_on_surface_geometry.h:53
NurbsCurveOnSurfaceGeometry & operator=(const NurbsCurveOnSurfaceGeometry &rOther)
Assignment operator.
Definition: nurbs_curve_on_surface_geometry.h:113
void SpansLocalSpace(std::vector< double > &rSpans, IndexType DirectionIndex=0) const override
Definition: nurbs_curve_on_surface_geometry.h:246
IntegrationInfo GetDefaultIntegrationInfo() const override
Provides the default integration dependent on the polynomial degree of the underlying surface.
Definition: nurbs_curve_on_surface_geometry.h:388
std::string Info() const override
Turn back information as a string.
Definition: nurbs_curve_on_surface_geometry.h:603
CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rLocalCoordinates) const override
Definition: nurbs_curve_on_surface_geometry.h:518
NurbsCurvePointerType pGetCurve()
Definition: nurbs_curve_on_surface_geometry.h:220
double DeterminantOfJacobian(const CoordinatesArrayType &rPoint) const override
Definition: nurbs_curve_on_surface_geometry.h:374
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: nurbs_curve_on_surface_geometry.h:56
SizeType PolynomialDegree(IndexType LocalDirectionIndex) const override
Return polynomial degree of the curve.
Definition: nurbs_curve_on_surface_geometry.h:211
NurbsCurveOnSurfaceGeometry(NurbsCurveOnSurfaceGeometry< TWorkingSpaceDimension, TOtherCurveContainerPointType, TOtherSurfaceContainerPointType > const &rOther)
Copy constructor, with different point type.
Definition: nurbs_curve_on_surface_geometry.h:97
BaseType::GeometriesArrayType GeometriesArrayType
Definition: nurbs_curve_on_surface_geometry.h:58
double Length() const override
Computes the length of a nurbs curve.
Definition: nurbs_curve_on_surface_geometry.h:356
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: nurbs_curve_on_surface_geometry.h:59
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_on_surface_geometry.h:335
void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) override
This method creates a list of quadrature point geometries from a list of integration points.
Definition: nurbs_curve_on_surface_geometry.h:428
bool HasGeometryPart(const IndexType Index) const override
This function is used to check if the index is GeometryType::BACKGROUND_GEOMETRY_INDEX.
Definition: nurbs_curve_on_surface_geometry.h:186
KRATOS_CLASS_POINTER_DEFINITION(NurbsCurveOnSurfaceGeometry)
Counted pointer of NurbsCurveOnSurfaceGeometry.
GeometryType::Pointer GeometryPointer
Definition: nurbs_curve_on_surface_geometry.h:45
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: nurbs_curve_on_surface_geometry.h:609
Geometry< NodeType > BaseType
Definition: nurbs_curve_on_surface_geometry.h:47
Point Center() const override
Provides the center of the underlying surface.
Definition: nurbs_curve_on_surface_geometry.h:350
void CreateIntegrationPoints(IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) const override
Definition: nurbs_curve_on_surface_geometry.h:402
NurbsSurfaceGeometry< 3, TSurfaceContainerPointType > NurbsSurfaceType
Definition: nurbs_curve_on_surface_geometry.h:52
NurbsCurveOnSurfaceGeometry(typename NurbsSurfaceType::Pointer pSurface, typename NurbsCurveType::Pointer pCurve)
Constructor.
Definition: nurbs_curve_on_surface_geometry.h:74
const NurbsCurvePointerType pGetCurve() const
Returns the const NurbsCurveOnSurface::Pointer of this brep.
Definition: nurbs_curve_on_surface_geometry.h:226
NurbsInterval DomainInterval() const
Definition: nurbs_curve_on_surface_geometry.h:273
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: nurbs_curve_on_surface_geometry.h:593
Geometry< NodeType > GeometryType
Definition: nurbs_curve_on_surface_geometry.h:44
BaseType::PointsArrayType PointsArrayType
Definition: nurbs_curve_on_surface_geometry.h:57
void SpansLocalSpace(std::vector< double > &rSpans, double Start, double End) const
Definition: nurbs_curve_on_surface_geometry.h:255
SizeType PointsNumberInDirection(IndexType LocalDirectionIndex) const override
Returns number of points of NurbsCurve.
Definition: nurbs_curve_on_surface_geometry.h:236
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: nurbs_curve_on_surface_geometry.h:615
NurbsCurveOnSurfaceGeometry()
Default constructor.
Definition: nurbs_curve_on_surface_geometry.h:84
Class for optimized use of intervals.
Definition: nurbs_interval.h:36
Definition: nurbs_surface_geometry.h:38
Definition: nurbs_surface_shape_functions.h:31
void ComputeNurbsShapeFunctionValues(const Vector &rKnotsU, const Vector &rKnotsV, const Vector &Weights, const double ParameterU, const double ParameterV)
Definition: nurbs_surface_shape_functions.h:379
std::vector< int > ControlPointIndices(SizeType NumberOfControlPointsU, SizeType NumberOfControlPointsV) const
Definition: nurbs_surface_shape_functions.h:175
static constexpr IndexType IndexOfShapeFunctionRow(const SizeType DerivativeOrderU, const SizeType DerivativeOrderV) noexcept
Definition: nurbs_surface_shape_functions.h:76
SizeType NumberOfNonzeroControlPoints() const
Definition: nurbs_surface_shape_functions.h:151
void ComputeBSplineShapeFunctionValues(const Vector &rKnotsU, const Vector &rKnotsV, const double ParameterU, const double ParameterV)
Definition: nurbs_surface_shape_functions.h:280
Point class.
Definition: point.h:59
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
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
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
static constexpr SizeType GetBinomCoefficient(const SizeType N, const SizeType K) noexcept
Definition: nurbs_utilities.h:117
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
const GeometryData BrepCurve< TContainerPointType, TContainerPointEmbeddedType >::msGeometryData & msGeometryDimension
Definition: brep_curve.h:483
a
Definition: generate_stokes_twofluid_element.py:77
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
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
p
Definition: sensitivityMatrix.py:52
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31