Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
dem_post_processing.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5
7
8namespace DEM
9{
10 template <int dim, typename PropertiesIndex, dem_statistic_variable var>
11 statistics
13 const Particles::ParticleHandler<dim> &particle_handler,
14 const MPI_Comm &mpi_communicator)
15 {
16 double total_variable = 0;
17 double max_variable = DBL_MIN;
18 double min_variable = DBL_MAX;
19
20
21 for (auto &particle : particle_handler)
22 {
23 // Get the properties of the particle
24 auto particle_properties = particle.get_properties();
25
26 double variable = 0;
27
28 if constexpr (var ==
30 {
31 // Put particle velocity in a tensor
32 Tensor<1, dim> velocity;
33 for (int d = 0; d < dim; ++d)
34 velocity[d] = particle_properties[PropertiesIndex::v_x + d];
35
36 // Kinetic energy is 0.5*m*u^2
37 variable = 0.5 * particle_properties[PropertiesIndex::mass] *
38 velocity.norm_square();
39 }
41 {
42 // Put angular velocity in a tensor
43 Tensor<1, 3> omega;
44 if constexpr (dim == 2)
45 {
46 omega[2] = particle_properties[PropertiesIndex::omega_z];
47 }
48 if constexpr (dim == 3)
49 {
50 for (int d = 0; d < dim; ++d)
51 omega[d] = particle_properties[PropertiesIndex::omega_x + d];
52 }
53
54 // Kinetic energy is 0.1*m*d^2 * w^2
55 variable = 0.1 * particle_properties[PropertiesIndex::mass] *
56 Utilities::fixed_power<2>(
57 particle_properties[PropertiesIndex::dp]) *
58 omega.norm_square();
59 }
60
61 if constexpr (var == dem_statistic_variable::velocity)
62 {
63 // Put particle velocity in a tensor
64 Tensor<1, dim> velocity;
65 for (int d = 0; d < dim; ++d)
66 velocity[d] = particle_properties[PropertiesIndex::v_x + d];
67
68 variable = velocity.norm();
69 }
70
71 if constexpr (var == dem_statistic_variable::omega)
72 {
73 // Put angular velocity in a tensor
74 Tensor<1, 3> omega;
75 if constexpr (dim == 2)
76 {
77 omega[2] = particle_properties[PropertiesIndex::omega_z];
78 }
79 if constexpr (dim == 3)
80 {
81 for (int d = 0; d < dim; ++d)
82 omega[d] = particle_properties[PropertiesIndex::omega_x + d];
83 }
84
85 variable = omega.norm();
86 }
87
88 total_variable += variable;
89
90 max_variable = std::max(variable, max_variable);
91 min_variable = std::min(variable, min_variable);
92 }
93
94 total_variable = Utilities::MPI::sum(total_variable, mpi_communicator);
95 max_variable = Utilities::MPI::max(max_variable, mpi_communicator);
96 min_variable = Utilities::MPI::min(min_variable, mpi_communicator);
97
98 statistics stats;
99 stats.total = total_variable;
100 stats.max = max_variable;
101 stats.min = min_variable;
102 stats.average = total_variable / particle_handler.n_global_particles();
103
104 return stats;
105 }
106
107
108 template statistics
110 2,
113 const Particles::ParticleHandler<2, 2> &particle_handler,
114 const MPI_Comm &mpi_communicator);
115
116 template statistics
118 3,
121 const Particles::ParticleHandler<3, 3> &particle_handler,
122 const MPI_Comm &mpi_communicator);
123
124 template statistics
126 2,
129 const Particles::ParticleHandler<2, 2> &particle_handler,
130 const MPI_Comm &mpi_communicator);
131
132 template statistics
134 3,
137 const Particles::ParticleHandler<3, 3> &particle_handler,
138 const MPI_Comm &mpi_communicator);
139
140 template statistics
144 const Particles::ParticleHandler<2, 2> &particle_handler,
145 const MPI_Comm &mpi_communicator);
146
147 template statistics
151 const Particles::ParticleHandler<3, 3> &particle_handler,
152 const MPI_Comm &mpi_communicator);
153
154 template statistics
158 const Particles::ParticleHandler<2, 2> &particle_handler,
159 const MPI_Comm &mpi_communicator);
160
161 template statistics
165 const Particles::ParticleHandler<3, 3> &particle_handler,
166 const MPI_Comm &mpi_communicator);
167
168
169 template statistics
171 2,
174 const Particles::ParticleHandler<2, 2> &particle_handler,
175 const MPI_Comm &mpi_communicator);
176
177 template statistics
179 3,
182 const Particles::ParticleHandler<3, 3> &particle_handler,
183 const MPI_Comm &mpi_communicator);
184
185 template statistics
187 2,
190 const Particles::ParticleHandler<2, 2> &particle_handler,
191 const MPI_Comm &mpi_communicator);
192
193 template statistics
195 3,
198 const Particles::ParticleHandler<3, 3> &particle_handler,
199 const MPI_Comm &mpi_communicator);
200
201 template statistics
205 const Particles::ParticleHandler<2, 2> &particle_handler,
206 const MPI_Comm &mpi_communicator);
207
208 template statistics
212 const Particles::ParticleHandler<3, 3> &particle_handler,
213 const MPI_Comm &mpi_communicator);
214
215 template statistics
219 const Particles::ParticleHandler<2, 2> &particle_handler,
220 const MPI_Comm &mpi_communicator);
221
222 template statistics
226 const Particles::ParticleHandler<3, 3> &particle_handler,
227 const MPI_Comm &mpi_communicator);
228
229
230 template statistics
232 2,
235 const Particles::ParticleHandler<2, 2> &particle_handler,
236 const MPI_Comm &mpi_communicator);
237
238 template statistics
240 2,
243 const Particles::ParticleHandler<2, 2> &particle_handler,
244 const MPI_Comm &mpi_communicator);
245
246 template statistics
248 3,
251 const Particles::ParticleHandler<3, 3> &particle_handler,
252 const MPI_Comm &mpi_communicator);
253
254 template statistics
256 3,
259 const Particles::ParticleHandler<3, 3> &particle_handler,
260 const MPI_Comm &mpi_communicator);
261
262 template statistics
264 2,
267 const Particles::ParticleHandler<2, 2> &particle_handler,
268 const MPI_Comm &mpi_communicator);
269
270 template statistics
272 2,
275 const Particles::ParticleHandler<2, 2> &particle_handler,
276 const MPI_Comm &mpi_communicator);
277
278 template statistics
280 3,
283 const Particles::ParticleHandler<3, 3> &particle_handler,
284 const MPI_Comm &mpi_communicator);
285
286 template statistics
288 3,
291 const Particles::ParticleHandler<3, 3> &particle_handler,
292 const MPI_Comm &mpi_communicator);
293
294 template statistics
298 const Particles::ParticleHandler<2, 2> &particle_handler,
299 const MPI_Comm &mpi_communicator);
300
301 template statistics
305 const Particles::ParticleHandler<2, 2> &particle_handler,
306 const MPI_Comm &mpi_communicator);
307
308 template statistics
312 const Particles::ParticleHandler<3, 3> &particle_handler,
313 const MPI_Comm &mpi_communicator);
314
315 template statistics
319 const Particles::ParticleHandler<3, 3> &particle_handler,
320 const MPI_Comm &mpi_communicator);
321
322 template statistics
326 const Particles::ParticleHandler<2, 2> &particle_handler,
327 const MPI_Comm &mpi_communicator);
328
329 template statistics
333 const Particles::ParticleHandler<2, 2> &particle_handler,
334 const MPI_Comm &mpi_communicator);
335
336 template statistics
340 const Particles::ParticleHandler<3, 3> &particle_handler,
341 const MPI_Comm &mpi_communicator);
342
343 template statistics
347 const Particles::ParticleHandler<3, 3> &particle_handler,
348 const MPI_Comm &mpi_communicator);
349
350} // namespace DEM
A simple container for storing basic statistical values.
Definition utilities.h:56
double average
The average value of the dataset.
Definition utilities.h:81
double max
The maximum value in the dataset.
Definition utilities.h:75
double min
The minimum value in the dataset.
Definition utilities.h:72
double total
The sum of all values in the dataset.
Definition utilities.h:78
DEM particle property definitions and output name management.
PropertiesIndex
Particle property indices for CFD-DEM multiphysics simulations.
PropertiesIndex
Particle property indices for CFD-DEM simulations.
PropertiesIndex
Particle property indices for DEM multiphysics simulations.
PropertiesIndex
Particle property indices for pure DEM simulations.
This namespace defines all the data containers and required operations on these containers for the DE...
statistics calculate_granular_statistics(const Particles::ParticleHandler< dim > &particle_handler, const MPI_Comm &mpi_communicator)
Calculate statistics on a DEM ParticleHandler. At the moment, the following statistics are supported: