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

Continue use of crs representation of connectivity

- cell->face is reversed
- face->local face number in cell
parent 9055e3e1
No related branches found
No related tags found
1 merge request!6Feature/crs
......@@ -215,10 +215,10 @@ class Connectivity2D
return m_cell_nodes;
}
const Kokkos::View<const unsigned int**> cellFaces() const
{
return m_cell_faces;
}
// const Kokkos::View<const unsigned int**> cellFaces() const
// {
// return m_cell_faces;
// }
const Kokkos::View<const unsigned short*> cellNbNodes() const
{
......@@ -230,10 +230,10 @@ class Connectivity2D
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*> cellNbFaces() const
// {
// return m_cell_nb_faces;
// }
const Kokkos::View<const unsigned short**> faceCellLocalFace() const
{
......
......@@ -23,8 +23,12 @@ public:
static constexpr size_t dimension = 3;
ConnectivityMatrix m_cell_to_face_matrix;
ConnectivityMatrixShort m_cell_to_face_is_reversed_matrix;
ConnectivityMatrix m_face_to_cell_matrix;
ConnectivityMatrixShort m_face_to_cell_local_face_matrix;
ConnectivityMatrix m_face_to_node_matrix;
ConnectivityMatrix m_node_to_cell_matrix;
ConnectivityMatrixShort m_node_to_cell_local_node_matrix;
......@@ -39,11 +43,6 @@ private:
const Kokkos::View<const unsigned int**> m_cell_nodes;
Kokkos::View<double*> m_inv_cell_nb_nodes;
Kokkos::View<const unsigned short*> m_cell_nb_faces;
Kokkos::View<const bool**> m_cell_faces_is_reversed;
Kokkos::View<const unsigned short**> m_face_cell_local_face;
Kokkos::View<const unsigned short*> m_node_nb_faces;
Kokkos::View<const unsigned int**> m_node_faces;
......@@ -255,8 +254,6 @@ private:
std::cerr << __FILE__ << ':' << __LINE__ << ':'
<< rang::fg::red << " only works for hexa" << rang::fg::reset << '\n';
m_cell_nb_faces = cell_nb_faces;
m_number_of_faces = face_cells_map.size();
std::cerr << __FILE__ << ':' << __LINE__ << ':'
......@@ -301,6 +298,24 @@ private:
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector);
}
{
std::vector<std::vector<unsigned short>> face_to_cell_local_face_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;
std::vector<unsigned short>& cells_vector = face_to_cell_local_face_vector[l];
cells_vector.resize(cells_info_vector.size());
for (size_t j=0; j<cells_info_vector.size(); ++j) {
const auto& [cell_number, local_face_in_cell, reversed] = cells_info_vector[j];
cells_vector[j] = local_face_in_cell;
}
++l;
}
m_face_to_cell_local_face_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("face_to_cell_local_face_matrix",
face_to_cell_local_face_vector);
}
#warning check that the number of cell per faces is <=2
{
......@@ -325,34 +340,25 @@ private:
<< 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);
{
std::vector<std::vector<unsigned short>> cell_to_face_is_reversed_vector(m_number_of_cells);
for (size_t j=0; j<cell_to_face_is_reversed_vector.size(); ++j) {
cell_to_face_is_reversed_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_is_reversed(cell_number,cell_local_face) = reversed;
cell_to_face_is_reversed_vector[cell_number][cell_local_face] = reversed;
}
++l;
}
}
m_cell_faces_is_reversed = cell_faces_is_reversed;
Kokkos::View<unsigned short**> face_cell_local_face("face_cell_local_face",
m_number_of_faces, m_max_nb_node_per_cell);
{
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) {
unsigned short cell_local_face = std::get<1>(cells_vector[lj]);
face_cell_local_face(l,lj) = cell_local_face;
}
++l;
}
m_cell_to_face_is_reversed_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("cell_to_face_is_reversed_matrix",
cell_to_face_is_reversed_vector);
}
m_face_cell_local_face = face_cell_local_face;
std::unordered_map<unsigned int, std::vector<unsigned int>> node_faces_map;
for (size_t l=0; l<m_face_to_node_matrix.numRows(); ++l) {
......@@ -448,11 +454,6 @@ private:
return m_cell_nodes;
}
const Kokkos::View<const bool**> cellFacesIsReversed() const
{
return m_cell_faces_is_reversed;
}
const Kokkos::View<const unsigned short*> cellNbNodes() const
{
return m_cell_nb_nodes;
......@@ -463,11 +464,6 @@ private:
return m_inv_cell_nb_nodes;
}
const Kokkos::View<const unsigned short**> faceCellLocalFace() const
{
return m_face_cell_local_face;
}
unsigned int getFaceNumber(const std::vector<unsigned int>& face_nodes) const
{
const Face face(face_nodes);
......
......@@ -140,9 +140,6 @@ private:
}
});
const Kokkos::View<const bool**> cell_faces_is_reversed
= m_mesh.connectivity().cellFacesIsReversed();
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;
......@@ -152,10 +149,11 @@ private:
node_id_to_local[cell_nodes(j,R)] = R;
}
const auto& cell_faces = m_mesh.connectivity().m_cell_to_face_matrix.rowConst(j);
const auto& cell_faces_is_reversed = m_mesh.connectivity().m_cell_to_face_is_reversed_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)) {
if (cell_faces_is_reversed(L)) {
for (size_t rl = 0; rl<face_nodes.length; ++rl) {
m_Cjr(j, node_id_to_local[face_nodes(rl)]) -= Nlr(l,rl);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment