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 "TimeIntegratedPostprocessor.h" 11 : #include "CrankNicolson.h" 12 : #include "TransientBase.h" 13 : 14 : registerMooseObject("MooseApp", TimeIntegratedPostprocessor); 15 : registerMooseObjectRenamed("MooseApp", 16 : TotalVariableValue, 17 : "04/01/2022 00:00", 18 : TimeIntegratedPostprocessor); 19 : 20 : InputParameters 21 6302 : TimeIntegratedPostprocessor::validParams() 22 : { 23 6302 : InputParameters params = GeneralPostprocessor::validParams(); 24 12604 : params.addClassDescription("Integrate a Postprocessor value over time."); 25 25208 : params.addParam<PostprocessorName>("value", "The name of the postprocessor"); 26 25208 : MooseEnum schemes("implicit-euler trapezoidal-rule", "trapezoidal-rule"); 27 18906 : params.addParam<MooseEnum>( 28 : "time_integration_scheme", schemes, "Time integration scheme to use for the postprocessors"); 29 12604 : return params; 30 6302 : } 31 : 32 90 : TimeIntegratedPostprocessor::TimeIntegratedPostprocessor(const InputParameters & parameters) 33 : : GeneralPostprocessor(parameters), 34 90 : _value(0), 35 90 : _value_old(getPostprocessorValueOldByName(name())), 36 180 : _pps_value(getPostprocessorValue("value")), 37 180 : _pps_value_old(getPostprocessorValueOld("value")), 38 270 : _time_integration_scheme(getParam<MooseEnum>("time_integration_scheme")) 39 : { 40 90 : if (!dynamic_cast<TransientBase *>(_app.getExecutioner())) 41 0 : mooseError( 42 : "Time integration of postprocessor has only been implemented with a transient executioner"); 43 : 44 : // Only check if the user did not select it manually 45 270 : if (!isParamSetByUser("time_integration_scheme")) 46 : { 47 : const auto time_integrators = 48 0 : dynamic_cast<TransientBase *>(_app.getExecutioner())->getTimeIntegrators(); 49 0 : for (const auto & ti : time_integrators) 50 0 : if (_time_integration_scheme == TimeIntegration::TrapezoidalRule && 51 0 : !dynamic_cast<CrankNicolson *>(ti)) 52 0 : mooseInfo( 53 : "The time integration in this postprocessor uses the trapezoidal rule method. The " 54 : "equation time integration scheme does not use the trapezoidal rule. If the " 55 : "postprocessor uses variable values, even indirectly, we would recommend you " 56 : "code the same time integration method for the time-integrated postprocessor. " 57 : "Specify the 'time_integration_scheme' parameter to silence this warning."); 58 0 : } 59 90 : } 60 : 61 : void 62 465 : TimeIntegratedPostprocessor::initialize() 63 : { 64 465 : } 65 : 66 : void 67 465 : TimeIntegratedPostprocessor::execute() 68 : { 69 465 : if (_time_integration_scheme == TimeIntegration::ImplicitEuler) 70 23 : _value = _value_old + _pps_value * _dt; 71 : // 2nd order trapezoidal rule is a better default for other integrators 72 : else 73 442 : _value = _value_old + 0.5 * (_pps_value + _pps_value_old) * _dt; 74 465 : } 75 : 76 : Real 77 465 : TimeIntegratedPostprocessor::getValue() const 78 : { 79 465 : return _value; 80 : }