https://mooseframework.inl.gov
ParallelSolutionStorage.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "GeneralReporter.h"
13 
19 {
20 public:
23  virtual void initialSetup() override;
24  virtual void initialize() override {}
25  virtual void execute() override {}
26  virtual void finalize() override {}
27 
34  void
35  addEntry(const VariableName & vname, unsigned int global_i, const DenseVector<Real> & solution);
40  std::unordered_map<unsigned int, std::vector<DenseVector<Real>>> &
42  getStorage(const VariableName & variable);
43 
44  const std::unordered_map<unsigned int, std::vector<DenseVector<Real>>> &
45  getStorage(const VariableName & variable) const;
47 
49  std::map<VariableName, std::unordered_map<unsigned int, std::vector<DenseVector<Real>>>> &
50  getStorage() const
51  {
53  }
54 
61  bool hasGlobalSample(unsigned int global_sample_i, const VariableName & variable) const;
62 
69  const std::vector<DenseVector<Real>> & getGlobalSample(unsigned int global_sample_i,
70  const VariableName & variable) const;
71 
76  unsigned int totalNumberOfStoredSolutions(const VariableName & vname) const;
77 
79  const std::vector<VariableName> & variableNames() const { return _variable_names; }
80 
81 protected:
87  std::map<VariableName, std::unordered_map<unsigned int, std::vector<DenseVector<Real>>>> &
89 
90 private:
92  const std::vector<VariableName> & _variable_names;
93 };
94 
95 void to_json(
96  nlohmann::json & json,
97  const std::map<VariableName, std::unordered_map<unsigned int, std::vector<DenseVector<Real>>>> &
98  solution_storage);
void to_json(nlohmann::json &json, const std::map< VariableName, std::unordered_map< unsigned int, std::vector< DenseVector< Real >>>> &solution_storage)
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.
virtual void execute() override
unsigned int totalNumberOfStoredSolutions(const VariableName &vname) const
Return the number of total stored solutions for a given variable.
std::map< VariableName, std::unordered_map< unsigned int, std::vector< DenseVector< Real > > > > & getStorage() const
Get the whole solution container.
ParallelSolutionStorage(const InputParameters &parameters)
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...
virtual void initialize() override
virtual void finalize() override
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...
const InputParameters & parameters() const
const std::vector< VariableName > & variableNames() const
Get the variable names which we can receive.
std::map< VariableName, std::unordered_map< unsigned int, std::vector< DenseVector< Real > > > > & _distributed_solutions
The container of the solutions.
virtual void initialSetup() override
static InputParameters validParams()
A Reporter which stores serialized solution fields for given variables in a distributed fashion...