www.mooseframework.org
WedgeFunction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "WedgeFunction.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<Function>();
15  params.addClassDescription("Function object for tests/ins/jeffery_hamel responsible for setting "
16  "the exact value of the velocity and pressure variables.");
17  params.addRequiredParam<Real>(
18  "alpha_degrees", "The wedge half-angle size (in degrees) used in computing 'f' below.");
19  params.addRequiredParam<Real>("Re", "The Reynolds number used in computing 'f' below.");
20  params.addRequiredRangeCheckedParam<unsigned int>(
21  "var_num",
22  "var_num<3",
23  "The variable (0==vel_x, 1==vel_y, 2==p) we are computing the exact solution for.");
24  params.addRequiredParam<Real>("mu", "dynamic viscosity");
25  params.addRequiredParam<Real>("rho", "density");
26  params.addRequiredParam<Real>("K", "Constant obtained by interating the Jeffery-Hamel ODE once.");
27  params.addRequiredParam<FunctionName>(
28  "f", "The pre-computed semi-analytic exact solution f(theta) as a PiecewiseLinear function.");
29  params.addClassDescription(
30  "Function which computes the exact solution for Jeffery-Hamel flow in a wedge.");
31  return params;
32 }
33 
34 WedgeFunction::WedgeFunction(const InputParameters & parameters)
35  : Function(parameters),
36  FunctionInterface(this),
37  _alpha_radians(libMesh::pi * (getParam<Real>("alpha_degrees") / 180.)),
38  _Re(getParam<Real>("Re")),
39  _var_num(getParam<unsigned int>("var_num")),
40  _mu(getParam<Real>("mu")),
41  _rho(getParam<Real>("rho")),
42  _nu(_mu / _rho),
43  _K(getParam<Real>("K")),
44  _lambda(_Re * _nu / _alpha_radians),
45  _p_star(-2 * _mu * _lambda * (1 + _K)),
46  _f(getFunction("f"))
47 {
48 }
49 
50 Real
51 WedgeFunction::value(Real /*t*/, const Point & p)
52 {
53  const Real r = std::sqrt(p(0) * p(0) + p(1) * p(1));
54  const Real theta = std::atan2(p(1), p(0));
55 
56  // This is really unlikely to happen unless someone does something
57  // very strange with their mesh.
58  mooseAssert(r != 0., "The exact solution is singular at r=0.");
59 
60  // The "f" function is defined in terms of eta=theta/alpha, and it
61  // is only defined for positive angles, since it is symmetric about
62  // 0.
63  const Real eta = std::abs(theta) / _alpha_radians;
64 
65  // We pass "eta" to the PiecewiseLinear function in place of "time",
66  // plus a dummy Point which is not used.
67  const Real f_value = _f.value(eta, Point(0., 0., 0.));
68 
69  // Vars 0 and 1 are the velocities.
70  if (_var_num < 2)
71  {
72  // Converts the radial velocity vector to x and y components, respectively.
73  const Real cs[2] = {std::cos(theta), std::sin(theta)};
74 
75  // Compute the centerline velocity for this r.
76  const Real u_max = _lambda / r;
77 
78  // The true velocity value is simply u_max * f, times either
79  // cos(theta) or sin(theta) to convert it to Cartesian coordinates.
80  return u_max * f_value * cs[_var_num];
81  }
82 
83  // Otherwise, we are computing the pressure.
84  else
85  return _p_star + (2 * _mu * _lambda) / (r * r) * (f_value + _K);
86 }
Function & _f
The pre-computed semi-analytic exact solution f(theta) as a PiecewiseLinear function.
Definition: WedgeFunction.h:87
virtual Real value(Real t, const Point &p) override
Definition: WedgeFunction.C:51
const Real _alpha_radians
The half-angle of the wedge, stored in radians.
Definition: WedgeFunction.h:38
const Real _p_star
The pressure constant, whose value is determined from the pressure pin.
Definition: WedgeFunction.h:81
InputParameters validParams< WedgeFunction >()
Definition: WedgeFunction.C:12
const Real _lambda
The quantity u_max(r) * r, which is constant for this problem, and can be computed given the Reynolds...
Definition: WedgeFunction.h:73
const Real _K
The constant K from the Jeffery-Hamel solution, defined by: K = -f - 1/(4 * alpha^2) * (alpha * Re * ...
Definition: WedgeFunction.h:65
const Real _mu
The (constant) dynamic viscosity of the fluid. Usually specified in [GlobalParams].
Definition: WedgeFunction.h:50
WedgeFunction(const InputParameters &parameters)
Definition: WedgeFunction.C:34
const unsigned int _var_num
The variable (vel_x==0, vel_y==1, p==2) being computed by this instance of WedgeFunction.
Definition: WedgeFunction.h:47