Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/fdrmrc/AggloDeal into main
Browse files Browse the repository at this point in the history
  • Loading branch information
fdrmrc committed Dec 5, 2023
2 parents 5de482c + dbb3edd commit fd34d42
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 657 deletions.
13 changes: 11 additions & 2 deletions include/agglomeration_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,11 @@ class AgglomerationHandler : public Subscriptor
const auto &agglo_neigh =
agglomerated_neighbor(cell,
f); // returns the neighboring master
const unsigned int n_faces_agglomerated_neighbor =
n_faces(agglo_neigh);
// Loop over all cells of neighboring agglomerate
for (unsigned int f_out = 0; f_out < n_faces(agglo_neigh); ++f_out)
for (unsigned int f_out = 0; f_out < n_faces_agglomerated_neighbor;
++f_out)
{
if (agglomerated_neighbor(agglo_neigh, f_out).state() ==
IteratorState::valid &&
Expand Down Expand Up @@ -520,7 +523,7 @@ class AgglomerationHandler : public Subscriptor
* is as it can be equal to -1 (meaning that the cell is a master one).
*/
std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>
get_slaves_of_idx(const int idx) const;
get_slaves_of_idx(types::global_cell_index idx) const;



Expand Down Expand Up @@ -773,6 +776,12 @@ class AgglomerationHandler : public Subscriptor

Quadrature<dim - 1> agglomeration_face_quad;

// Associate the master cell to the slaves.
std::unordered_map<
types::global_cell_index,
std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>>
master2slaves;


/**
* Initialize connectivity informations
Expand Down
30 changes: 13 additions & 17 deletions src/agglomeration_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ AgglomerationHandler<dim, spacedim>::agglomerate_cells(
cell; // set iterator to master cell
}

std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>
slaves;
slaves.reserve(vec_of_cells.size() - 1);
for (const auto &cell : vec_of_cells)
{
if (cell->active_cell_index() != master_idx)
master_slave_relationships_iterators[cell->active_cell_index()] =
master_slave_relationships_iterators[master_idx];
{
master_slave_relationships_iterators[cell->active_cell_index()] =
master_slave_relationships_iterators[master_idx];
slaves.push_back(cell);
}
}
master2slaves[master_idx] = slaves;

for (const types::global_cell_index idx : global_indices)
{
Expand All @@ -87,22 +94,11 @@ AgglomerationHandler<dim, spacedim>::agglomerate_cells(


template <int dim, int spacedim>
std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>
AgglomerationHandler<dim, spacedim>::get_slaves_of_idx(const int idx) const
inline std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>
AgglomerationHandler<dim, spacedim>::get_slaves_of_idx(
const types::global_cell_index idx) const
{
std::vector<typename Triangulation<dim, spacedim>::active_cell_iterator>
slaves;

// Loop over the tria, and check if a each cell is a slave of master cell
// idx If no slave is found, return an empty vector.
for (const auto &cell : tria->active_cell_iterators())
{
if (master_slave_relationships[cell->active_cell_index()] == idx)
{
slaves.push_back(cell);
}
}
return slaves;
return master2slaves.at(idx);
}


Expand Down
Loading

0 comments on commit fd34d42

Please sign in to comment.