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

Continue connectivity structures clean-up

parent 05e5d04b
No related branches found
No related tags found
1 merge request!6Feature/crs
......@@ -19,8 +19,6 @@ public:
private:
std::vector<RefNodeList> m_ref_node_list;
size_t m_number_of_nodes;
const size_t& m_number_of_faces = m_number_of_nodes;
const size_t m_number_of_cells;
const Kokkos::View<const unsigned int**> m_cell_nodes;
......@@ -30,15 +28,6 @@ private:
Kokkos::View<double*> m_inv_cell_nb_nodes;
const Kokkos::View<const unsigned short*>& m_cell_nb_faces = m_cell_nb_nodes;
Kokkos::View<const unsigned short*> m_node_nb_cells;
const Kokkos::View<const unsigned short*>& m_face_nb_cells = m_node_nb_cells;
Kokkos::View<const unsigned int**> m_node_cells;
const Kokkos::View<const unsigned int**>& m_face_cells = m_node_cells;
Kokkos::View<const unsigned short**> m_node_cell_local_node;
const Kokkos::View<const unsigned short**>& m_face_cell_local_face = m_node_cell_local_node;
size_t m_max_nb_node_per_cell;
const Kokkos::View<const unsigned int**>
......@@ -82,14 +71,14 @@ public:
return m_ref_node_list[i];
}
const size_t& numberOfNodes() const
size_t numberOfNodes() const
{
return m_number_of_nodes;
return m_node_to_cell_matrix.numRows();
}
const size_t& numberOfFaces() const
size_t numberOfFaces() const
{
return m_number_of_faces;
return m_node_to_cell_matrix.numRows();
}
const size_t& numberOfCells() const
......@@ -112,11 +101,6 @@ public:
return m_cell_faces;
}
const Kokkos::View<const unsigned short*> nodeNbCells() const
{
return m_node_nb_cells;
}
const Kokkos::View<const unsigned short*> cellNbNodes() const
{
return m_cell_nb_nodes;
......@@ -132,31 +116,6 @@ public:
return m_cell_nb_faces;
}
const Kokkos::View<const unsigned short*> faceNbCells() const
{
return m_face_nb_cells;
}
const Kokkos::View<const unsigned int**> nodeCells() const
{
return m_node_cells;
}
const Kokkos::View<const unsigned int**> faceCells() const
{
return m_face_cells;
}
const Kokkos::View<const unsigned short**> nodeCellLocalNode() const
{
return m_node_cell_local_node;
}
const Kokkos::View<const unsigned short**> faceCellLocalFace() const
{
return m_face_cell_local_face;
}
Connectivity1D(const Connectivity1D&) = delete;
Connectivity1D(const size_t& number_of_cells)
......@@ -175,10 +134,6 @@ public:
m_cell_nb_nodes,
m_number_of_cells,
m_max_nb_node_per_cell,
m_number_of_nodes,
m_node_nb_cells,
m_node_cells,
m_node_cell_local_node,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
}
......@@ -199,10 +154,6 @@ public:
m_cell_nb_nodes,
m_number_of_cells,
m_max_nb_node_per_cell,
m_number_of_nodes,
m_node_nb_cells,
m_node_cells,
m_node_cell_local_node,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
}
......
......@@ -28,7 +28,6 @@ class Connectivity2D
const size_t m_number_of_cells;
size_t m_number_of_faces;
size_t m_number_of_nodes;
const Kokkos::View<const unsigned short*> m_cell_nb_nodes;
const Kokkos::View<const unsigned int**> m_cell_nodes;
......@@ -37,10 +36,6 @@ class Connectivity2D
Kokkos::View<const unsigned short*> m_cell_nb_faces;
Kokkos::View<unsigned int**> m_cell_faces;
Kokkos::View<const unsigned short*> m_node_nb_cells;
Kokkos::View<const unsigned int**> m_node_cells;
Kokkos::View<const unsigned short**> m_node_cell_local_node;
Kokkos::View<unsigned short*> m_face_nb_cells;
Kokkos::View<unsigned int**> m_face_cells;
Kokkos::View<unsigned short**> m_face_cell_local_face;
......@@ -214,9 +209,9 @@ class Connectivity2D
return m_ref_node_list[i];
}
const size_t& numberOfNodes() const
size_t numberOfNodes() const
{
return m_number_of_nodes;
return m_node_to_cell_matrix.numRows();
}
const size_t& numberOfFaces() const
......@@ -323,10 +318,6 @@ class Connectivity2D
m_cell_nb_nodes,
m_number_of_cells,
m_max_nb_node_per_cell,
m_number_of_nodes,
m_node_nb_cells,
m_node_cells,
m_node_cell_local_node,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
......
......@@ -32,7 +32,6 @@ private:
const size_t m_number_of_cells;
size_t m_number_of_faces;
size_t m_number_of_nodes;
const Kokkos::View<const unsigned short*> m_cell_nb_nodes;
const Kokkos::View<const unsigned int**> m_cell_nodes;
......@@ -42,10 +41,6 @@ private:
Kokkos::View<const unsigned int**> m_cell_faces;
Kokkos::View<const bool**> m_cell_faces_is_reversed;
Kokkos::View<const unsigned short*> m_node_nb_cells;
Kokkos::View<const unsigned int**> m_node_cells;
Kokkos::View<const unsigned short**> m_node_cell_local_node;
Kokkos::View<const unsigned short*> m_face_nb_cells;
Kokkos::View<const unsigned int**> m_face_cells;
Kokkos::View<const unsigned short**> m_face_cell_local_face;
......@@ -387,7 +382,7 @@ private:
node_faces_map[r].push_back(l);
}
}
Kokkos::View<unsigned short*> node_nb_faces("node_nb_faces", m_number_of_nodes);
Kokkos::View<unsigned short*> node_nb_faces("node_nb_faces", this->numberOfNodes());
size_t max_nb_face_per_node = 0;
for (auto node_faces : node_faces_map) {
max_nb_face_per_node = std::max(node_faces.second.size(), max_nb_face_per_node);
......@@ -395,7 +390,7 @@ private:
}
m_node_nb_faces = node_nb_faces;
Kokkos::View<unsigned int**> node_faces("node_faces", m_number_of_nodes, max_nb_face_per_node);
Kokkos::View<unsigned int**> node_faces("node_faces", this->numberOfNodes(), max_nb_face_per_node);
for (auto node_faces_vector : node_faces_map) {
const unsigned int r = node_faces_vector.first;
const std::vector<unsigned int>& faces_vector = node_faces_vector.second;
......@@ -437,9 +432,10 @@ private:
return m_ref_node_list[i];
}
const size_t& numberOfNodes() const
KOKKOS_INLINE_FUNCTION
size_t numberOfNodes() const
{
return m_number_of_nodes;
return m_node_to_cell_matrix.numRows();
}
const size_t& numberOfFaces() const
......@@ -555,10 +551,6 @@ private:
m_cell_nb_nodes,
m_number_of_cells,
m_max_nb_node_per_cell,
m_number_of_nodes,
m_node_nb_cells,
m_node_cells,
m_node_cell_local_node,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
......
......@@ -14,10 +14,6 @@ class ConnectivityUtils
const Kokkos::View<const unsigned short*> cell_nb_nodes,
const size_t& number_of_cells,
size_t& max_nb_node_per_cell,
size_t& number_of_nodes,
Kokkos::View<const unsigned short*>& node_nb_cells,
Kokkos::View<const unsigned int**>& node_cells,
Kokkos::View<const unsigned short**>& node_cell_local_node,
ConnectivityMatrix& node_to_cell_matrix,
ConnectivityMatrix& node_to_cell_local_node_matrix)
{
......@@ -46,29 +42,6 @@ class ConnectivityUtils
}
}
number_of_nodes = node_cells_map.size();
Kokkos::View<unsigned short*> built_node_nb_cells("node_nb_cells", node_cells_map.size());
size_t max_node_cells = 0;
for (const auto& i_cell_vector : node_cells_map) {
const auto& [i, cells_vector] = i_cell_vector;
const size_t nb_cells = cells_vector.size();
built_node_nb_cells[i] = nb_cells;
if (nb_cells > max_node_cells) {
max_node_cells = nb_cells;
}
}
node_nb_cells = built_node_nb_cells;
Kokkos::View<unsigned int**> built_node_cells("node_cells", node_cells_map.size(), max_node_cells);
for (const auto& i_cell_vector : node_cells_map) {
const auto& [i, cells_vector] = i_cell_vector;
for (size_t j=0; j<cells_vector.size(); ++j) {
built_node_cells(i,j) = cells_vector[j];
}
}
node_cells = built_node_cells;
std::vector<std::vector<unsigned int>> node_to_cell_vector(node_cells_map.size());
for (const auto& i_cell_vector : node_cells_map) {
const auto& [r, cells_vector] = i_cell_vector;
......@@ -77,26 +50,12 @@ class ConnectivityUtils
node_to_cell_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("node_to_cell_matrix", node_to_cell_vector);
Kokkos::View<unsigned short**> built_node_cell_local_node("node_cell_local_node",
node_cells_map.size(), max_node_cells);
Kokkos::parallel_for(number_of_nodes, KOKKOS_LAMBDA(const unsigned int& r){
for (unsigned short J=0; J<node_nb_cells[r]; ++J) {
const unsigned int j = node_cells(r,J);
for (unsigned int R=0; R<cell_nb_nodes[j]; ++R) {
if (cell_nodes(j,R) == r) {
built_node_cell_local_node(r,J)=R;
break;
}
}
}
});
node_cell_local_node = built_node_cell_local_node;
std::vector<std::vector<unsigned int>> node_to_cell_local_node_vector(node_cells_map.size());
for (unsigned int r=0; r<node_cells_map.size(); ++r) {
node_to_cell_local_node_vector[r].resize(node_nb_cells[r]);
for (unsigned short J=0; J<node_nb_cells[r]; ++J) {
const unsigned int j = node_cells(r,J);
const auto& node_to_cell = node_to_cell_matrix.rowConst(r);
node_to_cell_local_node_vector[r].resize(node_to_cell.length);
for (unsigned short J=0; J<node_to_cell.length; ++J) {
const unsigned int j = node_to_cell(J);
for (unsigned int R=0; R<cell_nb_nodes[j]; ++R) {
if (cell_nodes(j,R) == r) {
node_to_cell_local_node_vector[r][J] = R;
......
......@@ -36,7 +36,8 @@ public:
return *m_connectivity;
}
const size_t& numberOfNodes() const
KOKKOS_INLINE_FUNCTION
size_t numberOfNodes() const
{
return m_connectivity->numberOfNodes();
}
......
......@@ -67,7 +67,6 @@ private:
}
};
KOKKOS_INLINE_FUNCTION
const Kokkos::View<const double*>
computeRhoCj(const Kokkos::View<const double*>& rhoj,
......@@ -140,40 +139,20 @@ private:
for (const auto& handler : m_boundary_condition_list) {
switch (handler.boundaryCondition().type()) {
case BoundaryCondition::normal_velocity: {
std::cerr << "normal_velocity NIY\n";
std::cerr << __FILE__ << ':' << __LINE__ << ": normal_velocity BC NIY\n";
std::exit(0);
break;
}
case BoundaryCondition::velocity: {
std::cerr << "velocity NIY\n";
std::cerr << __FILE__ << ':' << __LINE__ << ": velocity BC NIY\n";
std::exit(0);
break;
}
case BoundaryCondition::pressure: {
const PressureBoundaryCondition& pressure_bc
= dynamic_cast<const PressureBoundaryCondition&>(handler.boundaryCondition());
const Kokkos::View<const unsigned int**> face_cells
= m_connectivity.faceCells();
const Kokkos::View<const unsigned short**> face_cell_local_face
= m_connectivity.faceCellLocalFace();
const Kokkos::View<const Rd**> Cjr
= m_mesh_data.Cjr();
Kokkos::parallel_for(pressure_bc.numberOfFaces(), KOKKOS_LAMBDA(const int& l_number) {
// quite ugly: node/faces are melt in a bad way... at least works in 1d...
const int l = pressure_bc.faceList()[l_number];
Assert(m_connectivity.faceNbCells()[l] == 1);
#warning remove this specialization
if constexpr(dimension ==3) {
const unsigned int j = m_connectivity.m_face_to_cell_matrix.entries(l); //face_cells(l,0);
const unsigned int L = face_cell_local_face(l,0);
m_br(l) -= pressure_bc.value()*Cjr(j,L);
} else {
const unsigned int j = face_cells(l,0);
const unsigned int L = face_cell_local_face(l,0);
m_br(l) -= pressure_bc.value()*Cjr(j,L);
}
});
// const PressureBoundaryCondition& pressure_bc
// = dynamic_cast<const PressureBoundaryCondition&>(handler.boundaryCondition());
std::cerr << __FILE__ << ':' << __LINE__ << ": pressure BC NIY\n";
std::exit(0);
break;
}
case BoundaryCondition::symmetry: {
......@@ -236,13 +215,6 @@ private:
});
}
void inverse(const Kokkos::View<const double*>& x,
Kokkos::View<double*>& inv_x) const {
Kokkos::parallel_for(x.size(), KOKKOS_LAMBDA(const int& r) {
inv_x(r) = 1./x(r);
});
}
KOKKOS_INLINE_FUNCTION
void computeExplicitFluxes(const Kokkos::View<const Rd*>& xr,
const Kokkos::View<const Rd*>& xj,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment