Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
insertion_packed.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 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_packed_h
5#define lethe_insertion_packed_h
6
7#include <dem/insertion.h>
9
10#include <random>
11#include <vector>
12
13using namespace dealii;
14
15template <int dim, typename PropertiesIndex>
16class InsertionPacked : public Insertion<dim, PropertiesIndex>
17{
18public:
19 /**
20 * @brief Insert particles using the packed insertion method.
21 *
22 * Particles are inserted by randomly generating points inside the insertion
23 * region and assigning them particle properties (such as their diameter).
24 * Because the generated configuration may contain particle-particle and
25 * particle-wall overlaps, particles are iteratively displaced along the
26 * corresponding contact normal directions until all overlaps are resolved.
27 *
28 * @param size_distribution_object_container Contains all distribution for each
29 * particle type
30 * @param triangulation Triangulation to access the cells in which the
31 * particles are inserted
32 * @param dem_parameters DEM parameters declared in the .prm file
33 */
35 const std::vector<std::shared_ptr<Distribution>>
36 &size_distribution_object_container,
37 const parallel::distributed::Triangulation<dim> &triangulation,
38 const DEMSolverParameters<dim> &dem_parameters);
39
40 /**
41 * @brief Carries out the packed insertion of particles.
42 *
43 * @param particle_handler The particle handler of particles which are being
44 * inserted
45 * @param triangulation Triangulation to access the cells in which the
46 * particles are inserted
47 * @param dem_parameters DEM parameters declared in the .prm file
48 *
49 */
50 virtual void
51 insert(Particles::ParticleHandler<dim> &particle_handler,
52 const parallel::distributed::Triangulation<dim> &triangulation,
53 const DEMSolverParameters<dim> &dem_parameters) override;
54
55
56 /**
57 * @brief Serialize the packed insertion object to an output archive.
58 * For the packing insertion, nothing needs to be stored.
59 *
60 * @param ar Output archive where the attributes are stored.
61 */
62 virtual void
63 serialize(boost::archive::text_oarchive &ar) override
64 {
65 (void)ar;
66 }
67
68 /**
69 * @brief Deserialize an input archive to the packed insertion object.
70 * For the packing insertion, nothing needs to be stored.
71 *
72 * @param ar Input archive where the attributes are stored.
73 *
74 */
75 virtual void
76 deserialize(boost::archive::text_iarchive &ar) override
77 {
78 (void)ar;
79 }
80
81 /**
82 * @brief Displace the locally owned particles by the displacements
83 * accumulated by the shift contact models.
84 *
85 * Each contact of a particle adds a displacement to the entry of that
86 * particle in the force container of the contact outcomes. Each particle is
87 * moved by the sum of the displacements of its contacts, limited to a
88 * maximum norm, and the norm of the applied displacement is added to the
89 * displacement used by the dynamic contact detection. The force container is
90 * then reset to zero for the next pseudo-time step.
91 *
92 * @param[in,out] particle_handler The particle handler of particles which are
93 * being inserted.
94 * @param[in] max_displacement Maximum displacement of a particle during a
95 * single pseudo-time step.
96 * @param[in,out] contact_outcome Contact outcomes holding the accumulated
97 * displacements of the particles.
98 * @param[in,out] displacements Displacement of each particle since the last
99 * contact detection step. The norm of the applied displacement is added.
100 */
101 static void
103 Particles::ParticleHandler<dim> &particle_handler,
104 const double max_displacement,
106 std::vector<double> &displacements);
107
108private:
109 /**
110 * @brief Generate an insertion point inside an insertion box.
111 *
112 * @param insertion_location Generated insertion location.
113 * @param rng Random number generator.
114 * @param insertion_information Insertion parameters read from the .prm file.
115 */
116 void
117 generate_insertion_location(Point<dim> &insertion_location,
118 std::mt19937 &rng,
119 const InsertionInfo<dim> &insertion_information);
120
121
122 // Minimum and maximum boundaries of the insertion box in the direction order
123 // It means that axis 0 is not necessarily x, since it depends on the order
124 // of the insertion direction.
125 std::vector<double> axis_min, axis_max;
126
127 /// Function used to insert particles inside or outside an arbitrary shape.
128 std::shared_ptr<Function<dim>> acceptance_fct;
129};
130#endif
Handles all the parameters declared in the parameter handler file.
virtual void deserialize(boost::archive::text_iarchive &ar) override
Deserialize an input archive to the packed insertion object. For the packing insertion,...
std::vector< double > axis_max
void generate_insertion_location(Point< dim > &insertion_location, std::mt19937 &rng, const InsertionInfo< dim > &insertion_information)
Generate an insertion point inside an insertion box.
static void apply_shift_displacement(Particles::ParticleHandler< dim > &particle_handler, const double max_displacement, ParticleInteractionOutcomes< PropertiesIndex > &contact_outcome, std::vector< double > &displacements)
Displace the locally owned particles by the displacements accumulated by the shift contact models.
virtual void serialize(boost::archive::text_oarchive &ar) override
Serialize the packed insertion object to an output archive. For the packing insertion,...
std::vector< double > axis_min
virtual void insert(Particles::ParticleHandler< dim > &particle_handler, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters) override
Carries out the packed insertion of particles.
InsertionPacked(const std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container, const parallel::distributed::Triangulation< dim > &triangulation, const DEMSolverParameters< dim > &dem_parameters)
Insert particles using the packed insertion method.
std::shared_ptr< Function< dim > > acceptance_fct
Function used to insert particles inside or outside an arbitrary shape.
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.
Class where the outcomes of particle-particle interactions are stored.