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

Use cell->face matrix connectivity

parent 3214cbe5
No related branches found
No related tags found
1 merge request!6Feature/crs
......@@ -15,7 +15,7 @@ class Connectivity1D
public:
static constexpr size_t dimension = 1;
ConnectivityMatrix m_node_to_cell_matrix;
ConnectivityMatrix m_node_to_cell_local_node_matrix;
ConnectivityMatrixShort m_node_to_cell_local_node_matrix;
private:
std::vector<RefNodeList> m_ref_node_list;
......
......@@ -20,7 +20,7 @@ class Connectivity2D
static constexpr size_t dimension = 2;
ConnectivityMatrix m_node_to_cell_matrix;
ConnectivityMatrix m_node_to_cell_local_node_matrix;
ConnectivityMatrixShort m_node_to_cell_local_node_matrix;
ConnectivityMatrix m_face_to_cell_matrix;
ConnectivityMatrix m_face_to_node_matrix;
......
......@@ -22,10 +22,11 @@ class Connectivity3D
public:
static constexpr size_t dimension = 3;
ConnectivityMatrix m_node_to_cell_matrix;
ConnectivityMatrix m_node_to_cell_local_node_matrix;
ConnectivityMatrix m_cell_to_face_matrix;
ConnectivityMatrix m_face_to_cell_matrix;
ConnectivityMatrix m_face_to_node_matrix;
ConnectivityMatrix m_node_to_cell_matrix;
ConnectivityMatrixShort m_node_to_cell_local_node_matrix;
private:
std::vector<RefFaceList> m_ref_face_list;
......@@ -39,7 +40,6 @@ private:
Kokkos::View<double*> m_inv_cell_nb_nodes;
Kokkos::View<const unsigned short*> m_cell_nb_faces;
Kokkos::View<const unsigned int**> m_cell_faces;
Kokkos::View<const bool**> m_cell_faces_is_reversed;
Kokkos::View<const unsigned short**> m_face_cell_local_face;
......@@ -284,8 +284,8 @@ private:
}
}
std::vector<std::vector<unsigned int>> face_to_cell_vector(m_number_of_faces);
{
std::vector<std::vector<unsigned int>> face_to_cell_vector(m_number_of_faces);
size_t l=0;
for (const auto& face_cells_vector : face_cells_map) {
const auto& cells_info_vector = face_cells_vector.second;
......@@ -297,28 +297,33 @@ private:
}
++l;
}
}
m_face_to_cell_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector);
}
#warning check that the number of cell per faces is <=2
std::cerr << __FILE__ << ':' << __LINE__ << ':'
<< rang::fg::red << " m_max_nb_face_per_cell forced to 6" << rang::fg::reset << '\n';
m_max_nb_face_per_cell = 6;
Kokkos::View<unsigned int**> cell_faces("cell_faces", m_number_of_cells, m_max_nb_face_per_cell);
{
std::vector<std::vector<unsigned int>> cell_to_face_vector(m_number_of_cells);
for (size_t j=0; j<cell_to_face_vector.size(); ++j) {
cell_to_face_vector[j].resize(cell_nb_faces[j]);
}
int l=0;
for (const auto& face_cells_vector : face_cells_map) {
const auto& cells_vector = face_cells_vector.second;
for (unsigned short lj=0; lj<cells_vector.size(); ++lj) {
const auto& [cell_number, cell_local_face, reversed] = cells_vector[lj];
cell_faces(cell_number,cell_local_face) = l;
cell_to_face_vector[cell_number][cell_local_face] = l;
}
++l;
}
m_cell_to_face_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("cell_to_face_matrix", cell_to_face_vector);
}
m_cell_faces = cell_faces;
std::cerr << __FILE__ << ':' << __LINE__ << ':'
<< rang::fg::red << " m_max_nb_face_per_cell forced to 6" << rang::fg::reset << '\n';
m_max_nb_face_per_cell = 6;
Kokkos::View<bool**> cell_faces_is_reversed("cell_faces_is_reversed", m_number_of_cells, m_max_nb_face_per_cell);
{
......@@ -443,11 +448,6 @@ private:
return m_cell_nodes;
}
const Kokkos::View<const unsigned int**> cellFaces() const
{
return m_cell_faces;
}
const Kokkos::View<const bool**> cellFacesIsReversed() const
{
return m_cell_faces_is_reversed;
......@@ -463,21 +463,6 @@ private:
return m_inv_cell_nb_nodes;
}
const Kokkos::View<const unsigned short*> cellNbFaces() const
{
return m_cell_nb_faces;
}
// const Kokkos::View<const unsigned short*> faceNbCells() const
// {
// return m_face_nb_cells;
// }
// const Kokkos::View<const unsigned int**> faceCells() const
// {
// return m_face_cells;
// }
const Kokkos::View<const unsigned short**> faceCellLocalFace() const
{
return m_face_cell_local_face;
......
......@@ -6,6 +6,8 @@
#include <Kokkos_StaticCrsGraph.hpp>
typedef Kokkos::StaticCrsGraph<unsigned int, Kokkos::HostSpace> ConnectivityMatrix;
#warning use right type (unsigned short)
typedef Kokkos::StaticCrsGraph<unsigned int, Kokkos::HostSpace> ConnectivityMatrixShort;
class ConnectivityUtils
{
......@@ -15,7 +17,7 @@ class ConnectivityUtils
const size_t& number_of_cells,
size_t& max_nb_node_per_cell,
ConnectivityMatrix& node_to_cell_matrix,
ConnectivityMatrix& node_to_cell_local_node_matrix)
ConnectivityMatrixShort& node_to_cell_local_node_matrix)
{
std::map<unsigned int, std::vector<unsigned int>> node_cells_map;
using namespace Kokkos::Experimental;
......@@ -65,7 +67,7 @@ class ConnectivityUtils
}
}
node_to_cell_local_node_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("node_to_cell_local_node_matrix", node_to_cell_local_node_vector);
= Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("node_to_cell_local_node_matrix", node_to_cell_local_node_vector);
}
};
......
......@@ -140,14 +140,9 @@ private:
}
});
const Kokkos::View<const unsigned int**> cell_faces
= m_mesh.connectivity().cellFaces();
const Kokkos::View<const bool**> cell_faces_is_reversed
= m_mesh.connectivity().cellFacesIsReversed();
const Kokkos::View<const unsigned short*> cell_nb_faces
= m_mesh.connectivity().cellNbFaces();
Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) {
for (int R=0; R<cell_nb_nodes[j]; ++R) {
m_Cjr(j,R) = zero;
......@@ -156,8 +151,9 @@ private:
for (size_t R=0; R<cell_nb_nodes[j]; ++R) {
node_id_to_local[cell_nodes(j,R)] = R;
}
for (size_t L=0; L<cell_nb_faces[j]; ++L) {
const size_t l = cell_faces(j, L);
const auto& cell_faces = m_mesh.connectivity().m_cell_to_face_matrix.rowConst(j);
for (size_t L=0; L<cell_faces.length; ++L) {
const size_t l = cell_faces(L);
const auto& face_nodes = m_mesh.connectivity().m_face_to_node_matrix.rowConst(l);
if (cell_faces_is_reversed(j, L)) {
for (size_t rl = 0; rl<face_nodes.length; ++rl) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment