1 #ifndef CALCULATE_GLOBAL_PHYSICAL_PROPERTIES_H
2 #define CALCULATE_GLOBAL_PHYSICAL_PROPERTIES_H
58 double added_volume = 0.0;
60 #pragma omp parallel for reduction(+ : added_volume)
64 if (it->GetGeometry()[0].Is(BLOCKED)) {
67 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
69 const double particle_radius = r_spheric_particle.
GetRadius();
70 added_volume += 4.0 / 3.0 *
Globals::Pi * particle_radius * particle_radius * particle_radius;
85 KRATOS_ERROR_IF(pElements.size() == 0) <<
"Cannot compute maximum of the required nodal variable. Empty model part. Could not compute the maximum of the required variable " << r_variable << std::endl;
87 ElementsArrayType::iterator it_begin = pElements.ptr_begin();
89 KRATOS_ERROR_IF_NOT(it_begin->GetGeometry()[0].SolutionStepsDataHas(r_variable)) <<
"Cannot compute maximum of the required nodal variable. Missing nodal variable " << r_variable << std::endl;
91 std::vector<double> max_values;
96 max_values[
k] = max_val;
101 unsigned int elem_counter;
103 #pragma omp parallel for private(elem_counter)
108 max_values[
k] =
std::max(max_values[
k], (it)->GetGeometry()[0].FastGetSolutionStepValue(r_variable));
115 max_val =
std::max(max_val, max_values[
k]);
127 KRATOS_ERROR_IF(pElements.size() == 0) <<
"Cannot compute minimum of the required nodal variable. Empty model part. Could not compute the maximum of the required variable " << r_variable << std::endl;
129 ElementsArrayType::iterator it_begin = pElements.ptr_begin();
131 KRATOS_ERROR_IF_NOT(it_begin->GetGeometry()[0].SolutionStepsDataHas(r_variable)) <<
"Cannot compute minimum of the required nodal variable. Missing variable " << r_variable << std::endl;
133 std::vector<double> min_values;
138 min_values[
k] = min_val;
143 unsigned int elem_counter;
145 #pragma omp parallel for private(elem_counter)
150 min_values[
k] =
std::min(min_values[
k], (it)->GetGeometry()[0].FastGetSolutionStepValue(r_variable));
157 min_val =
std::min(min_val, min_values[
k]);
171 std::vector<double> radii;
173 unsigned int particle_counter = 0;
175 #pragma omp parallel for private(particle_counter)
181 radii[particle_counter] = r_spheric_particle.
GetRadius();
186 if (particle_counter) {
187 std::sort(radii.begin(), radii.end());
188 int half =
div(size, 2).quot;
189 bool even = (size%2 == 0);
190 double d50 = even ? 2 * radii[half] : radii[half] + radii[half + 1];
206 double added_mass = 0.0;
208 #pragma omp parallel for reduction(+ : added_mass)
212 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
213 double particle_mass = (it)->GetGeometry()[0].FastGetSolutionStepValue(NODAL_MASS);
214 added_mass += particle_mass;
234 #pragma omp parallel for reduction(+ : cm_x, cm_y, cm_z)
238 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
239 double particle_mass = (it)->GetGeometry()[0].FastGetSolutionStepValue(NODAL_MASS);
240 cm_x += particle_mass * (it)->GetGeometry()[0].Coordinates()[0];
241 cm_y += particle_mass * (it)->GetGeometry()[0].Coordinates()[1];
242 cm_z += particle_mass * (it)->GetGeometry()[0].Coordinates()[2];
248 center_of_mass[0] = total_mass_inv * cm_x;
249 center_of_mass[1] = total_mass_inv * cm_y;
250 center_of_mass[2] = total_mass_inv * cm_z;
252 return center_of_mass;
260 double gravitational_energy;
262 if (total_mass == 0) gravitational_energy = 0.0;
267 gravitational_energy = total_mass * (center_of_mass_to_reference[0] * gravity[0] + center_of_mass_to_reference[1] * gravity[1] + center_of_mass_to_reference[2] * gravity[2]);
269 return gravitational_energy;
279 double kinematic_energy = 0.0;
281 #pragma omp parallel for reduction(+ : kinematic_energy)
285 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
286 double particle_translational_kinematic_energy = 0.0;
288 (it)->
Calculate(PARTICLE_TRANSLATIONAL_KINEMATIC_ENERGY, particle_translational_kinematic_energy, r_model_part.
GetProcessInfo());
290 kinematic_energy += particle_translational_kinematic_energy;
296 return kinematic_energy;
306 double rotational_kinematic_energy = 0.0;
308 #pragma omp parallel for reduction(+ : rotational_kinematic_energy)
312 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
313 double particle_rotational_kinematic_energy = 0.0;
315 (it)->
Calculate(PARTICLE_ROTATIONAL_KINEMATIC_ENERGY, particle_rotational_kinematic_energy, r_model_part.
GetProcessInfo());
317 rotational_kinematic_energy += particle_rotational_kinematic_energy;
323 return rotational_kinematic_energy;
333 double elastic_energy = 0.0;
335 #pragma omp parallel for reduction(+ : elastic_energy)
339 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
340 double particle_elastic_energy = 0.0;
344 elastic_energy += particle_elastic_energy;
350 return elastic_energy;
360 double frictional_energy = 0.0;
362 #pragma omp parallel for reduction(+ : frictional_energy)
366 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
367 double particle_frictional_energy = 0.0;
369 (it)->
Calculate(PARTICLE_INELASTIC_FRICTIONAL_ENERGY, particle_frictional_energy, r_model_part.
GetProcessInfo());
371 frictional_energy += particle_frictional_energy;
377 return frictional_energy;
384 double viscodamping_energy = 0.0;
386 #pragma omp parallel for reduction(+ : viscodamping_energy)
390 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
391 double particle_viscodamping_energy = 0.0;
393 (it)->
Calculate(PARTICLE_INELASTIC_VISCODAMPING_ENERGY, particle_viscodamping_energy, r_model_part.
GetProcessInfo());
395 viscodamping_energy += particle_viscodamping_energy;
401 return viscodamping_energy;
408 double rollingresistance_energy = 0.0;
410 #pragma omp parallel for reduction(+ : rollingresistance_energy)
414 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
415 double particle_rollingresistance_energy = 0.0;
417 (it)->
Calculate(PARTICLE_INELASTIC_ROLLING_RESISTANCE_ENERGY, particle_rollingresistance_energy, r_model_part.
GetProcessInfo());
419 rollingresistance_energy += particle_rollingresistance_energy;
425 return rollingresistance_energy;
439 #pragma omp parallel for reduction(+ : m_x, m_y, m_z)
443 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
446 m_x += particle_momentum[0];
447 m_y += particle_momentum[1];
448 m_z += particle_momentum[2];
474 #pragma omp parallel for reduction(+ : am_x, am_y, am_z)
478 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)) {
481 array_1d<double, 3> center_of_mass_to_particle = (it)->GetGeometry()[0].Coordinates() - center_of_mass;
489 am_x += particle_local_angular_momentum[0] + aux[0];
490 am_y += particle_local_angular_momentum[1] + aux[1];
491 am_z += particle_local_angular_momentum[2] + aux[2];
497 angular_momentum[0] = am_x;
498 angular_momentum[1] = am_y;
499 angular_momentum[2] = am_z;
501 return angular_momentum;
510 double sum_of_contact_forces_x = 0.0;
511 double sum_of_contact_forces_y = 0.0;
512 double sum_of_contact_forces_z = 0.0;
514 #pragma omp parallel for reduction(+ : sum_of_contact_forces_x, sum_of_contact_forces_y, sum_of_contact_forces_z)
518 if ((it)->IsNot(DEMFlags::BELONGS_TO_A_CLUSTER)){
519 const array_1d<double, 3>& contact_force = (it)->GetGeometry()[0].FastGetSolutionStepValue(CONTACT_FORCES);
520 sum_of_contact_forces_x += contact_force[0];
521 sum_of_contact_forces_y += contact_force[1];
522 sum_of_contact_forces_z += contact_force[2];
528 sum_of_contact_forces[0] = sum_of_contact_forces_x;
529 sum_of_contact_forces[1] = sum_of_contact_forces_y;
530 sum_of_contact_forces[2] = sum_of_contact_forces_z;
531 return sum_of_contact_forces;
541 return mInitialCenterOfMassAndMass;
555 virtual std::string
Info()
const
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
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
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
Definition: calculate_global_physical_properties.h:32
ModelPart::ElementsContainerType ElementsArrayType
Definition: calculate_global_physical_properties.h:35
virtual std::string Info() const
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: calculate_global_physical_properties.h:555
double CalculateTotalMass(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:202
double CalculateD50(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:166
SphericElementGlobalPhysicsCalculator(ModelPart &r_model_part)
Default constructor.
Definition: calculate_global_physical_properties.h:41
std::vector< unsigned int > & GetElementPartition()
Definition: calculate_global_physical_properties.h:577
array_1d< double, 3 > GetInitialCenterOfMass()
Definition: calculate_global_physical_properties.h:539
double CalculateMaxNodalVariable(ModelPart &r_model_part, const Variable< double > &r_variable)
Definition: calculate_global_physical_properties.h:82
double CalculateInelasticViscodampingEnergy(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:380
array_1d< double, 3 > CalculateSumOfInternalForces(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:507
ElementsArrayType::iterator GetElementPartitionEnd(ModelPart &r_model_part, unsigned int k)
Definition: calculate_global_physical_properties.h:588
array_1d< double, 3 > CalulateTotalAngularMomentum(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:465
double CalculateInelasticFrictionalEnergy(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:356
double CalculateElasticEnergy(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:329
double CalculateMinNodalVariable(ModelPart &r_model_part, const Variable< double > &r_variable)
Definition: calculate_global_physical_properties.h:124
ElementsArrayType::iterator GetElementPartitionBegin(ModelPart &r_model_part, unsigned int k)
Definition: calculate_global_physical_properties.h:582
double CalculateTranslationalKinematicEnergy(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:275
KRATOS_CLASS_POINTER_DEFINITION(SphericElementGlobalPhysicsCalculator)
array_1d< double, 3 > CalculateCenterOfMass(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:225
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: calculate_global_physical_properties.h:562
array_1d< double, 3 > CalculateTotalMomentum(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:431
double CalculateRotationalKinematicEnergy(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:302
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: calculate_global_physical_properties.h:568
double CalculateTotalVolume(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:55
double CalculateInelasticRollingResistanceEnergy(ModelPart &r_model_part)
Definition: calculate_global_physical_properties.h:404
std::vector< unsigned int > mElementsPartition
Definition: calculate_global_physical_properties.h:619
virtual ~SphericElementGlobalPhysicsCalculator()
Destructor.
Definition: calculate_global_physical_properties.h:49
double CalculateGravitationalPotentialEnergy(ModelPart &r_model_part, const array_1d< double, 3 > reference_point)
Definition: calculate_global_physical_properties.h:258
Definition: spheric_particle.h:31
virtual double GetRadius()
Definition: spheric_particle.cpp:2195
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
constexpr double Pi
Definition: global_variables.h:25
TDataType Calculate(GeometryType &dummy, const Variable< TDataType > &rVariable)
Definition: add_geometries_to_python.cpp:103
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int k
Definition: quadrature.py:595
def div(DN, x)
This method defines the divergence.
Definition: sympy_fe_utilities.py:291