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 : #pragma once 11 : 12 : #include "GeneralReporter.h" 13 : class Transient; 14 : 15 : /** 16 : * Report the time and iteration information for the simulation. 17 : */ 18 : class IterationInfo : public GeneralReporter 19 : { 20 : public: 21 : static InputParameters validParams(); 22 : IterationInfo(const InputParameters & parameters); 23 400 : virtual void initialize() override {} 24 400 : virtual void finalize() override {} 25 : virtual void execute() override; 26 : 27 : protected: 28 : const MultiMooseEnum & _items; 29 : 30 : // Reporter values to return (all are computed as "replicated" values) 31 : Real & _time_value; 32 : unsigned int & _time_step_value; 33 : unsigned int & _num_linear; 34 : unsigned int & _num_nonlinear; 35 : unsigned int & _num_fixed_point; 36 : 37 : /// The nonlinear system that this should report iteration info for 38 : const unsigned int _nl_sys_num; 39 : 40 : // Used to allow for optional declare 41 : Real _dummy_real = 0; 42 : unsigned int _dummy_unsigned_int = 0; 43 : 44 : // Helper to perform optional declaration based on "_items" 45 : template <typename T> 46 : T & declareHelper(const std::string & item_name, T & _dummy, bool extra_check = true); 47 : }; 48 : 49 : template <typename T> 50 : T & 51 330 : IterationInfo::declareHelper(const std::string & item_name, T & dummy, bool extra_check) 52 : { 53 330 : return (extra_check && (!_items.isValid() || _items.isValueSet(item_name))) 54 990 : ? declareValueByName<T>(item_name, REPORTER_MODE_REPLICATED) 55 660 : : dummy; 56 : }