https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WedgeFunction.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 "WedgeFunction.h"
11
12registerMooseObject("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.");
33 "Function which computes the exact solution for Jeffery-Hamel flow in a wedge.");
34 return params;
35}
36
38 : Function(parameters),
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
53Real
54WedgeFunction::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}
const Real p
Point eta
registerMooseObject("NavierStokesTestApp", WedgeFunction)
void ErrorVector unsigned int
static InputParameters validParams()
virtual Real value(Real t, const Point &p) const
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const Point & _point_zero
Function object for tests/ins/jeffery_hamel responsible for setting the exact value of the velocity a...
WedgeFunction(const InputParameters &parameters)
const Real _alpha_radians
The half-angle of the wedge, stored in radians.
const Real _mu
The (constant) dynamic viscosity of the fluid. Usually specified in [GlobalParams].
virtual Real value(Real t, const Point &p) const override
static InputParameters validParams()
const unsigned int _var_num
The variable (vel_x==0, vel_y==1, p==2) being computed by this instance of WedgeFunction.
const Real _p_star
The pressure constant, whose value is determined from the pressure pin.
const Real _K
The constant K from the Jeffery-Hamel solution, defined by: K = -f - 1/(4 * alpha^2) * (alpha * Re * ...
const Real _lambda
The quantity u_max(r) * r, which is constant for this problem, and can be computed given the Reynolds...
const Function & _f
The pre-computed semi-analytic exact solution f(theta) as a PiecewiseLinear function.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...