https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CosineHumpFunction.C
Go to the documentation of this file.
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
12registerMooseObject("ThermalHydraulicsApp", CosineHumpFunction);
13
16{
18
19 MooseEnum axis("x=0 y=1 z=2");
20 params.addRequiredParam<MooseEnum>("axis", axis, "Coordinate axis on which the hump occurs");
21 params.addRequiredParam<Real>("hump_center_position", "Hump center position on selected axis");
22 params.addRequiredParam<Real>("hump_width", "Width of the hump");
23 params.addRequiredParam<Real>("hump_begin_value", "Value before and after the hump");
24 params.addRequiredParam<Real>("hump_center_value", "Value at the center of the hump");
25
26 params.addClassDescription("Computes a cosine hump of a user-specified width and height");
27
28 return params;
29}
30
32 : Function(parameters),
33
34 _component(getParam<MooseEnum>("axis")),
35 _hump_width(getParam<Real>("hump_width")),
36 _hump_center_position(getParam<Real>("hump_center_position")),
37
38 _hump_begin_value(getParam<Real>("hump_begin_value")),
39 _hump_center_value(getParam<Real>("hump_center_value")),
40
41 _cosine_amplitude(0.5 * (_hump_center_value - _hump_begin_value)),
42 _hump_mid_value(0.5 * (_hump_center_value + _hump_begin_value)),
43 _hump_left_end(_hump_center_position - 0.5 * _hump_width),
44 _hump_right_end(_hump_center_position + 0.5 * _hump_width)
45{
46}
47
48Real
49CosineHumpFunction::value(Real /*t*/, const Point & p) const
50{
51 const Real x = p(_component);
52
53 if (x < _hump_left_end)
54 return _hump_begin_value;
55 else if (x > _hump_right_end)
56 return _hump_begin_value;
57 else
58 return _hump_mid_value -
60 std::cos(2 * M_PI / _hump_width * (x - _hump_center_position + 0.5 * _hump_width));
61}
62
63RealVectorValue
64CosineHumpFunction::gradient(Real /*t*/, const Point & /*p*/) const
65{
66 mooseError(name(), ": ", __PRETTY_FUNCTION__, " is not implemented.");
67}
registerMooseObject("ThermalHydraulicsApp", CosineHumpFunction)
const std::vector< double > x
const Real p
Computes a cosine hump of a user-specified width and height.
CosineHumpFunction(const InputParameters &parameters)
virtual Real value(Real t, const Point &p) const
const Real _hump_mid_value
Middle value of hump.
const Real & _hump_begin_value
Value before and after the hump.
const Real _cosine_amplitude
Cosine amplitude.
const Real & _hump_width
Width of hump.
static InputParameters validParams()
virtual RealVectorValue gradient(Real t, const Point &p) const
const Real & _hump_center_position
Hump center position on selected axis.
const Real _hump_right_end
Right end of hump.
const unsigned int _component
Component index of axis on which hump occurs.
const Real _hump_left_end
Left end of hump.
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::string & name() const
void mooseError(Args &&... args) const