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.
parallel_bond_utilities.h
Go to the documentation of this file.
1 #ifndef PARALLEL_BOND_UTILITIES_H
2 #define PARALLEL_BOND_UTILITIES_H
3 
4 #include "includes/define.h"
8 
9 #ifdef _OPENMP
10 #include <omp.h>
11 #endif
12 
13 namespace Kratos {
14 
16 
17  public:
18 
21 
23 
25 
27 
29 
30  virtual ~ParallelBondUtilities() {};
31 
33  {
35  KRATOS_TRY;
36 
37  ElementsArrayType& rElements = rModelPart.GetCommunicator().LocalMesh().Elements();
38 
39  block_for_each(rElements, [&](ModelPart::ElementType& rElement) {
40 
41  SphericContinuumParticle& r_sphere = dynamic_cast<SphericContinuumParticle&>(rElement);
42 
43  for (int i = 0; i < (int) r_sphere.mContinuumInitialNeighborsSize; i++) {
44 
45  if (!r_sphere.mNeighbourElements[i]) {
46  continue;
47  }
48 
49  const auto& other_particle = r_sphere.mNeighbourElements[i];
50  array_1d<double, 3> other_to_me_vector;
51  noalias(other_to_me_vector) = r_sphere.GetGeometry()[0].Coordinates() - other_particle->GetGeometry()[0].Coordinates();
52  const double& this_radius = r_sphere.GetRadius();
53  const double& other_radius = other_particle->GetRadius();
54  const double distance = DEM_MODULUS_3(other_to_me_vector);
55  const double radius_sum = this_radius + other_radius;
56  const double& initial_delta = r_sphere.GetInitialDelta(i);
57  const double initial_dist = radius_sum - initial_delta;
58  const double indentation = initial_dist - distance;
59  Kratos::DEMContinuumConstitutiveLaw::Pointer ccl = r_sphere.mContinuumConstitutiveLawArray[i];
60  DEM_KDEM_with_damage_parallel_bond* p_parallel_bond_ccl = dynamic_cast<DEM_KDEM_with_damage_parallel_bond*>(&*ccl);
61  p_parallel_bond_ccl->mInitialIndentationForBondedPart = indentation;
62  }
63  });
64 
65  KRATOS_CATCH("");
66  }
67 
69  {
71  KRATOS_TRY;
72 
73  ElementsArrayType& rElements = rModelPart.GetCommunicator().LocalMesh().Elements();
74 
75  block_for_each(rElements, [&](ModelPart::ElementType& rElement) {
76 
77  SphericContinuumParticle& r_sphere = dynamic_cast<SphericContinuumParticle&>(rElement);
78 
79  for (int i = 0; i < (int) r_sphere.mContinuumInitialNeighborsSize; i++) {
80 
81  if (!r_sphere.mNeighbourElements[i]) {
82  continue;
83  }
84 
85  const auto& other_particle = r_sphere.mNeighbourElements[i];
86  array_1d<double, 3> other_to_me_vector;
87  noalias(other_to_me_vector) = r_sphere.GetGeometry()[0].Coordinates() - other_particle->GetGeometry()[0].Coordinates();
88  const double& this_radius = r_sphere.GetRadius();
89  const double& other_radius = other_particle->GetRadius();
90  const double distance = DEM_MODULUS_3(other_to_me_vector);
91  const double radius_sum = this_radius + other_radius;
92  const double& initial_delta = r_sphere.GetInitialDelta(i);
93  const double initial_dist = radius_sum - initial_delta;
94  const double indentation = initial_dist - distance;
95  Kratos::DEMContinuumConstitutiveLaw::Pointer ccl = r_sphere.mContinuumConstitutiveLawArray[i];
96  if (ccl->GetTypeOfLaw() == "parallel_bond_CL"){
97  DEM_parallel_bond* p_parallel_bond_ccl = dynamic_cast<DEM_parallel_bond*>(&*ccl);
98  p_parallel_bond_ccl->mInitialIndentationForBondedPart = indentation;
99  }
100  }
101  });
102 
103  KRATOS_CATCH("");
104  }
105 
106  }; // Class ParallelBondUtilities
107 
108 } // namespace Kratos.
109 
110 #endif // PARALLEL_BOND_UTILITIES_H
#define DEM_MODULUS_3(a)
Definition: DEM_application_variables.h:29
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Definition: DEM_KDEM_with_damage_parallel_bond_CL.h:10
double mInitialIndentationForBondedPart
Definition: DEM_KDEM_with_damage_parallel_bond_CL.h:126
Definition: DEM_parallel_bond_CL.h:16
double mInitialIndentationForBondedPart
Definition: DEM_parallel_bond_CL.h:190
Base class for all Elements.
Definition: element.h:60
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
Definition: parallel_bond_utilities.h:15
ModelPart::ElementsContainerType ElementsArrayType
Definition: parallel_bond_utilities.h:19
ModelPart::NodesContainerType NodesContainerType
Definition: parallel_bond_utilities.h:20
virtual ~ParallelBondUtilities()
Destructor.
Definition: parallel_bond_utilities.h:30
void SetCurrentIndentationAsAReferenceInParallelBondsForPBM(ModelPart &rModelPart)
Definition: parallel_bond_utilities.h:68
void SetCurrentIndentationAsAReferenceInParallelBonds(ModelPart &rModelPart)
Definition: parallel_bond_utilities.h:32
ParallelBondUtilities()
Default constructor.
Definition: parallel_bond_utilities.h:26
KRATOS_CLASS_POINTER_DEFINITION(ParallelBondUtilities)
Definition: spheric_continuum_particle.h:26
std::vector< Kratos::DEMContinuumConstitutiveLaw::Pointer > mContinuumConstitutiveLawArray
Definition: spheric_continuum_particle.h:135
unsigned int mContinuumInitialNeighborsSize
Definition: spheric_continuum_particle.h:133
virtual double GetInitialDelta(int index)
Definition: spheric_continuum_particle.cpp:834
virtual double GetRadius()
Definition: spheric_particle.cpp:2195
std::vector< SphericParticle * > mNeighbourElements
Definition: spheric_particle.h:248
#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
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
integer i
Definition: TensorModule.f:17