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.
quadrature_points_utility.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 // Main author:
11 //
12 
13 #if !defined(KRATOS_QUADRATURE_POINTS_UTILITY_H_INCLUDED)
14 #define KRATOS_QUADRATURE_POINTS_UTILITY_H_INCLUDED
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "includes/define.h"
22 #include "geometries/geometry.h"
26 
27 namespace Kratos
28 {
31 
33  template<class TPointType>
35  {
36  public:
39 
42 
43  typedef std::size_t SizeType;
44  typedef std::size_t IndexType;
45 
47 
51 
52  static typename GeometryType::Pointer CreateFromCoordinates(
53  typename GeometryType::Pointer pGeometry,
54  const array_1d<double, 3>& rCoordinates,
55  double integration_weight)
56  {
57  KRATOS_TRY;
58 
59  array_1d<double, 3> local_coordinates;
60  pGeometry->PointLocalCoordinates(local_coordinates, rCoordinates);
61 
62  return CreateFromLocalCoordinates(*(pGeometry.get()), local_coordinates, integration_weight);
63 
64  KRATOS_CATCH("");
65  }
66 
67  static typename GeometryType::Pointer CreateFromLocalCoordinates(
68  GeometryType& rGeometry,
69  const array_1d<double, 3>& rLocalCoordinates,
70  double integration_weight)
71  {
72  KRATOS_TRY;
73 
74  IntegrationPoint<3> int_p(rLocalCoordinates, integration_weight);
75  Vector N;
76  rGeometry.ShapeFunctionsValues(N, rLocalCoordinates);
77  Matrix N_matrix(1, N.size());
78  for (IndexType i = 0; i < N.size(); ++i)
79  {
80  N_matrix(0, i) = N[i];
81  }
82 
83  Matrix DN_De;
84  rGeometry.ShapeFunctionsLocalGradients(DN_De, rLocalCoordinates);
85 
87  rGeometry.GetDefaultIntegrationMethod(),
88  int_p,
89  N_matrix,
90  DN_De);
91 
92  return CreateQuadraturePoint(
93  rGeometry.WorkingSpaceDimension(),
94  rGeometry.LocalSpaceDimension(),
95  data_container,
96  rGeometry.Points(),
97  &rGeometry);
98 
99  KRATOS_CATCH("");
100  }
101 
102 
105  PointsArrayType rPoints,
106  double LocalTangentU,
107  double LocalTangentV,
108  GeometryType* pGeometryParent)
109  {
110  return Kratos::make_shared<
112  rPoints,
113  rShapeFunctionContainer,
114  LocalTangentU,
115  LocalTangentV,
116  pGeometryParent);
117  }
118 
121  PointsArrayType rPoints,
122  double LocalTangentU,
123  double LocalTangentV)
124  {
125  return Kratos::make_shared<
127  rPoints,
128  rShapeFunctionContainer,
129  LocalTangentU,
130  LocalTangentV);
131  }
132 
135  PointsArrayType rPoints,
136  Matrix LocalTangentMatrix,
137  GeometryType* pGeometryParent)
138  {
139  return Kratos::make_shared<
141  rPoints,
142  rShapeFunctionContainer,
143  LocalTangentMatrix,
144  pGeometryParent);
145  }
146 
149  PointsArrayType rPoints,
150  Matrix LocalTangentMatrix)
151  {
152  return Kratos::make_shared<
154  rPoints,
155  rShapeFunctionContainer,
156  LocalTangentMatrix );
157  }
158 
160  SizeType WorkingSpaceDimension,
161  SizeType LocalSpaceDimension,
163  PointsArrayType rPoints,
164  GeometryType* pGeometryParent)
165  {
166  if (WorkingSpaceDimension == 1 && LocalSpaceDimension == 1)
167  return Kratos::make_shared<
169  rPoints,
170  rShapeFunctionContainer,
171  pGeometryParent);
172  else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 1)
173  return Kratos::make_shared<
175  rPoints,
176  rShapeFunctionContainer,
177  pGeometryParent);
178  else if (WorkingSpaceDimension == 3 && LocalSpaceDimension == 1)
179  return Kratos::make_shared<
181  rPoints,
182  rShapeFunctionContainer,
183  pGeometryParent);
184  else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 2)
185  return Kratos::make_shared<
187  rPoints,
188  rShapeFunctionContainer,
189  pGeometryParent);
190  else if (WorkingSpaceDimension == 3 && LocalSpaceDimension == 2)
191  return Kratos::make_shared<
193  rPoints,
194  rShapeFunctionContainer,
195  pGeometryParent);
196  else if (WorkingSpaceDimension == 3 && LocalSpaceDimension == 3)
197  return Kratos::make_shared<
199  rPoints,
200  rShapeFunctionContainer,
201  pGeometryParent);
202  else{
203  KRATOS_ERROR << "Working/Local space dimension combinations are "
204  << "not provided for QuadraturePointGeometry. WorkingSpaceDimension: "
205  << WorkingSpaceDimension << ", LocalSpaceDimension: " << LocalSpaceDimension
206  << std::endl;
207  }
208  }
209 
211  SizeType WorkingSpaceDimension,
212  SizeType LocalSpaceDimension,
214  PointsArrayType rPoints)
215  {
216  if (WorkingSpaceDimension == 1 && LocalSpaceDimension == 1)
217  return Kratos::make_shared<
219  rPoints,
220  rShapeFunctionContainer);
221  else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 1)
222  return Kratos::make_shared<
224  rPoints,
225  rShapeFunctionContainer);
226  else if (WorkingSpaceDimension == 3 && LocalSpaceDimension == 1)
227  return Kratos::make_shared<
229  rPoints,
230  rShapeFunctionContainer);
231  else if (WorkingSpaceDimension == 2 && LocalSpaceDimension == 2)
232  return Kratos::make_shared<
234  rPoints,
235  rShapeFunctionContainer);
236  else if (WorkingSpaceDimension == 3 && LocalSpaceDimension == 2)
237  return Kratos::make_shared<
239  rPoints,
240  rShapeFunctionContainer);
241  else if (WorkingSpaceDimension == 3 && LocalSpaceDimension == 3)
242  return Kratos::make_shared<
244  rPoints,
245  rShapeFunctionContainer);
246  else {
247  KRATOS_ERROR << "Working/Local space dimension combinations are "
248  << "not provided for QuadraturePointGeometry. WorkingSpaceDimension: "
249  << WorkingSpaceDimension << ", LocalSpaceDimension: " << LocalSpaceDimension
250  << std::endl;
251  }
252  }
253 
254  static std::vector<GeometryPointerType> Create(
255  GeometryPointerType pGeometry) {
256  KRATOS_TRY;
257 
258  auto integration_points = pGeometry->IntegrationPoints();
259  auto default_method = pGeometry->GetDefaultIntegrationMethod();
260  auto r_N = pGeometry->ShapeFunctionsValues();
261 
262  std::vector<GeometryPointerType> geometry_pointer_vector(integration_points.size());
263 
264  for (IndexType i = 0; i < integration_points.size(); ++i)
265  {
266  Matrix N_i = ZeroMatrix(1, pGeometry->size());
267  for (IndexType j = 0; j < pGeometry->size(); ++j)
268  {
269  N_i(0, j) = r_N(i, j);
270  }
271 
273  default_method,
274  integration_points[i],
275  N_i,
276  pGeometry->ShapeFunctionLocalGradient(i));
277 
278  geometry_pointer_vector[i] = CreateQuadraturePoint(
279  pGeometry->WorkingSpaceDimension(), pGeometry->LocalSpaceDimension(),
280  data_container, pGeometry->Points(), pGeometry.get());
281  }
282  return geometry_pointer_vector;
283 
284  KRATOS_CATCH("");
285  }
286 
287  static std::vector<GeometryPointerType> Create(
288  GeometryPointerType pGeometry,
289  GeometryData::IntegrationMethod ThisIntegrationMethod) {
290  KRATOS_TRY;
291 
292  auto integration_points = pGeometry->IntegrationPoints(ThisIntegrationMethod);
293  auto r_N = pGeometry->ShapeFunctionsValues(ThisIntegrationMethod);
294 
295  std::vector<GeometryPointerType> geometry_pointer_vector(integration_points.size());
296 
297  for (IndexType i = 0; i < integration_points.size(); ++i)
298  {
299  Matrix N_i = ZeroMatrix(1, pGeometry->size());
300  for (IndexType j = 0; j < pGeometry->size(); ++j)
301  {
302  N_i(0, j) = r_N(i, j);
303  }
304 
306  ThisIntegrationMethod,
307  integration_points[i],
308  N_i,
309  pGeometry->ShapeFunctionLocalGradient(i, ThisIntegrationMethod));
310 
311  geometry_pointer_vector[i] = CreateQuadraturePoint(
312  pGeometry->WorkingSpaceDimension(), pGeometry->LocalSpaceDimension(),
313  data_container, pGeometry->Points(), pGeometry.get());
314  }
315  return geometry_pointer_vector;
316 
317  KRATOS_CATCH("");
318  }
319 
321  static void Create(
322  GeometryType& rGeometry,
323  typename GeometryType::GeometriesArrayType& rResultGeometries,
324  typename GeometryType::IntegrationPointsArrayType& rIntegrationPoints,
325  SizeType NumberOfShapeFunctionDerivatives)
326  {
327  KRATOS_ERROR_IF(NumberOfShapeFunctionDerivatives > 1)
328  << "Create can only compute shape functions up to an derivative order of 1. "
329  << "Demanded derivative order: " << NumberOfShapeFunctionDerivatives << std::endl;
330 
331  // Resize containers.
332  if (rResultGeometries.size() != rIntegrationPoints.size())
333  rResultGeometries.resize(rIntegrationPoints.size());
334 
335  auto default_method = rGeometry.GetDefaultIntegrationMethod();
336 
337  Vector N;
338  Matrix DN_De;
339  for (IndexType i = 0; i < rIntegrationPoints.size(); ++i)
340  {
341  rGeometry.ShapeFunctionsValues(N, rIntegrationPoints[i]);
342 
343  Matrix N_matrix = ZeroMatrix(1, N.size());
344  if (NumberOfShapeFunctionDerivatives >= 0) {
345  for (IndexType j = 0; j < N.size(); ++j)
346  {
347  N_matrix(0, j) = N[j];
348  }
349  }
350 
352  if (NumberOfShapeFunctionDerivatives > 0) {
353  rGeometry.ShapeFunctionsLocalGradients(DN_De, rIntegrationPoints[i]);
354  }
355 
357  default_method, rIntegrationPoints[i],
358  N_matrix, DN_De);
359 
361  rGeometry.WorkingSpaceDimension(), rGeometry.LocalSpaceDimension(),
362  data_container, rGeometry);
363  }
364  }
365 
369 
370  /* @brief This function updates the location of the respective
371  * QuadraturePointGeometry and resets the point vector and the parent.
372  */
374  typename GeometryType::Pointer pGeometry,
375  const array_1d<double, 3>& rLocalCoordinates,
376  const double rIntegrationWeight,
377  GeometryType& rParentGeometry)
378  {
379  pGeometry->SetGeometryParent(&rParentGeometry);
380  pGeometry->Points() = rParentGeometry.Points();
381 
382  IntegrationPoint<3> int_p(rLocalCoordinates, rIntegrationWeight);
383 
384  Vector N;
385  pGeometry->ShapeFunctionsValues(N, rLocalCoordinates);
386  Matrix N_matrix(1, N.size());
387  for (IndexType i = 0; i < N.size(); ++i) {
388  N_matrix(0, i) = N[i];
389  }
390 
391  Matrix DN_De;
392  pGeometry->ShapeFunctionsLocalGradients(DN_De, rLocalCoordinates);
393 
395  pGeometry->GetDefaultIntegrationMethod(), int_p, N_matrix, DN_De);
396 
397  pGeometry->SetGeometryShapeFunctionContainer(data_container);
398  }
399 
400  };
402 } // namespace Kratos.
403 
404 #endif // KRATOS_QUADRATURE_POINTS_UTILITY_H_INCLUDED defined
A Class for the creation of integration points.
Definition: quadrature_points_utility.h:35
static GeometryType::Pointer CreateFromLocalCoordinates(GeometryType &rGeometry, const array_1d< double, 3 > &rLocalCoordinates, double integration_weight)
Definition: quadrature_points_utility.h:67
Geometry< TPointType > GeometryType
Definition: quadrature_points_utility.h:40
static GeometryPointerType CreateQuadraturePoint(SizeType WorkingSpaceDimension, SizeType LocalSpaceDimension, GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints)
Definition: quadrature_points_utility.h:210
static GeometryType::Pointer CreateFromCoordinates(typename GeometryType::Pointer pGeometry, const array_1d< double, 3 > &rCoordinates, double integration_weight)
Definition: quadrature_points_utility.h:52
PointerVector< TPointType > PointsArrayType
Definition: quadrature_points_utility.h:46
static std::vector< GeometryPointerType > Create(GeometryPointerType pGeometry)
Definition: quadrature_points_utility.h:254
static GeometryPointerType CreateQuadraturePointSurfaceInVolume(GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, Matrix LocalTangentMatrix, GeometryType *pGeometryParent)
Definition: quadrature_points_utility.h:133
static void Create(GeometryType &rGeometry, typename GeometryType::GeometriesArrayType &rResultGeometries, typename GeometryType::IntegrationPointsArrayType &rIntegrationPoints, SizeType NumberOfShapeFunctionDerivatives)
creates a quadrature point geometry on a provided location.
Definition: quadrature_points_utility.h:321
static GeometryPointerType CreateQuadraturePointCurveOnSurface(GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, double LocalTangentU, double LocalTangentV, GeometryType *pGeometryParent)
Definition: quadrature_points_utility.h:103
std::size_t SizeType
Definition: quadrature_points_utility.h:43
static std::vector< GeometryPointerType > Create(GeometryPointerType pGeometry, GeometryData::IntegrationMethod ThisIntegrationMethod)
Definition: quadrature_points_utility.h:287
Geometry< TPointType >::Pointer GeometryPointerType
Definition: quadrature_points_utility.h:41
static GeometryPointerType CreateQuadraturePoint(SizeType WorkingSpaceDimension, SizeType LocalSpaceDimension, GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, GeometryType *pGeometryParent)
Definition: quadrature_points_utility.h:159
static GeometryPointerType CreateQuadraturePointCurveOnSurface(GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, double LocalTangentU, double LocalTangentV)
Definition: quadrature_points_utility.h:119
static void UpdateFromLocalCoordinates(typename GeometryType::Pointer pGeometry, const array_1d< double, 3 > &rLocalCoordinates, const double rIntegrationWeight, GeometryType &rParentGeometry)
Definition: quadrature_points_utility.h:373
static GeometryPointerType CreateQuadraturePointSurfaceInVolume(GeometryShapeFunctionContainer< GeometryData::IntegrationMethod > &rShapeFunctionContainer, PointsArrayType rPoints, Matrix LocalTangentMatrix)
Definition: quadrature_points_utility.h:147
std::size_t IndexType
Definition: quadrature_points_utility.h:44
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
std::vector< IntegrationPointType > IntegrationPointsArrayType
Definition: geometry.h:161
SizeType LocalSpaceDimension() const
Definition: geometry.h:1300
const Matrix & ShapeFunctionsValues() const
Definition: geometry.h:3393
const PointsArrayType & Points() const
Definition: geometry.h:1768
IntegrationMethod GetDefaultIntegrationMethod() const
Definition: geometry.h:2004
const ShapeFunctionsGradientsType & ShapeFunctionsLocalGradients() const
Definition: geometry.h:3539
SizeType WorkingSpaceDimension() const
Definition: geometry.h:1287
Definition: geometry_shape_function_container.h:60
Short class definition.
Definition: integration_point.h:52
size_type size() const
Definition: pointer_vector.h:255
void resize(size_type dim)
Definition: pointer_vector.h:314
Definition: quadrature_point_curve_on_surface_geometry.h:43
A sinlge quadrature point, that can be used for geometries without a predefined integration scheme,...
Definition: quadrature_point_geometry.h:44
A sinlge quadrature point, that can be used for geometries without a predefined integration scheme,...
Definition: quadrature_point_surface_in_volume_geometry.h:40
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#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
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
shared_ptr< C > make_shared(Args &&...args)
Definition: smart_pointers.h:40
int j
Definition: quadrature.py:648
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17