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.
wave_element.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 authors: Miguel Maso Sotomayor
11 //
12 
13 #ifndef KRATOS_WAVE_ELEMENT_H_INCLUDED
14 #define KRATOS_WAVE_ELEMENT_H_INCLUDED
15 
16 // System includes
17 
18 
19 // External includes
20 
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "includes/element.h"
25 #include "includes/serializer.h"
27 
28 namespace Kratos
29 {
32 
35 
39 
43 
47 
51 
53 template<std::size_t TNumNodes>
54 class WaveElement : public Element
55 {
56 public:
59 
60  typedef std::size_t IndexType;
61 
62  typedef Node NodeType;
63 
65 
67 
69 
72 
76 
80 
85 
89  WaveElement(IndexType NewId, const NodesArrayType& ThisNodes) : Element(NewId, ThisNodes){}
90 
94  WaveElement(IndexType NewId, GeometryType::Pointer pGeometry) : Element(NewId, pGeometry){}
95 
99  WaveElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties) : Element(NewId, pGeometry, pProperties){}
100 
104  ~ WaveElement() override {};
105 
109 
117  Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override
118  {
119  return Kratos::make_intrusive<WaveElement<TNumNodes>>(NewId, this->GetGeometry().Create(ThisNodes), pProperties);
120  }
121 
129  Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
130  {
131  return Kratos::make_intrusive<WaveElement<TNumNodes>>(NewId, pGeom, pProperties);
132  }
133 
140  Element::Pointer Clone(IndexType NewId, NodesArrayType const& ThisNodes) const override
141  {
142  Element::Pointer p_new_elem = Create(NewId, this->GetGeometry().Create(ThisNodes), this->pGetProperties());
143  p_new_elem->SetData(this->GetData());
144  p_new_elem->Set(Flags(*this));
145  return p_new_elem;
146  }
147 
152  int Check(const ProcessInfo& rCurrentProcessInfo) const override;
153 
159  void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override;
160 
166  void GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo& rCurrentProcessInfo) const override;
167 
171  void GetValuesVector(Vector& rValues, int Step = 0) const override;
172 
176  void GetFirstDerivativesVector(Vector& rValues, int Step = 0) const override;
177 
181  void GetSecondDerivativesVector(Vector& rValues, int Step = 0) const override;
182 
190  const Variable<double>& rVariable,
191  std::vector<double>& rValues,
192  const ProcessInfo& rCurrentProcessInfo) override;
193 
200  void Calculate(
201  const Variable<array_1d<double,3>>& rVariable,
202  array_1d<double,3>& rOutput,
203  const ProcessInfo& rCurrentProcessInfo) override;
204 
208  void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override;
209 
216  void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix, VectorType& rRightHandSideVector, const ProcessInfo& rCurrentProcessInfo) override;
217 
223  void CalculateMassMatrix(MatrixType& rMassMatrix, const ProcessInfo& rCurrentProcessInfo) override;
224 
230  void CalculateDampingMatrix(MatrixType& rDampingMatrix, const ProcessInfo& rCurrentProcessInfo) override;
231 
235 
241 
246  const Parameters GetSpecifications() const override;
247 
251 
255  std::string Info() const override
256  {
257  return "WaveElement";
258  }
259 
263  void PrintInfo(std::ostream& rOStream) const override
264  {
265  rOStream << Info() << " : " << Id();
266  }
267 
271  void PrintData(std::ostream& rOStream) const override
272  {
273  rOStream << GetGeometry();
274  }
275 
279 
280 
282 
283 protected:
286 
287  static constexpr IndexType mLocalSize = 3 * TNumNodes;
288 
292 
293 
297 
298  struct ElementData
299  {
301  double stab_factor;
304  double gravity;
305  double length;
308 
309  double depth;
310  double height;
312 
317 
328 
329  FrictionLaw::Pointer p_bottom_friction;
330  };
331 
335 
336  virtual const Variable<double>& GetUnknownComponent(int Index) const;
337 
338  virtual LocalVectorType GetUnknownVector(const ElementData& rData) const;
339 
340  virtual void InitializeData(ElementData& rData, const ProcessInfo& rCurrentProcessInfo);
341 
342  virtual void GetNodalData(ElementData& rData, const GeometryType& rGeometry, int Step = 0);
343 
344  virtual void UpdateGaussPointData(ElementData& rData, const array_1d<double,TNumNodes>& rN);
345 
347  const GeometryType& rGeometry,
348  Vector &rGaussWeights,
349  Matrix &rNContainer,
351 
352  static double ShapeFunctionProduct(
353  const array_1d<double,TNumNodes>& rN,
354  const std::size_t I,
355  const std::size_t J);
356 
358  const array_1d<array_1d<double,3>,TNumNodes>& rV,
359  const array_1d<double,TNumNodes>& rN);
360 
362  const array_1d<double,TNumNodes>& rS,
363  const BoundedMatrix<double,TNumNodes,2>& rDN_DX);
364 
365  static double VectorDivergence(
366  const array_1d<array_1d<double,3>,TNumNodes>& rV,
367  const BoundedMatrix<double,TNumNodes,2>& rDN_DX);
368 
370  const array_1d<array_1d<double,3>,TNumNodes>& rV,
371  const BoundedMatrix<double,TNumNodes,2>& rDN_DX);
372 
373  static double InverseHeight(const ElementData& rData);
374 
375  static double WetFraction(const ElementData& rData);
376 
377  virtual void CalculateArtificialViscosity(
378  BoundedMatrix<double,3,3>& rViscosity,
379  BoundedMatrix<double,2,2>& rDiffusion,
380  const ElementData& rData,
381  const array_1d<double,TNumNodes>& rN,
382  const BoundedMatrix<double,TNumNodes,2>& rDN_DX);
383 
384  virtual void CalculateArtificialDamping(
385  BoundedMatrix<double,3,3>& rDamping,
386  const ElementData& rData);
387 
388  void AddWaveTerms(
389  LocalMatrixType& rMatrix,
390  LocalVectorType& rVector,
391  const ElementData& rData,
392  const array_1d<double,TNumNodes>& rN,
393  const BoundedMatrix<double,TNumNodes,2>& rDN_DX,
394  const double Weight = 1.0);
395 
396  void AddFrictionTerms(
397  LocalMatrixType& rMatrix,
398  LocalVectorType& rVector,
399  const ElementData& rData,
400  const array_1d<double,TNumNodes>& rN,
401  const BoundedMatrix<double,TNumNodes,2>& rDN_DX,
402  const double Weight = 1.0);
403 
405  LocalMatrixType& rMatrix,
406  LocalVectorType& rVector,
407  const ElementData& rData,
408  const array_1d<double,TNumNodes>& rN,
409  const BoundedMatrix<double,TNumNodes,2>& rDN_DX,
410  const double Weight = 1.0);
411 
412  virtual void AddDispersiveTerms(
413  LocalVectorType& rVector,
414  const ElementData& rData,
415  const array_1d<double,TNumNodes>& rN,
416  const BoundedMatrix<double,TNumNodes,2>& rDN_DX,
417  const double Weight = 1.0);
418 
419  virtual void AddMassTerms(
420  LocalMatrixType& rMatrix,
421  const ElementData& rData,
422  const array_1d<double,TNumNodes>& rN,
423  const BoundedMatrix<double,TNumNodes,2>& rDN_DX,
424  const double Weight = 1.0);
425 
426  virtual double StabilizationParameter(const ElementData& rData) const;
427 
429 
430 private:
433 
434 
438 
439 
443 
444  friend class Serializer;
445 
446  void save(Serializer& rSerializer) const override
447  {
449  }
450 
451  void load(Serializer& rSerializer) override
452  {
454  }
455 
459 
460 
462 
463 }; // Class WaveElement
464 
468 
469 
473 
474 
476 
478 
479 } // namespace Kratos.
480 
481 #endif // KRATOS_WAVE_ELEMENT_H_INCLUDED defined
Base class for all Elements.
Definition: element.h:60
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
Matrix MatrixType
Definition: element.h:90
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
PropertiesType::Pointer pGetProperties()
returns the pointer to the property of the element. Does not throw an error, to allow copying of elem...
Definition: element.h:1014
std::size_t IndexType
Definition: flags.h:74
Flags()
Default constructor.
Definition: flags.h:119
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
DataValueContainer & GetData()
Definition: geometrical_object.h:212
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
virtual Pointer Create(PointsArrayType const &rThisPoints) const
Creates a new geometry pointer.
Definition: geometry.h:813
IndexType Id() const
Definition: indexed_object.h:107
Definition: amatrix_interface.h:41
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
Implementation of a linear element for shallow water problems.
Definition: wave_element.h:55
virtual void AddDispersiveTerms(LocalVectorType &rVector, const ElementData &rData, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX, const double Weight=1.0)
Definition: wave_element.cpp:567
Node NodeType
Definition: wave_element.h:62
GeometryData::IntegrationMethod GetIntegrationMethod() const override
GetIntegrationMethod Return the integration order to be used.
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
Fill given array with containing the element's degrees of freedom.
Definition: wave_element.cpp:96
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, PropertiesType::Pointer pProperties) const override
Create a new element pointer.
Definition: wave_element.h:129
virtual void CalculateArtificialDamping(BoundedMatrix< double, 3, 3 > &rDamping, const ElementData &rData)
Definition: wave_element.cpp:436
void AddFrictionTerms(LocalMatrixType &rMatrix, LocalVectorType &rVector, const ElementData &rData, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX, const double Weight=1.0)
Definition: wave_element.cpp:526
std::size_t IndexType
Definition: wave_element.h:60
virtual void CalculateArtificialViscosity(BoundedMatrix< double, 3, 3 > &rViscosity, BoundedMatrix< double, 2, 2 > &rDiffusion, const ElementData &rData, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX)
Definition: wave_element.cpp:425
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
Calculate the elemental mass matrix.
Definition: wave_element.cpp:710
GeometryType::ShapeFunctionsGradientsType ShapeFunctionsGradientsType
Definition: wave_element.h:68
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(WaveElement)
Pointer definition.
Element::Pointer Clone(IndexType NewId, NodesArrayType const &ThisNodes) const override
Create a new element pointer and clone the previous element data.
Definition: wave_element.h:140
virtual void GetNodalData(ElementData &rData, const GeometryType &rGeometry, int Step=0)
Definition: wave_element.cpp:217
void AddArtificialViscosityTerms(LocalMatrixType &rMatrix, LocalVectorType &rVector, const ElementData &rData, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX, const double Weight=1.0)
Definition: wave_element.cpp:577
WaveElement(IndexType NewId, const NodesArrayType &ThisNodes)
Constructor using an array of nodes.
Definition: wave_element.h:89
static double ShapeFunctionProduct(const array_1d< double, TNumNodes > &rN, const std::size_t I, const std::size_t J)
Definition: wave_element.cpp:338
~ WaveElement() override
Destructor.
Definition: wave_element.h:104
void CalculateGeometryData(const GeometryType &rGeometry, Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionsGradientsType &rDN_DX)
Definition: wave_element.cpp:305
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
Fill given vector with the linear system row index for the element's degrees of freedom.
Definition: wave_element.cpp:75
static double WetFraction(const ElementData &rData)
Definition: wave_element.cpp:417
static constexpr IndexType mLocalSize
Definition: wave_element.h:287
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Check that all required data containers are properly initialized and registered in Kratos.
Definition: wave_element.cpp:45
void CalculateOnIntegrationPoints(const Variable< double > &rVariable, std::vector< double > &rValues, const ProcessInfo &rCurrentProcessInfo) override
Access for variables on Integration points.
Definition: wave_element.cpp:157
void Calculate(const Variable< array_1d< double, 3 >> &rVariable, array_1d< double, 3 > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Access for variables on Integration points.
Definition: wave_element.cpp:750
static array_1d< double, 3 > VectorProduct(const array_1d< array_1d< double, 3 >, TNumNodes > &rV, const array_1d< double, TNumNodes > &rN)
Definition: wave_element.cpp:348
void InitializeSolutionStep(const ProcessInfo &rCurrentProcessInfo) override
Is called in the beginning of each solution step.
Definition: wave_element.cpp:168
static array_1d< double, 3 > ScalarGradient(const array_1d< double, TNumNodes > &rS, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX)
Definition: wave_element.cpp:362
BoundedMatrix< double, 3 *TNumNodes, 3 *TNumNodes > LocalMatrixType
Definition: wave_element.h:66
void CalculateDampingMatrix(MatrixType &rDampingMatrix, const ProcessInfo &rCurrentProcessInfo) override
Calculate the diffusion matrix for monotonic corrected schemes.
Definition: wave_element.cpp:744
static double InverseHeight(const ElementData &rData)
Definition: wave_element.cpp:409
WaveElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties)
Constructor using Geometry and Properties.
Definition: wave_element.h:99
void GetSecondDerivativesVector(Vector &rValues, int Step=0) const override
Get the second time derivative of variable which defines the degrees of freedom.
Definition: wave_element.cpp:150
array_1d< double, 3 *TNumNodes > LocalVectorType
Definition: wave_element.h:64
virtual const Variable< double > & GetUnknownComponent(int Index) const
Definition: wave_element.cpp:174
void AddWaveTerms(LocalMatrixType &rMatrix, LocalVectorType &rVector, const ElementData &rData, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX, const double Weight=1.0)
Definition: wave_element.cpp:458
void GetValuesVector(Vector &rValues, int Step=0) const override
Get the variable which defines the degrees of freedom.
Definition: wave_element.cpp:117
virtual double StabilizationParameter(const ElementData &rData) const
Definition: wave_element.cpp:656
WaveElement(IndexType NewId, GeometryType::Pointer pGeometry)
Constructor using Geometry.
Definition: wave_element.h:94
std::string Info() const override
Turn back information as a string.
Definition: wave_element.h:255
virtual LocalVectorType GetUnknownVector(const ElementData &rData) const
Definition: wave_element.cpp:186
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: wave_element.h:263
virtual void UpdateGaussPointData(ElementData &rData, const array_1d< double, TNumNodes > &rN)
Definition: wave_element.cpp:231
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
Calculate the elemental contribution to the problem.
Definition: wave_element.cpp:664
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const override
Create a new element pointer.
Definition: wave_element.h:117
void GetFirstDerivativesVector(Vector &rValues, int Step=0) const override
Get the time derivative of variable which defines the degrees of freedom.
Definition: wave_element.cpp:134
static BoundedMatrix< double, 3, 3 > VectorGradient(const array_1d< array_1d< double, 3 >, TNumNodes > &rV, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX)
Definition: wave_element.cpp:392
WaveElement()
Default constructor.
Definition: wave_element.h:84
const Parameters GetSpecifications() const override
This method provides the specifications/requirements of the element.
Definition: wave_element.cpp:32
virtual void InitializeData(ElementData &rData, const ProcessInfo &rCurrentProcessInfo)
Definition: wave_element.cpp:200
virtual void AddMassTerms(LocalMatrixType &rMatrix, const ElementData &rData, const array_1d< double, TNumNodes > &rN, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX, const double Weight=1.0)
Definition: wave_element.cpp:625
static double VectorDivergence(const array_1d< array_1d< double, 3 >, TNumNodes > &rV, const BoundedMatrix< double, TNumNodes, 2 > &rDN_DX)
Definition: wave_element.cpp:377
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: wave_element.h:271
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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
def Index()
Definition: hdf5_io_tools.py:38
def load(f)
Definition: ode_solve.py:307
J
Definition: sensitivityMatrix.py:58
Definition: wave_element.h:299
double stab_factor
Definition: wave_element.h:301
double length
Definition: wave_element.h:305
array_1d< array_1d< double, 3 >, TNumNodes > nodal_q
Definition: wave_element.h:323
double height
Definition: wave_element.h:310
array_1d< double, TNumNodes > nodal_f
Definition: wave_element.h:318
array_1d< array_1d< double, 3 >, TNumNodes > nodal_a
Definition: wave_element.h:324
array_1d< double, TNumNodes > nodal_w
Definition: wave_element.h:321
array_1d< array_1d< double, 3 >, TNumNodes > nodal_Jh
Definition: wave_element.h:325
double relative_dry_height
Definition: wave_element.h:303
double depth
Definition: wave_element.h:309
double gravity
Definition: wave_element.h:304
array_1d< double, 3 > velocity
Definition: wave_element.h:311
BoundedMatrix< double, 3, 3 > A1
Definition: wave_element.h:313
bool integrate_by_parts
Definition: wave_element.h:300
BoundedMatrix< double, 3, 3 > A2
Definition: wave_element.h:314
array_1d< array_1d< double, 3 >, TNumNodes > nodal_v_mesh
Definition: wave_element.h:327
array_1d< array_1d< double, 3 >, TNumNodes > nodal_Ju
Definition: wave_element.h:326
double absorbing_distance
Definition: wave_element.h:306
double absorbing_damping
Definition: wave_element.h:307
array_1d< double, 3 > b1
Definition: wave_element.h:315
FrictionLaw::Pointer p_bottom_friction
Definition: wave_element.h:329
array_1d< double, TNumNodes > nodal_h
Definition: wave_element.h:319
double shock_stab_factor
Definition: wave_element.h:302
array_1d< double, TNumNodes > nodal_z
Definition: wave_element.h:320
array_1d< double, 3 > b2
Definition: wave_element.h:316
array_1d< array_1d< double, 3 >, TNumNodes > nodal_v
Definition: wave_element.h:322