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 "IntegralPreservingFunctionIC.h" 11 : #include "Function.h" 12 : #include "UserObject.h" 13 : 14 : registerMooseObject("MooseApp", IntegralPreservingFunctionIC); 15 : 16 : InputParameters 17 14326 : IntegralPreservingFunctionIC::validParams() 18 : { 19 14326 : InputParameters params = FunctionIC::validParams(); 20 14326 : params.addRequiredParam<PostprocessorName>( 21 : "integral", "Postprocessor providing the integral of the function, for normalization"); 22 14326 : params.addRequiredParam<Real>("magnitude", 23 : "Desired magnitude of the initial condition upon integration"); 24 14326 : params.addClassDescription("Function initial condition that preserves an integral"); 25 14326 : return params; 26 0 : } 27 : 28 32 : IntegralPreservingFunctionIC::IntegralPreservingFunctionIC(const InputParameters & parameters) 29 : : FunctionIC(parameters), 30 32 : _pp_name(getParam<PostprocessorName>("integral")), 31 32 : _integral(getPostprocessorValue("integral")), 32 64 : _magnitude(getParam<Real>("magnitude")) 33 : { 34 32 : } 35 : 36 : void 37 30 : IntegralPreservingFunctionIC::initialSetup() 38 : { 39 30 : const UserObject & pp = _fe_problem.getUserObject<UserObject>(_pp_name); 40 30 : if (!pp.getExecuteOnEnum().isValueSet(EXEC_INITIAL)) 41 4 : mooseError("The 'execute_on' parameter for the '" + _pp_name + 42 : "' postprocessor must include 'initial'!"); 43 26 : } 44 : 45 : Real 46 4031 : IntegralPreservingFunctionIC::value(const Point & p) 47 : { 48 4031 : if (std::abs(_integral) < libMesh::TOLERANCE) 49 3 : mooseError("The integral of '" + _pp_name + "' cannot be zero!"); 50 : 51 4028 : return magnitude() * _func.value(_t, p) / _integral; 52 : }