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

Remove m_cell_to_node_matrix member

Now use m_item_to_item_matrix[cell_id][node_id] instead
parent 5b7dfe1b
No related branches found
No related tags found
1 merge request!6Feature/crs
...@@ -7,9 +7,13 @@ void Connectivity<3>::_computeFaceCellConnectivities() ...@@ -7,9 +7,13 @@ void Connectivity<3>::_computeFaceCellConnectivities()
Kokkos::View<unsigned short*> cell_nb_faces("cell_nb_faces", this->numberOfCells()); Kokkos::View<unsigned short*> cell_nb_faces("cell_nb_faces", this->numberOfCells());
typedef std::tuple<unsigned int, unsigned short, bool> CellFaceInfo; typedef std::tuple<unsigned int, unsigned short, bool> CellFaceInfo;
const auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
std::map<Face, std::vector<CellFaceInfo>> face_cells_map; std::map<Face, std::vector<CellFaceInfo>> face_cells_map;
for (unsigned int j=0; j<this->numberOfCells(); ++j) { for (unsigned int j=0; j<this->numberOfCells(); ++j) {
const auto& cell_nodes = m_cell_to_node_matrix.rowConst(j); const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
switch (cell_nodes.length) { switch (cell_nodes.length) {
case 4: { // tetrahedron case 4: { // tetrahedron
...@@ -182,11 +186,14 @@ void Connectivity<3>::_computeFaceCellConnectivities() ...@@ -182,11 +186,14 @@ void Connectivity<3>::_computeFaceCellConnectivities()
template<> template<>
void Connectivity<2>::_computeFaceCellConnectivities() void Connectivity<2>::_computeFaceCellConnectivities()
{ {
const auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
// In 2D faces are simply define // In 2D faces are simply define
typedef std::pair<unsigned int, unsigned short> CellFaceId; typedef std::pair<unsigned int, unsigned short> CellFaceId;
std::map<Face, std::vector<CellFaceId>> face_cells_map; std::map<Face, std::vector<CellFaceId>> face_cells_map;
for (unsigned int j=0; j<this->numberOfCells(); ++j) { for (unsigned int j=0; j<this->numberOfCells(); ++j) {
const auto& cell_nodes = m_cell_to_node_matrix.rowConst(j); const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
for (unsigned short r=0; r<cell_nodes.length; ++r) { for (unsigned short r=0; r<cell_nodes.length; ++r) {
unsigned int node0_id = cell_nodes(r); unsigned int node0_id = cell_nodes(r);
unsigned int node1_id = cell_nodes((r+1)%cell_nodes.length); unsigned int node1_id = cell_nodes((r+1)%cell_nodes.length);
......
...@@ -230,12 +230,10 @@ class Connectivity final ...@@ -230,12 +230,10 @@ class Connectivity final
public: public:
static constexpr size_t dimension = Dimension; static constexpr size_t dimension = Dimension;
private:
ConnectivityMatrix m_cell_to_node_matrix;
public: public:
ConnectivityMatrix cellToNodeMatrix() const ConnectivityMatrix cellToNodeMatrix() const
{ {
return m_cell_to_node_matrix; return m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
} }
NodeValuePerCell<unsigned short> m_cell_to_node_local_cell; NodeValuePerCell<unsigned short> m_cell_to_node_local_cell;
...@@ -323,7 +321,9 @@ private: ...@@ -323,7 +321,9 @@ private:
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
size_t numberOfCells() const size_t numberOfCells() const
{ {
return m_cell_to_node_matrix.numRows(); const auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
return cell_to_node_matrix.numRows();
} }
const Kokkos::View<const double*> invCellNbNodes() const const Kokkos::View<const double*> invCellNbNodes() const
...@@ -347,32 +347,34 @@ private: ...@@ -347,32 +347,34 @@ private:
Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector) Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector)
{ {
m_cell_to_node_matrix = cell_by_node_vector; auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
cell_to_node_matrix = cell_by_node_vector;
Assert(this->numberOfCells()>0); Assert(this->numberOfCells()>0);
{ {
Kokkos::View<double*> inv_cell_nb_nodes("inv_cell_nb_nodes", this->numberOfCells()); Kokkos::View<double*> inv_cell_nb_nodes("inv_cell_nb_nodes", this->numberOfCells());
Kokkos::parallel_for(this->numberOfCells(), KOKKOS_LAMBDA(const int& j){ Kokkos::parallel_for(this->numberOfCells(), KOKKOS_LAMBDA(const int& j){
const auto& cell_nodes = m_cell_to_node_matrix.rowConst(j); const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
inv_cell_nb_nodes[j] = 1./cell_nodes.length; inv_cell_nb_nodes[j] = 1./cell_nodes.length;
}); });
m_inv_cell_nb_nodes = inv_cell_nb_nodes; m_inv_cell_nb_nodes = inv_cell_nb_nodes;
} }
m_connectivity_computer.computeInverseConnectivityMatrix(m_cell_to_node_matrix, m_connectivity_computer.computeInverseConnectivityMatrix(cell_to_node_matrix,
m_node_to_cell_matrix); m_node_to_cell_matrix);
m_node_to_cell_local_node = CellValuePerNode<unsigned short>(*this); m_node_to_cell_local_node = CellValuePerNode<unsigned short>(*this);
m_connectivity_computer.computeLocalChildItemNumberInItem(m_cell_to_node_matrix, m_connectivity_computer.computeLocalChildItemNumberInItem(cell_to_node_matrix,
m_node_to_cell_matrix, m_node_to_cell_matrix,
m_node_to_cell_local_node); m_node_to_cell_local_node);
m_cell_to_node_local_cell = NodeValuePerCell<unsigned short>(*this); m_cell_to_node_local_cell = NodeValuePerCell<unsigned short>(*this);
m_connectivity_computer.computeLocalChildItemNumberInItem(m_node_to_cell_matrix, m_connectivity_computer.computeLocalChildItemNumberInItem(m_node_to_cell_matrix,
m_cell_to_node_matrix, cell_to_node_matrix,
m_cell_to_node_local_cell); m_cell_to_node_local_cell);
if constexpr (Dimension>1) { if constexpr (Dimension>1) {
this->_computeFaceCellConnectivities(); this->_computeFaceCellConnectivities();
...@@ -403,7 +405,10 @@ inline const ConnectivityMatrix& ...@@ -403,7 +405,10 @@ inline const ConnectivityMatrix&
Connectivity<3>::itemToItemMatrix<TypeOfItem::cell, Connectivity<3>::itemToItemMatrix<TypeOfItem::cell,
TypeOfItem::node>() const TypeOfItem::node>() const
{ {
return m_cell_to_node_matrix; const auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
return cell_to_node_matrix;
} }
template <> template <>
...@@ -450,7 +455,10 @@ inline const ConnectivityMatrix& ...@@ -450,7 +455,10 @@ inline const ConnectivityMatrix&
Connectivity<2>::itemToItemMatrix<TypeOfItem::cell, Connectivity<2>::itemToItemMatrix<TypeOfItem::cell,
TypeOfItem::node>() const TypeOfItem::node>() const
{ {
return m_cell_to_node_matrix; const auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
return cell_to_node_matrix;
} }
template <> template <>
...@@ -488,7 +496,10 @@ inline const ConnectivityMatrix& ...@@ -488,7 +496,10 @@ inline const ConnectivityMatrix&
Connectivity<1>::itemToItemMatrix<TypeOfItem::cell, Connectivity<1>::itemToItemMatrix<TypeOfItem::cell,
TypeOfItem::node>() const TypeOfItem::node>() const
{ {
return m_cell_to_node_matrix; const auto& cell_to_node_matrix
= m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)];
return cell_to_node_matrix;
} }
template <> template <>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment