Line data Source code
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 : 12 : InputParameters 13 1940 : SnapshotContainerBase::validParams() 14 : { 15 1940 : InputParameters params = GeneralReporter::validParams(); 16 : 17 3880 : params.addParam<NonlinearSystemName>( 18 : "nonlinear_system_name", 19 : "nl0", 20 : "Option to select which nonlinear system's solution shall be stored."); 21 1940 : return params; 22 0 : } 23 : 24 970 : SnapshotContainerBase::SnapshotContainerBase(const InputParameters & parameters) 25 : : GeneralReporter(parameters), 26 970 : _accumulated_data( 27 1940 : declareRestartableDataWithContext<Snapshots>("accumulated_snapshots", (void *)&comm())), 28 970 : _nonlinear_system_number( 29 2910 : _fe_problem.nlSysNum(getParam<NonlinearSystemName>("nonlinear_system_name"))) 30 : { 31 970 : } 32 : 33 : void 34 970 : SnapshotContainerBase::initialSetup() 35 : { 36 970 : _accumulated_data.clear(); 37 970 : } 38 : 39 : const NumericVector<Number> & 40 0 : 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 0 : return _accumulated_data[local_i]; 47 : } 48 : 49 : void 50 1480 : SnapshotContainerBase::execute() 51 : { 52 : // Store the cloned snapshot. Each derived class has to implement the cloneSnapshot() method. 53 2960 : _accumulated_data.addPointer(collectSnapshot()); 54 1480 : } 55 : 56 : void 57 660 : dataStore(std::ostream & stream, SnapshotContainerBase::Snapshots & v, void * context) 58 : { 59 660 : storeHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context); 60 660 : } 61 : 62 : void 63 510 : dataLoad(std::istream & stream, SnapshotContainerBase::Snapshots & v, void * context) 64 : { 65 510 : loadHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context); 66 510 : }