Skip to content
Snippets Groups Projects
Commit b1d0fcb3 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add construction and access to a cell to cell graph

The considered graph is built joining cells through their faces
parent 176f4182
No related branches found
No related tags found
1 merge request!11Feature/mpi
......@@ -264,5 +264,5 @@ target_link_libraries(
kokkos
${PARMETIS_LIBRARIES}
${MPI_CXX_LINK_FLAGS} ${MPI_CXX_LIBRARIES}
PastisUtils
PastisMesh)
PastisMesh
PastisUtils)
......@@ -25,6 +25,8 @@
#include <CellType.hpp>
#include <CSRGraph.hpp>
#include <RefId.hpp>
#include <ItemType.hpp>
#include <RefNodeList.hpp>
......@@ -32,6 +34,7 @@
#include <tuple>
#include <algorithm>
#include <set>
template <size_t Dimension>
class Connectivity;
......@@ -530,6 +533,42 @@ class Connectivity final
return m_ref_node_list[i];
}
PASTIS_INLINE
CSRGraph cellToCellGraph() const
{
std::vector<std::set<int>> cell_cells(this->numberOfCells());
const auto& face_to_cell_matrix
= this->faceToCellMatrix();
for (FaceId l=0; l<this->numberOfFaces(); ++l) {
const auto& face_to_cell = face_to_cell_matrix[l];
if (face_to_cell.size() == 2) {
const int cell_0 = face_to_cell[0];
const int cell_1 = face_to_cell[1];
cell_cells[cell_0].insert(cell_1);
cell_cells[cell_1].insert(cell_0);
}
}
Array<int> entries(this->numberOfCells()+1);
entries[0]=0;
for (size_t j=0; j<this->numberOfCells(); ++j) {
entries[j+1] = entries[j]+cell_cells[j].size();
}
Array<int> neighbors(entries[this->numberOfCells()]);
{
size_t k=0;
for (size_t j=0; j<this->numberOfCells(); ++j) {
for (auto cell_id : cell_cells[j]) {
neighbors[k] = cell_id;
++k;
}
}
}
return CSRGraph(entries, neighbors);
}
PASTIS_INLINE
size_t numberOfNodes() const final
{
......
......@@ -4,11 +4,14 @@
#include <ItemValue.hpp>
#include <TinyVector.hpp>
#include <CSRGraph.hpp>
#include <memory>
struct IMesh
{
virtual const size_t meshDimension() const = 0;
virtual CSRGraph cellToCellGraph() const = 0;
~IMesh() = default;
};
......@@ -27,6 +30,12 @@ private:
NodeValue<Rd> m_mutable_xr;
public:
PASTIS_INLINE
CSRGraph cellToCellGraph() const final
{
return m_connectivity->cellToCellGraph();
}
PASTIS_INLINE
const size_t meshDimension() const
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment