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.
point_on_geometry.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 #if !defined(KRATOS_POINT_ON_GEOMETRY_H_INCLUDED )
12 #define KRATOS_POINT_ON_GEOMETRY_H_INCLUDED
13 
14 // System includes
15 
16 // External includes
17 
18 // Project includes
19 #include "geometries/geometry.h"
20 
22 
23 namespace Kratos
24 {
27 
28 /* @class PointOnGeometry
29  * @ingroup KratosCore
30  * @brief The PointOnGeometry acts as topology for points on various types
31  * of geometries as faces or curves.
32  */
33 template<class TContainerPointType, int TWorkingSpaceDimension, int TLocalSpaceDimensionOfBackground>
35  : public Geometry<typename TContainerPointType::value_type>
36 {
37 public:
41 
44 
45  typedef typename TContainerPointType::value_type PointType;
46 
49  typedef typename GeometryType::Pointer GeometryPointer;
50 
52 
53  typedef typename BaseType::IndexType IndexType;
54  typedef typename BaseType::SizeType SizeType;
55 
60 
64 
67  const CoordinatesArrayType LocalCoordinates,
68  typename GeometryType::Pointer pBackgroundGeometry)
69  : BaseType(PointsArrayType(), &msGeometryData)
70  , mLocalCoordinates(LocalCoordinates)
71  , mpBackgroundGeometry(pBackgroundGeometry)
72  {
73  KRATOS_ERROR_IF(pBackgroundGeometry->WorkingSpaceDimension() != this->WorkingSpaceDimension())
74  << "Working space dimension of background geometry (" << pBackgroundGeometry->WorkingSpaceDimension()
75  << ") does not coincide with WorkingSpaceDimension of this geometry (" << this->WorkingSpaceDimension() << ")."
76  << std::endl;
77  KRATOS_ERROR_IF(pBackgroundGeometry->LocalSpaceDimension() != this->LocalSpaceDimension())
78  << "Local space dimension of background geometry (" << pBackgroundGeometry->LocalSpaceDimension()
79  << ") does not coincide with LocalSpaceDimension of this geometry (" << this->LocalSpaceDimension() << ")."
80  << std::endl;
81  }
82 
85  : BaseType( rOther )
86  , mLocalCoordinates(rOther.mLocalCoordinates)
87  , mpBackgroundGeometry(rOther.mpBackgroundGeometry)
88  {
89  }
90 
92  ~PointOnGeometry() override = default;
93 
97 
100  {
101  BaseType::operator=( rOther );
102  mLocalCoordinates = rOther.mLocalCoordinates;
103  mpBackgroundGeometry = rOther.mpBackgroundGeometry;
104  return *this;
105  }
106 
110 
111  typename BaseType::Pointer Create( PointsArrayType const& ThisPoints ) const override
112  {
113  return typename BaseType::Pointer( new PointOnGeometry( ThisPoints ) );
114  }
115 
119 
127  {
128  const auto& const_this = *this;
129  return std::const_pointer_cast<GeometryType>(
130  const_this.pGetGeometryPart(Index));
131  }
132 
140  {
142  return mpBackgroundGeometry;
143 
144  KRATOS_ERROR << "Index " << Index << " not existing as geometry part in PointOnGeometry #"
145  << this->Id() << std::endl;
146  }
147 
148  /* @brief only true if BACKGROUND_GEOMETRY_INDEX is used.
149  * Brep Points have no other geometries.
150  */
151  bool HasGeometryPart(IndexType Index) const override
152  {
154  }
155 
159 
161  SizeType PolynomialDegree(IndexType LocalDirectionIndex) const override
162  {
163  return mpBackgroundGeometry->PolynomialDegree(LocalDirectionIndex);
164  }
165 
169 
170  /* @brief Calculates the global location of this point on the background geometry.
171  *
172  * @return Point which is the location of this quadrature point.
173  */
174  Point Center() const override
175  {
176  CoordinatesArrayType global_location;
177  mpBackgroundGeometry->GlobalCoordinates(global_location, mLocalCoordinates);
178  return Point(global_location);
179  }
180 
181  /*
182  * @brief This method maps from dimension space to working space.
183  * @param rResult array_1d<double, 3> with the coordinates in working space
184  * @param LocalCoordinates The local coordinates in dimension space
185  * @return array_1d<double, 3> with the coordinates in working space
186  * @see PointLocalCoordinates
187  */
189  CoordinatesArrayType& rResult,
190  const CoordinatesArrayType& rLocalCoordinates
191  ) const override
192  {
193  KRATOS_ERROR << "Trying to access the GlobalCoordinates via PointOnGeometry. "
194  << "However, this is not possible. Try to access the global coordinates of"
195  << " any local coordinates via accessing the background geometry through: "
196  << "pGetGeometryPart(GeometryType::BACKGROUND_GEOMETRY_INDEX)." << std::endl;
197 
198  return rResult;
199  }
200 
204 
207  {
209  }
210 
214 
215  /* Creates a integration point on the background geometry.
216  * @param return integration points list with one entry.
217  */
219  IntegrationPointsArrayType& rIntegrationPoints,
220  IntegrationInfo& rIntegrationInfo) const override
221  {
222  if (rIntegrationPoints.size() != 1) { rIntegrationPoints.resize(1); }
223  rIntegrationPoints[0][0] = mLocalCoordinates[0];
224  rIntegrationPoints[0][1] = mLocalCoordinates[1];
225  rIntegrationPoints[0][2] = mLocalCoordinates[2];
226  rIntegrationPoints[0].Weight() = 1.0;
227  }
228 
232 
233  /* @brief creates a list of quadrature point geometry
234  * at the specific location of this PointOnGeometry on the background geometry.
235  *
236  * @param rResultGeometries list of ONE quadrature point geometries.
237  * @param rIntegrationPoints list of ONE integration point.
238  * @param NumberOfShapeFunctionDerivatives the number of evaluated
239  * derivatives of shape functions at the quadrature point geometries.
240  *
241  * @see quadrature_point_geometry.h
242  */
244  GeometriesArrayType& rResultGeometries,
245  IndexType NumberOfShapeFunctionDerivatives,
246  IntegrationInfo& rIntegrationInfo) override
247  {
248  IntegrationPointsArrayType integration_point(1);
249  this->CreateIntegrationPoints(integration_point, rIntegrationInfo);
250 
251  GeometriesArrayType rQuadraturePointGeometries(1);
252  mpBackgroundGeometry->CreateQuadraturePointGeometries(
253  rQuadraturePointGeometries, NumberOfShapeFunctionDerivatives, integration_point, rIntegrationInfo);
254 
255  if (rResultGeometries.size() != 1) { rResultGeometries.resize(1); }
256  // assignment operator for quadrature point geometry with Dimension being 0.
257  rResultGeometries(0) = Kratos::make_shared<
259  std::move(rQuadraturePointGeometries(0)->Points()),
260  rQuadraturePointGeometries(0)->GetGeometryData().GetGeometryShapeFunctionContainer(),
261  this);
262  }
263 
267 
269  Vector &rResult,
270  const CoordinatesArrayType& rCoordinates) const override
271  {
272  mpBackgroundGeometry->ShapeFunctionsValues(rResult, mLocalCoordinates);
273 
274  return rResult;
275  }
276 
278  Matrix& rResult,
279  const CoordinatesArrayType& rCoordinates) const override
280  {
281  mpBackgroundGeometry->ShapeFunctionsLocalGradients(rResult, mLocalCoordinates);
282 
283  return rResult;
284  }
285 
289 
291  {
293  }
294 
298 
300  std::string Info() const override
301  {
302  return "PointOnGeometry";
303  }
304 
306  void PrintInfo( std::ostream& rOStream ) const override
307  {
308  rOStream << "PointOnGeometry";
309  }
310 
312  void PrintData( std::ostream& rOStream ) const override
313  {
314  BaseType::PrintData( rOStream );
315  std::cout << std::endl;
316  rOStream << " PointOnGeometry" << std::endl;
317  }
318 
320 
321 private:
324 
325  static const GeometryData msGeometryData;
326 
327  static const GeometryDimension msGeometryDimension;
328 
332 
333  CoordinatesArrayType mLocalCoordinates;
334 
335  typename GeometryType::Pointer mpBackgroundGeometry;
336 
340 
342  explicit PointOnGeometry(const PointsArrayType& ThisPoints)
343  : BaseType(ThisPoints, &msGeometryData)
344  {
345  }
346 
350 
351  friend class Serializer;
352 
353  void save( Serializer& rSerializer ) const override
354  {
356  rSerializer.save("LocalCoordinates", mLocalCoordinates);
357  rSerializer.save("pBackgroundGeometry", mpBackgroundGeometry);
358  }
359 
360  void load( Serializer& rSerializer ) override
361  {
363  rSerializer.load("LocalCoordinates", mLocalCoordinates);
364  rSerializer.load("pBackgroundGeometry", mpBackgroundGeometry);
365  }
366 
367  PointOnGeometry()
368  : BaseType( PointsArrayType(), &msGeometryData )
369  {}
370 
372 
373 }; // Class PointOnGeometry
374 
377 
379 template<class TContainerPointType, int TWorkingSpaceDimension, int TLocalSpaceDimensionOfBackground> inline std::istream& operator >> (
380  std::istream& rIStream,
382 
384 template<class TContainerPointType, int TWorkingSpaceDimension, int TLocalSpaceDimensionOfBackground> inline std::ostream& operator << (
385  std::ostream& rOStream,
387 {
388  rThis.PrintInfo( rOStream );
389  rOStream << std::endl;
390  rThis.PrintData( rOStream );
391  return rOStream;
392 }
393 
397 
398 template<class TContainerPointType, int TWorkingSpaceDimension, int TLocalSpaceDimensionOfBackground> const
399 GeometryData PointOnGeometry<TContainerPointType, TWorkingSpaceDimension, TLocalSpaceDimensionOfBackground>::msGeometryData(
402  {}, {}, {});
403 
404 template<class TContainerPointType, int TWorkingSpaceDimension, int TLocalSpaceDimensionOfBackground>
405 const GeometryDimension PointOnGeometry<TContainerPointType, TWorkingSpaceDimension, TLocalSpaceDimensionOfBackground>::msGeometryDimension(TWorkingSpaceDimension, TLocalSpaceDimensionOfBackground);
406 
408 }// namespace Kratos.
409 
410 #endif // KRATOS_POINT_ON_GEOMETRY_H_INCLUDED defined
Definition: geometry_data.h:60
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
SizeType LocalSpaceDimension() const
Definition: geometry.h:1300
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
const PointsArrayType & Points() const
Definition: geometry.h:1768
static constexpr IndexType BACKGROUND_GEOMETRY_INDEX
Definition: geometry.h:220
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
Integration information for the creation of integration points.
Definition: integration_info.h:35
Point class.
Definition: point.h:59
Definition: point_on_geometry.h:36
std::string Info() const override
Turn back information as a string.
Definition: point_on_geometry.h:300
IntegrationInfo GetDefaultIntegrationInfo() const override
Provides the default integration dependent on the polynomial degree.
Definition: point_on_geometry.h:206
Matrix & ShapeFunctionsLocalGradients(Matrix &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: point_on_geometry.h:277
void CreateQuadraturePointGeometries(GeometriesArrayType &rResultGeometries, IndexType NumberOfShapeFunctionDerivatives, IntegrationInfo &rIntegrationInfo) override
Definition: point_on_geometry.h:243
PointOnGeometry(const CoordinatesArrayType LocalCoordinates, typename GeometryType::Pointer pBackgroundGeometry)
Constructor with the local coordinates and background geometry.
Definition: point_on_geometry.h:66
TContainerPointType::value_type PointType
Definition: point_on_geometry.h:45
GeometryPointer pGetGeometryPart(IndexType Index) override
This function returns the pointer of the background geometry of this point. Accesseable via GeometryT...
Definition: point_on_geometry.h:126
void CreateIntegrationPoints(IntegrationPointsArrayType &rIntegrationPoints, IntegrationInfo &rIntegrationInfo) const override
Definition: point_on_geometry.h:218
BaseType::Pointer Create(PointsArrayType const &ThisPoints) const override
Definition: point_on_geometry.h:111
Vector & ShapeFunctionsValues(Vector &rResult, const CoordinatesArrayType &rCoordinates) const override
Definition: point_on_geometry.h:268
BaseType::SizeType SizeType
Definition: point_on_geometry.h:54
PointOnGeometry & operator=(const PointOnGeometry &rOther)
Assignment operator.
Definition: point_on_geometry.h:99
Geometry< typename TContainerPointType::value_type > GeometryType
Definition: point_on_geometry.h:48
BaseType::GeometriesArrayType GeometriesArrayType
Definition: point_on_geometry.h:58
BaseType::CoordinatesArrayType CoordinatesArrayType
Definition: point_on_geometry.h:57
GeometryData::KratosGeometryFamily GetGeometryFamily() const override
Definition: point_on_geometry.h:290
GeometryData::IntegrationMethod IntegrationMethod
Definition: point_on_geometry.h:51
KRATOS_CLASS_POINTER_DEFINITION(PointOnGeometry)
Pointer definition of PointOnGeometry.
BaseType::IndexType IndexType
Definition: point_on_geometry.h:53
BaseType::IntegrationPointsArrayType IntegrationPointsArrayType
Definition: point_on_geometry.h:59
~PointOnGeometry() override=default
Destructor.
GeometryType::Pointer GeometryPointer
Definition: point_on_geometry.h:49
Geometry< typename TContainerPointType::value_type > BaseType
Definition: point_on_geometry.h:47
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: point_on_geometry.h:306
bool HasGeometryPart(IndexType Index) const override
Use to check if certain Indexed object is within the geometry parts of this geometry.
Definition: point_on_geometry.h:151
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: point_on_geometry.h:312
Point Center() const override
Definition: point_on_geometry.h:174
BaseType::PointsArrayType PointsArrayType
Definition: point_on_geometry.h:56
const GeometryPointer pGetGeometryPart(IndexType Index) const override
This function returns the pointer of the background geometry of this point. Accesseable via GeometryT...
Definition: point_on_geometry.h:139
SizeType PolynomialDegree(IndexType LocalDirectionIndex) const override
Return polynomial degree of the background geometry.
Definition: point_on_geometry.h:161
CoordinatesArrayType & GlobalCoordinates(CoordinatesArrayType &rResult, const CoordinatesArrayType &rLocalCoordinates) const override
Definition: point_on_geometry.h:188
PointOnGeometry(PointOnGeometry const &rOther)
Copy constructor.
Definition: point_on_geometry.h:84
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
A sinlge quadrature point, that can be used for geometries without a predefined integration scheme,...
Definition: quadrature_point_geometry.h:44
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
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
shared_ptr< C > make_shared(Args &&...args)
Definition: smart_pointers.h:40
def Index()
Definition: hdf5_io_tools.py:38
def load(f)
Definition: ode_solve.py:307