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_time_integration_detail.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 #if !defined(KRATOS_FLUID_ELEMENT_TIME_INTEGRATION_DETAIL_H)
14 #define KRATOS_FLUID_ELEMENT_TIME_INTEGRATION_DETAIL_H
15 
16 // External includes
17 
18 // Project includes
19 #include "includes/define.h"
21 
22 namespace Kratos
23 {
24 
25 namespace Internals {
26 
27 template <class TElementData, bool TDataKnowsAboutTimeIntegration>
29 public:
32  TElementData& rData,
33  Kratos::Matrix& rLHS,
34  Kratos::Vector& rRHS);
35 };
36 
37 // For Standard data: Time integration is not available ///////////////////////////////////////////
38 
39 template <class TElementData>
40 class FluidElementTimeIntegrationDetail<TElementData, false> {
41 public:
44  TElementData& rData,
45  Kratos::Matrix& rLHS,
46  Kratos::Vector& rRHS)
47  {
48  KRATOS_TRY;
49  KRATOS_ERROR << "Trying to use time-integrated element functions with a "
50  "data type that does not know previous time step data"
51  << std::endl;
52  KRATOS_CATCH("");
53  }
54 };
55 
56 // Specialized time integration (BDF2) ////////////////////////////////////////////////////////////
57 
58 template <class TElementData>
59 class FluidElementTimeIntegrationDetail<TElementData, true> {
60 public:
63  TElementData& rData,
64  Kratos::Matrix& rLHS,
65  Kratos::Vector& rRHS)
66  {
67  Kratos::Matrix mass_matrix = ZeroMatrix(rLHS.size1(),rLHS.size2());
68  Kratos::Matrix velocity_lhs = ZeroMatrix(rLHS.size1(),rLHS.size2());
69 
70  pElement->AddVelocitySystem(rData,velocity_lhs,rRHS);
71  pElement->AddMassLHS(rData,mass_matrix);
72 
73  noalias(rLHS) += rData.bdf0*mass_matrix + velocity_lhs;
74 
75  Vector acceleration = ZeroVector(rRHS.size());
76 
77  int row = 0;
78  const auto& r_velocities = rData.Velocity;
79  const auto& r_velocities_step1 = rData.Velocity_OldStep1;
80  const auto& r_velocities_step2 = rData.Velocity_OldStep2;
81 
82  for (unsigned int i = 0; i < TElementData::NumNodes; ++i) {
83  for (unsigned int d = 0; d < TElementData::Dim; ++d) {
84  // Velocity dofs
85  acceleration[row] = rData.bdf0*r_velocities(i,d);
86  acceleration[row] += rData.bdf1*r_velocities_step1(i,d);
87  acceleration[row] += rData.bdf2*r_velocities_step2(i,d);
88  ++row;
89  }
90  ++row; // Pressure dof
91  }
92 
93  noalias(rRHS) -= prod(mass_matrix,acceleration);
94  }
95 };
96 
97 } // namespace Internals
98 
99 } // namespace Kratos
100 
101 #endif // KRATOS_FLUID_ELEMENT_TIME_INTEGRATION_DETAIL_H
Large Displacement Lagrangian Element for 3D and 2D geometries. (base class)
Definition: fluid_element.h:61
virtual void AddMassLHS(TElementData &rData, MatrixType &rMassMatrix)
Definition: fluid_element.cpp:792
virtual void AddVelocitySystem(TElementData &rData, MatrixType &rLocalLHS, VectorType &rLocalRHS)
Definition: fluid_element.cpp:777
static void AddTimeIntegratedSystem(FluidElement< TElementData > *pElement, TElementData &rData, Kratos::Matrix &rLHS, Kratos::Vector &rRHS)
Definition: fluid_element_time_integration_detail.h:42
static void AddTimeIntegratedSystem(FluidElement< TElementData > *pElement, TElementData &rData, Kratos::Matrix &rLHS, Kratos::Vector &rRHS)
Definition: fluid_element_time_integration_detail.h:61
Definition: fluid_element_time_integration_detail.h:28
static void AddTimeIntegratedSystem(FluidElement< TElementData > *pElement, TElementData &rData, Kratos::Matrix &rLHS, Kratos::Vector &rRHS)
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
tuple acceleration
Definition: generate_droplet_dynamics.py:117
int d
Definition: ode_solve.py:397
integer i
Definition: TensorModule.f:17