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.
pore_pressure_communicator_utility.hpp
Go to the documentation of this file.
1 /*
2  * Author: Miguel Angel Celigueta
3  *
4  * maceli@cimne.upc.edu
5  */
6 
7 #ifndef PORE_PRESSURE_COMMUNICATOR_UTILITY_H
8 #define PORE_PRESSURE_COMMUNICATOR_UTILITY_H
9 
10 #include "includes/variables.h"
11 #include <limits>
12 #include <iostream>
13 #include <iomanip>
14 
15 #ifdef _OPENMP
16 #include <omp.h>
17 #endif
18 
19 #include "includes/define.h"
20 #include "includes/condition.h"
21 #include "includes/model_part.h"
23 #include "../../PoromechanicsApplication/poromechanics_application_variables.h"
24 #include "../../DEMApplication/DEM_application_variables.h"
25 
27 
28 namespace Kratos {
29 
31 
32  public:
33 
34  typedef ModelPart::NodesContainerType::ContainerType::iterator NodesIteratorType;
35 
37 
38  PorePressureCommunicatorUtility(ModelPart& r_source_model_part, ModelPart& destination_model_part):mrSourceModelPart(r_source_model_part), mrDestinationModelPart(destination_model_part) {
39  Check();
40  }
41 
43  delete mpSearchStructure;
44  }
45 
46  void Initialize() {
47  mpSearchStructure = new BinBasedFastPointLocator<2>(mrSourceModelPart);
48  mpSearchStructure->UpdateSearchDatabase();
49  }
50 
52 
54 
55  const int max_results = 10000;
56 
57  #pragma omp parallel
58  {
59  Vector N;
60  typename BinBasedFastPointLocator<2>::ResultContainerType results(max_results);
61  typename BinBasedFastPointLocator<2>::ResultIteratorType results_begin = results.begin();
62 
63  int property_id = 0;
64  for (int i = 0; i < (int)mrDestinationModelPart.Elements().size(); i++) {
65  const auto elem_it = mrDestinationModelPart.ElementsBegin() + i;
66  property_id = elem_it->GetProperties().Id();
67  break;
68  }
69  const double porosity = mrDestinationModelPart.GetProperties(property_id)[POROSITY];
70  const double particle_volume_to_voronoi_volume_factor = 1.0 / (1.0 - porosity);
71 
72  #pragma omp for
73  for (int i = 0; i < (int)mrDestinationModelPart.Elements().size(); i++) {
74  const auto elem_it = mrDestinationModelPart.ElementsBegin() + i;
75  auto& central_node = elem_it->GetGeometry()[0];
76  const auto& particle_coordinates = central_node.Coordinates();
77  SphericParticle* particle = dynamic_cast<SphericParticle*>(&*elem_it);
78  const double particle_volume = particle->CalculateVolume();
79  const double particle_mass = particle->GetMass();
80 
81  bool is_found = false;
82  Element::Pointer shared_p_element;
83  is_found = mpSearchStructure->FindPointOnMesh(particle_coordinates, N, shared_p_element, results_begin, max_results, 0.0);
84  double gravity = 9.81;
85  const double well_radius = 0.075;
86  if ((particle_coordinates[0] * particle_coordinates[0] + particle_coordinates[1] * particle_coordinates[1]) < well_radius * well_radius) {
87  noalias(central_node.FastGetSolutionStepValue(EXTERNAL_APPLIED_FORCE)) = -1.0 * particle_coordinates * particle_mass * gravity / well_radius;
88  } else if (is_found) {
89  const auto& geom = shared_p_element->GetGeometry();
90  array_1d<double, 3> interpolated_gradient_of_pore_pressure = ZeroVector(3);
91  for (size_t j = 0; j < geom.size(); j++) {
92  noalias(interpolated_gradient_of_pore_pressure) += N[j] * geom[j].FastGetSolutionStepValue(WATER_PRESSURE_GRADIENT);
93  }
94  noalias(central_node.FastGetSolutionStepValue(EXTERNAL_APPLIED_FORCE)) = -1.0 * interpolated_gradient_of_pore_pressure * particle_volume * particle_volume_to_voronoi_volume_factor;
95  }
96  }
97  }
98 
99  KRATOS_CATCH("")
100  }
101 
102  virtual std::string Info() const { return "";}
103 
104  virtual void PrintInfo(std::ostream& rOStream) const {}
105 
106  virtual void PrintData(std::ostream& rOStream) const {}
107 
108  private:
109 
110  ModelPart& mrSourceModelPart;
111  ModelPart& mrDestinationModelPart;
112  BinBasedFastPointLocator<2>* mpSearchStructure;
113 
115 
116  void Check() {
117 
118  }
119 
120  }; // class PorePressureCommunicatorUtility
121 
122 } // namespace Kratos
123 
124 #endif // PORE_PRESSURE_COMMUNICATOR_UTILITY_H
void UpdateSearchDatabase()
Function to construct or update the search database.
Definition: binbased_fast_point_locator.h:139
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
PropertiesType & GetProperties(IndexType PropertiesId, IndexType MeshIndex=0)
Returns the Properties::Pointer corresponding to it's identifier.
Definition: model_part.cpp:710
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
Definition: pore_pressure_communicator_utility.hpp:30
virtual ~PorePressureCommunicatorUtility()
Definition: pore_pressure_communicator_utility.hpp:42
void Initialize()
Definition: pore_pressure_communicator_utility.hpp:46
PorePressureCommunicatorUtility(ModelPart &r_source_model_part, ModelPart &destination_model_part)
Definition: pore_pressure_communicator_utility.hpp:38
virtual void PrintInfo(std::ostream &rOStream) const
Definition: pore_pressure_communicator_utility.hpp:104
virtual void PrintData(std::ostream &rOStream) const
Definition: pore_pressure_communicator_utility.hpp:106
virtual std::string Info() const
Definition: pore_pressure_communicator_utility.hpp:102
void ComputeForceOnParticlesDueToPorePressureGradient()
Definition: pore_pressure_communicator_utility.hpp:51
KRATOS_CLASS_POINTER_DEFINITION(PorePressureCommunicatorUtility)
ModelPart::NodesContainerType::ContainerType::iterator NodesIteratorType
Definition: pore_pressure_communicator_utility.hpp:34
Definition: spheric_particle.h:31
virtual double GetMass()
Definition: spheric_particle.cpp:2209
virtual double CalculateVolume()
Definition: spheric_particle.cpp:2196
#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
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
int j
Definition: quadrature.py:648
N
Definition: sensitivityMatrix.py:29
porosity
Definition: sp_statistics.py:18
integer i
Definition: TensorModule.f:17