From fdfd33c52d1eb803c20c3e6347a858b45d35ba47 Mon Sep 17 00:00:00 2001 From: Dmitrij Naumov <dmitrij@naumov.de> Date: Wed, 14 Jan 2015 00:08:53 +0000 Subject: [PATCH] [IO] Move same code for mesh creation into newMesh(). --- FileIO/MPI_IO/NodePartitionedMeshReader.cpp | 51 +++++++++------------ FileIO/MPI_IO/NodePartitionedMeshReader.h | 8 ++++ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp index 8d78776926a..35a7ece22d6 100644 --- a/FileIO/MPI_IO/NodePartitionedMeshReader.cpp +++ b/FileIO/MPI_IO/NodePartitionedMeshReader.cpp @@ -157,20 +157,8 @@ MeshLib::NodePartitionedMesh* NodePartitionedMeshReader::readBinary( setElements(mesh_nodes, ghost_elem_data, mesh_elems, process_ghost); //---------------------------------------------------------------------------------- - //Create a mesh and return it - const std::size_t n_nghost_elem = static_cast<std::size_t>(_mesh_info.regular_elements); - const unsigned n_global_base_nodes = static_cast<unsigned>(_mesh_info.global_base_nodes); - const unsigned n_global_nodes = static_cast<unsigned>(_mesh_info.global_nodes); - const unsigned n_base_nodes = static_cast<unsigned>(_mesh_info.base_nodes); - const unsigned n_active_base_nodes = static_cast<unsigned>(_mesh_info.active_base_nodes); - const unsigned n_active_nodes = static_cast<unsigned>(_mesh_info.active_nodes); - - return new MeshLib::NodePartitionedMesh( - BaseLib::extractBaseName(file_name_base) + std::to_string(_mpi_comm_size), - mesh_nodes, glb_node_ids, - mesh_elems, n_nghost_elem, - n_global_base_nodes, n_global_nodes, - n_base_nodes, n_active_base_nodes, n_active_nodes); + return newMesh(BaseLib::extractBaseName(file_name_base), + mesh_nodes, glb_node_ids, mesh_elems); } bool NodePartitionedMeshReader::openASCIIFiles(std::string const& file_name_base, @@ -362,21 +350,8 @@ MeshLib::NodePartitionedMesh* NodePartitionedMeshReader::readASCII( if(_mpi_rank == i) { - //---------------------------------------------------------------------------------- - //Create a mesh - const std::size_t n_nghost_elem = static_cast<std::size_t>(_mesh_info.regular_elements); - const unsigned n_global_base_nodes = static_cast<unsigned>(_mesh_info.global_base_nodes); - const unsigned n_global_nodes = static_cast<unsigned>(_mesh_info.global_nodes); - const unsigned n_base_nodes = static_cast<unsigned>(_mesh_info.base_nodes); - const unsigned n_active_base_nodes = static_cast<unsigned>(_mesh_info.active_base_nodes); - const unsigned n_active_nodes = static_cast<unsigned>(_mesh_info.active_nodes); - - np_mesh = new MeshLib::NodePartitionedMesh( - BaseLib::extractBaseName(file_name_base) + std::to_string(_mpi_comm_size), - mesh_nodes, glb_node_ids, - mesh_elems, n_nghost_elem, - n_global_base_nodes, n_global_nodes, - n_base_nodes, n_active_base_nodes, n_active_nodes); + np_mesh = newMesh(BaseLib::extractBaseName(file_name_base), + mesh_nodes, glb_node_ids, mesh_elems); } } @@ -392,6 +367,24 @@ MeshLib::NodePartitionedMesh* NodePartitionedMeshReader::readASCII( return np_mesh; } +MeshLib::NodePartitionedMesh* +NodePartitionedMeshReader::newMesh( + std::string const& mesh_name, + std::vector<MeshLib::Node*> const& mesh_nodes, + std::vector<std::size_t> const& glb_node_ids, + std::vector<MeshLib::Element*> const& mesh_elems) const +{ + return new MeshLib::NodePartitionedMesh( + mesh_name + std::to_string(_mpi_comm_size), + mesh_nodes, glb_node_ids, mesh_elems, + static_cast<std::size_t>(_mesh_info.regular_elements), + static_cast<unsigned>(_mesh_info.global_base_nodes), + static_cast<unsigned>(_mesh_info.global_nodes), + static_cast<unsigned>(_mesh_info.base_nodes), + static_cast<unsigned>(_mesh_info.active_base_nodes), + static_cast<unsigned>(_mesh_info.active_nodes)); +} + void NodePartitionedMeshReader::readElementASCII(std::ifstream &ins, std::vector<long>& elem_data, const bool ghost) const { diff --git a/FileIO/MPI_IO/NodePartitionedMeshReader.h b/FileIO/MPI_IO/NodePartitionedMeshReader.h index 3326cc2c8e4..209f5fda6ed 100644 --- a/FileIO/MPI_IO/NodePartitionedMeshReader.h +++ b/FileIO/MPI_IO/NodePartitionedMeshReader.h @@ -84,6 +84,14 @@ class NodePartitionedMeshReader } _mesh_info; + /*! Creates a new mesh using PartitionMeshInfo + */ + MeshLib::NodePartitionedMesh* newMesh( + std::string const& mesh_name, + std::vector<MeshLib::Node*> const& mesh_nodes, + std::vector<std::size_t> const& glb_node_ids, + std::vector<MeshLib::Element*> const& mesh_elems) const; + /*! \brief Create a NodePartitionedMesh object, read binary mesh data in the manner of parallel, and return a pointer to it. -- GitLab