From d967a6fa17410751bcb02d9f732bef8bb24dd870 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Fri, 11 Jan 2019 19:18:59 +0100 Subject: [PATCH] Begin ConnectivityDescriptor class implementation --- src/mesh/Connectivity.cpp | 81 +++++++++++++++++++++++++++++++++++++++ src/mesh/Connectivity.hpp | 23 +++++++++++ 2 files changed, 104 insertions(+) diff --git a/src/mesh/Connectivity.cpp b/src/mesh/Connectivity.cpp index 07701bbb9..9c9684c23 100644 --- a/src/mesh/Connectivity.cpp +++ b/src/mesh/Connectivity.cpp @@ -288,6 +288,87 @@ Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector, } +template<size_t Dimension> +Connectivity<Dimension>:: +Connectivity(const ConnectivityDescriptor& descriptor) +{ +#warning should be checked by + Assert(descriptor.cell_by_node_vector.size() == descriptor.cell_type_vector.size()); + Assert(descriptor.cell_number_vector.size() == descriptor.cell_type_vector.size()); + + auto& cell_to_node_matrix + = m_item_to_item_matrix[itemTId(ItemType::cell)][itemTId(ItemType::node)]; + cell_to_node_matrix = descriptor.cell_by_node_vector; + + { + CellValue<CellType> cell_type(*this); + parallel_for(this->numberOfCells(), PASTIS_LAMBDA(const CellId& j){ + cell_type[j] = descriptor.cell_type_vector[j]; + }); + m_cell_type = cell_type; + } + + { + CellValue<int> cell_number(*this); + cell_number = convert_to_array(descriptor.cell_number_vector); + m_cell_number = cell_number; + } + + { + NodeValue<int> node_number(*this); + node_number = convert_to_array(descriptor.node_number_vector); + m_node_number = node_number; + } + + { + CellValue<int> cell_global_index(*this); +#warning index must start accounting number of global indices of other procs +#warning must take care of ghost cells + int first_index = 0; + parallel_for(this->numberOfCells(), PASTIS_LAMBDA(const CellId& j) { + cell_global_index[j] = first_index+j; + }); + m_cell_global_index = cell_global_index; + } + + + { + CellValue<double> inv_cell_nb_nodes(*this); + parallel_for(this->numberOfCells(), PASTIS_LAMBDA(const CellId& j) { + const auto& cell_nodes = cell_to_node_matrix.rowConst(j); + inv_cell_nb_nodes[j] = 1./cell_nodes.length; + }); + m_inv_cell_nb_nodes = inv_cell_nb_nodes; + } + + { + CellValue<int> cell_owner(*this); + cell_owner = convert_to_array(descriptor.cell_owner_vector); + m_cell_owner = cell_owner; + } + + { + NodeValue<int> node_owner(*this); + node_owner = convert_to_array(descriptor.node_owner_vector); + m_node_owner = node_owner; + } + + if constexpr (Dimension>1) { + this->_computeCellFaceAndFaceNodeConnectivities(); + } +} + +template Connectivity1D:: +Connectivity(const ConnectivityDescriptor& descriptor); + +template Connectivity2D:: +Connectivity(const ConnectivityDescriptor& descriptor); + +template Connectivity3D:: +Connectivity(const ConnectivityDescriptor& descriptor); + + + template Connectivity1D:: Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector, const std::vector<CellType>& cell_type_vector, diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index a04c0f7e0..71044616c 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -36,6 +36,27 @@ #include <algorithm> #include <set> +class ConnectivityDescriptor +{ + private: + + public: + std::vector<std::vector<unsigned int>>& cell_by_node_vector; + std::vector<CellType>& cell_type_vector; + std::vector<int>& cell_number_vector; + std::vector<int>& node_number_vector; + std::vector<int>& cell_owner_vector; + std::vector<int>& node_owner_vector; + + ConnectivityDescriptor& operator=(const ConnectivityDescriptor&) = delete; + ConnectivityDescriptor& operator=(ConnectivityDescriptor&&) = delete; + + ConnectivityDescriptor() = default; + ConnectivityDescriptor(const ConnectivityDescriptor&) = default; + ConnectivityDescriptor(ConnectivityDescriptor&&) = delete; + ~ConnectivityDescriptor() = default; +}; + template <size_t Dimension> class Connectivity; @@ -688,6 +709,8 @@ class Connectivity final Connectivity(const Connectivity&) = delete; + Connectivity(const ConnectivityDescriptor& descriptor); + Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector, const std::vector<CellType>& cell_type_vector, const std::vector<int>& cell_number_vector, -- GitLab