Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
acdaigneault committed Aug 9, 2024
1 parent b6a32dc commit 496b99c
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 149 deletions.
13 changes: 13 additions & 0 deletions include/dem/contact_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ struct particle_line_contact_info
Point<3> point_two;
};

/**
* @brief Handle information related to the calculation of the particle-line
* contact forces. TODO
*/
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 calculation of the particle-point
* contact forces.
Expand Down
5 changes: 2 additions & 3 deletions include/dem/data_containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ namespace DEM
particle_point_in_contact;

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

// <particle id, (particle iterator, point)>
Expand Down
13 changes: 3 additions & 10 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 @@ -95,11 +96,7 @@ class BoundaryCellsInformation
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 +239,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 Down
18 changes: 6 additions & 12 deletions include/dem/particle_point_line_broad_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,11 @@ find_particle_point_contact_pairs(
* lines.
*/
template <int dim>
typename DEM::dem_data_structures<dim>::particle_line_candidates
void
find_particle_line_contact_pairs(
const Particles::ParticleHandler<dim> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<dim>::active_cell_iterator,
Point<dim>,
Point<dim>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<dim>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<dim>::particle_line_candidates
&particle_line_contact_candidates);

Expand All @@ -125,14 +122,11 @@ find_particle_line_contact_pairs(
* status checks.
*/
template <int dim>
typename DEM::dem_data_structures<dim>::particle_line_candidates
void
find_particle_line_contact_pairs(
const Particles::ParticleHandler<dim> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<dim>::active_cell_iterator,
Point<dim>,
Point<dim>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<dim>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<dim>::particle_line_candidates
&particle_line_contact_candidates,
const AdaptiveSparseContacts<dim> &sparse_contacts_object);
Expand Down
23 changes: 18 additions & 5 deletions source/dem/find_boundary_cells_information.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,24 @@ BoundaryCellsInformation<dim>::find_particle_point_and_line_contact_cells(
{
for (auto &map_iterator : cell_boundary_lines)
{
boundary_cells_with_lines.insert(
{cell_id_string,
std::make_tuple(cell,
map_iterator.second.first,
map_iterator.second.second)});
Point<3> vertex_one, vertex_two;

if constexpr (dim == 3)
{
vertex_one = map_iterator.second.first;
vertex_two = map_iterator.second.second;
}

if constexpr (dim == 2)
{
vertex_one =
point_nd_to_3d(map_iterator.second.first);
vertex_two =
point_nd_to_3d(map_iterator.second.second);
}
boundary_cells_with_lines.emplace(
cell_id_string,
cell_line_info<dim>{cell, vertex_one, vertex_two});

// Add the cell to local_cells_with_boundary_lines to
// be used in
Expand Down
147 changes: 59 additions & 88 deletions source/dem/particle_point_line_broad_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ find_particle_point_contact_pairs(
typename DEM::dem_data_structures<dim>::particle_point_candidates
&particle_point_contact_candidates)
{
// Clear the candidate map
particle_point_contact_candidates.clear();

// Defining and resetting a local particle-point candidate counter. This is
// used as a key to the output map
int contact_candidate_counter = 0;
Expand Down Expand Up @@ -70,6 +73,9 @@ find_particle_point_contact_pairs(
&particle_point_contact_candidates,
const AdaptiveSparseContacts<dim> &sparse_contacts_object)
{
// Clear the candidate map
particle_point_contact_candidates.clear();

// Defining and resetting a local particle-point candidate counter. This is
// used as a key to the output map
int contact_candidate_counter = 0;
Expand Down Expand Up @@ -121,17 +127,17 @@ find_particle_point_contact_pairs(

// This function finds all the particle-line contact candidates
template <int dim>
typename DEM::dem_data_structures<dim>::particle_line_candidates
void
find_particle_line_contact_pairs(
const Particles::ParticleHandler<dim> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<dim>::active_cell_iterator,
Point<dim>,
Point<dim>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<dim>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<dim>::particle_line_candidates
&particle_line_contact_candidates)
{
// Clear the candidates map
particle_line_contact_candidates.clear();

// Defining and resetting a local particle-line candidate counter. This is
// used as a key to the output map
unsigned int contact_candidate_counter = 0;
Expand All @@ -145,56 +151,44 @@ find_particle_line_contact_pairs(
map_iterator != boundary_cells_with_lines.end();
++map_iterator)
{
auto cells_with_boundary_lines_information = &map_iterator->second;

// Getting the cell and the locations of boundary vertices (beginning and
// ending points of the boundary line) as local variables
auto cell_with_boundary_line =
std::get<0>(*cells_with_boundary_lines_information);

Point<dim> first_vertex_location =
std::get<1>(*cells_with_boundary_lines_information);
Point<dim> second_vertex_location =
std::get<2>(*cells_with_boundary_lines_information);
const cell_line_info<dim> &cells_with_boundary_lines_info =
map_iterator->second;

// Finding particles located in the corresponding cell
typename Particles::ParticleHandler<dim>::particle_iterator_range
particles_in_cell =
particle_handler.particles_in_cell(cell_with_boundary_line);
particles_in_cell = particle_handler.particles_in_cell(
cells_with_boundary_lines_info.cell);

for (typename Particles::ParticleHandler<dim>::particle_iterator_range::
iterator particles_in_cell_iterator = particles_in_cell.begin();
for (auto particles_in_cell_iterator = particles_in_cell.begin();
particles_in_cell_iterator != particles_in_cell.end();
++particles_in_cell_iterator)
{
// Making the tuple (particle, beginning and ending points of the
// boundary line) and adding it to the
// particle_line_contact_candidates map. This map is the output of
// this function
particle_line_contact_candidates.insert(
{contact_candidate_counter,
std::make_tuple(particles_in_cell_iterator,
first_vertex_location,
second_vertex_location)});
// Adding the particle line contact info to the
// particle_line_contact_candidates map.
particle_line_contact_candidates.emplace(
contact_candidate_counter,
particle_line_contact_info<dim>{
particles_in_cell_iterator,
cells_with_boundary_lines_info.point_one,
cells_with_boundary_lines_info.point_two});
++contact_candidate_counter;
}
}
return particle_line_contact_candidates;
}

template <int dim>
typename DEM::dem_data_structures<dim>::particle_line_candidates
void
find_particle_line_contact_pairs(
const Particles::ParticleHandler<dim> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<dim>::active_cell_iterator,
Point<dim>,
Point<dim>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<dim>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<dim>::particle_line_candidates
&particle_line_contact_candidates,
const AdaptiveSparseContacts<dim> &sparse_contacts_object)
{
// Clear the candidates map
particle_line_contact_candidates.clear();

// Defining and resetting a local particle-line candidate counter. This is
// used as a key to the output map
unsigned int contact_candidate_counter = 0;
Expand All @@ -208,91 +202,68 @@ find_particle_line_contact_pairs(
map_iterator != boundary_cells_with_lines.end();
++map_iterator)
{
auto cells_with_boundary_lines_information = &map_iterator->second;

// Getting the cell and the locations of boundary vertices (beginning and
// ending points of the boundary line) as local variables
auto cell_with_boundary_line =
std::get<0>(*cells_with_boundary_lines_information);
const cell_line_info<dim> &cells_with_boundary_lines_info =
map_iterator->second;

// If main cell has status other than mobile, skip to next cell
unsigned int main_cell_mobility_status =
sparse_contacts_object.check_cell_mobility(cell_with_boundary_line);
sparse_contacts_object.check_cell_mobility(
cells_with_boundary_lines_info.cell);
if (main_cell_mobility_status != AdaptiveSparseContacts<dim>::mobile)
continue;

Point<dim> first_vertex_location =
std::get<1>(*cells_with_boundary_lines_information);
Point<dim> second_vertex_location =
std::get<2>(*cells_with_boundary_lines_information);

// Finding particles located in the corresponding cell
typename Particles::ParticleHandler<dim>::particle_iterator_range
particles_in_cell =
particle_handler.particles_in_cell(cell_with_boundary_line);
particles_in_cell = particle_handler.particles_in_cell(
cells_with_boundary_lines_info.cell);

for (auto particles_in_cell_iterator = particles_in_cell.begin();
particles_in_cell_iterator != particles_in_cell.end();
++particles_in_cell_iterator)
{
// Making the tuple (particle, beginning and ending points of the
// boundary line) and adding it to the
// particle_line_contact_candidates map. This map is the output of
// this function
// Adding the particle line contact info to the
// particle_line_contact_candidates map.
particle_line_contact_candidates.emplace(
contact_candidate_counter,
std::make_tuple(particles_in_cell_iterator,
first_vertex_location,
second_vertex_location));
particle_line_contact_info<dim>{
particles_in_cell_iterator,
cells_with_boundary_lines_info.point_one,
cells_with_boundary_lines_info.point_two});
++contact_candidate_counter;
}
}

return particle_line_contact_candidates;
}

template typename DEM::dem_data_structures<2>::particle_line_candidates
find_particle_line_contact_pairs(
template void
find_particle_line_contact_pairs<2>(
const Particles::ParticleHandler<2> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<2>::active_cell_iterator,
Point<2>,
Point<2>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<2>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<2>::particle_line_candidates
&particle_line_contact_candidates);

template typename DEM::dem_data_structures<3>::particle_line_candidates
find_particle_line_contact_pairs(
template void
find_particle_line_contact_pairs<3>(
const Particles::ParticleHandler<3> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<3>::active_cell_iterator,
Point<3>,
Point<3>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<3>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<3>::particle_line_candidates
&particle_line_contact_candidates);

template typename DEM::dem_data_structures<2>::particle_line_candidates
find_particle_line_contact_pairs(
template void
find_particle_line_contact_pairs<2>(
const Particles::ParticleHandler<2> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<2>::active_cell_iterator,
Point<2>,
Point<2>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<2>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<2>::particle_line_candidates
&particle_line_contact_candidates,
const AdaptiveSparseContacts<2> &sparse_contacts_object);

template typename DEM::dem_data_structures<3>::particle_line_candidates
find_particle_line_contact_pairs(
template void
find_particle_line_contact_pairs<3>(
const Particles::ParticleHandler<3> &particle_handler,
const std::unordered_map<
std::string,
std::tuple<typename Triangulation<3>::active_cell_iterator,
Point<3>,
Point<3>>> &boundary_cells_with_lines,
const std::unordered_map<std::string, cell_line_info<3>>
&boundary_cells_with_lines,
typename DEM::dem_data_structures<3>::particle_line_candidates
&particle_line_contact_candidates,
const AdaptiveSparseContacts<3> &sparse_contacts_object);
Expand Down
Loading

0 comments on commit 496b99c

Please sign in to comment.