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