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.
poro_explicit_vv_scheme.hpp
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license:
9 //kratos/license.txt
10 //
11 // Main authors: Ignasi de Pouplana
12 //
13 //
14 
15 #if !defined(KRATOS_PORO_EXPLICIT_VV_SCHEME_HPP_INCLUDED)
16 #define KRATOS_PORO_EXPLICIT_VV_SCHEME_HPP_INCLUDED
17 
18 /* External includes */
19 
20 /* Project includes */
23 
24 // Application includes
26 
27 namespace Kratos {
28 
31 
35 
37 
40 
44 
48 
55 template <class TSparseSpace,
56  class TDenseSpace //= DenseSpace<double>
57  >
59  : public PoroExplicitCDScheme<TSparseSpace, TDenseSpace> {
60 
61 public:
64 
68 
74 
79 
81  typedef std::size_t SizeType;
82 
84  typedef std::size_t IndexType;
85 
88 
90  static constexpr double numerical_limit = std::numeric_limits<double>::epsilon();
91 
93  using BaseType::mAlpha;
94  using BaseType::mBeta;
95  using BaseType::mTheta;
97 
100 
104 
110  : PoroExplicitCDScheme<TSparseSpace, TDenseSpace>()
111  {
112 
113  }
114 
118 
122 
129  ModelPart& rModelPart,
130  const SizeType DomainSize = 3
131  ) override
132  {
133  KRATOS_TRY
134 
136  NodesArrayType& r_nodes = rModelPart.Nodes();
137 
138  // The first iterator of the array of nodes
139  const auto it_node_begin = rModelPart.NodesBegin();
140 
142  #pragma omp parallel for schedule(guided,512)
143  for (int i = 0; i < static_cast<int>(r_nodes.size()); ++i) {
144  auto it_node = (it_node_begin + i);
145  it_node->SetValue(NODAL_MASS, 0.0);
146  // TODO: Set Nodal AntiCompressibility to zero for mass-balance equation (C=1/Q, with Q being the compressibility coeff.)
147  array_1d<double, 3>& r_force_residual = it_node->FastGetSolutionStepValue(FORCE_RESIDUAL);
148  double& r_flux_residual = it_node->FastGetSolutionStepValue(FLUX_RESIDUAL);
149  array_1d<double, 3>& r_external_force = it_node->FastGetSolutionStepValue(EXTERNAL_FORCE);
150  array_1d<double, 3>& r_internal_force = it_node->FastGetSolutionStepValue(INTERNAL_FORCE);
151  array_1d<double, 3>& r_damping_force = it_node->FastGetSolutionStepValue(DAMPING_FORCE);
152  noalias(r_force_residual) = ZeroVector(3);
153  r_flux_residual = 0.0;
154  noalias(r_external_force) = ZeroVector(3);
155  noalias(r_internal_force) = ZeroVector(3);
156  noalias(r_damping_force) = ZeroVector(3);
157  Matrix& rInitialStress = it_node->FastGetSolutionStepValue(INITIAL_STRESS_TENSOR);
158  if(rInitialStress.size1() != 3)
159  rInitialStress.resize(3,3,false);
160  noalias(rInitialStress) = ZeroMatrix(3,3);
161  }
162 
163  KRATOS_CATCH("")
164  }
165 
170  void InitializeResidual(ModelPart& rModelPart) override
171  {
172  KRATOS_TRY
173 
174  // The array of nodes
175  NodesArrayType& r_nodes = rModelPart.Nodes();
176 
177  // Auxiliar values
178  const array_1d<double, 3> zero_array = ZeroVector(3);
179  // Initializing the variables
180  VariableUtils().SetVariable(FORCE_RESIDUAL, zero_array,r_nodes);
181  VariableUtils().SetVariable(FLUX_RESIDUAL, 0.0,r_nodes);
182  VariableUtils().SetVariable(EXTERNAL_FORCE, zero_array,r_nodes);
183  VariableUtils().SetVariable(INTERNAL_FORCE, zero_array,r_nodes);
184  VariableUtils().SetVariable(DAMPING_FORCE, zero_array,r_nodes);
185 
186  KRATOS_CATCH("")
187  }
188 
189  void Predict(
190  ModelPart& rModelPart,
191  DofsArrayType& rDofSet,
193  TSystemVectorType& Dx,
195  ) override
196  {
197  KRATOS_TRY;
198 
199  this->CalculateAndAddRHS(rModelPart);
200 
201  // The current process info
202  const ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo();
203 
204  // The array of nodes
205  NodesArrayType& r_nodes = rModelPart.Nodes();
206 
208  const SizeType dim = r_current_process_info[DOMAIN_SIZE];
209 
210  // Step Update
211  mDeltaTime = r_current_process_info[DELTA_TIME];
212 
213  // The iterator of the first node
214  const auto it_node_begin = rModelPart.NodesBegin();
215 
216  // Getting dof position
217  const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X);
218 
219  #pragma omp parallel for schedule(guided,512)
220  for (int i = 0; i < static_cast<int>(r_nodes.size()); ++i) {
221  // Current step information "N+1" (before step update).
222  this->PredictTranslationalDegreesOfFreedom(it_node_begin + i, disppos, dim);
223  } // for Node parallel
224 
225  InitializeResidual(rModelPart);
226 
227  this->CalculateAndAddRHS(rModelPart);
228 
229  KRATOS_CATCH("")
230  }
231 
239  NodeIterator itCurrentNode,
240  const IndexType DisplacementPosition,
241  const SizeType DomainSize = 3
242  )
243  {
244  array_1d<double, 3>& r_displacement = itCurrentNode->FastGetSolutionStepValue(DISPLACEMENT);
245  array_1d<double, 3>& r_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY);
246  const double nodal_mass = itCurrentNode->GetValue(NODAL_MASS);
247 
248  const array_1d<double, 3>& r_external_force = itCurrentNode->FastGetSolutionStepValue(EXTERNAL_FORCE);
249  const array_1d<double, 3>& r_internal_force = itCurrentNode->FastGetSolutionStepValue(INTERNAL_FORCE);
250  const array_1d<double, 3>& r_damping_force = itCurrentNode->FastGetSolutionStepValue(DAMPING_FORCE);
251 
252  std::array<bool, 3> fix_displacements = {false, false, false};
253  fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed());
254  fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed());
255  if (DomainSize == 3)
256  fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed());
257 
258  // Solution of the explicit equation:
259  if (nodal_mass > numerical_limit){
260  for (IndexType j = 0; j < DomainSize; j++) {
261  if (fix_displacements[j] == false) {
262  r_displacement[j] += r_velocity[j]*mDeltaTime + 0.5 * (r_external_force[j]
263  - r_internal_force[j]
264  - r_damping_force[j])/nodal_mass * mDeltaTime * mDeltaTime;
265  r_velocity[j] += 0.5 * mDeltaTime * (r_external_force[j]
266  - r_internal_force[j]
267  - r_damping_force[j])/nodal_mass;
268  }
269  }
270  }
271  else {
272  noalias(r_displacement) = ZeroVector(3);
273  noalias(r_velocity) = ZeroVector(3);
274  }
275  }
276 
284  NodeIterator itCurrentNode,
285  const IndexType DisplacementPosition,
286  const SizeType DomainSize = 3
287  ) override
288  {
289  array_1d<double, 3>& r_velocity = itCurrentNode->FastGetSolutionStepValue(VELOCITY);
290  const double nodal_mass = itCurrentNode->GetValue(NODAL_MASS);
291 
292  double& r_current_water_pressure = itCurrentNode->FastGetSolutionStepValue(WATER_PRESSURE);
293  double& r_current_dt_water_pressure = itCurrentNode->FastGetSolutionStepValue(DT_WATER_PRESSURE);
294 
295  const array_1d<double, 3>& r_external_force = itCurrentNode->FastGetSolutionStepValue(EXTERNAL_FORCE);
296  const array_1d<double, 3>& r_internal_force = itCurrentNode->FastGetSolutionStepValue(INTERNAL_FORCE);
297  const array_1d<double, 3>& r_damping_force = itCurrentNode->FastGetSolutionStepValue(DAMPING_FORCE);
298 
299  std::array<bool, 3> fix_displacements = {false, false, false};
300  fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed());
301  fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed());
302  if (DomainSize == 3)
303  fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed());
304 
305  // Solution of the explicit equation:
306  if (nodal_mass > numerical_limit){
307  for (IndexType j = 0; j < DomainSize; j++) {
308  if (fix_displacements[j] == false) {
309  r_velocity[j] += 0.5 * mDeltaTime * (r_external_force[j]
310  - r_internal_force[j]
311  - r_damping_force[j])/nodal_mass;
312  }
313  }
314  }
315  else {
316  noalias(r_velocity) = ZeroVector(3);
317  }
318  // Solution of the darcy_equation
319  if( itCurrentNode->IsFixed(WATER_PRESSURE) == false ) {
320  // TODO: this is on standby
321  r_current_water_pressure = 0.0;
322  r_current_dt_water_pressure = 0.0;
323  }
324 
325  const array_1d<double, 3>& r_velocity_old = itCurrentNode->FastGetSolutionStepValue(VELOCITY,1);
326  array_1d<double, 3>& r_acceleration = itCurrentNode->FastGetSolutionStepValue(ACCELERATION);
327 
328  noalias(r_acceleration) = (1.0/mDeltaTime) * (r_velocity - r_velocity_old);
329  }
330 
339  Element& rCurrentElement,
340  LocalSystemVectorType& RHS_Contribution,
342  const ProcessInfo& rCurrentProcessInfo
343  ) override
344  {
345  KRATOS_TRY
346 
347  // this->TCalculateRHSContribution(rCurrentElement, RHS_Contribution, rCurrentProcessInfo);
348  // rCurrentElement.CalculateRightHandSide(RHS_Contribution, rCurrentProcessInfo);
349  rCurrentElement.AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, DAMPING_FORCE, rCurrentProcessInfo);
350 
351  KRATOS_CATCH("")
352  }
353 
357 
361 
365 
369 
371 
372 protected:
373 
377 
378 
381 
382 
386 
390 
394 
398 
402 
406 
408 
409 private:
412 
416 
420 
424 
428 
432 
436 
438 
439 }; /* Class PoroExplicitVVScheme */
440 
442 
445 
447 
448 } /* namespace Kratos.*/
449 
450 #endif /* KRATOS_PORO_EXPLICIT_VV_SCHEME_HPP_INCLUDED defined */
Base class for all Elements.
Definition: element.h:60
virtual void AddExplicitContribution(const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:622
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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
An explicit forward euler scheme with a split of the inertial term.
Definition: poro_explicit_cd_scheme.hpp:59
double mDeltaTime
Definition: poro_explicit_cd_scheme.hpp:742
ModelPart::NodeIterator NodeIterator
Definition fo the node iterator.
Definition: poro_explicit_cd_scheme.hpp:86
ModelPart::NodesContainerType NodesArrayType
Definition: poro_explicit_cd_scheme.hpp:77
double mAlpha
Definition: poro_explicit_cd_scheme.hpp:743
double mTheta
Definition: poro_explicit_cd_scheme.hpp:745
double mGCoefficient
Definition: poro_explicit_cd_scheme.hpp:746
std::size_t IndexType
Definition of the index type.
Definition: poro_explicit_cd_scheme.hpp:83
std::size_t SizeType
Definition of the size type.
Definition: poro_explicit_cd_scheme.hpp:80
virtual void CalculateAndAddRHS(ModelPart &rModelPart)
Definition: poro_explicit_cd_scheme.hpp:348
double mBeta
Definition: poro_explicit_cd_scheme.hpp:744
An explicit forward euler scheme with a split of the inertial term.
Definition: poro_explicit_vv_scheme.hpp:59
Scheme< TSparseSpace, TDenseSpace > BaseofBaseType
The definition of the base type.
Definition: poro_explicit_vv_scheme.hpp:66
void UpdateTranslationalDegreesOfFreedom(NodeIterator itCurrentNode, const IndexType DisplacementPosition, const SizeType DomainSize=3) override
This method updates the translation DoF.
Definition: poro_explicit_vv_scheme.hpp:283
BaseType::TSystemMatrixType TSystemMatrixType
Definition: poro_explicit_vv_scheme.hpp:71
PoroExplicitCDScheme< TSparseSpace, TDenseSpace > BaseType
Definition: poro_explicit_vv_scheme.hpp:67
void InitializeResidual(ModelPart &rModelPart) override
This method initializes the residual in the nodes of the model part.
Definition: poro_explicit_vv_scheme.hpp:170
PoroExplicitVVScheme()
Default constructor.
Definition: poro_explicit_vv_scheme.hpp:109
std::size_t IndexType
Definition of the index type.
Definition: poro_explicit_vv_scheme.hpp:84
ModelPart::NodesContainerType NodesArrayType
Definition: poro_explicit_vv_scheme.hpp:78
BaseType::TSystemVectorType TSystemVectorType
Definition: poro_explicit_vv_scheme.hpp:72
virtual ~PoroExplicitVVScheme()
Definition: poro_explicit_vv_scheme.hpp:117
void Predict(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the prediction of the solution.
Definition: poro_explicit_vv_scheme.hpp:189
ModelPart::NodeIterator NodeIterator
Definition fo the node iterator.
Definition: poro_explicit_vv_scheme.hpp:87
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: poro_explicit_vv_scheme.hpp:338
std::size_t SizeType
Definition of the size type.
Definition: poro_explicit_vv_scheme.hpp:81
static constexpr double numerical_limit
The definition of the numerical limit.
Definition: poro_explicit_vv_scheme.hpp:90
void InitializeExplicitScheme(ModelPart &rModelPart, const SizeType DomainSize=3) override
This method initializes some rutines related with the explicit scheme.
Definition: poro_explicit_vv_scheme.hpp:128
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: poro_explicit_vv_scheme.hpp:73
ModelPart::ElementsContainerType ElementsArrayType
The arrays of elements and nodes.
Definition: poro_explicit_vv_scheme.hpp:76
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: poro_explicit_vv_scheme.hpp:77
BaseType::DofsArrayType DofsArrayType
Some definitions related with the base class.
Definition: poro_explicit_vv_scheme.hpp:70
KRATOS_CLASS_POINTER_DEFINITION(PoroExplicitVVScheme)
Counted pointer of PoroExplicitVVScheme.
virtual void PredictTranslationalDegreesOfFreedom(NodeIterator itCurrentNode, const IndexType DisplacementPosition, const SizeType DomainSize=3)
This method updates the translation DoF.
Definition: poro_explicit_vv_scheme.hpp:238
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
virtual void EquationId(const Element &rElement, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo)
This method gets the eqaution id corresponding to the current element.
Definition: scheme.h:636
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
typename TDenseSpace::VectorType LocalSystemVectorType
Local system vector type definition.
Definition: scheme.h:80
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetVariable(const TVarType &rVariable, const TDataType &rValue, NodesContainerType &rNodes, const unsigned int Step=0)
Sets the nodal value of a scalar variable.
Definition: variable_utils.h:675
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
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
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int j
Definition: quadrature.py:648
A
Definition: sensitivityMatrix.py:70
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17