Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
insertion_volume.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_insertion_volume_h
5#define lethe_insertion_volume_h
6
7#include <dem/insertion.h>
8
9using namespace dealii;
10
11template <int dim, typename PropertiesIndex>
12class InsertionVolume : public Insertion<dim, PropertiesIndex>
13{
14public:
15 /**
16 * @brief The constructor investigates if the insertion box is large enough
17 * to handle the desired number of particles with the specified insertion
18 * parameters.
19 * If the insertion box is not adequately large, the number of
20 * inserted particles at each insertion step is updated. It also finds the
21 * insertion points in each direction (number_of_particles_x_direction,
22 * number_of_particles_y_direction and number_of_particles_z_direction).
23 *
24 * @param[in] size_distribution_object_container Contains all distribution for
25 * each particle type
26 * @param[in] triangulation Triangulation to access the cells in which the
27 * particles are inserted
28 * @param[in] dem_parameters DEM parameters declared in the .prm file
29 * @param[in] maximum_particle_diameter Maximum particle diameter based on
30 * values defined in the parameter handler
31 */
33 const std::vector<std::shared_ptr<Distribution>>
34 &size_distribution_object_container,
35 const parallel::distributed::Triangulation<dim> &triangulation,
36 const DEMSolverParameters<dim> &dem_parameters,
37 const double maximum_particle_diameter);
38
39 /**
40 * @brief Carries out the volume insertion of particles.
41 *
42 * @param[in] particle_handler The particle handler of particles which are
43 * being inserted
44 * @param[in] triangulation Triangulation to access the cells in which the
45 * particles are inserted
46 * @param[in] dem_parameters DEM parameters declared in the .prm file
47 *
48 */
49 virtual void
50 insert(Particles::ParticleHandler<dim> &particle_handler,
51 const parallel::distributed::Triangulation<dim> &triangulation,
52 const DEMSolverParameters<dim> &dem_parameters) override;
53
54
55
56 /**
57 * @brief Serialize the volume insertion object to an output archive.
58 *
59 * @param[out] ar Output archive where the attributes are stored.
60 */
61 virtual void
62 serialize(boost::archive::text_oarchive &ar) override
63 {
65 }
66
67 /**
68 * @brief Deserialize an input archive to the volume insertion object.
69 *
70 * @param[in] ar Input archive where the attributes are stored.
71 *
72 */
73 virtual void
74 deserialize(boost::archive::text_iarchive &ar) override
75 {
77 }
78
79private:
80 /**
81 * @brief Adjust the number of inserted particles for this insertion time step
82 * if the number required by the used is larger than what is allowed by the
83 * insertion box and the acceptance function.
84 *
85 * @param[in] insertion_information DEM insertion parameters declared in the
86 * .prm
87 * @param[in] pcout Printing in parallel
88 * @param[in] inserted_this_step Number of particle to insert at the current
89 * insertion step. This value is updated if the requested number of particles
90 * for insertion in the current insertion step is larger than the maximum
91 * number of inserted particles based on the insertion box size.
92 */
93 void
95 const InsertionInfo<dim> &insertion_information,
96 const ConditionalOStream &pcout,
97 unsigned int &inserted_this_step);
98
99 /**
100 * @brief Converts id of particles to volume insertion location
101 *
102 * @param[out] insertion_location Insertion location of the particle
103 * @param[in] id Particle_id
104 * @param[in] random_number1 A random number to create randomness in volume
105 * insertion
106 * @param[in] random_number2 A random number to create randomness in volume
107 * insertion
108 * @param[in] insertion_information DEM insertion parameters declared in the
109 * .prm file
110 */
111 void
112 find_insertion_location(Point<dim> &insertion_location,
113 const unsigned int id,
114 const double random_number1,
115 const double random_number2,
116 const InsertionInfo<dim> &insertion_information);
117
118 /**
119 * @brief Fills the filted_box_index vector. Also finds how many insertion
120 * points are valid inside the insertion box after applying the acceptance
121 * function.
122 *
123 * @param[in] insertion_information DEM insertion parameters declared in the
124 * .prm
125 */
126 void
127 set_filtered_index(const InsertionInfo<dim> &insertion_information);
128
130
131 /// Number of particles of each type that remain to be inserted in the
132 /// upcoming insertion steps
134
135 // Number of insertion points in the x, y and z directions
137
138 /// Minimum and maximum boundaries of the insertion box in the direction order
139 /// It means that axis 0 is not necessarily x, since it depends on the order
140 /// of the insertion direction.
141 std::vector<double> axis_min, axis_max;
142
143 /// Function used to insert particle inside our outside an arbitrary shape.
144 std::shared_ptr<Function<dim>> acceptance_fct;
145
146 /// Map used to transfer from the filtered to the pre-filted numbering of the
147 /// insertion point inside the insertion box.
148 std::vector<unsigned int> filted_box_index;
149
150 /// The first and last index that will get inserted by this process following
151 /// the filtered numeration.
153
154 /// The total number of valid points inside the box on all processes after
155 /// applying the acceptance function.
157
158 /// Maximum particle diameter based on the values defined in the parameter
159 const double maximum_diameter;
160};
161#endif
Handles all the parameters declared in the parameter handler file.
void set_filtered_index(const InsertionInfo< dim > &insertion_information)
Fills the filted_box_index vector. Also finds how many insertion points are valid inside the insertio...
unsigned int current_inserting_particle_type
virtual void insert(Particles::ParticleHandler< dim > &particle_handler, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters) override
Carries out the volume insertion of particles.
std::vector< double > axis_min
unsigned int last_index_this_proc
std::vector< double > axis_max
virtual void serialize(boost::archive::text_oarchive &ar) override
Serialize the volume insertion object to an output archive.
virtual void deserialize(boost::archive::text_iarchive &ar) override
Deserialize an input archive to the volume insertion object.
unsigned int number_of_valid_insertion_point_global
void find_insertion_location(Point< dim > &insertion_location, const unsigned int id, const double random_number1, const double random_number2, const InsertionInfo< dim > &insertion_information)
Converts id of particles to volume insertion location.
const double maximum_diameter
Maximum particle diameter based on the values defined in the parameter.
std::vector< int > number_of_particles_directions
std::shared_ptr< Function< dim > > acceptance_fct
Function used to insert particle inside our outside an arbitrary shape.
unsigned int first_index_this_proc
unsigned int particles_of_each_type_remaining
std::vector< unsigned int > filted_box_index
void adjust_insertion_count_by_insertion_box_capacity(const InsertionInfo< dim > &insertion_information, const ConditionalOStream &pcout, unsigned int &inserted_this_step)
Adjust the number of inserted particles for this insertion time step if the number required by the us...
InsertionVolume(const std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters, const double maximum_particle_diameter)
The constructor investigates if the insertion box is large enough to handle the desired number of par...
Insertion(const std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters)
Carries out the insertion of particles. This is the base class of volume_insertion,...
Definition insertion.cc:10
Parameters controlling particle insertion in DEM simulations.