20 "simulations on sub-applications.");
23 "The names of the variables whose serialized solution this object is supposed to receive.");
32 _distributed_solutions(
34 std::map<VariableName,
35 std::unordered_map<unsigned
int,
std::vector<DenseVector<
Real>>>>>(
37 _variable_names(getParam<
std::vector<VariableName>>(
"variables"))
41 vname, std::unordered_map<
unsigned int, std::vector<DenseVector<Real>>>());
53 unsigned int global_i,
54 const DenseVector<Real> & solution)
58 "We are trying to add a variable that we cannot receive!");
60 auto sample_insert_pair =
63 sample_insert_pair.first->second.push_back(std::move(solution));
71 return std::accumulate(
75 [](
unsigned int count,
const std::pair<unsigned int, std::vector<DenseVector<Real>>> & sample)
76 {
return std::move(count) + sample.second.size(); });
81 const VariableName & variable)
const 88 return (variable_storage.find(global_sample_i) != variable_storage.end());
91 const std::vector<DenseVector<Real>> &
93 const VariableName & variable)
const 96 "We don't have the requested variable!");
98 mooseAssert(variable_storage.find(global_sample_i) != variable_storage.end(),
99 "We don't have the requested global sample index! ");
101 return libmesh_map_find(variable_storage, global_sample_i);
104 std::unordered_map<unsigned int, std::vector<DenseVector<Real>>> &
109 "We are trying to access container for variable '", variable,
"' but we don't have it!");
114 const std::unordered_map<unsigned int, std::vector<DenseVector<Real>>> &
119 "We are trying to access container for variable '", variable,
"' but we don't have it!");
126 nlohmann::json & json,
127 const std::map<VariableName, std::unordered_map<
unsigned int, std::vector<DenseVector<Real>>>> &
130 for (
const auto & vname_pair : solution_storage)
132 auto & variable_storage = json[vname_pair.first];
133 for (
const auto & sample_pair : vname_pair.second)
135 auto & sample_storage = variable_storage[std::to_string(sample_pair.first)];
136 sample_storage = std::vector<std::vector<Real>>();
137 for (
const auto & sample : sample_pair.second)
139 sample_storage.push_back(sample.get_values());
const std::vector< VariableName > & _variable_names
The names of the variables whose serialized solution this object is supposed to receive.
void addEntry(const VariableName &vname, unsigned int global_i, const DenseVector< Real > &solution)
Add a new solution entry to the container.
unsigned int totalNumberOfStoredSolutions(const VariableName &vname) const
Return the number of total stored solutions for a given variable.
void to_json(nlohmann::json &json, const std::map< VariableName, std::unordered_map< unsigned int, std::vector< DenseVector< Real >>>> &solution_storage)
static InputParameters validParams()
std::map< VariableName, std::unordered_map< unsigned int, std::vector< DenseVector< Real > > > > & getStorage() const
Get the whole solution container.
ParallelSolutionStorage(const InputParameters ¶meters)
registerMooseObject("StochasticToolsApp", ParallelSolutionStorage)
bool hasGlobalSample(unsigned int global_sample_i, const VariableName &variable) const
Determine if we have the solution vector with a given global sample index for a given variable...
const ReporterMode REPORTER_MODE_DISTRIBUTED
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
const std::vector< DenseVector< Real > > & getGlobalSample(unsigned int global_sample_i, const VariableName &variable) const
Get the serialized solution field which is associated with a given global sample index and variable...
std::map< VariableName, std::unordered_map< unsigned int, std::vector< DenseVector< Real > > > > & _distributed_solutions
The container of the solutions.
void ErrorVector unsigned int
virtual void initialSetup() override
static InputParameters validParams()
A Reporter which stores serialized solution fields for given variables in a distributed fashion...