1 #ifndef POST_UTILITIES_H
2 #define POST_UTILITIES_H
51 rCompleteModelPart.
Nodes().reserve(tot_nodes);
52 rCompleteModelPart.
Elements().reserve(tot_elements);
55 rCompleteModelPart.
Nodes().push_back(*node_it);
60 rCompleteModelPart.
Elements().push_back(*elem_it);
72 int tot_size = rCompleteModelPart.
Nodes().size();
76 Node &
i = *i_iterator;
77 if (
i.IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {tot_size += 1;}
79 rCompleteModelPart.
Nodes().reserve(tot_size);
80 rCompleteModelPart.
Elements().reserve(tot_size);
84 Node &
i = *i_iterator;
85 if (
i.IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {rCompleteModelPart.
Nodes().push_back(*node_it);}
90 Node&
i = (*elem_it)->GetGeometry()[0];
91 if (
i.IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {rCompleteModelPart.
Elements().push_back(*elem_it);}
101 double velocity_X = 0.0, velocity_Y = 0.0, velocity_Z = 0.0;
102 int number_of_elements = 0;
110 std::tie(velocity_X,velocity_Y,velocity_Z,number_of_elements) = block_for_each<MultipleReduction>(pElements, [&](
ModelPart::ElementType& rElement){
112 double local_sum_x = 0.0;
113 double local_sum_y = 0.0;
114 double local_sum_z = 0.0;
115 int local_sum_elem = 0;
117 if (coor[0] >= low_point[0] && coor[0] <= high_point[0] &&
118 coor[1] >= low_point[1] && coor[1] <= high_point[1] &&
119 coor[2] >= low_point[2] && coor[2] <= high_point[2]) {
121 local_sum_x += rElement.
GetGeometry()[0].FastGetSolutionStepValue(VELOCITY_X);
122 local_sum_y += rElement.
GetGeometry()[0].FastGetSolutionStepValue(VELOCITY_Y);
123 local_sum_z += rElement.
GetGeometry()[0].FastGetSolutionStepValue(VELOCITY_Z);
128 for (
int i = 0;
i < 3; ++
i) {
129 KRATOS_ERROR_IF(high_point[
i] < low_point[
i]) <<
"Check the limits of the Velocity Trap Box. Maximum coordinates smaller than minimum coordinates." << std::endl;
132 return std::make_tuple(local_sum_x, local_sum_y, local_sum_z, local_sum_elem);
135 if (number_of_elements) {
136 velocity_X /= number_of_elements;
137 velocity_Y /= number_of_elements;
138 velocity_Z /= number_of_elements;
154 for (ModelPart::NodesContainerType::ptr_iterator node_pointer_it = mesh_nodes.ptr_begin();
155 node_pointer_it != mesh_nodes.ptr_end(); ++node_pointer_it) {
157 const array_1d<double, 3>& contact_forces_summed_at_structure_point = (*node_pointer_it)->FastGetSolutionStepValue(CONTACT_FORCES);
158 noalias(total_forces) += contact_forces_summed_at_structure_point;
161 noalias(vector_from_structure_center_to_structure_point) = (*node_pointer_it)->Coordinates() - rotation_center;
166 noalias(total_moment) += moment_to_add;
172 for (ModelPart::NodesContainerType::ptr_iterator node_pointer_it = mesh_nodes.ptr_begin(); node_pointer_it != mesh_nodes.ptr_end(); ++node_pointer_it) {
174 const array_1d<double, 3> elastic_forces_added_up_at_node = (*node_pointer_it)->FastGetSolutionStepValue(ELASTIC_FORCES);
175 noalias(total_forces) += elastic_forces_added_up_at_node;
182 double total_poisson_value = 0.0;
183 unsigned int number_of_spheres_to_evaluate_poisson = 0;
187 for (
unsigned int k = 0;
k < pElements.size();
k++) {
189 ElementsArrayType::iterator it = pElements.ptr_begin() +
k;
190 Element* raw_p_element = &(*it);
192 double& particle_poisson_value = p_sphere->
GetGeometry()[0].FastGetSolutionStepValue(POISSON_VALUE);
193 particle_poisson_value = 0.0;
194 double epsilon_XY = 0.0;
195 double epsilon_Z = 0.0;
196 unsigned int number_of_neighbors_per_sphere_to_evaluate_poisson = 0;
201 for (
unsigned int i = 0;
i < number_of_neighbors;
i++) {
206 double initial_distance_XY = sqrt(initial_other_to_me_vector[0] * initial_other_to_me_vector[0] + initial_other_to_me_vector[1] * initial_other_to_me_vector[1]);
207 double initial_distance_Z = initial_other_to_me_vector[2];
209 if (initial_distance_XY && initial_distance_Z) {
210 epsilon_XY = -1 + sqrt(other_to_me_vector[0] * other_to_me_vector[0] + other_to_me_vector[1] * other_to_me_vector[1]) / initial_distance_XY;
211 epsilon_Z = -1 + fabs(other_to_me_vector[2] / initial_distance_Z);
215 if (((-epsilon_XY / epsilon_Z) > 0.5) || ((-epsilon_XY / epsilon_Z) < 0.0))
continue;
216 particle_poisson_value -= epsilon_XY / epsilon_Z;
217 number_of_neighbors_per_sphere_to_evaluate_poisson++;
221 if (number_of_neighbors_per_sphere_to_evaluate_poisson) {
222 particle_poisson_value /= number_of_neighbors_per_sphere_to_evaluate_poisson;
223 number_of_spheres_to_evaluate_poisson++;
224 total_poisson_value += particle_poisson_value;
228 if (number_of_spheres_to_evaluate_poisson) total_poisson_value /= number_of_spheres_to_evaluate_poisson;
230 return_data[0] = total_poisson_value;
239 double total_poisson_value = 0.0;
240 unsigned int number_of_bonds_to_evaluate_poisson = 0;
242 double total_epsilon_y_value = 0.0;
245 for (
unsigned int k = 0;
k < pElements.size();
k++) {
247 ElementsArrayType::iterator it = pElements.ptr_begin() +
k;
248 Element* raw_p_element = &(*it);
250 double& particle_poisson_value = p_sphere->
GetGeometry()[0].FastGetSolutionStepValue(POISSON_VALUE);
251 particle_poisson_value = 0.0;
252 double epsilon_X = 0.0;
253 double epsilon_Y = 0.0;
254 unsigned int number_of_neighbors_to_evaluate_poisson = 0;
257 double average_sphere_epsilon_y_value = 0.0;
261 for (
unsigned int i = 0;
i < number_of_neighbors;
i++)
266 double initial_distance_X = initial_other_to_me_vector[0];
267 double initial_distance_Y = initial_other_to_me_vector[1];
268 if (initial_distance_X && initial_distance_Y) {
269 epsilon_X = -1 + fabs(other_to_me_vector[0] / initial_distance_X);
270 epsilon_Y = -1 + fabs(other_to_me_vector[1] / initial_distance_Y);
273 particle_poisson_value -= epsilon_X / epsilon_Y;
274 number_of_neighbors_to_evaluate_poisson++;
275 total_poisson_value -= epsilon_X / epsilon_Y;
276 number_of_bonds_to_evaluate_poisson++;
278 average_sphere_epsilon_y_value += epsilon_Y;
280 if (number_of_neighbors_to_evaluate_poisson) particle_poisson_value /= number_of_neighbors_to_evaluate_poisson;
282 total_epsilon_y_value += average_sphere_epsilon_y_value / number_of_neighbors;
285 if (number_of_bonds_to_evaluate_poisson) total_poisson_value /= number_of_bonds_to_evaluate_poisson;
287 total_epsilon_y_value /= pElements.size();
289 return_data[0] = total_poisson_value;
290 return_data[1] = total_epsilon_y_value;
300 bool if_trihedron_option = (
bool) r_process_info[TRIHEDRON_OPTION];
306 #pragma omp parallel for
307 for (
int k = 0;
k < (
int) pSpheresNodes.size();
k++) {
310 Node &
i = *i_iterator;
314 if (if_trihedron_option &&
i.IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
320 #pragma omp parallel for
321 for (
int k = 0;
k < (
int) pClusterNodes.size();
k++) {
324 Node &
i = *i_iterator;
340 double total_force = block_for_each<MaxReduction<double>>(pParticleElements, [&](
ModelPart::ElementType& rParticleElement) ->
double {
342 double local_force = 0.0;
343 const auto& n0 = geom[0];
344 if (n0.IsNot(DEMFlags::FIXED_VEL_X) &&
345 n0.IsNot(DEMFlags::FIXED_VEL_Y) &&
346 n0.IsNot(DEMFlags::FIXED_VEL_Z)){
348 particle_forces = n0.FastGetSolutionStepValue(TOTAL_FORCES);
349 double mass = n0.FastGetSolutionStepValue(NODAL_MASS);
350 particle_forces[0] += mass * gravity[0];
351 particle_forces[1] += mass * gravity[1];
352 particle_forces[2] += mass * gravity[2];
365 double total_elastic_force = block_for_each<MaxReduction<double>>(pContactElements, [&](
ModelPart::ElementType& rContactElement) ->
double {
367 double local_force = 0.0;
368 if (geom[0].IsNot(DEMFlags::FIXED_VEL_X) &&
369 geom[0].IsNot(DEMFlags::FIXED_VEL_Y) &&
370 geom[0].IsNot(DEMFlags::FIXED_VEL_Z)){
372 contact_forces = rContactElement.GetValue(LOCAL_CONTACT_FORCE);
381 double adimensional_value = 0.0;
382 if (total_elastic_force != 0.0) {
383 adimensional_value = total_force/total_elastic_force;
386 KRATOS_ERROR <<
"There are no elastic forces= " << total_elastic_force << std::endl;
389 return adimensional_value;
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Base class for all Elements.
Definition: element.h:60
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
NodesContainerType & Nodes()
Definition: mesh.h:346
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
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
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
This class defines the node.
Definition: node.h:65
ptr_iterator ptr_end()
Returns an iterator pointing to the end of the underlying data container.
Definition: pointer_vector_set.h:404
ptr_iterator ptr_begin()
Returns an iterator pointing to the beginning of the underlying data container.
Definition: pointer_vector_set.h:386
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
Definition: post_utilities.h:26
double QuasiStaticAdimensionalNumber(ModelPart &rParticlesModelPart, ModelPart &rContactModelPart, const ProcessInfo &r_process_info)
Definition: post_utilities.h:334
array_1d< double, 3 > ComputePoisson(ModelPart &rModelPart)
Definition: post_utilities.h:179
array_1d< double, 3 > ComputePoisson2D(ModelPart &rModelPart)
Definition: post_utilities.h:236
virtual ~PostUtilities()
Destructor.
Definition: post_utilities.h:41
void AddModelPartToModelPart(ModelPart &rCompleteModelPart, ModelPart &rModelPartToAdd)
Definition: post_utilities.h:43
void AddSpheresNotBelongingToClustersToMixModelPart(ModelPart &rCompleteModelPart, ModelPart &rModelPartToAdd)
Definition: post_utilities.h:66
ModelPart::ElementsContainerType ElementsArrayType
Definition: post_utilities.h:30
ModelPart::NodesContainerType NodesContainerType
Definition: post_utilities.h:31
array_1d< double, 3 > VelocityTrap(ModelPart &rModelPart, const array_1d< double, 3 > &low_point, const array_1d< double, 3 > &high_point)
Definition: post_utilities.h:97
void IntegrationOfForces(ModelPart::NodesContainerType &mesh_nodes, array_1d< double, 3 > &total_forces, array_1d< double, 3 > &rotation_center, array_1d< double, 3 > &total_moment)
Definition: post_utilities.h:151
KRATOS_CLASS_POINTER_DEFINITION(PostUtilities)
void IntegrationOfElasticForces(ModelPart::NodesContainerType &mesh_nodes, array_1d< double, 3 > &total_forces)
Definition: post_utilities.h:170
PostUtilities()
Default constructor.
Definition: post_utilities.h:37
void ComputeEulerAngles(ModelPart &rSpheresModelPart, ModelPart &rClusterModelPart)
Definition: post_utilities.h:297
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Definition: spheric_particle.h:31
std::vector< SphericParticle * > mNeighbourElements
Definition: spheric_particle.h:248
utility function to do a sum reduction
Definition: reduction_utilities.h:68
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
static void module(const array_1d< double, 3 > &Vector, double &distance)
Definition: GeometryFunctions.h:127
static void EulerAnglesFromRotationAngle(array_1d< double, 3 > &EulerAngles, const array_1d< double, 3 > &RotatedAngle)
Definition: GeometryFunctions.h:870
void QuaternionToGiDEulerAngles(const Quaternion< double > &quaternion, array_1d< double, 3 > &EulerAngles)
Definition: GeometryFunctions.h:1618
static void CrossProduct(const double u[3], const double v[3], double ReturnVector[3])
Definition: GeometryFunctions.h:325
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 INNER_LOOP_ITERATION DISTANCE_THRESHOLD ACTIVE_CHECK_FACTOR AUXILIAR_COORDINATES NORMAL_GAP WEIGHTED_GAP WEIGHTED_SCALAR_RESIDUAL bool
Definition: contact_structural_mechanics_application_variables.h:93
ModelPart::NodesContainerType NodesArrayType
Definition: gid_gauss_point_container.h:42
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
float velocity
Definition: PecletTest.py:54
int k
Definition: quadrature.py:595
integer i
Definition: TensorModule.f:17
Definition: reduction_utilities.h:310