Skip to content

Commit

Permalink
Re-organize underlying VPP data structure to maintain declare order
Browse files Browse the repository at this point in the history
  • Loading branch information
aeslaughter committed Apr 20, 2017
1 parent 47d0082 commit 179c2ed
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion framework/include/base/FEProblemBase.h
Expand Up @@ -753,7 +753,7 @@ class FEProblemBase : public SubProblem, public Restartable
* Get the vectors for a specific VectorPostprocessor.
* @param vpp_name The name of the VectorPostprocessor
*/
const std::map<std::string, VectorPostprocessorData::VectorPostprocessorState> &
const std::vector<std::pair<std::string, VectorPostprocessorData::VectorPostprocessorState>> &
getVectorPostprocessorVectors(const std::string & vpp_name);

// Dampers /////
Expand Down
10 changes: 2 additions & 8 deletions framework/include/vectorpostprocessors/VectorPostprocessorData.h
Expand Up @@ -71,12 +71,6 @@ class VectorPostprocessorData : public Restartable
getVectorPostprocessorValueOld(const VectorPostprocessorName & vpp_name,
const std::string & vector_name);

/**
* Get the map of names -> VectorPostprocessor values. Exposed for error checking.
*/
// const std::map<std::string, std::map<std::string, VectorPostprocessorValue*> > & values()
// const { return _values; }

/**
* Check to see if a VPP has any vectors at all
*/
Expand All @@ -86,7 +80,7 @@ class VectorPostprocessorData : public Restartable
* Get the map of vectors for a particular VectorPostprocessor
* @param vpp_name The name of the VectorPostprocessor
*/
const std::map<std::string, VectorPostprocessorState> &
const std::vector<std::pair<std::string, VectorPostprocessorState>> &
vectors(const std::string & vpp_name) const;

/**
Expand All @@ -100,7 +94,7 @@ class VectorPostprocessorData : public Restartable
bool get_current);

/// Values of the vector post-processor
std::map<std::string, std::map<std::string, VectorPostprocessorState>> _values;
std::map<std::string, std::vector<std::pair<std::string, VectorPostprocessorState>>> _values;

std::set<std::string> _requested_items;
std::set<std::string> _supplied_items;
Expand Down
2 changes: 1 addition & 1 deletion framework/src/base/FEProblemBase.C
Expand Up @@ -2569,7 +2569,7 @@ FEProblemBase::declareVectorPostprocessorVector(const VectorPostprocessorName &
return _vpps_data.declareVector(name, vector_name);
}

const std::map<std::string, VectorPostprocessorData::VectorPostprocessorState> &
const std::vector<std::pair<std::string, VectorPostprocessorData::VectorPostprocessorState>> &
FEProblemBase::getVectorPostprocessorVectors(const std::string & vpp_name)
{
return _vpps_data.vectors(vpp_name);
Expand Down
21 changes: 18 additions & 3 deletions framework/src/vectorpostprocessors/VectorPostprocessorData.C
Expand Up @@ -58,9 +58,24 @@ VectorPostprocessorData::getVectorPostprocessorHelper(const VectorPostprocessorN
const std::string & vector_name,
bool get_current)
{
// Intentional use of RHS brackets on a std::map to do a multilevel retrieve or insert
auto & vec_struct = _values[vpp_name][vector_name];
// Intentional use of RHS brackets on a std::map to do a retrieve or insert
auto & vec_storage = _values[vpp_name];

// lambda for doing compairison on name (i.e., first item in pair)
auto comp = [&vector_name](std::pair<std::string, VectorPostprocessorState> & pair) {
return pair.first == vector_name;
};

// Search for the vector, if it is not located create the entry in the storage
auto iter = std::find_if(vec_storage.begin(), vec_storage.end(), comp);
if (iter == vec_storage.end())
{
vec_storage.emplace_back(
std::pair<std::string, VectorPostprocessorState>(vector_name, VectorPostprocessorState()));
iter = vec_storage.end() - 1; // can't use rbegin() because we need a forward iterator
}

auto & vec_struct = iter->second;
if (!vec_struct.current)
{
mooseAssert(!vec_struct.old, "Uninitialized pointers in VectorPostprocessor Data");
Expand All @@ -79,7 +94,7 @@ VectorPostprocessorData::hasVectors(const std::string & vpp_name) const
return _values.find(vpp_name) != _values.end();
}

const std::map<std::string, VectorPostprocessorData::VectorPostprocessorState> &
const std::vector<std::pair<std::string, VectorPostprocessorData::VectorPostprocessorState>> &
VectorPostprocessorData::vectors(const std::string & vpp_name) const
{
auto vec_pair = _values.find(vpp_name);
Expand Down

0 comments on commit 179c2ed

Please sign in to comment.