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 "CosineHumpFunction.h" 11 : 12 : registerMooseObject("ThermalHydraulicsApp", CosineHumpFunction); 13 : 14 : InputParameters 15 83 : CosineHumpFunction::validParams() 16 : { 17 83 : InputParameters params = Function::validParams(); 18 : 19 166 : MooseEnum axis("x=0 y=1 z=2"); 20 166 : params.addRequiredParam<MooseEnum>("axis", axis, "Coordinate axis on which the hump occurs"); 21 166 : params.addRequiredParam<Real>("hump_center_position", "Hump center position on selected axis"); 22 166 : params.addRequiredParam<Real>("hump_width", "Width of the hump"); 23 166 : params.addRequiredParam<Real>("hump_begin_value", "Value before and after the hump"); 24 166 : params.addRequiredParam<Real>("hump_center_value", "Value at the center of the hump"); 25 : 26 83 : params.addClassDescription("Computes a cosine hump of a user-specified width and height"); 27 : 28 83 : return params; 29 83 : } 30 : 31 44 : CosineHumpFunction::CosineHumpFunction(const InputParameters & parameters) 32 : : Function(parameters), 33 : 34 44 : _component(getParam<MooseEnum>("axis")), 35 88 : _hump_width(getParam<Real>("hump_width")), 36 88 : _hump_center_position(getParam<Real>("hump_center_position")), 37 : 38 88 : _hump_begin_value(getParam<Real>("hump_begin_value")), 39 88 : _hump_center_value(getParam<Real>("hump_center_value")), 40 : 41 44 : _cosine_amplitude(0.5 * (_hump_center_value - _hump_begin_value)), 42 44 : _hump_mid_value(0.5 * (_hump_center_value + _hump_begin_value)), 43 44 : _hump_left_end(_hump_center_position - 0.5 * _hump_width), 44 44 : _hump_right_end(_hump_center_position + 0.5 * _hump_width) 45 : { 46 44 : } 47 : 48 : Real 49 1577 : CosineHumpFunction::value(Real /*t*/, const Point & p) const 50 : { 51 1577 : const Real x = p(_component); 52 : 53 1577 : if (x < _hump_left_end) 54 505 : return _hump_begin_value; 55 1072 : else if (x > _hump_right_end) 56 467 : return _hump_begin_value; 57 : else 58 605 : return _hump_mid_value - 59 605 : _cosine_amplitude * 60 605 : std::cos(2 * M_PI / _hump_width * (x - _hump_center_position + 0.5 * _hump_width)); 61 : } 62 : 63 : RealVectorValue 64 0 : CosineHumpFunction::gradient(Real /*t*/, const Point & /*p*/) const 65 : { 66 0 : mooseError(name(), ": ", __PRETTY_FUNCTION__, " is not implemented."); 67 : }