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.
compute_dem_face_load_utility.h
Go to the documentation of this file.
1 /*
2  * Author: Salva Latorre and Ignasi Pouplana
3  *
4  * latorre@cimne.upc.edu
5  * ipouplana@cimne.upc.edu
6  */
7 
8 #ifndef COMPUTE_DEM_FACE_LOAD_UTILITY_H
9 #define COMPUTE_DEM_FACE_LOAD_UTILITY_H
10 
11 #include "includes/variables.h"
12 #include <limits>
13 #include <iostream>
14 #include <iomanip>
15 
16 #ifdef _OPENMP
17 #include <omp.h>
18 #endif
19 
20 #include "includes/define.h"
21 #include "includes/condition.h"
22 #include "includes/model_part.h"
24 
25 namespace Kratos {
26 
28 
29  public:
30 
31  typedef ModelPart::NodesContainerType::ContainerType::iterator NodesIteratorType;
32 
34 
36 
38 
39  void ClearDEMFaceLoads(ModelPart& r_structural_skin_model_part) {
40 
42 
43  #pragma omp parallel for
44  for (int i=0; i<(int)r_structural_skin_model_part.Nodes().size(); i++) {
45  auto node_it = r_structural_skin_model_part.NodesBegin() + i;
46  array_1d<double, 3>& node_rhs = node_it->FastGetSolutionStepValue(DEM_SURFACE_LOAD);
47  node_rhs = ZeroVector(3);
48  }
49 
50  KRATOS_CATCH("")
51  }
52 
53  void CalculateDEMFaceLoads(ModelPart& r_structural_skin_model_part, const double DEM_delta_time, const double FEM_delta_time) {
54 
56 
57  static bool nodal_area_already_computed = false;
58 
59  if (!nodal_area_already_computed) {
60  #pragma omp parallel for
61  for (int i=0; i<(int)r_structural_skin_model_part.Nodes().size(); i++) {
62  auto node_it = r_structural_skin_model_part.NodesBegin() + i;
63  double& node_area = node_it->GetSolutionStepValue(DEM_NODAL_AREA);
64  node_area = 0.0;
65  }
66 
67  ModelPart::ConditionsContainerType& source_conditions = r_structural_skin_model_part.Conditions();
68 
69  const double one_third = 1.0/3.0;
70 
71  for (unsigned int i = 0; i < source_conditions.size(); i++) {
72  ModelPart::ConditionsContainerType::iterator it = r_structural_skin_model_part.ConditionsBegin() + i;
73  Condition::GeometryType& geometry = it->GetGeometry();
74  double condition_area = geometry.Area();
75 
76  for (unsigned int i = 0; i < geometry.size(); i++) { //talking about each of the three nodes of the condition
77  double& node_area = geometry[i].FastGetSolutionStepValue(DEM_NODAL_AREA);
78  node_area += one_third * condition_area; //TODO: ONLY FOR TRIANGLE... Generalize for 3 or 4 nodes
79  }
80  }
81 
82  nodal_area_already_computed = true;
83  }
84 
85  #pragma omp parallel for
86  for (int i=0; i<(int)r_structural_skin_model_part.Nodes().size(); i++) {
87  auto node_it = r_structural_skin_model_part.NodesBegin() + i;
88  double& nodal_area = node_it->FastGetSolutionStepValue(DEM_NODAL_AREA);
89 
90  if (nodal_area && FEM_delta_time) {
91  node_it->FastGetSolutionStepValue(DEM_SURFACE_LOAD) += node_it->FastGetSolutionStepValue(CONTACT_FORCES) * DEM_delta_time / (nodal_area * FEM_delta_time);
92  }
93  }
94 
95  KRATOS_CATCH("")
96  }
97 
98  virtual std::string Info() const { return "";}
99 
100  virtual void PrintInfo(std::ostream& rOStream) const {}
101 
102  virtual void PrintData(std::ostream& rOStream) const {}
103 
104  private:
105 
106  ComputeDEMFaceLoadUtility& operator= (ComputeDEMFaceLoadUtility const& rOther);
107 
108  }; // class ComputeDEMFaceLoadUtility
109 
110 } // namespace Kratos
111 
112 #endif // COMPUTE_DEM_FACE_LOAD_UTILITY_H
Definition: compute_dem_face_load_utility.h:27
void CalculateDEMFaceLoads(ModelPart &r_structural_skin_model_part, const double DEM_delta_time, const double FEM_delta_time)
Definition: compute_dem_face_load_utility.h:53
void ClearDEMFaceLoads(ModelPart &r_structural_skin_model_part)
Definition: compute_dem_face_load_utility.h:39
virtual void PrintData(std::ostream &rOStream) const
Definition: compute_dem_face_load_utility.h:102
ComputeDEMFaceLoadUtility()
Definition: compute_dem_face_load_utility.h:35
virtual void PrintInfo(std::ostream &rOStream) const
Definition: compute_dem_face_load_utility.h:100
virtual ~ComputeDEMFaceLoadUtility()
Definition: compute_dem_face_load_utility.h:37
ModelPart::NodesContainerType::ContainerType::iterator NodesIteratorType
Definition: compute_dem_face_load_utility.h:31
KRATOS_CLASS_POINTER_DEFINITION(ComputeDEMFaceLoadUtility)
virtual std::string Info() const
Definition: compute_dem_face_load_utility.h:98
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
virtual double Area() const
This method calculate and return area or surface area of this geometry depending to it's dimension.
Definition: geometry.h:1345
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
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
#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
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
integer i
Definition: TensorModule.f:17