LCOV - code coverage report
Current view: top level - src/reporters - SnapshotContainerBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #31405 (292dce) with base fef103 Lines: 22 25 88.0 %
Date: 2025-09-04 07:57:52 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          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        2134 : SnapshotContainerBase::validParams()
      14             : {
      15        2134 :   InputParameters params = GeneralReporter::validParams();
      16             : 
      17        4268 :   params.addParam<NonlinearSystemName>(
      18             :       "nonlinear_system_name",
      19             :       "nl0",
      20             :       "Option to select which nonlinear system's solution shall be stored.");
      21        2134 :   return params;
      22           0 : }
      23             : 
      24        1067 : SnapshotContainerBase::SnapshotContainerBase(const InputParameters & parameters)
      25             :   : GeneralReporter(parameters),
      26        1067 :     _accumulated_data(
      27        2134 :         declareRestartableDataWithContext<Snapshots>("accumulated_snapshots", (void *)&comm())),
      28        1067 :     _nonlinear_system_number(
      29        3201 :         _fe_problem.nlSysNum(getParam<NonlinearSystemName>("nonlinear_system_name")))
      30             : {
      31        1067 : }
      32             : 
      33             : void
      34        1067 : SnapshotContainerBase::initialSetup()
      35             : {
      36        1067 :   _accumulated_data.clear();
      37        1067 : }
      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        1628 : SnapshotContainerBase::execute()
      51             : {
      52             :   // Store the cloned snapshot. Each derived class has to implement the cloneSnapshot() method.
      53        3256 :   _accumulated_data.addPointer(collectSnapshot());
      54        1628 : }
      55             : 
      56             : void
      57         726 : dataStore(std::ostream & stream, SnapshotContainerBase::Snapshots & v, void * context)
      58             : {
      59         726 :   storeHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context);
      60         726 : }
      61             : 
      62             : void
      63         561 : dataLoad(std::istream & stream, SnapshotContainerBase::Snapshots & v, void * context)
      64             : {
      65         561 :   loadHelper(stream, static_cast<UniqueStorage<NumericVector<Number>> &>(v), context);
      66         561 : }

Generated by: LCOV version 1.14