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

Clean-up of few member functions in view of connectivity builder

- rename _computeNodeCellConnectivity -> _computeInverseConnectivityMatrix
- add _computeLocalChildItemNumberInItem
parent 39e4d87a
No related branches found
No related tags found
1 merge request!6Feature/crs
......@@ -91,64 +91,6 @@ void Connectivity<3>::_computeFaceCellConnectivities()
}
}
{
std::vector<std::vector<unsigned int>> face_to_node_vector(face_cells_map.size());
int l=0;
for (const auto& face_info : face_cells_map) {
const Face& face = face_info.first;
face_to_node_vector[l] = face.nodeIdList();
++l;
}
m_face_to_node_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_node_matrix", face_to_node_vector);
}
{
int l=0;
for (const auto& face_cells_vector : face_cells_map) {
const Face& face = face_cells_vector.first;
m_face_number_map[face] = l;
++l;
}
}
{
std::vector<std::vector<unsigned int>> face_to_cell_vector(face_cells_map.size());
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 int>& cells_vector = face_to_cell_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] = cell_number;
}
++l;
}
m_face_to_cell_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector);
}
{
std::vector<std::vector<unsigned short>> face_to_cell_local_face_vector(face_cells_map.size());
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
{
std::vector<std::vector<unsigned int>> cell_to_face_vector(this->numberOfCells());
for (size_t j=0; j<cell_to_face_vector.size(); ++j) {
......@@ -187,6 +129,35 @@ void Connectivity<3>::_computeFaceCellConnectivities()
cell_to_face_is_reversed_vector);
}
{
std::vector<std::vector<unsigned int>> face_to_node_vector(face_cells_map.size());
int l=0;
for (const auto& face_info : face_cells_map) {
const Face& face = face_info.first;
face_to_node_vector[l] = face.nodeIdList();
++l;
}
m_face_to_node_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_node_matrix", face_to_node_vector);
}
{
int l=0;
for (const auto& face_cells_vector : face_cells_map) {
const Face& face = face_cells_vector.first;
m_face_number_map[face] = l;
++l;
}
}
this->_computeInverseConnectivityMatrix(m_cell_to_face_matrix,
m_face_to_cell_matrix);
this->_computeLocalChildItemNumberInItem(m_cell_to_face_matrix,
m_face_to_cell_matrix,
m_face_to_cell_local_face_matrix);
#warning check that the number of cell per faces is <=2
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) {
const auto& face_nodes = m_face_to_node_matrix.rowConst(l);
......
......@@ -274,8 +274,11 @@ private:
std::unordered_map<Face, unsigned int, typename Face::Hash> m_face_number_map;
void _computeFaceCellConnectivities();
void _computeNodeCellConnectivity(const ConnectivityMatrix& cell_to_node_matrix,
ConnectivityMatrix& node_to_cell_matrix,
void _computeInverseConnectivityMatrix(const ConnectivityMatrix& cell_to_node_matrix,
ConnectivityMatrix& node_to_cell_matrix);
void _computeLocalChildItemNumberInItem(const ConnectivityMatrix& cell_to_node_matrix,
const ConnectivityMatrix& node_to_cell_matrix,
ConnectivityMatrixShort& node_to_cell_local_node_matrix);
public:
......@@ -379,10 +382,12 @@ private:
node_id_per_cell_vector);
}
this->_computeNodeCellConnectivity(m_cell_to_node_matrix,
this->_computeInverseConnectivityMatrix(m_cell_to_node_matrix,
m_node_to_cell_matrix);
this->_computeLocalChildItemNumberInItem(m_cell_to_node_matrix,
m_node_to_cell_matrix,
m_node_to_cell_local_node_matrix);
if constexpr (Dimension>1) {
this->_computeFaceCellConnectivities();
}
......@@ -396,59 +401,62 @@ private:
template<size_t Dimension>
inline void Connectivity<Dimension>::
_computeNodeCellConnectivity(const ConnectivityMatrix& cell_to_node_matrix,
ConnectivityMatrix& node_to_cell_matrix,
ConnectivityMatrixShort& node_to_cell_local_node_matrix)
{
_computeInverseConnectivityMatrix(const ConnectivityMatrix& item_to_child_item_matrix,
ConnectivityMatrix& child_item_to_item_matrix)
{
std::map<unsigned int, std::vector<unsigned int>> node_cells_map;
const size_t& number_of_cells = cell_to_node_matrix.numRows();
std::map<unsigned int, std::vector<unsigned int>> child_item_to_item_vector_map;
const size_t& number_of_items = item_to_child_item_matrix.numRows();
for (unsigned int j=0; j<number_of_cells; ++j) {
const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
for (unsigned int r=0; r<cell_nodes.length; ++r) {
node_cells_map[cell_nodes(r)].push_back(j);
for (unsigned int j=0; j<number_of_items; ++j) {
const auto& item_to_child_items = item_to_child_item_matrix.rowConst(j);
for (unsigned int r=0; r<item_to_child_items.length; ++r) {
child_item_to_item_vector_map[item_to_child_items(r)].push_back(j);
}
}
{
size_t i=0;
for (const auto& [node_id, cell_vector] : node_cells_map) {
if (node_id != i) {
std::cerr << "sparse node numerotation NIY\n";
for (const auto& [child_item_id, item_vector] : child_item_to_item_vector_map) {
if (child_item_id != i) {
std::cerr << "sparse item numerotation NIY\n";
std::exit(0);
}
++i;
}
}
std::vector<std::vector<unsigned int>> node_to_cell_vector(node_cells_map.size());
for (const auto& [r, cells_vector] : node_cells_map) {
node_to_cell_vector[r] = cells_vector;
std::vector<std::vector<unsigned int>> child_item_to_items_vector(child_item_to_item_vector_map.size());
for (const auto& [child_item_id, item_vector] : child_item_to_item_vector_map) {
child_item_to_items_vector[child_item_id] = item_vector;
}
node_to_cell_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("node_to_cell_matrix", node_to_cell_vector);
child_item_to_item_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrix>("child_item_to_item_matrix", child_item_to_items_vector);
}
{
std::vector<std::vector<unsigned int>> node_to_cell_local_node_vector(node_to_cell_matrix.numRows());
for (unsigned int r=0; r<node_to_cell_matrix.numRows(); ++r) {
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);
const auto& cell_nodes = cell_to_node_matrix.rowConst(j);
for (unsigned int R=0; R<cell_nodes.length; ++R) {
if (cell_nodes(R) == r) {
node_to_cell_local_node_vector[r][J] = R;
template<size_t Dimension>
inline void Connectivity<Dimension>::
_computeLocalChildItemNumberInItem(const ConnectivityMatrix& item_to_child_items_matrix,
const ConnectivityMatrix& child_item_to_items_matrix,
ConnectivityMatrixShort& child_item_number_in_item_matrix)
{
std::vector<std::vector<unsigned int>> child_item_number_in_item_vector(child_item_to_items_matrix.numRows());
for (unsigned int r=0; r<child_item_to_items_matrix.numRows(); ++r) {
const auto& child_item_to_items = child_item_to_items_matrix.rowConst(r);
child_item_number_in_item_vector[r].resize(child_item_to_items.length);
for (unsigned short J=0; J<child_item_to_items.length; ++J) {
const unsigned int j = child_item_to_items(J);
const auto& item_to_child_items = item_to_child_items_matrix.rowConst(j);
for (unsigned int R=0; R<item_to_child_items.length; ++R) {
if (item_to_child_items(R) == r) {
child_item_number_in_item_vector[r][J] = R;
break;
}
}
}
}
node_to_cell_local_node_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("node_to_cell_local_node_matrix", node_to_cell_local_node_vector);
}
child_item_number_in_item_matrix
= Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("child_item_number_in_item_matrix", child_item_number_in_item_vector);
}
using Connectivity3D = Connectivity<3>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment