Skip to content

Commit 1c148d4

Browse files
authored
Dem insertion: clear and add (chaos-polymtl#1135)
Description of the problem LPBF spreading simulations requires a lots of particles. Most of them are useless during most of the simulation time, as they are deep the powder dispenser. It would be more efficient to only simulate the particles required for the layer N and not for the following layers. Description of the solution A new insertion method called "clear and add" has been implemented. This method is very similar to file insertion in that it reads particle position, diameter and velocity from input files. First, we define a clearing box, where particles will be deleted. Then, we insert new particles from an insertion file. Each insertion, a different insertion file can be use. How Has This Been Tested? Custom parameter file. (See slack) Comments I still need to do a test, and example and the documentation for this method. I have change the order for the parsing of the parameters. It is now in alphabetical order. It is cleaner IMO. Former-commit-id: f69c03c
1 parent a1c468b commit 1c148d4

33 files changed

+707
-205
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to the Lethe project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/).
55

6+
## [Master] - 2024-05-27
7+
8+
### Changed
9+
10+
- MINOR The "insertion file name" parameter has been renamed to "list of input files". It now supports a list of input files that will be used in order when inserting particles. [#1135](https://github.com/chaos-polymtl/lethe/pull/1135)
11+
612
## [Master] - 2024-05-26
713

814
### Fixed

applications_tests/lethe-particles/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ file(COPY periodic_gmsh_files/pipe.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/
2424
file(COPY load_balancing_solid_object_files/square.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/load_balancing_solid_object.${_build_type}")
2525
file(COPY insert_file_3d_files/particles.input DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/insert_file_3d.${_build_type}")
2626
file(COPY moving_float_files/square.msh DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/moving_float.${_build_type}")
27+
file(COPY insert_and_remove_with_files_files/particles_00.input DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/insert_and_remove_with_files.${_build_type}")
28+
file(COPY insert_and_remove_with_files_files/particles_01.input DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/insert_and_remove_with_files.${_build_type}")
2729

2830
file(COPY moving_receptacle_files/restart.insertion_object DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/restart_moving_receptacle.${_build_type}/mpirun=1/")
2931
file(COPY moving_receptacle_files/restart.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/restart_moving_receptacle.${_build_type}/mpirun=1/")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Listing of Parameters
2+
#----------------------
3+
4+
set dimension = 3
5+
6+
#---------------------------------------------------
7+
# Simulation Control
8+
#---------------------------------------------------
9+
10+
subsection simulation control
11+
set time step = 1e-5
12+
set time end = 0.11
13+
set log frequency = 10000
14+
set output frequency = 0
15+
end
16+
17+
#---------------------------------------------------
18+
# Timer
19+
#---------------------------------------------------
20+
21+
subsection timer
22+
set type = none
23+
end
24+
25+
#---------------------------------------------------
26+
# Test
27+
#---------------------------------------------------
28+
29+
subsection test
30+
set enable = true
31+
end
32+
33+
#---------------------------------------------------
34+
# Model parameters
35+
#---------------------------------------------------
36+
37+
subsection model parameters
38+
subsection contact detection
39+
set contact detection method = dynamic
40+
set dynamic contact search size coefficient = 0.9
41+
set neighborhood threshold = 1.3
42+
end
43+
set particle particle contact force method = hertz_mindlin_limit_overlap
44+
set particle wall contact force method = nonlinear
45+
set rolling resistance torque method = constant_resistance
46+
set integration method = velocity_verlet
47+
end
48+
49+
#---------------------------------------------------
50+
# Lagrangian Physical Properties
51+
#---------------------------------------------------
52+
53+
subsection lagrangian physical properties
54+
set gx = 0.0
55+
set gy = 0.0
56+
set gz = 0.0
57+
set number of particle types = 1
58+
subsection particle type 0
59+
set size distribution type = uniform
60+
set diameter = 0.1
61+
set number of particles = 6
62+
set density particles = 1000
63+
set young modulus particles = 1000000
64+
set poisson ratio particles = 0.3
65+
set restitution coefficient particles = 0.3
66+
set friction coefficient particles = 0.1
67+
set rolling friction particles = 0.05
68+
end
69+
set young modulus wall = 1000000
70+
set poisson ratio wall = 0.3
71+
set restitution coefficient wall = 0.3
72+
set friction coefficient wall = 0.1
73+
set rolling friction wall = 0.05
74+
end
75+
76+
#---------------------------------------------------
77+
# Insertion Info
78+
#---------------------------------------------------
79+
80+
subsection insertion info
81+
set insertion method = file
82+
set insertion frequency = 100
83+
set list of input files = ../particles_00.input, ../particles_01.input
84+
set removal box points coordinates = 0., -1., -1.: 1., 1., 1.
85+
set remove particles = true
86+
end
87+
88+
#---------------------------------------------------
89+
# Mesh
90+
#---------------------------------------------------
91+
92+
subsection mesh
93+
set type = dealii
94+
set grid type = hyper_cube
95+
set grid arguments = -0.8 : 0.8 : false
96+
set initial refinement = 2
97+
set expand particle-wall contact search = false
98+
end
99+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
*********************
3+
Running on 1 rank(s)
4+
*********************
5+
DEM time-step is 0.115554% of Rayleigh time step
6+
Warning: It is recommended to increase the time-step
7+
Reading triangulation
8+
9+
Finished reading triangulation
10+
Warning: expansion of particle-wall contact list is disabled.
11+
This feature is useful in geometries with concave boundaries.
12+
*********************************************************************
13+
4 particles of type 0 were inserted, 2 particles of type 0 remaining
14+
*********************************************************************
15+
*********************************************************************
16+
2 particles of type 0 were inserted, 0 particles of type 0 remaining
17+
*********************************************************************
18+
19+
*****************************************************************
20+
Transient iteration: 10000 Time: 0.1 Time step: 1e-05
21+
*****************************************************************
22+
| Variable | Min | Max | Average | Total |
23+
| Contact list generation | 0.0000e+00 | 1.0000e+02 | 1.0000e+02 | 1.0000e+02 |
24+
| Velocity magnitude | 0.0000e+00 | 2.2251e-308 | 0.0000e+00 | 0.0000e+00 |
25+
| Angular velocity magnitude | 0.0000e+00 | 2.2251e-308 | 0.0000e+00 | 0.0000e+00 |
26+
| Translational kinetic energy | 0.0000e+00 | 2.2251e-308 | 0.0000e+00 | 0.0000e+00 |
27+
| Rotational kinetic energy | 0.0000e+00 | 2.2251e-308 | 0.0000e+00 | 0.0000e+00 |
28+
id, type, dp, x, y, z
29+
0 0 0.10000 -0.2000 0.0000 0.0000
30+
1 0 0.10000 -0.2000 0.3000 0.0000
31+
2 0 0.10000 0.2000 0.0000 0.1000
32+
3 0 0.10000 0.2000 0.5000 0.1000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
p_x; p_y; p_z; v_x; v_y; v_z; w_x; w_y; w_z; diameters; fem_force_x; fem_force_y; fem_force_z; fem_torque_x; fem_torque_y; fem_torque_z
2+
-0.2; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.1 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0
3+
-0.2; 0.3; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.1 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0
4+
0.2; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.1 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0
5+
0.2; 0.3; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.1 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
p_x; p_y; p_z; v_x; v_y; v_z; w_x; w_y; w_z; diameters; fem_force_x; fem_force_y; fem_force_z; fem_torque_x; fem_torque_y; fem_torque_z
2+
0.2; 0.0; 0.1; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.1 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0
3+
0.2; 0.5; 0.1; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.1 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0 ; 0.0

applications_tests/lethe-particles/insert_file_3d.prm

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ end
7979

8080
subsection insertion info
8181
set insertion method = file
82-
set insertion file name = ../particles.input
82+
set list of input files = ../particles.input
8383
set insertion frequency = 5000
8484
end
8585

applications_tests/lethe-particles/insert_plane_3d.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ id, type, dp, x, y, z
4040
28 0 0.01000 0.2079 -0.0069 0.3979
4141
29 0 0.01000 -0.0357 -0.0020 -0.3063
4242
30 0 0.01000 0.2206 0.0303 0.1907
43-
31 0 0.01000 -0.0391 0.0187 0.2174
43+
31 0 0.01000 -0.0391 0.0187 0.2174

doc/source/parameters/dem/insertion_info.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ In this subsection, insertion methods which are ``volume``, ``plane``, ``list``
1515
1616
# Every method
1717
set insertion frequency = 20000
18+
set remove particles = false
19+
set removal box points coordinates = 0., 0., 0.: 1., 1., 1.
1820
1921
# If method = volume
2022
set inserted number of particles at each time step = 100
@@ -50,7 +52,7 @@ In this subsection, insertion methods which are ``volume``, ``plane``, ``list``
5052
set list diameters = 0.
5153
5254
# If method = file
53-
set insertion file name = particles.input
55+
set list of input files = particles.input
5456
end
5557
5658
The ``insertion method`` parameter chooses the type of insertion. Acceptable choices are ``volume``, ``plane``, ``list`` and ``file``. Different insertion method can share the same parameter.
@@ -59,6 +61,8 @@ The ``insertion method`` parameter chooses the type of insertion. Acceptable cho
5961

6062
* The ``insertion maximum offset`` and ``insertion prn seed`` parameters defines the random offset values to the initial positions of particles during a ``volume`` and ``plane`` insertion. The ``insertion maximum offset`` parameter defines the maximum value for an offset. The ``insertion prn seed`` parameter defines the pseudo-random number (PRN) with which offset values are getting generated.
6163

64+
* The ``removal box points coordinates`` parameter defines a removal box where particles will be removed from the triangulation just before the insertion of new particles. This assures that there is no excessive overlap between new and previously inserted particles. If the ``remove particles`` parameter is set to ``false`` particle removal will not be performed.
65+
6266
-------
6367
Volume
6468
-------
@@ -119,7 +123,7 @@ The ``list`` insertion method insert particles at precis coordinates with specif
119123
---------------------
120124
File
121125
---------------------
122-
The ``file`` insertion method insert particles in a similar way to the ``list`` insertion method. The main difference between these two methods is the option to use an external file provided by the ``insertion file name`` parameter. This parameter is set at ``particles.input`` by default. This file has to follow this structure:
126+
The ``file`` insertion method inserts particles in a similar way to the ``list`` insertion method. The main difference between these two methods is the option to use external files provided by the ``list of input files`` parameter. This parameter is set at ``particles.input`` by default, but a file list can be specified. At each insertion time step, a different file will be used. If the end of the list is reached and there are still particles to be inserted, the list returns to the first file. An insertion file must follow this structure:
123127

124128
.. code-block:: text
125129
@@ -133,4 +137,4 @@ Each line is associated with a particle and its properties. The ``fem_force`` an
133137
The ``file`` insertion combine with the ``extract-particles-properties-from-vtu.py`` python code can be a useful tool. The loading of particles and the rest of the simulation can be performed in two different triangulations, witch is not the case of the the restart feature. This means that the loading triangulation can have smaller cells and a bigger domain to allow for the use of larger insertion boxes. Then, particles properties can be extracted and the remainder of the simulation can be performed in the appropriate triangulation.
134138

135139
.. warning::
136-
The critical Rayleigh time step is computed from the parameters in the ``particle type`` subsections, not the ``insertion info`` subsection. It is the user's responsibility to fill the ``particle type`` subsections correctly according to the diameter values stored in the insertion input file, otherwise Rayleigh time percentage displayed at the start of every DEM simulation may not be accurate.
140+
The critical Rayleigh time step is computed from the parameters in the ``particle type`` subsections, not the ``insertion info`` subsection. It is the user's responsibility to fill the ``particle type`` subsections correctly according to the diameter values stored in the insertion input file, otherwise Rayleigh time percentage displayed at the start of every DEM simulation may not be accurate.

include/core/parameters.h

+4
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,10 @@ namespace Parameters
16441644
std::vector<T> vector = Utilities::string_to_double(vector_of_string);
16451645
return vector;
16461646
}
1647+
if constexpr (std::is_same<T, std::string>::value)
1648+
{
1649+
return vector_of_string;
1650+
}
16471651
}
16481652

16491653
} // namespace Parameters

include/core/parameters_lagrangian.h

+23-16
Original file line numberDiff line numberDiff line change
@@ -178,33 +178,40 @@ namespace Parameters
178178
// Insertion frequency
179179
int insertion_frequency;
180180

181-
// Direction (axis) of insertion of particles (1st, 2nd, 3rd)
182-
std::vector<unsigned int> direction_sequence;
181+
/* Removal box: */
182+
bool removing_particles_in_region;
183183

184-
// Insertion box info (xmin,xmax,ymin,ymax,zmin,zmax)
185-
Point<3> insertion_box_point_1, insertion_box_point_2;
184+
// Clear box info (xmin,xmax,ymin,ymax,zmin,zmax)
185+
Point<3> clear_box_point_1, clear_box_point_2;
186+
187+
/* File: */
188+
std::vector<std::string> list_of_input_files;
189+
190+
/* Plane: */
191+
// Plane normal vector
192+
Tensor<1, 3> insertion_plane_normal_vector;
193+
// Plane point
194+
Point<3> insertion_plane_point;
186195

196+
/* List */
197+
// Containers used for the list insertion method
198+
std::vector<double> list_x, list_y, list_z, list_vx, list_vy, list_vz,
199+
list_wx, list_wy, list_wz, list_d;
200+
201+
/* Volume */
202+
// Direction sequence for the insertion of particles (1st, 2nd, 3rd)
203+
std::vector<unsigned int> direction_sequence;
204+
// Insertion box info (p_1 , p_2)
205+
Point<3> insertion_box_point_1, insertion_box_point_2;
187206
// Insertion initial velocity conditions
188207
Tensor<1, 3> initial_vel, initial_omega;
189-
190208
// Insertion distance threshold
191209
double distance_threshold;
192-
193210
// Insertion random number range
194211
double insertion_maximum_offset;
195-
196212
// Insertion random number seed
197213
int seed_for_insertion;
198214

199-
std::vector<double> list_x, list_y, list_z, list_vx, list_vy, list_vz,
200-
list_wx, list_wy, list_wz, list_d;
201-
202-
std::string insertion_particles_file_name;
203-
204-
// Insertion plane definition
205-
Tensor<1, 3> insertion_plane_normal_vector;
206-
Point<3> insertion_plane_point;
207-
208215
static void
209216
declare_parameters(ParameterHandler &prm);
210217
void

include/dem/dem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class DEMSolver
397397
std::vector<std::shared_ptr<SerialSolid<dim - 1, dim>>> solids;
398398

399399
// Distribution objects
400-
std::vector<std::shared_ptr<Distribution>> distribution_object_container;
400+
std::vector<std::shared_ptr<Distribution>> size_distribution_object_container;
401401

402402
// Adaptive sparce contacts (ASC) in cells object
403403
AdaptiveSparseContacts<dim> sparse_contacts_object;

include/dem/input_parameter_inspection.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ using namespace std;
3030
*
3131
* @param dem_parameters Input DEM parameters in the parameter handler file
3232
* @param pcout Printing in parallel
33-
* @param distribution_object_container Contain all the types of distribution
33+
* @param size_distribution_object_container Contain all the types of distribution
3434
* being used for each type of particle.
3535
*
3636
*/
3737

3838
template <int dim>
3939
void
40-
input_parameter_inspection(
41-
const DEMSolverParameters<dim> &dem_parameters,
42-
const ConditionalOStream &pcout,
43-
const std::vector<shared_ptr<Distribution>> &distribution_object_container);
40+
input_parameter_inspection(const DEMSolverParameters<dim> &dem_parameters,
41+
const ConditionalOStream &pcout,
42+
const std::vector<shared_ptr<Distribution>>
43+
&size_distribution_object_container);
4444

4545
#endif /* input_parameter_inspection_h */

include/dem/insertion.h

+46-3
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ class Insertion
6464
* volume_insertion, plane_insertion, list_insertion and file_insertion
6565
* classes.
6666
*
67-
* @param distribution_object_container Contains all distribution for each
68-
* type of particle
67+
* @param size_distribution_object_container Contains all distribution for each
68+
* particle type
69+
* @param triangulation Triangulation to access the cells in which the
70+
* particles are inserted
71+
* @param dem_parameters DEM parameters declared in the .prm file
6972
*/
7073
Insertion(const std::vector<std::shared_ptr<Distribution>>
71-
&distribution_object_container);
74+
&size_distribution_object_container,
75+
const parallel::distributed::Triangulation<dim> &triangulation,
76+
const DEMSolverParameters<dim> &dem_parameters);
7277

7378
/**
7479
* @brief This function is overridden by the volume_insertion, plane_insertion,
@@ -159,6 +164,29 @@ class Insertion
159164
const DEMSolverParameters<dim> &dem_parameters,
160165
const ConditionalOStream &pcout);
161166

167+
/**
168+
* @brief Find every cell that are completely and partially inside de the
169+
* clearing box. For the cell completely inside the box, all the particles
170+
* will be deleted. For those partially inside, a fine verification is
171+
* required.
172+
*
173+
* @param triangulation Triangulation to access the cells in which the
174+
* particles deleted.
175+
*/
176+
void
177+
find_cells_in_removing_box(
178+
const parallel::distributed::Triangulation<dim> &triangulation);
179+
180+
/**
181+
* @brief Remove every particle located inside a predefined zone. Currently,
182+
* the zone is defined by a box.
183+
*
184+
* @param particle_handler The particle handler of particles which are being
185+
* removed.
186+
*/
187+
void
188+
remove_particles_in_box(Particles::ParticleHandler<dim> &particle_handler);
189+
162190
// Number of particles inserted at each insertion time step. This value can
163191
// change in the last insertion step to reach the desired number of particles
164192
unsigned int inserted_this_step;
@@ -181,6 +209,21 @@ class Insertion
181209
// particle during an insertion time step
182210
std::vector<std::shared_ptr<Distribution>> distributions_objects;
183211

212+
// Clearing bool
213+
const bool removing_particles_in_region;
214+
215+
// Clearing box coordinates
216+
Point<dim> p_min, p_max;
217+
218+
// Cell iterator containers for clearing
219+
std::set<typename Triangulation<dim>::active_cell_iterator> in_removal_box;
220+
std::set<typename Triangulation<dim>::active_cell_iterator>
221+
edge_of_removal_box;
222+
223+
// For when the triangulation has changed (i.e. when load balancing)
224+
bool mark_for_update;
225+
boost::signals2::connection change_to_triangulation;
226+
184227
private:
185228
// Stores particles diameters
186229
std::vector<double> particle_sizes;

0 commit comments

Comments
 (0)