Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
grid_motion.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5#include <dem/grid_motion.h>
6
7#include <deal.II/grid/grid_tools.h>
8
9using namespace dealii;
10
11template <int dim, int spacedim>
13 const Parameters::Lagrangian::GridMotion<spacedim> &grid_motion_parameters,
14 const double dem_time_step)
15{
16 auto *action_manager = DEMActionManager::get_action_manager();
17
18 switch (grid_motion_parameters.motion_type)
19 {
21 {
23 break;
24 }
26 {
27 // Communicate to the action manager that there is a grid motion
28 action_manager->set_grid_motion_enabled();
29
32 grid_motion_parameters.grid_rotational_speed * dem_time_step;
33 rotation_axis = grid_motion_parameters.grid_rotational_axis;
34 break;
35 }
37 spacedim>::MotionType::translational:
38 {
39 // Flag and communicate to the action manager that there is a
40 // grid motion
41 action_manager->set_grid_motion_enabled();
42
45 grid_motion_parameters.grid_translational_velocity * dem_time_step;
46 break;
47 }
48 default:
49 AssertThrow(false, ExcNotImplemented());
50 }
51}
52
53template <>
54void
56{
57 throw ExcImpossibleInDim(1);
58 // TODO We need to add this function to GridTools for dim=1
59 // GridTools::rotate(rotation_angle, triangulation);
60}
61
62template <>
63void
64GridMotionBase<2, 2>::move_grid_rotational(Triangulation<2, 2> &triangulation)
65{
66 GridTools::rotate(rotation_angle, triangulation);
67}
68
69template <>
70void
71GridMotionBase<2, 3>::move_grid_rotational(Triangulation<2, 3> &triangulation)
72{
73 Tensor<1, 3> axis({0, 0, 0});
74 axis[rotation_axis] = 1;
75 GridTools::rotate(axis, rotation_angle, triangulation);
76}
77
78template <>
79void
80GridMotionBase<3, 3>::move_grid_rotational(Triangulation<3, 3> &triangulation)
81{
82 Tensor<1, 3> axis({0, 0, 0});
83 axis[rotation_axis] = 1;
84 GridTools::rotate(axis, rotation_angle, triangulation);
85}
86
87template <int dim, int spacedim>
88void
90 Triangulation<dim, spacedim> &triangulation)
91{
92 GridTools::shift(shift_vector, triangulation);
93}
94
95template <int dim, int spacedim>
96void
100 &particle_wall_pairs_in_contact,
101 const typename DEM::dem_data_structures<
102 spacedim>::boundary_points_and_normal_vectors
103 &updated_boundary_points_and_normal_vectors)
104{
105 // If there is no grid motion, exit the function
106 if (!DEMActionManager::get_action_manager()->check_grid_motion_enabled())
107 return;
108
109 for (auto &[particle_id, pairs_in_contact_content] :
110 particle_wall_pairs_in_contact)
111 {
112 // Prevent compiler warning
113 (void)particle_id;
114 for (auto pairs_in_contact_iterator = pairs_in_contact_content.begin();
115 pairs_in_contact_iterator != pairs_in_contact_content.end();)
116 {
117 auto global_face_id = pairs_in_contact_iterator->first;
118 auto &contact_information = pairs_in_contact_iterator->second;
119
120 // Since we used the negative keys for diamond-shaped cells, we check
121 // and remove these elements from the particle_wall_pairs_in_contact
122 if (global_face_id >= 0)
123 {
124 contact_information.normal_vector =
125 updated_boundary_points_and_normal_vectors.at(global_face_id)
126 .first;
127 contact_information.point_on_boundary =
128 updated_boundary_points_and_normal_vectors.at(global_face_id)
129 .second;
130 ++pairs_in_contact_iterator;
131 }
132 else
133 {
134 pairs_in_contact_content.erase(pairs_in_contact_iterator++);
135 }
136 }
137 }
138}
139
140template class GridMotionBase<1, 2>;
141template class GridMotionBase<2, 2>;
142template class GridMotionBase<2, 3>;
143template class GridMotionBase<3, 3>;
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
Carries out motion of the triangulation, including rotational, translational and rotational-translati...
Definition grid_motion.h:28
FuncPtrType grid_motion
Definition grid_motion.h:31
double rotation_angle
void update_boundary_points_and_normal_vectors_in_contact_list(typename DEM::dem_data_structures< spacedim >::particle_wall_in_contact &particle_wall_pairs_in_contact, const typename DEM::dem_data_structures< spacedim >::boundary_points_and_normal_vectors &updated_boundary_points_and_normal_vectors)
Carries out updating the boundary points and normal vectors in the particle-wall contact list.
GridMotionBase(const Parameters::Lagrangian::GridMotion< spacedim > &grid_motion_parameters, const double dem_time_step)
The constructor sets up the grid motion function defined in the parameter handler,...
void no_motion(Triangulation< dim, spacedim > &)
Dummy function for no motion for grid motion pointer to point to.
void move_grid_rotational(Triangulation< dim, spacedim > &triangulation)
Carries out rotational motion of the triangulation.
unsigned int rotation_axis
Tensor< 1, spacedim > shift_vector
void move_grid_translational(Triangulation< dim, spacedim > &triangulation)
Carries out translational motion of the triangulation.
Parameters for grid (mesh) motion in DEM simulations.
double grid_rotational_speed
Rotational speed of the rotating grid (rad/s).
unsigned int grid_rotational_axis
Rotational axis of the rotating grid (0=x, 1=y, 2=z).
enum Parameters::Lagrangian::GridMotion::MotionType motion_type
Type of grid motion.
Tensor< 1, dim > grid_translational_velocity
Translational velocity of the moving grid.
DEM data structure containers To improve readability of containers, there's a simple description abov...
ankerl::unordered_dense::map< types::particle_index, ankerl::unordered_dense::map< global_face_id, particle_wall_contact_info< dim > > > particle_wall_in_contact