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