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.
gauss_point_item.h
Go to the documentation of this file.
1 // KRATOS __ __ _____ ____ _ _ ___ _ _ ____
2 // | \/ | ____/ ___|| | | |_ _| \ | |/ ___|
3 // | |\/| | _| \___ \| |_| || || \| | | _
4 // | | | | |___ ___) | _ || || |\ | |_| |
5 // |_| |_|_____|____/|_| |_|___|_| \_|\____| APPLICATION
6 //
7 // License: BSD License
8 // license: MeshingApplication/license.txt
9 //
10 // Main authors: Vicente Mataix Ferrandiz
11 //
12 
13 #if !defined(KRATOS_GAUSS_POINT_ITEM )
14 #define KRATOS_GAUSS_POINT_ITEM
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "geometries/point.h"
23 
24 namespace Kratos
25 {
28 
32 
36 
40 
44 
52  : public Point
53 {
54 public:
55 
58 
60  typedef std::size_t IndexType;
61 
64 
68 
74  Point()
75  {
76  }
77 
84  {
85  }
86 
93  ConstitutiveLaw::Pointer pConstitutiveLaw,
94  const double Weight
95  ):Point(Coordinates),
96  mpConstitutiveLaw(std::move(pConstitutiveLaw)),
97  mWeight(Weight)
98  {
99  }
100 
102  GaussPointItem(const GaussPointItem& GP)= default;
103 
105  ~GaussPointItem() override= default;
106 
110 
114 
120  {
121  Point Point(this->Coordinates());
122 
123  return Point;
124  }
125 
130  void SetPoint(const Point& Point)
131  {
132  this->Coordinates() = Point.Coordinates();
133  }
134 
140  void SetConstitutiveLaw(ConstitutiveLaw::Pointer pConstitutiveLaw)
141  {
142  mpConstitutiveLaw = pConstitutiveLaw;
143  }
144 
150  ConstitutiveLaw::Pointer GetConstitutiveLaw()
151  {
152  return mpConstitutiveLaw;
153  }
154 
160  double GetWeight() const
161  {
162  return mWeight;
163  }
164 
170  void SetWeight(const double Weight)
171  {
172  mWeight = Weight;
173  }
174 
180  bool Has(const Variable<double>& rVariable)
181  {
182  const IndexType variable_key = rVariable.Key();
183  auto double_set = mMapDoubleVariables.find(variable_key);
184  if(double_set != mMapDoubleVariables.end()) {
185  return true;
186  }
187 
188  return false;
189  }
190 
196  bool Has(const Variable<array_1d<double, 3>>& rVariable)
197  {
198  const IndexType variable_key = rVariable.Key();
199  auto array_set = mMapArrayVariables.find(variable_key);
200  if(array_set != mMapArrayVariables.end()) {
201  return true;
202  }
203 
204  return false;
205  }
206 
212  bool Has(const Variable<Vector>& rVariable)
213  {
214  const IndexType variable_key = rVariable.Key();
215  auto vector_set = mMapVectorVariables.find(variable_key);
216  if(vector_set != mMapVectorVariables.end()) {
217  return true;
218  }
219 
220  return false;
221  }
222 
228  bool Has(const Variable<Matrix>& rVariable)
229  {
230  const IndexType variable_key = rVariable.Key();
231  auto matrix_set = mMapMatrixVariables.find(variable_key);
232  if(matrix_set != mMapMatrixVariables.end()) {
233  return true;
234  }
235 
236  return false;
237  }
238 
244  void SetValue(
245  const Variable<double>& rVariable,
246  const double rValue
247  )
248  {
249  const IndexType variable_key = rVariable.Key();
250  auto double_set = mMapDoubleVariables.find(variable_key);
251  if(double_set != mMapDoubleVariables.end()) {
252  mMapDoubleVariables[variable_key] = rValue;
253  return void();
254  }
255  mMapDoubleVariables.insert({variable_key, rValue});
256  }
257 
263  void SetValue(
264  const Variable<array_1d<double, 3>>& rVariable,
265  const array_1d<double, 3>& rValue
266  )
267  {
268  const IndexType variable_key = rVariable.Key();
269  auto array_set = mMapArrayVariables.find(variable_key);
270  if(array_set != mMapArrayVariables.end()) {
271  mMapArrayVariables[variable_key] = rValue;
272  return void();
273  }
274  mMapArrayVariables.insert({variable_key, rValue});
275  }
276 
282  void SetValue(
283  const Variable<Vector>& rVariable,
284  const Vector& rValue
285  )
286  {
287  const IndexType variable_key = rVariable.Key();
288  auto vector_set = mMapVectorVariables.find(variable_key);
289  if(vector_set != mMapVectorVariables.end()) {
290  mMapVectorVariables[variable_key] = rValue;
291  return void();
292  }
293  mMapVectorVariables.insert({variable_key, rValue});
294  }
295 
301  void SetValue(
302  const Variable<Matrix>& rVariable,
303  const Matrix& rValue
304  )
305  {
306  const IndexType variable_key = rVariable.Key();
307  auto matrix_set = mMapMatrixVariables.find(variable_key);
308  if(matrix_set != mMapMatrixVariables.end()) {
309  mMapMatrixVariables[variable_key] = rValue;
310  return void();
311  }
312  mMapMatrixVariables.insert({variable_key, rValue});
313  }
314 
321  double GetValue(
322  const Variable<double>& rVariable,
323  double& rValue
324  )
325  {
326  rValue = mMapDoubleVariables[rVariable.Key()];
327  return rValue;
328  }
329 
337  const Variable<array_1d<double, 3>>& rVariable,
338  array_1d<double, 3>& rValue
339  )
340  {
341  rValue = mMapArrayVariables[rVariable.Key()];
342  return rValue;
343  }
344 
352  const Variable<Vector>& rVariable,
353  Vector& rValue
354  )
355  {
356  rValue = mMapVectorVariables[rVariable.Key()];
357  return rValue;
358  }
359 
367  const Variable<Matrix>& rVariable,
368  Matrix& rValue
369  )
370  {
371  rValue = mMapMatrixVariables[rVariable.Key()];
372  return rValue;
373  }
374 
379  void RemoveId(const IndexType VariableKey)
380  {
381  auto double_set = mMapDoubleVariables.find(VariableKey);
382  if(double_set != mMapDoubleVariables.end()) {
383  mMapDoubleVariables.erase(double_set);
384  return void();
385  }
386  auto array_set = mMapArrayVariables.find(VariableKey);
387  if(array_set != mMapArrayVariables.end()) {
388  mMapArrayVariables.erase(array_set);
389  return void();
390  }
391  auto vector_set = mMapVectorVariables.find(VariableKey);
392  if(vector_set != mMapVectorVariables.end()) {
393  mMapVectorVariables.erase(vector_set);
394  return void();
395  }
396  auto matrix_set = mMapMatrixVariables.find(VariableKey);
397  if(matrix_set != mMapMatrixVariables.end()) {
398  mMapMatrixVariables.erase(matrix_set);
399  return void();
400  }
401  }
402 protected:
403 
406 
410 
414 
418 
422 
426 
431 
432 private:
438 
439  ConstitutiveLaw::Pointer mpConstitutiveLaw;
440  double mWeight;
441 
442  /* For values not available on the constitutive law */
443  std::unordered_map<IndexType,double> mMapDoubleVariables;
444  std::unordered_map<IndexType,array_1d<double, 3>> mMapArrayVariables;
445  std::unordered_map<IndexType,Vector> mMapVectorVariables;
446  std::unordered_map<IndexType,Matrix> mMapMatrixVariables;
447 
451 
455 
460 
464 
468 
472 }; // Class GaussPointItem
474 
477 
481 
483 
484 } // namespace Kratos.
485 
486 #endif // KRATOS_GAUSS_POINT_ITEM defined
Custom Gauss Point container to be used by the search.
Definition: gauss_point_item.h:53
void SetWeight(const double Weight)
Sets the integration weigth associated to the point.
Definition: gauss_point_item.h:170
double GetWeight() const
Returns the integration weigth associated to the point.
Definition: gauss_point_item.h:160
array_1d< double, 3 > GetValue(const Variable< array_1d< double, 3 >> &rVariable, array_1d< double, 3 > &rValue)
It return a value from the map (array_1d<double, 3>)
Definition: gauss_point_item.h:336
void SetValue(const Variable< Vector > &rVariable, const Vector &rValue)
It adds a new value to the map (Vector)
Definition: gauss_point_item.h:282
Point GetPoint()
Returns the point.
Definition: gauss_point_item.h:119
~GaussPointItem() override=default
Destructor.
double GetValue(const Variable< double > &rVariable, double &rValue)
It return a value from the map (double)
Definition: gauss_point_item.h:321
ConstitutiveLaw::Pointer GetConstitutiveLaw()
Returns the Constitutive Law associated to the point.
Definition: gauss_point_item.h:150
GaussPointItem(const GaussPointItem &GP)=default
Copy constructor (not really required)
Vector GetValue(const Variable< Vector > &rVariable, Vector &rValue)
It return a value from the map (Vector)
Definition: gauss_point_item.h:351
bool Has(const Variable< array_1d< double, 3 >> &rVariable)
It checks if an ID exists in the map.
Definition: gauss_point_item.h:196
void SetValue(const Variable< Matrix > &rVariable, const Matrix &rValue)
It adds a new value to the map (Matrix)
Definition: gauss_point_item.h:301
void RemoveId(const IndexType VariableKey)
It removes one particular pair from the map.
Definition: gauss_point_item.h:379
KRATOS_CLASS_POINTER_DEFINITION(GaussPointItem)
Counted pointer of GaussPointItem.
Matrix GetValue(const Variable< Matrix > &rVariable, Matrix &rValue)
It return a value from the map (Matrix)
Definition: gauss_point_item.h:366
GaussPointItem(const array_1d< double, 3 > &Coordinates)
Constructor with coordinates.
Definition: gauss_point_item.h:82
void SetValue(const Variable< double > &rVariable, const double rValue)
It adds a new value to the map (double)
Definition: gauss_point_item.h:244
void SetValue(const Variable< array_1d< double, 3 >> &rVariable, const array_1d< double, 3 > &rValue)
It adds a new value to the map (array_1d<double, 3>)
Definition: gauss_point_item.h:263
bool Has(const Variable< Matrix > &rVariable)
It checks if an ID exists in the map.
Definition: gauss_point_item.h:228
void SetConstitutiveLaw(ConstitutiveLaw::Pointer pConstitutiveLaw)
Sets the Constitutive Law associated to the point.
Definition: gauss_point_item.h:140
GaussPointItem(const array_1d< double, 3 > &Coordinates, ConstitutiveLaw::Pointer pConstitutiveLaw, const double Weight)
Complete constructor.
Definition: gauss_point_item.h:91
void SetPoint(const Point &Point)
Set the point.
Definition: gauss_point_item.h:130
bool Has(const Variable< Vector > &rVariable)
It checks if an ID exists in the map.
Definition: gauss_point_item.h:212
GaussPointItem()
Default constructor.
Definition: gauss_point_item.h:73
bool Has(const Variable< double > &rVariable)
It checks if an ID exists in the map.
Definition: gauss_point_item.h:180
std::size_t IndexType
The type used to idenify index and key.
Definition: gauss_point_item.h:60
Point class.
Definition: point.h:59
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
std::size_t IndexType
Definition: point.h:79
Point()
Default constructor.
Definition: point.h:86
KeyType Key() const
Definition: variable_data.h:187
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
namespace
Definition: array_1d.h:793