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.
fluid_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: Jordi Cotela
11 //
12 
13 #ifndef KRATOS_FLUID_ELEMENT_H
14 #define KRATOS_FLUID_ELEMENT_H
15 
16 #include "includes/checks.h"
17 #include "includes/define.h"
18 #include "includes/element.h"
19 #include "includes/serializer.h"
21 #include "geometries/geometry.h"
22 
23 #include "includes/cfd_variables.h"
26 
27 
28 namespace Kratos
29 {
30 
33 
36 
40 
44 
48 
52 
53 // Forward decalration of auxiliary class
54 namespace Internals {
55 template <class TElementData, bool TDataKnowsAboutTimeIntegration>
56 class FluidElementTimeIntegrationDetail;
57 }
58 
59 template <class TElementData>
60 class FluidElement : public Element
61 {
62 public:
65 
68 
70  typedef Node NodeType;
71 
74 
77 
79  typedef Vector VectorType;
80 
82  typedef Matrix MatrixType;
83 
84  typedef std::size_t IndexType;
85 
86  typedef std::size_t SizeType;
87 
88  typedef std::vector<std::size_t> EquationIdVectorType;
89 
90  typedef std::vector< Dof<double>::Pointer > DofsVectorType;
91 
93 
96 
99 
102 
103  using ElementData = TElementData;
104 
105  static constexpr unsigned int Dim = TElementData::Dim;
106 
107  static constexpr unsigned int NumNodes = TElementData::NumNodes;
108 
109  static constexpr unsigned int BlockSize = Dim + 1;
110 
111  static constexpr unsigned int LocalSize = NumNodes * BlockSize;
112 
113  static constexpr unsigned int StrainSize = TElementData::StrainSize;
114 
118 
119  //Constructors.
120 
122 
125  FluidElement(IndexType NewId = 0);
126 
128 
132  FluidElement(IndexType NewId, const NodesArrayType& ThisNodes);
133 
135 
139  FluidElement(IndexType NewId, GeometryType::Pointer pGeometry);
140 
142 
147  FluidElement(IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties);
148 
150  virtual ~FluidElement();
151 
155 
156 
160 
161 
163 
170  Element::Pointer Create(IndexType NewId,
171  NodesArrayType const& ThisNodes,
172  Properties::Pointer pProperties) const override;
173 
175 
182  Element::Pointer Create(IndexType NewId,
183  GeometryType::Pointer pGeom,
184  Properties::Pointer pProperties) const override;
185 
187 
189  void Initialize(const ProcessInfo &rCurrentProcessInfo) override;
190 
200  MatrixType& rLeftHandSideMatrix,
201  VectorType& rRightHandSideVector,
202  const ProcessInfo& rCurrentProcessInfo) override;
203 
212  MatrixType& rLeftHandSideMatrix,
213  const ProcessInfo& rCurrentProcessInfo) override;
214 
223  VectorType& rRightHandSideVector,
224  const ProcessInfo& rCurrentProcessInfo) override;
225 
233  MatrixType &rDampMatrix,
234  VectorType &rRightHandSideVector,
235  const ProcessInfo &rCurrentProcessInfo) override;
236 
242  void CalculateMassMatrix(
243  MatrixType &rMassMatrix,
244  const ProcessInfo &rCurrentProcessInfo) override;
245 
246 
252  void EquationIdVector(
253  EquationIdVectorType& rResult,
254  const ProcessInfo& rCurrentProcessInfo) const override;
255 
261  void GetDofList(
262  DofsVectorType& rElementalDofList,
263  const ProcessInfo& rCurrentProcessInfo) const override;
264 
265 
271  void GetFirstDerivativesVector(Vector& Values, int Step = 0) const override;
272 
273 
274 
280  void GetSecondDerivativesVector(Vector& Values, int Step = 0) const override;
281 
282 
288 
289 
293 
295  Variable<array_1d<double, 3>> const& rVariable,
296  std::vector<array_1d<double, 3>>& rValues,
297  ProcessInfo const& rCurrentProcessInfo) override;
298 
300  Variable<double> const& rVariable,
301  std::vector<double>& rValues,
302  ProcessInfo const& rCurrentProcessInfo) override;
303 
305  Variable<array_1d<double, 6>> const& rVariable,
306  std::vector<array_1d<double, 6>>& rValues,
307  ProcessInfo const& rCurrentProcessInfo) override;
308 
310  Variable<Vector> const& rVariable,
311  std::vector<Vector>& rValues,
312  ProcessInfo const& rCurrentProcessInfo) override;
313 
315  Variable<Matrix> const& rVariable,
316  std::vector<Matrix>& rValues,
317  ProcessInfo const& rCurrentProcessInfo) override;
318 
322 
323  int Check(const ProcessInfo &rCurrentProcessInfo) const override;
324 
328 
330  std::string Info() const override;
331 
332 
334  void PrintInfo(std::ostream& rOStream) const override;
335 
336 
340 
341 
343 
344 protected:
345 
348 
349 
353 
354 
358 
359 
363 
365 
371  virtual double GetAtCoordinate(
372  const typename TElementData::NodalScalarData& rValues,
373  const typename TElementData::ShapeFunctionsType& rN) const;
374 
376 
383  const typename TElementData::NodalVectorData& rValues,
384  const typename TElementData::ShapeFunctionsType& rN) const;
385 
387 
394  const typename TElementData::NodalTensorData &rValues,
395  const typename TElementData::ShapeFunctionsType &rN) const;
396 
398 
404  virtual double GetAtCoordinate(
405  const double Value,
406  const typename TElementData::ShapeFunctionsType& rN) const;
407 
409 
414  virtual void UpdateIntegrationPointData(
415  TElementData& rData,
416  unsigned int IntegrationPointIndex,
417  double Weight,
418  const typename TElementData::MatrixRowType& rN,
419  const typename TElementData::ShapeDerivativesType& rDN_DX) const;
420 
421  virtual void CalculateMaterialResponse(TElementData& rData) const;
422 
431  virtual void CalculateStrainRate(TElementData& rData) const;
432 
434  virtual void CalculateGeometryData(Vector& rGaussWeights,
435  Matrix& rNContainer,
436  ShapeFunctionDerivativesArrayType& rDN_DX) const;
437 
445  void ConvectionOperator(Vector& rResult,
446  const array_1d<double,3>& rConvVel,
447  const ShapeFunctionDerivativesType& DN_DX) const;
448 
449  virtual void AddTimeIntegratedSystem(
450  TElementData& rData,
451  MatrixType& rLHS,
452  VectorType& rRHS);
453 
454  virtual void AddTimeIntegratedLHS(
455  TElementData& rData,
456  MatrixType& rLHS);
457 
458  virtual void AddTimeIntegratedRHS(
459  TElementData& rData,
460  VectorType& rRHS);
461 
462  virtual void AddVelocitySystem(
463  TElementData& rData,
464  MatrixType& rLocalLHS,
465  VectorType& rLocalRHS);
466 
467  virtual void AddMassLHS(
468  TElementData& rData,
469  MatrixType& rMassMatrix);
470 
484  virtual void AddBoundaryTraction(
485  TElementData& rData,
486  const Vector& rUnitNormal,
487  MatrixType& rLHS,
488  VectorType& rRHS);
489 
491  const TElementData& rData,
492  array_1d<double,LocalSize>& rValues) const;
493 
494  void Calculate(
495  const Variable<double> &rVariable,
496  double &rOutput,
497  const ProcessInfo &rCurrentProcessInfo) override;
498 
499  void Calculate(
500  const Variable<array_1d<double, 3>> &rVariable,
501  array_1d<double, 3> &rOutput,
502  const ProcessInfo &rCurrentProcessInfo) override;
503 
504  void Calculate(
505  const Variable<Vector> &rVariable,
506  Vector &rOutput,
507  const ProcessInfo &rCurrentProcessInfo) override;
508 
509  void Calculate(
510  const Variable<Matrix> &rVariable,
511  Matrix &rOutput,
512  const ProcessInfo &rCurrentProcessInfo) override;
513 
517 
518  const ConstitutiveLaw::Pointer GetConstitutiveLaw() const;
519 
520  ConstitutiveLaw::Pointer GetConstitutiveLaw();
521 
525 
526 
530 
531 
533 
534 private:
535 
538 
542 
544  ConstitutiveLaw::Pointer mpConstitutiveLaw = nullptr;
545 
549 
550  friend class Internals::FluidElementTimeIntegrationDetail<TElementData, TElementData::ElementManagesTimeIntegration>;
551 
555 
556  friend class Serializer;
557 
558  void save(Serializer& rSerializer) const override;
559 
560  void load(Serializer& rSerializer) override;
561 
565 
566 
570 
571 
575 
576 
580 
581 
585 
587  FluidElement& operator=(FluidElement const& rOther);
588 
590  FluidElement(FluidElement const& rOther);
591 
593 
594 
595 }; // Class FluidElement
596 
597 namespace Internals {
598 
599 template< class TElementData, std::size_t TDim >
602 /* @param[out] rStrainRate The strain rate tensor (symmetric gradient of velocity) in Voigt notation.
603  * @param[in] rVelocities Matrix of nodal velocities, as provided by TElementData.
604  * @param[in] rDNDX Matrix of shape function gradients on the integration point, as provided by TElementData.
605  * @see ConstitutiveLaw.
606  */
607 static void Calculate(
608  Vector& rStrainRate,
609  const typename TElementData::NodalVectorData& rVelocities,
610  const typename TElementData::ShapeDerivativesType& rDNDX);
611 };
612 
613 template< class TElementData >
614 struct StrainRateSpecialization<TElementData,2> {
615 static void Calculate(
616  Vector& rStrainRate,
617  const typename TElementData::NodalVectorData& rVelocities,
618  const typename TElementData::ShapeDerivativesType& rDNDX);
619 };
620 
621 template< class TElementData >
622 struct StrainRateSpecialization<TElementData,3> {
623 static void Calculate(
624  Vector& rStrainRate,
625  const typename TElementData::NodalVectorData& rVelocities,
626  const typename TElementData::ShapeDerivativesType& rDNDX);
627 };
628 
629 }
630 
632 
635 
636 
640 
641 
643 template< class TElementData >
644 inline std::istream& operator >>(std::istream& rIStream,
646 {
647  return rIStream;
648 }
649 
651 template< class TElementData >
652 inline std::ostream& operator <<(std::ostream& rOStream,
653  const FluidElement<TElementData>& rThis)
654 {
655  rThis.PrintInfo(rOStream);
656  rOStream << std::endl;
657  rThis.PrintData(rOStream);
658 
659  return rOStream;
660 }
662 
664 
665 } // namespace Kratos.
666 
667 #endif // KRATOS_FLUID_ELEMENT_H
Base class for all Elements.
Definition: element.h:60
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
std::size_t IndexType
Definition: flags.h:74
Large Displacement Lagrangian Element for 3D and 2D geometries. (base class)
Definition: fluid_element.h:61
virtual ~FluidElement()
Destructor.
Definition: fluid_element.cpp:60
virtual void AddTimeIntegratedRHS(TElementData &rData, VectorType &rRHS)
Definition: fluid_element.cpp:764
GeometryType::ShapeFunctionsGradientsType ShapeFunctionDerivativesArrayType
Type for an array of shape function gradient matrices.
Definition: fluid_element.h:101
virtual void CalculateMaterialResponse(TElementData &rData) const
Definition: fluid_element.cpp:594
GeometryData::IntegrationMethod GetIntegrationMethod() const override
GetIntegrationMethod Return the integration order to be used.
Definition: fluid_element.cpp:366
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
EquationIdVector Returns the global system rows corresponding to each local row.
Definition: fluid_element.cpp:281
virtual double GetAtCoordinate(const typename TElementData::NodalScalarData &rValues, const typename TElementData::ShapeFunctionsType &rN) const
Get information from TElementData at a given point.
Definition: fluid_element.cpp:529
FluidElement()
Empty constructor needed for serialization.
Definition: fluid_element.cpp:33
Element::Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, Properties::Pointer pProperties) const override
Create a new element of this type.
virtual void AddMassLHS(TElementData &rData, MatrixType &rMassMatrix)
Definition: fluid_element.cpp:792
Vector VectorType
Vector type for local contributions to the linear system.
Definition: fluid_element.h:79
virtual void CalculateStrainRate(TElementData &rData) const
Calculate and save the strain rate in the data container This method calculates the strain rate with ...
Definition: fluid_element.cpp:613
std::size_t SizeType
Definition: fluid_element.h:86
static constexpr unsigned int Dim
Definition: fluid_element.h:105
FluidElement(IndexType NewId, GeometryType::Pointer pGeometry, Properties::Pointer pProperties)
Constuctor using geometry and properties.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: fluid_element.cpp:519
std::vector< Dof< double >::Pointer > DofsVectorType
Definition: fluid_element.h:90
static constexpr unsigned int NumNodes
Definition: fluid_element.h:107
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
GetDofList Returns a list of the element's Dofs.
Definition: fluid_element.cpp:304
const ConstitutiveLaw::Pointer GetConstitutiveLaw() const
Definition: fluid_element.cpp:841
MatrixRow< Matrix > ShapeFunctionsType
Type for shape function values container.
Definition: fluid_element.h:95
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(FluidElement)
Pointer definition of FluidElement.
std::string Info() const override
Turn back information as a string.
Definition: fluid_element.cpp:510
Matrix MatrixType
Matrix type for local contributions to the linear system.
Definition: fluid_element.h:82
Kratos::Matrix ShapeFunctionDerivativesType
Type for a matrix containing the shape function gradients.
Definition: fluid_element.h:98
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
CalculateLocalSystem Return empty matrices and vectors of appropriate size. This element does not hav...
Definition: fluid_element.cpp:105
static constexpr unsigned int LocalSize
Definition: fluid_element.h:111
void GetFirstDerivativesVector(Vector &Values, int Step=0) const override
GetFirstDerivativesVector Returns VELOCITY_X, VELOCITY_Y, (VELOCITY_Z,) PRESSURE for each node.
Definition: fluid_element.cpp:327
PointerVectorSet< Dof< double >, IndexedObject > DofsArrayType
Definition: fluid_element.h:92
void CalculateOnIntegrationPoints(Variable< array_1d< double, 3 >> const &rVariable, std::vector< array_1d< double, 3 >> &rValues, ProcessInfo const &rCurrentProcessInfo) override
void Initialize(const ProcessInfo &rCurrentProcessInfo) override
Set up the element for solution.
Definition: fluid_element.cpp:83
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
CalculateRightHandSide Return an empty matrix of appropriate size. This element does not have a local...
Definition: fluid_element.cpp:178
void ConvectionOperator(Vector &rResult, const array_1d< double, 3 > &rConvVel, const ShapeFunctionDerivativesType &DN_DX) const
Write the convective operator evaluated at this point (for each nodal funciton) to an array Evaluate ...
Definition: fluid_element.cpp:723
static constexpr unsigned int BlockSize
Definition: fluid_element.h:109
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
MassMatrix Calculate the local mass matrix.
Definition: fluid_element.cpp:248
virtual void CalculateGeometryData(Vector &rGaussWeights, Matrix &rNContainer, ShapeFunctionDerivativesArrayType &rDN_DX) const
Determine integration point weights and shape funcition derivatives from the element's geometry.
Definition: fluid_element.cpp:622
Geometry< NodeType >::PointsArrayType NodesArrayType
Definition of nodes container type, redefined from GeometryType.
Definition: fluid_element.h:76
std::vector< std::size_t > EquationIdVectorType
Definition: fluid_element.h:88
Geometry< NodeType > GeometryType
Geometry type (using with given NodeType)
Definition: fluid_element.h:73
std::size_t IndexType
Definition: fluid_element.h:84
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
CalculateLeftHandSide Return an empty matrix of appropriate size. This element does not have a local ...
Definition: fluid_element.cpp:145
void Calculate(const Variable< double > &rVariable, double &rOutput, const ProcessInfo &rCurrentProcessInfo) override
Definition: fluid_element.cpp:649
Element::Pointer Create(IndexType NewId, GeometryType::Pointer pGeom, Properties::Pointer pProperties) const override
Create a new element of this type using given geometry.
void GetCurrentValuesVector(const TElementData &rData, array_1d< double, LocalSize > &rValues) const
Definition: fluid_element.cpp:819
void GetSecondDerivativesVector(Vector &Values, int Step=0) const override
Returns ACCELERATION_X, ACCELERATION_Y, (ACCELERATION_Z,) 0 for each node.
Definition: fluid_element.cpp:347
void CalculateLocalVelocityContribution(MatrixType &rDampMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
CalculateLocalVelocityContribution Calculate the local contribution in terms of velocity and pressure...
Definition: fluid_element.cpp:210
virtual void AddBoundaryTraction(TElementData &rData, const Vector &rUnitNormal, MatrixType &rLHS, VectorType &rRHS)
Adds the boundary traction component along a cut plane for embedded formulations. This method adds th...
Definition: fluid_element.cpp:805
static constexpr unsigned int StrainSize
Definition: fluid_element.h:113
virtual void UpdateIntegrationPointData(TElementData &rData, unsigned int IntegrationPointIndex, double Weight, const typename TElementData::MatrixRowType &rN, const typename TElementData::ShapeDerivativesType &rDN_DX) const
Set up the element's data and constitutive law for the current integration point.
Definition: fluid_element.cpp:581
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: fluid_element.hpp:584
virtual void AddTimeIntegratedSystem(TElementData &rData, MatrixType &rLHS, VectorType &rRHS)
Definition: fluid_element.cpp:738
Node NodeType
Node type (default is: Node)
Definition: fluid_element.h:70
virtual void AddVelocitySystem(TElementData &rData, MatrixType &rLocalLHS, VectorType &rLocalRHS)
Definition: fluid_element.cpp:777
virtual void AddTimeIntegratedLHS(TElementData &rData, MatrixType &rLHS)
Definition: fluid_element.cpp:751
int Check(const ProcessInfo &rCurrentProcessInfo) const override
Definition: fluid_element.cpp:375
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
This object defines an indexed object.
Definition: indexed_object.h:54
Definition: fluid_element_time_integration_detail.h:28
This class defines the node.
Definition: node.h:65
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.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
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Kratos::PeriodicInterfaceProcess Process operator(std::istream &rIStream, PeriodicInterfaceProcess &rThis)
input stream function
AMatrix::MatrixRow< TExpressionType > MatrixRow
Definition: amatrix_interface.h:492
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
def load(f)
Definition: ode_solve.py:307
tuple const
Definition: ode_solve.py:403
Definition: fluid_element.hpp:82
Definition: fluid_element.h:600
static void Calculate(Vector &rStrainRate, const typename TElementData::NodalVectorData &rVelocities, const typename TElementData::ShapeDerivativesType &rDNDX)
Compute the strain rate vector in Voigt notation, to use as input for the fluid constitutive law.