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

Get ride of max subitem per item constants

- m_max_nb_node_per_cell
- m_max_nb_face_per_cell
- m_max_nb_node_per_face

Data structures tend to be more unstructured
parent 434aeb30
No related branches found
No related tags found
1 merge request!6Feature/crs
......@@ -31,8 +31,6 @@ private:
Kokkos::View<double*> m_inv_cell_nb_nodes;
size_t m_max_nb_node_per_cell;
std::vector<std::vector<unsigned int>>
_buildConnectivity(const size_t& number_of_cells)
{
......@@ -70,11 +68,6 @@ public:
return m_cell_to_node_matrix.numRows();
}
const size_t& maxNbNodePerCell() const
{
return m_max_nb_node_per_cell;
}
const Kokkos::View<const double*> invCellNbNodes() const
{
return m_inv_cell_nb_nodes;
......@@ -122,7 +115,6 @@ public:
ConnectivityUtils utils;
utils.computeNodeCellConnectivity(m_cell_to_node_matrix,
m_max_nb_node_per_cell,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
}
......
......@@ -42,8 +42,6 @@ class Connectivity2D
Kokkos::View<unsigned short**> m_face_cell_local_face;
Kokkos::View<unsigned short**> m_face_node_local_face;
size_t m_max_nb_node_per_cell;
struct Face
{
const unsigned int m_node0_id;
......@@ -125,20 +123,20 @@ class Connectivity2D
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector);
}
Kokkos::View<unsigned short**> face_cell_local_face("face_cell_local_face",
face_cells_map.size(), 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 = cells_vector[lj].second;
face_cell_local_face(l,lj) = cell_local_face;
}
++l;
}
}
m_face_cell_local_face = face_cell_local_face;
// Kokkos::View<unsigned short**> face_cell_local_face("face_cell_local_face",
// face_cells_map.size(), 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 = cells_vector[lj].second;
// face_cell_local_face(l,lj) = cell_local_face;
// }
// ++l;
// }
// }
// m_face_cell_local_face = face_cell_local_face;
}
public:
......@@ -190,20 +188,15 @@ class Connectivity2D
return m_cell_to_node_matrix.numRows();
}
const size_t& maxNbNodePerCell() const
{
return m_max_nb_node_per_cell;
}
const Kokkos::View<const double*> invCellNbNodes() const
{
return m_inv_cell_nb_nodes;
}
const Kokkos::View<const unsigned short**> faceCellLocalFace() const
{
return m_face_cell_local_face;
}
// const Kokkos::View<const unsigned short**> faceCellLocalFace() const
// {
// return m_face_cell_local_face;
// }
unsigned int getFaceNumber(const unsigned int node0_id,
const unsigned int node1_id) const
......@@ -260,7 +253,6 @@ class Connectivity2D
ConnectivityUtils utils;
utils.computeNodeCellConnectivity(m_cell_to_node_matrix,
m_max_nb_node_per_cell,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
......
......@@ -35,6 +35,7 @@ public:
ConnectivityMatrixShort m_node_to_cell_local_node_matrix;
// Stores numbering of nodes of each cell.
// gives an id to each node of each cell. (j,r) -> id
//
// This is different from m_cell_to_node_matrix which return the global id of
// a local node in a cell
......@@ -49,10 +50,6 @@ private:
Kokkos::View<const unsigned short*> m_node_nb_faces;
Kokkos::View<const unsigned int**> m_node_faces;
size_t m_max_nb_node_per_cell;
size_t m_max_nb_face_per_cell;
size_t m_max_nb_node_per_face;
class Face
{
public:
......@@ -255,8 +252,6 @@ private:
}
}
}
std::cerr << __FILE__ << ':' << __LINE__ << ':'
<< rang::fg::red << " m_max_nb_node_per_face forced to 4" << rang::fg::reset << '\n';
{
std::vector<std::vector<unsigned int>> face_to_node_vector(face_cells_map.size());
......@@ -270,7 +265,6 @@ private:
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_node_matrix", face_to_node_vector);
}
m_max_nb_node_per_face = 4;
{
int l=0;
for (const auto& face_cells_vector : face_cells_map) {
......@@ -335,10 +329,6 @@ private:
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("cell_to_face_matrix", cell_to_face_vector);
}
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;
{
std::vector<std::vector<unsigned short>> cell_to_face_is_reversed_vector(this->numberOfCells());
for (size_t j=0; j<cell_to_face_is_reversed_vector.size(); ++j) {
......@@ -435,21 +425,6 @@ private:
return m_cell_to_node_matrix.numRows();
}
const size_t& maxNbFacePerCell() const
{
return m_max_nb_face_per_cell;
}
const size_t& maxNbNodePerCell() const
{
return m_max_nb_node_per_cell;
}
const size_t& maxNbNodePerFace() const
{
return m_max_nb_node_per_face;
}
const Kokkos::View<const double*> invCellNbNodes() const
{
return m_inv_cell_nb_nodes;
......@@ -503,7 +478,6 @@ private:
ConnectivityUtils utils;
utils.computeNodeCellConnectivity(m_cell_to_node_matrix,
m_max_nb_node_per_cell,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
......
......@@ -13,19 +13,11 @@ class ConnectivityUtils
{
public:
void computeNodeCellConnectivity(const ConnectivityMatrix& cell_to_node_matrix,
size_t& max_nb_node_per_cell,
ConnectivityMatrix& node_to_cell_matrix,
ConnectivityMatrixShort& node_to_cell_local_node_matrix)
{
std::map<unsigned int, std::vector<unsigned int>> node_cells_map;
const size_t& number_of_cells = cell_to_node_matrix.numRows();
using namespace Kokkos::Experimental;
Kokkos::parallel_reduce(number_of_cells, KOKKOS_LAMBDA(const int& j, size_t& nb_max) {
const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
const size_t n = cell_nodes.length;
if (n > nb_max) nb_max = n;
}, Kokkos::Max<size_t>(max_nb_node_per_cell));
for (unsigned int j=0; j<number_of_cells; ++j) {
const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
......
......@@ -101,7 +101,8 @@ private:
} else if (dimension ==3) {
const Kokkos::View<const Rd*> xr = m_mesh.xr();
Kokkos::View<Rd**> Nlr("Nlr", m_mesh.connectivity().numberOfFaces(), m_mesh.connectivity().maxNbNodePerFace());
#warning Rewrite using better data structures and remove this explicit 4
Kokkos::View<Rd**> Nlr("Nlr", m_mesh.connectivity().numberOfFaces(), 4);
Kokkos::parallel_for(m_mesh.numberOfFaces(), KOKKOS_LAMBDA(const int& l) {
const auto& face_nodes = m_mesh.connectivity().m_face_to_node_matrix.rowConst(l);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment