Skip to content
Permalink
Browse files

Merge pull request #13107 from WilkAndy/non_scalability_13078

PorousFlowConnectedNodes sizeSequential method added
  • Loading branch information...
permcody committed Mar 25, 2019
2 parents 68416a1 + 982de30 commit 951cc84d7c6252efd19d2f3958ed7a5daa2a41dc
@@ -125,6 +125,13 @@ class PorousFlowConnectedNodes
unsigned indexOfSequentialConnection(dof_id_type sequential_node_ID_from,
dof_id_type sequential_node_ID_to) const;

/**
* Return the size of _sequential_id, for checking memory efficiency.
* The memory wasted by this class is (sizeSequential() - numNodes()) * (size of dof_id_type).
* finalizeAddingGlobalNodes() must have been called prior to calling this method
*/
std::size_t sizeSequential() const;

private:
bool _still_adding_global_nodes;
dof_id_type _min_global_id;
@@ -65,6 +65,15 @@ PorousFlowConnectedNodes::finalizeAddingGlobalNodes()
_neighbor_sets.assign(_global_id.size(), std::set<dof_id_type>());
}

std::size_t
PorousFlowConnectedNodes::sizeSequential() const
{
if (_still_adding_global_nodes)
mooseError("PorousFlowConnectedNodes: sizeSequential called, but _still_adding_global_nodes is "
"true. Probably you should have called finalizeAddingGlobalNodes.");
return _sequential_id.size();
}

dof_id_type
PorousFlowConnectedNodes::globalID(dof_id_type sequential_node_ID) const
{
@@ -190,6 +190,19 @@ TEST_F(PorousFlowConnectedNodesTest, errors)
"global_node_ID_to 12");
ASSERT_TRUE(pos != std::string::npos);
}

try
{
_n2.sizeSequential();
}
catch (const std::exception & err)
{
std::size_t pos =
std::string(err.what())
.find("PorousFlowConnectedNodes: sizeSequential called, but _still_adding_global_nodes "
"is true. Probably you should have called finalizeAddingGlobalNodes.");
ASSERT_TRUE(pos != std::string::npos);
}
}

TEST_F(PorousFlowConnectedNodesTest, numNodes)
@@ -262,3 +275,5 @@ TEST_F(PorousFlowConnectedNodesTest, connections)
EXPECT_EQ(_n1.globalConnectionsToSequentialID(1)[0], 1234);
EXPECT_EQ(_n1.globalConnectionsToSequentialID(2)[0], 1234);
}

TEST_F(PorousFlowConnectedNodesTest, sizeSequential) { EXPECT_EQ(_n1.sizeSequential(), 1234); }

0 comments on commit 951cc84

Please sign in to comment.
You can’t perform that action at this time.