Skip to content

Commit

Permalink
Modify some classes to functions and struct in DEM (chaos-polymtl#1232)
Browse files Browse the repository at this point in the history
Description
Some classes should not has been classes but functions or struct.
I modified those classes to a more coherent architechture.
I also gathered all the particle-object contact info structures in one file because it is more convenient that having 3 files for small structs.

Testing
Unit tests have been change according to that.

Former-commit-id: ce0736b
  • Loading branch information
acdaigneault authored Aug 11, 2024
1 parent 84ecdbc commit c91a665
Show file tree
Hide file tree
Showing 66 changed files with 1,952 additions and 1,849 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@
* ---------------------------------------------------------------------
*/

#ifndef lethe_particle_wall_contact_info_h
#define lethe_particle_wall_contact_info_h
#ifndef lethe_contact_info_h
#define lethe_contact_info_h

#include <deal.II/base/point.h>
#include <deal.II/base/tensor.h>

#include <deal.II/particles/particle_iterator.h>

using namespace dealii;

/**
* @brief This struct handles the information related to the calculation of the
* particle-wall contact force
* @brief Handle the information related to the calculation of the
* particle-particle contact force. Notably it is responsible for storing
* information that has to be preserved over multiple iterations of a contact,
* namely everything related to tangential overlaps
*/

using namespace dealii;
template <int dim>
struct particle_particle_contact_info
{
Particles::ParticleIterator<dim> particle_one;
Particles::ParticleIterator<dim> particle_two;
Tensor<1, 3> tangential_overlap;
};

template <int dim>
class particle_wall_contact_info
Expand All @@ -39,13 +48,16 @@ class particle_wall_contact_info
* boundary id. This is the commonly used constructor since it houses all the
* information required to perform the contact calculation.
*
* @param particle The iterator to the particle in contact with the wall
* @param normal_vector The outward pointing normal vector on the wall
* @param point_on_boundary A point that lies on the face
* @param boundary_id The boundary id. This id corresponds to the number attributed to the boundary condition.
* @param particle The iterator to the particle in contact with the wall.
* @param normal_vector The outward pointing normal vector on the wall.
* @param point_on_boundary A point that lies on the face.
* @param boundary_id The boundary id. This id corresponds to the number
* attributed to the boundary condition.
*
* TODO: This should be a struct and normal_overlap, normal_relative_velocity
* and tangential_relative_velocity should be removed and be calculated on the
* fly as done for pp forces with particle_particle_contact_info
*/

particle_wall_contact_info(const Particles::ParticleIterator<dim> &particle,
const Tensor<1, 3> &normal_vector,
const Point<3> &point_on_boundary,
Expand Down Expand Up @@ -89,4 +101,48 @@ class particle_wall_contact_info
Tensor<1, 3> tangential_relative_velocity;
};

/**
* @brief Handle information related to the calculation of the particle-line
* contact forces.
*/
template <int dim>
struct particle_line_contact_info
{
Particles::ParticleIterator<dim> particle;
Point<3> point_one;
Point<3> point_two;
};

/**
* @brief Handle information related to the calculation of the particle-point
* contact forces.
*/
template <int dim>
struct particle_point_contact_info
{
Particles::ParticleIterator<dim> particle;
Point<3> point;
};

/**
* @brief Handle information related to the cell-line matching.
*/
template <int dim>
struct cell_line_info
{
typename Triangulation<dim>::active_cell_iterator cell;
Point<3> point_one;
Point<3> point_two;
};

/**
* @brief Handle information related to the cell-point matching.
*/
template <int dim>
struct cell_point_info
{
typename Triangulation<dim>::active_cell_iterator cell;
Point<3> point;
};

#endif
27 changes: 14 additions & 13 deletions include/dem/data_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#define lethe_data_containers_h

#include <dem/boundary_cells_info_struct.h>
#include <dem/particle_particle_contact_info.h>
#include <dem/particle_point_line_contact_info_struct.h>
#include <dem/particle_wall_contact_info.h>
#include <dem/contact_info.h>

#include <deal.II/base/tensor.h>

Expand Down Expand Up @@ -121,21 +119,24 @@ namespace DEM
Particles::ParticleIterator<dim>>
particle_index_iterator_map;

// <particle id, point-line info>
// <particle id, line info>
typedef std::unordered_map<types::particle_index,
particle_point_line_contact_info_struct<dim>>
particle_point_line_contact_info;
particle_line_contact_info<dim>>
particle_line_in_contact;

// <particle id, (particle iterator, point, point)>
typedef std::unordered_map<
types::particle_index,
std::tuple<Particles::ParticleIterator<dim>, Point<dim>, Point<dim>>>
// <particle id, point info>
typedef std::unordered_map<types::particle_index,
particle_point_contact_info<dim>>
particle_point_in_contact;

// <particle id, line info>
typedef std::unordered_map<types::particle_index,
particle_line_contact_info<dim>>
particle_line_candidates;

// <particle id, (particle iterator, point)>
typedef std::unordered_map<
types::particle_index,
std::pair<Particles::ParticleIterator<dim>, Point<dim>>>
typedef std::unordered_map<types::particle_index,
particle_point_contact_info<dim>>
particle_point_candidates;

// <particle id, <global face id, particle iterator>>
Expand Down
5 changes: 0 additions & 5 deletions include/dem/dem.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,6 @@ class DEMSolver
*/
std::shared_ptr<ParticlesForceChainsBase<dim>> particles_force_chains_object;

/**
* @brief The post-processing object.
*/
LagrangianPostProcessing<dim> post_processing_object;

/**
* @brief The integrator object.
*/
Expand Down
23 changes: 5 additions & 18 deletions include/dem/dem_contact_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,11 @@ class DEMContactManager
particle_floating_wall_in_contact;
typename dem_data_structures<dim>::particle_wall_in_contact
particle_wall_in_contact;
typename dem_data_structures<dim>::particle_point_line_contact_info
particle_points_in_contact;
typename dem_data_structures<dim>::particle_point_line_contact_info
typename dem_data_structures<dim>::particle_line_in_contact
particle_lines_in_contact;
typename dem_data_structures<dim>::particle_point_in_contact
particle_points_in_contact;


// Container with all the contact information of adjacent
// local/ghost-local for pairwise contact force calculation
Expand All @@ -299,20 +300,6 @@ class DEMContactManager

// Containers with other information
typename DEM::dem_data_structures<dim>::cell_vector periodic_cells_container;

private:
// Broad search objects
ParticleParticleBroadSearch<dim> particle_particle_broad_search_object;
ParticleWallBroadSearch<dim> particle_wall_broad_search_object;
ParticlePointLineBroadSearch<dim> particle_point_line_broad_search_object;

// Fine search objects
ParticleParticleFineSearch<dim> particle_particle_fine_search_object;
ParticleWallFineSearch<dim> particle_wall_fine_search_object;
ParticlePointLineFineSearch<dim> particle_point_line_fine_search_object;

// Other relevant objects
FindCellNeighbors<dim> cell_neighbors_object;
};

#endif // lethe_dem_contact_manager_h
#endif
23 changes: 6 additions & 17 deletions include/dem/find_boundary_cells_information.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define lethe_find_boundary_cells_information_h

#include <dem/boundary_cells_info_struct.h>
#include <dem/contact_info.h>
#include <dem/data_containers.h>
#include <dem/dem_solver_parameters.h>

Expand Down Expand Up @@ -87,19 +88,13 @@ class BoundaryCellsInformation
return boundary_cells_information;
}

std::unordered_map<
std::string,
std::pair<typename Triangulation<dim>::active_cell_iterator, Point<dim>>> &
std::unordered_map<std::string, cell_point_info<dim>> &
get_boundary_cells_with_points()
{
return boundary_cells_with_points;
}

std::unordered_map<
std::string,
std::tuple<typename Triangulation<dim>::active_cell_iterator,
Point<dim>,
Point<dim>>> &
std::unordered_map<std::string, cell_line_info<dim>> &
get_boundary_cells_with_lines()
{
return boundary_cells_with_lines;
Expand Down Expand Up @@ -242,11 +237,7 @@ class BoundaryCellsInformation
global_boundary_cells_information;

// Structure that contains the boundary cells which have a line
std::unordered_map<
std::string,
std::tuple<typename Triangulation<dim>::active_cell_iterator,
Point<dim>,
Point<dim>>>
std::unordered_map<std::string, cell_line_info<dim>>
boundary_cells_with_lines;

// A vector of all the local cells with boundary lines. This vector is used in
Expand All @@ -255,9 +246,7 @@ class BoundaryCellsInformation
local_cells_with_boundary_lines;

// Structure that contains the boundary cells which have a point
std::unordered_map<
std::string,
std::pair<typename Triangulation<dim>::active_cell_iterator, Point<dim>>>
std::unordered_map<std::string, cell_point_info<dim>>
boundary_cells_with_points;

// Structure that contains the boundary cells with floating walls
Expand Down Expand Up @@ -286,4 +275,4 @@ class BoundaryCellsInformation
bool display_pw_contact_expansion_warning = true;
};

#endif /* find_boundary_cells_information_h */
#endif
Loading

0 comments on commit c91a665

Please sign in to comment.