Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
explicit_euler_integrator.cc
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
6
8
9#include <deal.II/base/exceptions.h>
10
11using namespace DEM;
12
13// The explicit Euler scheme is self-starting, so the opening step is simply a
14// regular step.
15template <int dim, typename PropertiesIndex>
16void
18 Particles::ParticleHandler<dim> &particle_handler,
19 const Tensor<1, 3> &g,
20 const double dt,
21 std::vector<Tensor<1, 3>> &torque,
22 std::vector<Tensor<1, 3>> &force,
23 const std::vector<double> &MOI)
24{
25 integrate(particle_handler, g, dt, torque, force, MOI);
26}
27
28// The velocities of the explicit Euler scheme are always synchronized with the
29// positions, so the closing step leaves them untouched. The force and the
30// torque still have to be reset: the force evaluation that precedes this call
31// has filled them, and the contact force objects accumulate into them.
32template <int dim, typename PropertiesIndex>
33void
35 Particles::ParticleHandler<dim> &particle_handler,
36 const Tensor<1, 3> & /*body_force*/,
37 const double /*time_step*/,
38 std::vector<Tensor<1, 3>> &torque,
39 std::vector<Tensor<1, 3>> &force,
40 const std::vector<double> & /*MOI*/)
41{
42 for (auto &particle : particle_handler)
43 {
44 const types::particle_index particle_id = particle.get_local_index();
45
46 force[particle_id] = 0.;
47 torque[particle_id] = 0.;
48 }
49}
50
51template <int dim, typename PropertiesIndex>
52void
54 Particles::ParticleHandler<dim> &particle_handler,
55 const Tensor<1, 3> &g,
56 const double dt,
57 std::vector<Tensor<1, 3>> &torque,
58 std::vector<Tensor<1, 3>> &force,
59 const std::vector<double> &MOI,
60 const parallel::distributed::Triangulation<dim> & /*triangulation*/,
61 AdaptiveSparseContacts<dim, PropertiesIndex> & /*sparse_contacts_object*/)
62{
63 integrate_end(particle_handler, g, dt, torque, force, MOI);
64}
65
66template <int dim, typename PropertiesIndex>
67void
69 Particles::ParticleHandler<dim> &particle_handler,
70 const Tensor<1, 3> &g,
71 const double dt,
72 std::vector<Tensor<1, 3>> &torque,
73 std::vector<Tensor<1, 3>> &force,
74 const std::vector<double> &MOI)
75{
76 for (auto particle = particle_handler.begin();
77 particle != particle_handler.end();
78 ++particle)
79 {
80 // Get the total array view to the particle properties and location once
81 // to improve efficiency
82 types::particle_index particle_id = particle->get_local_index();
83
84 auto particle_properties = particle->get_properties();
85 Tensor<1, 3> &particle_torque = torque[particle_id];
86 Tensor<1, 3> &particle_force = force[particle_id];
87 Point<3> particle_position;
88 double mass_inverse = 1 / particle_properties[PropertiesIndex::mass];
89 double MOI_inverse = 1 / MOI[particle_id];
90
91
92 if constexpr (dim == 3)
93 particle_position = particle->get_location();
94
95 if constexpr (dim == 2)
96 particle_position = point_nd_to_3d(particle->get_location());
97
98 Tensor<1, 3> acceleration;
99 for (int d = 0; d < 3; ++d)
100 {
101 acceleration[d] = g[d] + (particle_force[d]) * mass_inverse;
102
103 // Velocity integration:
104 particle_properties[PropertiesIndex::v_x + d] += dt * acceleration[d];
105
106 // Position integration
107 particle_position[d] +=
108 dt * particle_properties[PropertiesIndex::v_x + d];
109
110 particle_properties[PropertiesIndex::omega_x + d] +=
111 dt * (particle_torque[d] * MOI_inverse);
112 }
113
114 // Reinitialize force
115 particle_force = 0;
116
117 // Reinitialize torque
118 particle_torque = 0;
119
120 if constexpr (dim == 3)
121 particle->set_location(particle_position);
122
123 if constexpr (dim == 2)
124 {
125 Point<2> position_2d;
126 position_2d[0] = particle_position[0];
127 position_2d[1] = particle_position[1];
128 particle->set_location(position_2d);
129 }
130 }
131}
132
133// Explicit Euler not implemented for adaptive sparse contacts
134template <int dim, typename PropertiesIndex>
135void
137 Particles::ParticleHandler<dim> &particle_handler,
138 const Tensor<1, 3> &g,
139 const double dt,
140 std::vector<Tensor<1, 3>> &torque,
141 std::vector<Tensor<1, 3>> &force,
142 const std::vector<double> &MOI,
143 const parallel::distributed::Triangulation<dim> & /* triangulation */,
144 AdaptiveSparseContacts<dim, PropertiesIndex> & /* sparse_contacts_object */)
145{
146 auto *action_manager = DEMActionManager::get_action_manager();
147
148 bool use_default_function =
149 !action_manager->check_sparse_contacts_enabled() ||
150 action_manager->check_mobility_status_reset();
151
152 if (use_default_function)
153 {
154 integrate(particle_handler, g, dt, torque, force, MOI);
155 return;
156 }
157
158 throw std::runtime_error(
159 "Adaptive sparse contacts are not supported with explicit Euler integrator, use Velocity Verlet integrator.");
160}
161
163template class ExplicitEulerIntegrator<2,
165template class ExplicitEulerIntegrator<2,
167
168template class ExplicitEulerIntegrator<
169 2,
172template class ExplicitEulerIntegrator<3,
174template class ExplicitEulerIntegrator<3,
176
177template class ExplicitEulerIntegrator<
178 3,
Mechanism that disables contacts computation through mobility status of cells based on granular tempe...
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
Implementation of a classical explicit euler scheme for the integration of the particle motion....
virtual void integrate_start(Particles::ParticleHandler< dim > &particle_handler, const Tensor< 1, 3 > &body_force, const double time_step, std::vector< Tensor< 1, 3 > > &torque, std::vector< Tensor< 1, 3 > > &force, const std::vector< double > &MOI) override
Integrate the opening step of the scheme. The explicit Euler scheme is self-starting and keeps the ve...
virtual void integrate_end(Particles::ParticleHandler< dim > &particle_handler, const Tensor< 1, 3 > &body_force, const double time_step, std::vector< Tensor< 1, 3 > > &torque, std::vector< Tensor< 1, 3 > > &force, const std::vector< double > &MOI) override
Integrate the closing step of the scheme. The velocities of the explicit Euler scheme are already syn...
virtual void integrate(Particles::ParticleHandler< dim > &particle_handler, const Tensor< 1, 3 > &body_force, const double time_step, std::vector< Tensor< 1, 3 > > &torque, std::vector< Tensor< 1, 3 > > &force, const std::vector< double > &MOI) override
Integrate motion of all particles by using the acceleration with the explicit Euler method.
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.
This namespace defines all the data containers and required operations on these containers for the DE...
Point< 3 > point_nd_to_3d(const Point< dim > &point)