10template <
int dim,
typename PropertiesIndex>
12 const std::vector<std::shared_ptr<Distribution>>
13 &size_distribution_object_container,
14 const parallel::distributed::Triangulation<dim> &triangulation,
16 :
Insertion<dim, PropertiesIndex>(size_distribution_object_container,
20 dem_parameters.lagrangian_physical_properties.number.at(0))
21 ,
number_of_files(dem_parameters.insertion_info.list_of_input_files.size())
28template <
int dim,
typename PropertiesIndex>
31 Particles::ParticleHandler<dim> &particle_handler,
32 const parallel::distributed::Triangulation<dim> &triangulation,
57 std::map<std::string, std::vector<double>> particles_data;
65 unsigned int n_total_particles_to_insert = particles_data[
"p_x"].size();
69 n_total_particles_to_insert =
73 MPI_Comm communicator = triangulation.get_mpi_communicator();
74 auto this_mpi_process = Utilities::MPI::this_mpi_process(communicator);
75 const unsigned int n_particles_to_insert_this_proc =
76 this_mpi_process == 0 ? n_total_particles_to_insert : 0;
78 std::vector<Point<dim>> insertion_points_on_proc_this_step;
79 insertion_points_on_proc_this_step.reserve(
80 n_particles_to_insert_this_proc);
82 if (this_mpi_process == 0)
84 for (
unsigned int p = 0; p < n_particles_to_insert_this_proc; ++p)
86 if constexpr (dim == 2)
88 insertion_points_on_proc_this_step.emplace_back(Point<dim>(
89 {particles_data[
"p_x"][p], particles_data[
"p_y"][p]}));
92 if constexpr (dim == 3)
94 insertion_points_on_proc_this_step.emplace_back(
95 Point<dim>({particles_data[
"p_x"][p],
96 particles_data[
"p_y"][p],
97 particles_data[
"p_z"][p]}));
103 const auto my_bounding_box =
104 GridTools::compute_mesh_predicate_bounding_box(
105 triangulation, IteratorFilters::LocallyOwnedCell());
106 const auto global_bounding_boxes =
107 Utilities::MPI::all_gather(communicator, my_bounding_box);
111 std::vector<std::vector<double>> particle_properties;
116 n_particles_to_insert_this_proc,
118 particle_properties);
121 particle_handler.insert_global_particles(
122 insertion_points_on_proc_this_step,
123 global_bounding_boxes,
124 particle_properties);
130 ConditionalOStream pcout(
131 std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0);
139template <
int dim,
typename PropertiesIndex>
144 const unsigned int &inserted_this_step_this_proc,
145 std::map<std::string, std::vector<double>> &particles_data,
146 std::vector<std::vector<double>> &particle_properties)
149 particle_properties.reserve(inserted_this_step_this_proc);
156 for (
unsigned int particle_counter = 0;
157 particle_counter < inserted_this_step_this_proc;
161 double diameter = particles_data[
"diameters"][particle_counter];
165 double vel_x = particles_data[
"v_x"][particle_counter];
166 double vel_y = particles_data[
"v_y"][particle_counter];
167 double vel_z = particles_data[
"v_z"][particle_counter];
168 double omega_x = particles_data[
"w_x"][particle_counter];
169 double omega_y = particles_data[
"w_y"][particle_counter];
170 double omega_z = particles_data[
"w_z"][particle_counter];
171 double mass = density * 4. / 3. * M_PI *
172 Utilities::fixed_power<3, double>(diameter * 0.5);
176 std::vector<double> properties_of_one_particle(
177 PropertiesIndex::n_properties, 0.);
179 properties_of_one_particle[PropertiesIndex::type] = type;
180 properties_of_one_particle[PropertiesIndex::dp] = diameter;
181 properties_of_one_particle[PropertiesIndex::mass] = mass;
182 properties_of_one_particle[PropertiesIndex::v_x] = vel_x;
183 properties_of_one_particle[PropertiesIndex::v_y] = vel_y;
184 properties_of_one_particle[PropertiesIndex::v_z] = vel_z;
185 properties_of_one_particle[PropertiesIndex::omega_x] = omega_x;
186 properties_of_one_particle[PropertiesIndex::omega_y] = omega_y;
187 properties_of_one_particle[PropertiesIndex::omega_z] = omega_z;
191 properties_of_one_particle[PropertiesIndex::T] =
192 particles_data[
"T"][particle_counter];
193 properties_of_one_particle[PropertiesIndex::specific_heat] =
198 particle_properties.push_back(properties_of_one_particle);
199 properties_of_one_particle.clear();
Handles all the parameters declared in the parameter handler file.
Parameters::Lagrangian::LagrangianPhysicalProperties lagrangian_physical_properties
unsigned int current_inserting_particle_type
void assign_particle_properties_for_file_insertion(const DEMSolverParameters< dim > &dem_parameters, const unsigned int &inserted_this_step_this_proc, std::map< std::string, std::vector< double > > &particles_data, std::vector< std::vector< double > > &particle_properties)
Carries out assigning the properties of inserted particles specifically for the file insertion method...
unsigned int current_file_id
virtual void insert(Particles::ParticleHandler< dim > &particle_handler, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters) override
The InsertionFile class inserts particles using data stored in a file. This allows the insertion of a...
InsertionFile(const std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters)
The InsertionFile class inserts particles using data stored in a file. This allows the insertion of a...
const unsigned int number_of_files
const std::vector< std::string > insertion_files
unsigned int remaining_particles_of_each_type
void remove_particles_in_box(Particles::ParticleHandler< dim > &particle_handler)
Remove every particle located inside a predefined zone. Currently, the zone is defined by a box.
void find_cells_in_removing_box(const parallel::distributed::Triangulation< dim > &triangulation)
Find all cells that are completely and partially inside de the clearing box. For the cell completely ...
const bool removing_particles_in_region
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,...
void print_insertion_info(const unsigned int &inserted_this_step, const unsigned int &remained_particles, const unsigned int &particle_type, const ConditionalOStream &pcout)
Print information about the particles that have been inserted during an insertion time step.
void fill_vectors_from_file(std::map< std::string, std::vector< double > > &map, const std::string &file_name, const std::string &delimiter=" ")
function that read a file that was build from a dealii table and fill 2 vectors. The first vector con...
This namespace defines all the data containers and required operations on these containers for the DE...
constexpr bool has_thermal_properties
Whether a properties index set carries thermal properties.
unsigned int particle_type_number
Number of particle types.
std::vector< int > number
Number particles of each particle type.