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.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosPfemApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: May 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_FLUID_ELEMENT_H_INCLUDED)
11 #define KRATOS_FLUID_ELEMENT_H_INCLUDED
12 
13 // System includes
14 
15 // External includes
16 
17 // Project includes
18 #include "includes/checks.h"
19 #include "includes/element.h"
20 
21 namespace Kratos
22 {
37 
39 
45 class KRATOS_API(PFEM_APPLICATION) FluidElement
46  : public Element
47 {
48 public:
49 
55  typedef ConstitutiveLawType::Pointer ConstitutiveLawPointerType;
62 
66 
67 protected:
68 
73  KRATOS_DEFINE_LOCAL_FLAG( COMPUTE_RHS_VECTOR );
74  KRATOS_DEFINE_LOCAL_FLAG( COMPUTE_LHS_MATRIX );
75  KRATOS_DEFINE_LOCAL_FLAG( FINALIZED_STEP );
76 
81  struct ElementData
82  {
83  private:
84 
85  //variables including all integration points
87  const Matrix* pNcontainer;
88  const ProcessInfo* pProcessInfo;
89 
90  public:
91 
93 
94  double Alpha;
95  double Tau;
97 
98  //general variables for large displacement use
99  double detF;
100  double detJ;
101 
105 
107  Matrix L; //Velocity Gradient
108  Matrix F; //Incremental Deformation Gradient (n to n+1)
109 
112 
113  //variables including all integration points
117 
118 
123  {
124  pDN_De=&rDN_De;
125  };
126 
127  void SetShapeFunctions(const Matrix& rNcontainer)
128  {
129  pNcontainer=&rNcontainer;
130  };
131 
132  void SetProcessInfo(const ProcessInfo& rProcessInfo)
133  {
134  pProcessInfo=&rProcessInfo;
135  };
136 
137 
142  {
143  return *pDN_De;
144  };
145 
147  {
148  return *pNcontainer;
149  };
150 
152  {
153  return *pProcessInfo;
154  };
155 
156  void Initialize( const unsigned int& voigt_size,
157  const unsigned int& dimension,
158  const unsigned int& number_of_nodes )
159  {
160  StressMeasure = ConstitutiveLaw::StressMeasure_PK2;
161 
162  //integration
163  Alpha = 1.0;
164 
165  //stabilization
166  Tau = 0;
167 
168  //time step
169  IntegrationWeight = 1;
170 
171  //jacobians
172  detF = 1;
173  detJ = 1;
174 
175  //vectors
176  StrainVector.resize(voigt_size,false);
177  StressVector.resize(voigt_size,false);
178  N.resize(number_of_nodes,false);
179 
180  //matrices
181  B.resize(voigt_size,dimension*number_of_nodes,false);
182  L.resize(dimension,dimension,false);
183  F.resize(dimension,dimension,false);
184  DN_DX.resize(number_of_nodes,dimension,false);
185  ConstitutiveMatrix.resize(voigt_size,voigt_size,false);
186  DeltaPosition.resize(number_of_nodes,dimension,false);
187 
188  //others
189  J.resize(1,false);
190  j.resize(1,false);
191  J[0].resize(dimension,dimension,false);
192  j[0].resize(dimension,dimension,false);
193 
194  //pointers
195  pDN_De = NULL;
196  pNcontainer = NULL;
197  pProcessInfo = NULL;
198 
199  //fill containters
200  // noalias(StrainVector) = ZeroVector(voigt_size);
201  // noalias(StressVector) = ZeroVector(voigt_size);
202  // noalias(N) = ZeroVector(number_of_nodes);
203 
204  // noalias(B) = ZeroMatrix(voigt_size, dimension*number_of_nodes);
205  // noalias(L) = ZeroMatrix(dimension,dimension);
206  // noalias(F) = IdentityMatrix(dimension,dimension);
207 
208  // noalias(DN_DX) = ZeroMatrix(number_of_nodes, dimension);
209  // noalias(ConstitutiveMatrix) = ZeroMatrix(voigt_size, voigt_size);
210  // noalias(DeltaPosition) = ZeroMatrix(number_of_nodes, dimension);
211 
212  // noalias(J[0]) = ZeroMatrix(dimension,dimension);
213  // noalias(j[0]) = ZeroMatrix(dimension,dimension);
214 
215  }
216 
217  };
218 
219 
228  {
229  private:
230 
231  //for calculation local system with compacted LHS and RHS
232  MatrixType *mpLeftHandSideMatrix;
233  VectorType *mpRightHandSideVector;
234 
235  public:
236 
237  //calculation flags
239 
243  void SetLeftHandSideMatrix( MatrixType& rLeftHandSideMatrix ) { mpLeftHandSideMatrix = &rLeftHandSideMatrix; };
244 
245  void SetRightHandSideVector( VectorType& rRightHandSideVector ) { mpRightHandSideVector = &rRightHandSideVector; };
246 
247 
251  MatrixType& GetLeftHandSideMatrix() { return *mpLeftHandSideMatrix; };
252 
253  VectorType& GetRightHandSideVector() { return *mpRightHandSideVector; };
254 
255  };
256 
257 
258 public:
259 
262 
265 
267  FluidElement();
268 
270  FluidElement(IndexType NewId, GeometryType::Pointer pGeometry);
271 
272  FluidElement(IndexType NewId, GeometryType::Pointer pGeometry, PropertiesType::Pointer pProperties);
273 
275  FluidElement(FluidElement const& rOther);
276 
278  virtual ~FluidElement();
279 
283 
286 
290 
298  Element::Pointer Create(IndexType NewId, NodesArrayType const& ThisNodes, PropertiesType::Pointer pProperties) const override;
299 
307  Element::Pointer Clone(IndexType NewId, NodesArrayType const& ThisNodes) const override;
308 
309 
310  //************* GETTING METHODS
311 
317 
321  void GetDofList(DofsVectorType& rElementalDofList, const ProcessInfo& rCurrentProcessInfo) const override;
322 
326  void EquationIdVector(EquationIdVectorType& rResult, const ProcessInfo& rCurrentProcessInfo) const override;
327 
331  void GetValuesVector(Vector& rValues, int Step = 0) const override;
332 
336  void GetFirstDerivativesVector(Vector& rValues, int Step = 0) const override;
337 
341  void GetSecondDerivativesVector(Vector& rValues, int Step = 0) const override;
342 
343 
344 
345  //on integration points:
357  //SET
361  virtual void SetValuesOnIntegrationPoints(const Variable<double>& rVariable, const std::vector<double>& rValues, const ProcessInfo& rCurrentProcessInfo) override;
362 
366  void SetValuesOnIntegrationPoints(const Variable<Vector>& rVariable, const std::vector<Vector>& rValues, const ProcessInfo& rCurrentProcessInfo) override;
367 
371  void SetValuesOnIntegrationPoints(const Variable<Matrix>& rVariable, const std::vector<Matrix>& rValues, const ProcessInfo& rCurrentProcessInfo) override;
372 
377  const std::vector<ConstitutiveLaw::Pointer>& rValues,
378  const ProcessInfo& rCurrentProcessInfo ) override;
379 
380 
381  //GET:
382 
387  std::vector<ConstitutiveLaw::Pointer>& rValues,
388  const ProcessInfo& rCurrentProcessInfo ) override;
389 
390 
391 
392  //************* STARTING - ENDING METHODS
393 
398  virtual void Initialize(const ProcessInfo& rCurrentProcessInfo) override;
399 
403  void InitializeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override;
404 
408  void InitializeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override;
409 
413  void FinalizeNonLinearIteration(const ProcessInfo& rCurrentProcessInfo) override;
414 
418  void FinalizeSolutionStep(const ProcessInfo& rCurrentProcessInfo) override;
419 
420 
421  //************* COMPUTING METHODS
422 
423 
433  void CalculateLocalSystem(MatrixType& rLeftHandSideMatrix,
434  VectorType& rRightHandSideVector,
435  const ProcessInfo& rCurrentProcessInfo) override;
436 
437 
444  void CalculateRightHandSide(VectorType& rRightHandSideVector,
445  const ProcessInfo& rCurrentProcessInfo) override;
446 
447 
454  void CalculateLeftHandSide (MatrixType& rLeftHandSideMatrix,
455  const ProcessInfo& rCurrentProcessInfo) override;
456 
464  void CalculateFirstDerivativesContributions(MatrixType& rLeftHandSideMatrix,
465  VectorType& rRightHandSideVector,
466  const ProcessInfo& rCurrentProcessInfo) override;
467 
475  void CalculateSecondDerivativesContributions(MatrixType& rLeftHandSideMatrix,
476  VectorType& rRightHandSideVector,
477  const ProcessInfo& rCurrentProcessInfo) override;
478 
485  void CalculateSecondDerivativesLHS(MatrixType& rLeftHandSideMatrix,
486  const ProcessInfo& rCurrentProcessInfo) override;
487 
488 
495  void CalculateSecondDerivativesRHS(VectorType& rRightHandSideVector,
496  const ProcessInfo& rCurrentProcessInfo) override;
497 
504  void CalculateMassMatrix(MatrixType& rMassMatrix,
505  const ProcessInfo& rCurrentProcessInfo) override;
506 
513  void CalculateDampingMatrix(MatrixType& rDampingMatrix,
514  const ProcessInfo& rCurrentProcessInfo) override;
515 
516 
526  virtual void AddExplicitContribution(const VectorType& rRHSVector,
527  const Variable<VectorType>& rRHSVariable,
528  const Variable<array_1d<double,3> >& rDestinationVariable,
529  const ProcessInfo& rCurrentProcessInfo) override;
530 
531  //on integration points:
535  void CalculateOnIntegrationPoints(const Variable<double>& rVariable, std::vector<double>& rOutput, const ProcessInfo& rCurrentProcessInfo) override;
536 
540  void CalculateOnIntegrationPoints(const Variable<Vector>& rVariable, std::vector<Vector>& rOutput, const ProcessInfo& rCurrentProcessInfo) override;
541 
545  void CalculateOnIntegrationPoints(const Variable<Matrix >& rVariable, std::vector< Matrix >& rOutput, const ProcessInfo& rCurrentProcessInfo) override;
546 
547 
548  //************************************************************************************
549  //************************************************************************************
557  int Check(const ProcessInfo& rCurrentProcessInfo) const override;
558 
562 
570  std::string Info() const override
571  {
572  std::stringstream buffer;
573  buffer << "Fluid Element #" << Id();
574  return buffer.str();
575  }
576 
578  void PrintInfo(std::ostream& rOStream) const override
579  {
580  rOStream << "Fluid Element #" << Id();
581  }
582 
584  void PrintData(std::ostream& rOStream) const override
585  {
586  GetGeometry().PrintData(rOStream);
587  }
592 
593 protected:
599 
604 
608  std::vector<ConstitutiveLaw::Pointer> mConstitutiveLawVector;
609 
613 
617 
621  virtual void SetProcessInformation(const ProcessInfo& rCurrentProcessInfo);
622 
626  void IncreaseIntegrationMethod(IntegrationMethod& rThisIntegrationMethod,
627  unsigned int increment) const;
628 
632  virtual void CalculateElementalSystem(LocalSystemComponents& rLocalSystem,
633  const ProcessInfo& rCurrentProcessInfo);
634 
638  virtual void CalculateDynamicSystem(LocalSystemComponents& rLocalSystem,
639  const ProcessInfo& rCurrentProcessInfo);
640 
644  void PrintElementCalculation(LocalSystemComponents& rLocalSystem, ElementDataType& rVariables);
645 
646 
650  void CalculatePerturbedLeftHandSide (MatrixType& rLeftHandSideMatrix,
651  const ProcessInfo& rCurrentProcessInfo);
652 
657  virtual void CalculateAndAddLHS(LocalSystemComponents& rLocalSystem,
658  ElementDataType& rVariables);
659 
664  virtual void CalculateAndAddRHS(LocalSystemComponents& rLocalSystem,
665  ElementDataType& rVariables);
666 
667 
672  virtual void CalculateAndAddDynamicLHS(MatrixType& rLeftHandSideMatrix,
673  ElementDataType& rVariables);
674 
678  virtual void CalculateAndAddDynamicRHS(VectorType& rRightHandSideVector,
679  ElementDataType& rVariables);
680 
684  virtual void CalculateAndAddKvvm(MatrixType& rLeftHandSideMatrix,
685  ElementDataType& rVariables);
686 
690  virtual void CalculateAndAddKvvg(MatrixType& rLeftHandSideMatrix,
691  ElementDataType& rVariables);
692 
693 
697  virtual void CalculateAndAddExternalForces(VectorType& rRightHandSideVector,
698  ElementDataType& rVariables);
699 
700 
704  virtual void CalculateAndAddInternalForces(VectorType& rRightHandSideVector,
705  ElementDataType & rVariables);
706 
707 
711  virtual void SetElementData(ElementDataType& rVariables,
713  const int & rPointNumber);
714 
715 
719  virtual void CalculateMaterialResponse(ElementDataType& rVariables,
721  const int & rPointNumber);
722 
726  virtual unsigned int GetDofsSize() const;
727 
728 
732  bool IsSliver();
733 
737  virtual void InitializeSystemMatrices(MatrixType& rLeftHandSideMatrix,
738  VectorType& rRightHandSideVector,
739  Flags& rCalculationFlags);
740 
744  void InitializeConstitutiveLaw();
745 
746 
750  void ResetConstitutiveLaw() override;
751 
752 
756  void InitializeExplicitContributions();
757 
758 
762  virtual void CalculateKinematics(ElementDataType& rVariables,
763  const double& rPointNumber);
764 
768  virtual void CalculateKinetics(ElementDataType& rVariables,
769  const double& rPointNumber);
770 
774  virtual void InitializeElementData(ElementDataType & rVariables,
775  const ProcessInfo& rCurrentProcessInfo);
776 
780  virtual void TransformElementData(ElementDataType & rVariables,
781  const double& rPointNumber);
782 
786  virtual void FinalizeStepVariables(ElementDataType & rVariables,
787  const double& rPointNumber);
788 
792  void CalculateVelocityGradient(Matrix& rL,
793  const Matrix& rDN_DX,
794  unsigned int step = 0);
795 
799  void CalculateVelocityGradientVector(Vector& rVector,
800  const Matrix& rL,
801  const Matrix& rDN_DX,
802  unsigned int step = 0);
806  void CalculateVelocityGradientVector(Vector& rVector,
807  const Matrix& rDN_DX,
808  unsigned int step = 0);
809 
813  void CalculateSymmetricVelocityGradient(const Matrix& rL,
814  Vector& rStrainVector);
815 
819  void CalculateSkewSymmetricVelocityGradient(const Matrix& rL,
820  Vector& rStrainVector);
821 
825  virtual double& CalculateIntegrationWeight(double& rIntegrationWeight);
826 
827 
831  virtual double& CalculateTotalMass(double& rTotalMass, const ProcessInfo& rCurrentProcessInfo);
832 
833 
837  virtual double& CalculateVolumeChange(double& rVolumeChange, ElementDataType& rVariables);
838 
842  virtual Vector& CalculateVolumeForce(Vector& rVolumeForce, ElementDataType& rVariables);
843 
844 
855 
856 private:
857 
863 
864 
868 
869 
873 
874 
879 
883  friend class Serializer;
884 
885  // A private default constructor necessary for serialization
886 
887  virtual void save(Serializer& rSerializer) const override;
888 
889  virtual void load(Serializer& rSerializer) override;
890 
891 
898 
899 }; // Class FluidElement
900 
908 
909 } // namespace Kratos.
910 #endif // KRATOS_FLUID_ELEMENT_H_INCLUDED defined
Definition: constitutive_law.h:47
StressMeasure
Definition: constitutive_law.h:69
@ StressMeasure_PK2
Definition: constitutive_law.h:71
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
Definition: flags.h:58
std::size_t IndexType
Definition: flags.h:74
Large Displacement Lagrangian Element for 3D and 2D geometries. (base class)
Definition: fluid_element.h:61
GeometryData::IntegrationMethod IntegrationMethod
Type definition for integration methods.
Definition: fluid_element.hpp:59
IntegrationMethod mThisIntegrationMethod
Definition: fluid_element.hpp:603
void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const override
std::vector< ConstitutiveLaw::Pointer > mConstitutiveLawVector
Definition: fluid_element.hpp:608
void CalculateOnIntegrationPoints(const Variable< Vector > &rVariable, std::vector< Vector > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
ConstitutiveLawType::Pointer ConstitutiveLawPointerType
Pointer type for constitutive laws.
Definition: fluid_element.hpp:55
void GetFirstDerivativesVector(Vector &rValues, int Step=0) const override
FluidElement(IndexType NewId, GeometryType::Pointer pGeometry)
Default constructors.
ElementData ElementDataType
Type for element variables.
Definition: fluid_element.hpp:261
ConstitutiveLaw ConstitutiveLawType
Definition: fluid_element.hpp:53
IntegrationMethod GetIntegrationMethod() const override
void CalculateOnIntegrationPoints(const Variable< double > &rVariable, std::vector< double > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: fluid_element.hpp:578
FluidElement(FluidElement const &rOther)
Copy constructor.
void GetDofList(DofsVectorType &rElementalDofList, const ProcessInfo &rCurrentProcessInfo) const override
FluidElement & operator=(FluidElement const &rOther)
Assignment operator.
KRATOS_DEFINE_LOCAL_FLAG(FINALIZED_STEP)
void GetSecondDerivativesVector(Vector &rValues, int Step=0) const override
KRATOS_CLASS_INTRUSIVE_POINTER_DEFINITION(FluidElement)
Counted pointer of FluidElement.
std::string Info() const override
Turn back information as a string.
Definition: fluid_element.hpp:570
GeometryData::SizeType SizeType
Type for size.
Definition: fluid_element.hpp:61
virtual ~FluidElement()
Destructor.
void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
void CalculateOnIntegrationPoints(const Variable< Matrix > &rVariable, std::vector< Matrix > &rOutput, const ProcessInfo &rCurrentProcessInfo) override
virtual void Initialize(const ProcessInfo &rCurrentProcessInfo) override
void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo) override
void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo) override
KRATOS_DEFINE_LOCAL_FLAG(COMPUTE_LHS_MATRIX)
void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo) override
KRATOS_DEFINE_LOCAL_FLAG(COMPUTE_RHS_VECTOR)
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: fluid_element.hpp:584
ConstitutiveLawType::StressMeasure StressMeasureType
StressMeasure from constitutive laws.
Definition: fluid_element.hpp:57
int Check(const ProcessInfo &rCurrentProcessInfo) const override
IntegrationMethod
Definition: geometry_data.h:76
std::size_t SizeType
Definition: geometry_data.h:173
Definition: amatrix_interface.h:41
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
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
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
void SetValuesOnIntegrationPoints(TObject &dummy, const Variable< TDataType > &rVariable, const std::vector< TDataType > &values, const ProcessInfo &rCurrentProcessInfo)
Definition: add_mesh_to_python.cpp:185
pybind11::list CalculateOnIntegrationPoints(TObject &dummy, const Variable< TDataType > &rVariable, const ProcessInfo &rProcessInfo)
Definition: add_mesh_to_python.cpp:142
void InitializeSolutionStep(ConstructionUtility &rThisUtil, std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int phase)
Definition: add_custom_utilities_to_python.cpp:45
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int step
Definition: face_heat.py:88
F
Definition: hinsberg_optimization.py:144
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
def load(f)
Definition: ode_solve.py:307
int L
Definition: ode_solve.py:390
def Alpha(n, j)
Definition: quadrature.py:93
int j
Definition: quadrature.py:648
J
Definition: sensitivityMatrix.py:58
N
Definition: sensitivityMatrix.py:29
B
Definition: sensitivityMatrix.py:76
Definition: constitutive_law.h:189
Definition: fluid_element.hpp:82
double detF
Definition: fluid_element.hpp:99
const ProcessInfo & GetProcessInfo()
Definition: fluid_element.hpp:151
void SetShapeFunctionsGradients(const GeometryType::ShapeFunctionsGradientsType &rDN_De)
Definition: fluid_element.hpp:122
Matrix L
Definition: fluid_element.hpp:107
double detJ
Definition: fluid_element.hpp:100
Matrix ConstitutiveMatrix
Definition: fluid_element.hpp:111
Vector N
Definition: fluid_element.hpp:104
Vector StrainVector
Definition: fluid_element.hpp:102
const Matrix & GetShapeFunctions()
Definition: fluid_element.hpp:146
Matrix DN_DX
Definition: fluid_element.hpp:110
double Tau
Definition: fluid_element.hpp:95
double IntegrationWeight
Definition: fluid_element.hpp:96
const GeometryType::ShapeFunctionsGradientsType & GetShapeFunctionsGradients()
Definition: fluid_element.hpp:141
Matrix F
Definition: fluid_element.hpp:108
GeometryType::JacobiansType j
Definition: fluid_element.hpp:115
Matrix B
Definition: fluid_element.hpp:106
void SetProcessInfo(const ProcessInfo &rProcessInfo)
Definition: fluid_element.hpp:132
Matrix DeltaPosition
Definition: fluid_element.hpp:116
Vector StressVector
Definition: fluid_element.hpp:103
void Initialize(const unsigned int &voigt_size, const unsigned int &dimension, const unsigned int &number_of_nodes)
Definition: fluid_element.hpp:156
StressMeasureType StressMeasure
Definition: fluid_element.hpp:92
void SetShapeFunctions(const Matrix &rNcontainer)
Definition: fluid_element.hpp:127
double Alpha
Definition: fluid_element.hpp:94
GeometryType::JacobiansType J
Definition: fluid_element.hpp:114
Definition: fluid_element.hpp:228
Flags CalculationFlags
Definition: fluid_element.hpp:238
void SetLeftHandSideMatrix(MatrixType &rLeftHandSideMatrix)
Definition: fluid_element.hpp:243
MatrixType & GetLeftHandSideMatrix()
Definition: fluid_element.hpp:251
void SetRightHandSideVector(VectorType &rRightHandSideVector)
Definition: fluid_element.hpp:245
VectorType & GetRightHandSideVector()
Definition: fluid_element.hpp:253