https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
33void
38
39const NumericVector<Number> &
40SnapshotContainerBase::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
49void
51{
52 // Store the cloned snapshot. Each derived class has to implement the cloneSnapshot() method.
54}
55
56void
57dataStore(std::ostream & stream, SnapshotContainerBase::Snapshots & v, void * context)
58{
59 storeHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context);
60}
61
62void
63dataLoad(std::istream & stream, SnapshotContainerBase::Snapshots & v, void * context)
64{
65 loadHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context);
66}
void storeHelper(std::ostream &stream, P &data, void *context)
void loadHelper(std::istream &stream, P &data, void *context)
const double v
void dataLoad(std::istream &stream, SnapshotContainerBase::Snapshots &v, void *context)
void dataStore(std::ostream &stream, SnapshotContainerBase::Snapshots &v, void *context)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual void execute() override
SnapshotContainerBase(const InputParameters &parameters)
static InputParameters validParams()
Snapshots & _accumulated_data
Dynamic container for snapshot vectors.
virtual std::unique_ptr< NumericVector< Number > > collectSnapshot()=0
Clone the current snapshot vector.
const NumericVector< Number > & getSnapshot(unsigned int local_i) const
Return one of the stored snapshot vectors.
virtual void initialSetup() override
std::size_t size() const
T & addPointer(std::unique_ptr< T > &&ptr)