From 90c0f5b4e1667c919aad7694b883ef9942409cca Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Thu, 7 May 2015 17:43:32 +0200 Subject: [PATCH] [MeL] Make MeshSubset ctor parameters pointers. This should clarify the ownership of the vectors passed to the ctors. --- MeshLib/MeshSubset.h | 18 +++++++++--------- ProcessLib/GroundwaterFlowProcess.h | 2 +- Tests/AssemblerLib/LocalToGlobalIndexMap.cpp | 2 +- Tests/AssemblerLib/TestMeshComponentMap.cpp | 6 +++--- Tests/AssemblerLib/TestSerialLinearSolver.cpp | 2 +- .../TestSerialVectorMatrixBuilder.cpp | 2 +- Tests/MeshLib/MeshSubsets.cpp | 8 ++++---- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/MeshLib/MeshSubset.h b/MeshLib/MeshSubset.h index 5ae19b80b96..7149043fe9f 100644 --- a/MeshLib/MeshSubset.h +++ b/MeshLib/MeshSubset.h @@ -29,21 +29,21 @@ class MeshSubset { public: /// construct from nodes - MeshSubset(const Mesh& msh, std::vector<Node*> const& vec_items, + MeshSubset(const Mesh& msh, std::vector<Node*> const* vec_items, bool const delete_ptr = false) - : _msh(msh), _nodes(&vec_items), _eles(nullptr), _delete_ptr(delete_ptr) + : _msh(msh), _nodes(vec_items), _eles(nullptr), _delete_ptr(delete_ptr) {} /// construct from elements - MeshSubset(const Mesh& msh, std::vector<Element*> const& vec_items, + MeshSubset(const Mesh& msh, std::vector<Element*> const* vec_items, bool const delete_ptr = false) - : _msh(msh), _nodes(nullptr), _eles(&vec_items), _delete_ptr(delete_ptr) + : _msh(msh), _nodes(nullptr), _eles(vec_items), _delete_ptr(delete_ptr) {} /// construct from both nodes and elements - MeshSubset(const Mesh& msh, std::vector<Node*> const& vec_nodes, - std::vector<Element*> const& vec_eles, bool const delete_ptr = false) - : _msh(msh), _nodes(&vec_nodes), _eles(&vec_eles), _delete_ptr(delete_ptr) + MeshSubset(const Mesh& msh, std::vector<Node*> const* vec_nodes, + std::vector<Element*> const* vec_eles, bool const delete_ptr = false) + : _msh(msh), _nodes(vec_nodes), _eles(vec_eles), _delete_ptr(delete_ptr) {} ~MeshSubset() @@ -117,7 +117,7 @@ public: std::vector<Node*>* active_nodes = new std::vector<Node*>; if (_nodes == nullptr || _nodes->empty()) - return new MeshSubset(_msh, *active_nodes); // Empty mesh subset + return new MeshSubset(_msh, active_nodes); // Empty mesh subset for (auto n : nodes) { @@ -127,7 +127,7 @@ public: active_nodes->push_back(n); } - return new MeshSubset(_msh, *active_nodes, true); + return new MeshSubset(_msh, active_nodes, true); } private: diff --git a/ProcessLib/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlowProcess.h index 59ed1e35b12..645e80ddb63 100644 --- a/ProcessLib/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlowProcess.h @@ -79,7 +79,7 @@ public: DBUG("Construct dof mappings."); // Create single component dof in every of the mesh's nodes. - _mesh_subset_all_nodes = new MeshLib::MeshSubset(_mesh, _mesh.getNodes()); + _mesh_subset_all_nodes = new MeshLib::MeshSubset(_mesh, &_mesh.getNodes()); // Collect the mesh subsets in a vector. _all_mesh_subsets.push_back(new MeshLib::MeshSubsets(_mesh_subset_all_nodes)); diff --git a/Tests/AssemblerLib/LocalToGlobalIndexMap.cpp b/Tests/AssemblerLib/LocalToGlobalIndexMap.cpp index b95f7f79a7e..dcf996e500a 100644 --- a/Tests/AssemblerLib/LocalToGlobalIndexMap.cpp +++ b/Tests/AssemblerLib/LocalToGlobalIndexMap.cpp @@ -26,7 +26,7 @@ public: AssemblerLibLocalToGlobalIndexMapTest() { mesh = MeshLib::MeshGenerator::generateLineMesh(1.0, mesh_size); - nodesSubset = new MeshLib::MeshSubset(*mesh, mesh->getNodes()); + nodesSubset = new MeshLib::MeshSubset(*mesh, &mesh->getNodes()); // Add two components both based on the same nodesSubset. components.emplace_back(new MeshLib::MeshSubsets(nodesSubset)); diff --git a/Tests/AssemblerLib/TestMeshComponentMap.cpp b/Tests/AssemblerLib/TestMeshComponentMap.cpp index 8cb18557c1b..b57c81c7a6d 100644 --- a/Tests/AssemblerLib/TestMeshComponentMap.cpp +++ b/Tests/AssemblerLib/TestMeshComponentMap.cpp @@ -30,7 +30,7 @@ class AssemblerLibMeshComponentMapTest : public ::testing::Test : mesh(nullptr), nodesSubset(nullptr), cmap(nullptr) { mesh = MeshLib::MeshGenerator::generateLineMesh(1.0, mesh_size); - nodesSubset = new MeshLib::MeshSubset(*mesh, mesh->getNodes()); + nodesSubset = new MeshLib::MeshSubset(*mesh, &mesh->getNodes()); // Add two components both based on the same nodesSubset. components.emplace_back(new MeshLib::MeshSubsets(nodesSubset)); @@ -142,7 +142,7 @@ TEST_F(AssemblerLibMeshComponentMapTest, SubsetOfNodesByComponent) for (std::size_t id : ids) some_nodes.push_back(const_cast<MeshLib::Node*>(mesh->getNode(id))); - MeshLib::MeshSubset some_nodes_mesh_subset(*mesh, some_nodes); + MeshLib::MeshSubset some_nodes_mesh_subset(*mesh, &some_nodes); std::vector<MeshLib::MeshSubsets*> selected_components; selected_components.emplace_back(nullptr); // empty component @@ -173,7 +173,7 @@ TEST_F(AssemblerLibMeshComponentMapTest, SubsetOfNodesByLocation) for (std::size_t id : ids) some_nodes.push_back(const_cast<MeshLib::Node*>(mesh->getNode(id))); - MeshLib::MeshSubset some_nodes_mesh_subset(*mesh, some_nodes); + MeshLib::MeshSubset some_nodes_mesh_subset(*mesh, &some_nodes); std::vector<MeshLib::MeshSubsets*> selected_components; selected_components.emplace_back(nullptr); // empty component diff --git a/Tests/AssemblerLib/TestSerialLinearSolver.cpp b/Tests/AssemblerLib/TestSerialLinearSolver.cpp index 89211c21929..a52775db067 100644 --- a/Tests/AssemblerLib/TestSerialLinearSolver.cpp +++ b/Tests/AssemblerLib/TestSerialLinearSolver.cpp @@ -51,7 +51,7 @@ TEST(AssemblerLibSerialLinearSolver, Steady2DdiffusionQuadElem) // Prepare mesh items where data are assigned //-------------------------------------------------------------------------- const MeshLib::MeshSubset mesh_items_all_nodes(*ex1.msh, - ex1.msh->getNodes()); + &ex1.msh->getNodes()); //-------------------------------------------------------------------------- // Allocate a coefficient matrix, RHS and solution vectors diff --git a/Tests/AssemblerLib/TestSerialVectorMatrixBuilder.cpp b/Tests/AssemblerLib/TestSerialVectorMatrixBuilder.cpp index 396241f0b92..473705e3599 100644 --- a/Tests/AssemblerLib/TestSerialVectorMatrixBuilder.cpp +++ b/Tests/AssemblerLib/TestSerialVectorMatrixBuilder.cpp @@ -32,7 +32,7 @@ class AssemblerLibSerialVectorMatrixBuilder : public ::testing::Test : mesh(nullptr), nodesSubset(nullptr), cmap(nullptr) { mesh = MeshLib::MeshGenerator::generateLineMesh(1.0, mesh_size); - nodesSubset = new MeshLib::MeshSubset(*mesh, mesh->getNodes()); + nodesSubset = new MeshLib::MeshSubset(*mesh, &mesh->getNodes()); // Add two components both based on the same nodesSubset. components.emplace_back(new MeshLib::MeshSubsets(nodesSubset)); diff --git a/Tests/MeshLib/MeshSubsets.cpp b/Tests/MeshLib/MeshSubsets.cpp index 217415bae65..302fe4f830b 100644 --- a/Tests/MeshLib/MeshSubsets.cpp +++ b/Tests/MeshLib/MeshSubsets.cpp @@ -22,9 +22,9 @@ TEST(MeshLibMeshSubsets, UniqueMeshIds) std::vector<Node*> const empty_node_ptr_vector(0); - MeshSubset const ms0(m0, empty_node_ptr_vector); - MeshSubset const ms1(m1, empty_node_ptr_vector); - MeshSubset const ms1a(m1, empty_node_ptr_vector); + MeshSubset const ms0(m0, &empty_node_ptr_vector); + MeshSubset const ms1(m1, &empty_node_ptr_vector); + MeshSubset const ms1a(m1, &empty_node_ptr_vector); MeshSubset const* const mesh_subsets[3] = {&ms0, &ms1, &ms1a}; @@ -37,7 +37,7 @@ TEST(MeshLibMeshSubsets, UniqueMeshIds) TEST(MeshLibMeshSubsets, GetIntersectionByNodes) { Mesh const* const mesh = MeshGenerator::generateLineMesh(1., 10); - MeshSubset all_nodes_mesh_subset(*mesh, mesh->getNodes()); + MeshSubset all_nodes_mesh_subset(*mesh, &mesh->getNodes()); // Select nodes std::vector<Node*> some_nodes; -- GitLab