https://mooseframework.inl.gov
SnapshotContainerBase.C
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 #include "SnapshotContainerBase.h"
11 
14 {
16 
17  params.addParam<NonlinearSystemName>(
18  "nonlinear_system_name",
19  "nl0",
20  "Option to select which nonlinear system's solution shall be stored.");
21  return params;
22 }
23 
25  : GeneralReporter(parameters),
26  _accumulated_data(
27  declareRestartableDataWithContext<Snapshots>("accumulated_snapshots", (void *)&comm())),
28  _nonlinear_system_number(
29  _fe_problem.nlSysNum(getParam<NonlinearSystemName>("nonlinear_system_name")))
30 {
31 }
32 
33 void
35 {
37 }
38 
40 SnapshotContainerBase::getSnapshot(unsigned int local_i) const
41 {
42  mooseAssert(local_i < _accumulated_data.size(),
43  "The container only has (" + std::to_string(_accumulated_data.size()) +
44  ") solutions so we cannot find any with index (" + std::to_string(local_i) +
45  ")!");
46  return _accumulated_data[local_i];
47 }
48 
49 void
51 {
52  // Store the cloned snapshot. Each derived class has to implement the cloneSnapshot() method.
54 }
55 
56 void
57 dataStore(std::ostream & stream, SnapshotContainerBase::Snapshots & v, void * context)
58 {
59  storeHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context);
60 }
61 
62 void
63 dataLoad(std::istream & stream, SnapshotContainerBase::Snapshots & v, void * context)
64 {
65  loadHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context);
66 }
void dataLoad(std::istream &stream, SnapshotContainerBase::Snapshots &v, void *context)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const NumericVector< Number > & getSnapshot(unsigned int local_i) const
Return one of the stored snapshot vectors.
static InputParameters validParams()
std::size_t size() const
void storeHelper(std::ostream &stream, P &data, void *context)
Snapshots & _accumulated_data
Dynamic container for snapshot vectors.
static InputParameters validParams()
Storage for the snapshots.
void dataStore(std::ostream &stream, SnapshotContainerBase::Snapshots &v, void *context)
SnapshotContainerBase(const InputParameters &parameters)
static const std::string v
Definition: NS.h:84
virtual void initialSetup() override
virtual void execute() override
class infix_ostream_iterator if void
void loadHelper(std::istream &stream, P &data, void *context)
T & addPointer(std::unique_ptr< T > &&ptr)
virtual std::unique_ptr< NumericVector< Number > > collectSnapshot()=0
Clone the current snapshot vector.