KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
brep_curve.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 
11 #pragma once
12 
13 // System includes
14 
15 // External includes
16 
17 // Project includes
18 #include "geometries/geometry.h"
21 
22 
23 namespace Kratos
24 {
27 
34 template<class TContainerPointType, class TContainerPointEmbeddedType = TContainerPointType>
35 class BrepCurve
36  : public Geometry<typename TContainerPointType::value_type>
37 {
38 public:
42 
45 
46  typedef typename TContainerPointType::value_type PointType;
47 
50  typedef typename GeometryType::Pointer GeometryPointer;
51 
53 
55 
57 
58  typedef typename BaseType::IndexType IndexType;
59  typedef typename BaseType::SizeType SizeType;
60 
64 
68 
71  typename NurbsCurveType::Pointer pCurve)
72  : BaseType(PointsArrayType(), &msGeometryData)
73  , mpNurbsCurve(pCurve)
74  {
75  mIsTrimmed = false;
76  }
77 
79  explicit BrepCurve(const PointsArrayType& ThisPoints)
80  : BaseType(ThisPoints, &msGeometryData)
81  {
82  }
83 
85  BrepCurve(BrepCurve const& rOther)
86  : BaseType(rOther)
87  , mpNurbsCurve(rOther.mpNurbsCurve)
88  , mIsTrimmed(rOther.mIsTrimmed)
89  {
90  }
91 
93  template<class TOtherContainerPointType, class TOtherContainerPointEmbeddedType>
94  explicit BrepCurve(
96  : BaseType(rOther)
97  , mpNurbsCurve(rOther.mpNurbsCurve)
98  , mIsTrimmed(rOther.mIsTrimmed)
99  {
100  }
101 
103  ~BrepCurve() override = default;
104 
108 
110  BrepCurve& operator=( const BrepCurve& rOther )
111  {
112  BaseType::operator=( rOther );
113  mpNurbsCurve = rOther.mpNurbsCurve;
114  mIsTrimmed = rOther.mIsTrimmed;
115  return *this;
116  }
117 
119  template<class TOtherContainerPointType, class TOtherContainerPointEmbeddedType>
121  {
122  BaseType::operator=( rOther );
123  mpNurbsCurve = rOther.mpNurbsCurve;
124  mIsTrimmed = rOther.mIsTrimmed;
125  return *this;
126  }
127 
131 
132  typename BaseType::Pointer Create(PointsArrayType const& ThisPoints) const override
133  {
134  return typename BaseType::Pointer(new BrepCurve(ThisPoints));
135  }
136 
140 
149  {
150  const auto& const_this = *this;
151  return std::const_pointer_cast<GeometryType>(
152  const_this.pGetGeometryPart(Index));
153  }
154 
162  const GeometryPointer pGetGeometryPart(const IndexType Index) const override
163  {
165  return mpNurbsCurve;
166 
167  KRATOS_ERROR << "Index " << Index << " not existing in BrepCurve: "
168  << this->Id() << std::endl;
169  }
170 
177  bool HasGeometryPart(const IndexType Index) const override
178  {
180  return true;
181 
182  return false;
183  }
184 
188 
190  void Calculate(
191  const Variable<array_1d<double, 3>>& rVariable,
192  array_1d<double, 3>& rOutput) const override
193  {
194  if (rVariable == CHARACTERISTIC_GEOMETRY_LENGTH)
195  {
196  mpNurbsCurve->Calculate(rVariable, rOutput);
197  }
198  }
199 
203 
205  SizeType PolynomialDegree(IndexType LocalDirectionIndex) const override
206  {
207  return mpNurbsCurve->PolynomialDegree(LocalDirectionIndex);
208  }
209 
213 
214  /*
215  * @brief checks if the BrepCurve has any boundary trim information.
216  * @return true if has no trimming.
217  */
218  bool IsTrimmed() const
219  {
220  return mIsTrimmed;
221  }
222 
224  SizeType PointsNumberInDirection(IndexType DirectionIndex) const override
225  {
226  return mpNurbsCurve->PointsNumberInDirection(DirectionIndex);
227  }
228 
232 
234  Point Center() const override
235  {
236  return mpNurbsCurve->Center();
237  }
238 
269  const CoordinatesArrayType& rPointGlobalCoordinates,
270  CoordinatesArrayType& rProjectedPointLocalCoordinates,
271  const double Tolerance = std::numeric_limits<double>::epsilon()
272  ) const override
273  {
274  return mpNurbsCurve->ProjectionPointGlobalToLocalSpace(
275  rPointGlobalCoordinates, rProjectedPointLocalCoordinates, Tolerance);
276  }
277 
278  /*
279  * @brief This method maps from dimension space to working space.
280  * @param rResult array_1d<double, 3> with the coordinates in working space
281  * @param LocalCoordinates The local coordinates in dimension space
282  * @return array_1d<double, 3> with the coordinates in working space
283  * @see PointLocalCoordinates
284  */
286  CoordinatesArrayType& rResult,
287  const CoordinatesArrayType& rLocalCoordinates
288  ) const override
289  {
290  mpNurbsCurve->GlobalCoordinates(rResult, rLocalCoordinates);
291 
292  return rResult;
293  }
294 
298 
301  {
302  return mpNurbsCurve->GetDefaultIntegrationInfo();
303  }
304 
308 
309  /* Creates integration points on the nurbs surface of this geometry.
310  * @param return integration points.
311  */
313  IntegrationPointsArrayType& rIntegrationPoints,
314  IntegrationInfo& rIntegrationInfo) const override
315  {
316  std::vector<double> spans;
317  mpNurbsCurve->SpansLocalSpace(spans);
318 
320  rIntegrationPoints, spans, rIntegrationInfo);
321  }
322 
326 
327  /* @brief calls function of underlying nurbs curve.
328  *
329  * @param rResultGeometries list of quadrature point geometries.
330  * @param NumberOfShapeFunctionDerivatives the number of evaluated
331  * derivatives of shape functions at the quadrature point geometries.
332  * @param rIntegrationPoints the corresponding integration points.
333  *
334  * @see quadrature_point_geometry.h
335  */
337  GeometriesArrayType& rResultGeometries,
338  IndexType NumberOfShapeFunctionDerivatives,
339  const IntegrationPointsArrayType& rIntegrationPoints,
340  IntegrationInfo& rIntegrationInfo) override
341  {
342  mpNurbsCurve->CreateQuadraturePointGeometries(
343  rResultGeometries, NumberOfShapeFunctionDerivatives, rIntegrationPoints, rIntegrationInfo);
344 
345  for (IndexType i = 0; i < rResultGeometries.size(); ++i) {
346  rResultGeometries(i)->SetGeometryParent(this);
347  }
348  }
349 
353 
355  Vector &rResult,
356  const CoordinatesArrayType& rCoordinates) const override
357  {
358  mpNurbsCurve->ShapeFunctionsValues(rResult, rCoordinates);
359 
360  return rResult;
361  }
362 
364  Matrix& rResult,
365  const CoordinatesArrayType& rCoordinates) const override
366  {
367  mpNurbsCurve->ShapeFunctionsLocalGradients(rResult, rCoordinates);
368 
369  return rResult;
370  }
371 
375 
377  {
379  }
380 
382  {
384  }
385 
389 
391  std::string Info() const override
392  {
393  return "BrepCurve";
394  }
395 
397  void PrintInfo( std::ostream& rOStream ) const override
398  {
399  rOStream << "BrepCurve";
400  }
401 
403  void PrintData( std::ostream& rOStream ) const override
404  {
405  BaseType::PrintData( rOStream );
406  std::cout << std::endl;
407  rOStream << " BrepCurve " << std::endl;
408  }
409 
411 
412 private:
415 
416  static const GeometryData msGeometryData;
417 
418  static const GeometryDimension msGeometryDimension;
419 
423 
424  typename NurbsCurveType::Pointer mpNurbsCurve;
425 
429  bool mIsTrimmed;
430 
434 
435  friend class Serializer;
436 
437  void save( Serializer& rSerializer ) const override
438  {
440  rSerializer.save("NurbsCurve", mpNurbsCurve);
441  rSerializer.save("IsTrimmed", mIsTrimmed);
442  }
443 
444  void load( Serializer& rSerializer ) override
445  {
447  rSerializer.load("NurbsCurve", mpNurbsCurve);
448  rSerializer.load("IsTrimmed", mIsTrimmed);
449  }
450 
451  BrepCurve()
452  : BaseType( PointsArrayType(), &msGeometryData )
453  {}
454 
456 
457 }; // Class BrepCurve
458 
461 
463 template<class TContainerPointType, class TContainerPointEmbeddedType = TContainerPointType> inline std::istream& operator >> (
464  std::istream& rIStream,
466 
468 template<class TContainerPointType, class TContainerPointEmbeddedType = TContainerPointType> inline std::ostream& operator << (
469  std::ostream& rOStream,
471 {
472  rThis.PrintInfo( rOStream );
473  rOStream << std::endl;
474  rThis.PrintData( rOStream );
475  return rOStream;
476 }
477 
481 
482 template<class TContainerPointType, class TContainerPointEmbeddedType> const
486  {}, {}, {});
487 
488 template<class TContainerPointType, class TContainerPointEmbeddedType>
490 
492 }// namespace Kratos.
The BrepCurve acts as topology for curves. Those can be enclosed by a certain set of points.
Definition: brep_curve.h:37
SizeType PolynomialDegree(IndexType LocalDirectionIndex) const override
Return polynomial degree of the nurbs surface.
Definition: brep_curve.h:205
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: brep_curve.h:354
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: brep_curve.h:363
int ProjectionPointGlobalToLocalSpace(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rProjectedPointLocalCoordinates, const double Tolerance=std::numeric_limits< double >::epsilon()) const override
Calls projection of its nurbs curve. Projects a certain point on the geometry, or finds the closest p...
Definition: brep_curve.h:268
BrepCurve(BrepCurve const &rOther)
Copy constructor.
Definition: brep_curve.h:85
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: brep_curve.h:397
BaseType::Pointer Create(PointsArrayType const &ThisPoints) const override
Definition: brep_curve.h:132
GeometryType::Pointer GeometryPointer
Definition: brep_curve.h:50
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: brep_curve.h:62
BaseType::GeometriesArrayType GeometriesArrayType
Definition: brep_curve.h:56
GeometryData::KratosGeometryType GetGeometryType() const override
Definition: brep_curve.h:381
bool IsTrimmed() const
Definition: brep_curve.h:218
Geometry< typename TContainerPointType::value_type > GeometryType
Definition: brep_curve.h:49
void CreateIntegrationPoints(IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) const override
Definition: brep_curve.h:312
BrepCurve & operator=(BrepCurve< TOtherContainerPointType, TOtherContainerPointEmbeddedType > const &rOther)
Assignment operator for geometries with different point type.
Definition: brep_curve.h:120
BrepCurve & operator=(const BrepCurve &rOther)
Assignment operator.
Definition: brep_curve.h:110
TContainerPointType::value_type PointType
Definition: brep_curve.h:46
GeometryPointer pGetGeometryPart(const IndexType Index) override
This function returns the pointer of the geometry which is corresponding to the index....
Definition: brep_curve.h:148
BaseType::IndexType IndexType
Definition: brep_curve.h:58
void Calculate(const Variable< array_1d< double, 3 >> &rVariable, array_1d< double, 3 > &rOutput) const override
Calculate with array_1d<double, 3>
Definition: brep_curve.h:190
BaseType::PointsArrayType PointsArrayType
Definition: brep_curve.h:61
KRATOS_CLASS_POINTER_DEFINITION(BrepCurve)
Pointer definition of BrepCurve.
BrepCurve(BrepCurve< TOtherContainerPointType, TOtherContainerPointEmbeddedType > const &rOther)
Copy constructor from a geometry with different point type.
Definition: brep_curve.h:94
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: brep_curve.h:376
SizeType PointsNumberInDirection(IndexType DirectionIndex) const override
Returns number of points of NurbsSurface.
Definition: brep_curve.h:224
Point Center() const override
Provides the center of the underlying surface.
Definition: brep_curve.h:234
BrepCurve(const PointsArrayType &ThisPoints)
Constructor default.
Definition: brep_curve.h:79
std::string Info() const override
Turn back information as a string.
Definition: brep_curve.h:391
IntegrationInfo GetDefaultIntegrationInfo() const override
Provides the default integration dependent on the polynomial degree.
Definition: brep_curve.h:300
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: brep_curve.h:63
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: brep_curve.h:403
NurbsCurveGeometry< 3, TContainerPointType > NurbsCurveType
Definition: brep_curve.h:54
BrepCurve(typename NurbsCurveType::Pointer pCurve)
Constructor for untrimmed curve.
Definition: brep_curve.h:70
GeometryData::IntegrationMethod IntegrationMethod
Definition: brep_curve.h:52
Geometry< typename TContainerPointType::value_type > BaseType
Definition: brep_curve.h:48
~BrepCurve() override=default
Destructor.
bool HasGeometryPart(const IndexType Index) const override
This function is used to check if this BrepCurve has certain trim or curve object.
Definition: brep_curve.h:177
const GeometryPointer pGetGeometryPart(const IndexType Index) const override
This function returns the pointer of the geometry which is corresponding to the trim index....
Definition: brep_curve.h:162
BaseType::SizeType SizeType
Definition: brep_curve.h:59
void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, const IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) override
Definition: brep_curve.h:336
CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rLocalCoordinates) const override
Definition: brep_curve.h:285
Definition: geometry_data.h:60
KratosGeometryType
Definition: geometry_data.h:110
IntegrationMethod
Definition: geometry_data.h:76
KratosGeometryFamily
Definition: geometry_data.h:91
Definition: geometry_dimension.h:42
Geometry base class.
Definition: geometry.h:71
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: geometry.h:3834
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
std::size_t IndexType
Definition: geometry.h:137
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
static constexpr IndexType BACKGROUND_GEOMETRY_INDEX
Definition: geometry.h:220
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
Definition: nurbs_curve_geometry.h:33
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
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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
const GeometryData BrepCurve< TContainerPointType, TContainerPointEmbeddedType >::msGeometryData & msGeometryDimension
Definition: brep_curve.h:483
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def Index()
Definition: hdf5_io_tools.py:38
def load(f)
Definition: ode_solve.py:307
integer i
Definition: TensorModule.f:17