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