Skip to content
Snippets Groups Projects
Commit 90c0f5b4 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MeL] Make MeshSubset ctor parameters pointers.

This should clarify the ownership of the vectors
passed to the ctors.
parent c2759756
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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));
......
......@@ -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));
......
......@@ -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
......
......@@ -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
......
......@@ -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));
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment