https://mooseframework.inl.gov
ConvectedMesh.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 "ConvectedMesh.h"
11 
13 
16 {
18  params.addClassDescription(
19  "Corrects the convective derivative for situations in which the fluid mesh is dynamic.");
20  params.addRequiredCoupledVar("disp_x", "The x displacement");
21  params.addCoupledVar("disp_y", "The y displacement");
22  params.addCoupledVar("disp_z", "The z displacement");
23  params.addParam<MaterialPropertyName>("rho_name", "rho", "The name of the density");
24  params.addParam<bool>(
25  "supg", false, "Whether to perform SUPG stabilization of the momentum residuals");
26  return params;
27 }
28 
30  : INSBase(parameters),
31  _disp_x_dot(coupledDot("disp_x")),
32  _d_disp_x_dot(coupledDotDu("disp_x")),
33  _disp_x_id(coupled("disp_x")),
34  _disp_y_dot(isCoupled("disp_y") ? coupledDot("disp_y") : _zero),
35  _d_disp_y_dot(isCoupled("disp_y") ? coupledDotDu("disp_y") : _zero),
36  _disp_y_id(coupled("disp_y")),
37  _disp_z_dot(isCoupled("disp_z") ? coupledDot("disp_z") : _zero),
38  _d_disp_z_dot(isCoupled("disp_z") ? coupledDotDu("disp_z") : _zero),
39  _disp_z_id(coupled("disp_z")),
40  _rho(getMaterialProperty<Real>("rho_name")),
41  _supg(getParam<bool>("supg"))
42 {
43  if (_var.number() == _u_vel_var_number)
44  _component = 0;
45  else if (_var.number() == _v_vel_var_number)
46  _component = 1;
47  else if (_var.number() == _w_vel_var_number)
48  _component = 2;
49  else
50  paramError("variable", "The variable must match one of the velocity variables.");
51 }
52 
53 Real
55 {
57  _grad_u[_qp];
58 }
59 
60 Real
62 {
63  auto test = _test[_i][_qp];
64  const auto U = relativeVelocity();
65  if (_supg)
66  test += tau() * _grad_test[_i][_qp] * U;
67  return test * strongResidual();
68 }
69 
70 Real
72 {
73  const auto U = relativeVelocity();
74  return strongResidual() * ((dTauDUComp(component) * _grad_test[_i][_qp] * U) +
75  (tau() * _grad_test[_i][_qp](component) * _phi[_j][_qp]));
76 }
77 
78 Real
80 {
81  auto test = _test[_i][_qp];
82  const auto U = relativeVelocity();
83  if (_supg)
84  test += tau() * _grad_test[_i][_qp] * U;
85  auto jac = test * -_rho[_qp] *
87  _grad_phi[_j][_qp];
88  if (_supg)
90 
91  return jac;
92 }
93 
94 Real
96 {
97  mooseAssert(jvar != _var.number(), "Making sure I understand how old hand-coded Jacobians work.");
98 
99  auto test = _test[_i][_qp];
100  const auto U = relativeVelocity();
101  if (_supg)
102  test += tau() * _grad_test[_i][_qp] * U;
103 
104  if (jvar == _disp_x_id)
105  return test * -_rho[_qp] * _phi[_j][_qp] * _d_disp_x_dot[_qp] * _grad_u[_qp](0);
106  else if (jvar == _disp_y_id)
107  return test * -_rho[_qp] * _phi[_j][_qp] * _d_disp_y_dot[_qp] * _grad_u[_qp](1);
108  else if (jvar == _disp_z_id)
109  return test * -_rho[_qp] * _phi[_j][_qp] * _d_disp_z_dot[_qp] * _grad_u[_qp](2);
110  else if (jvar == _u_vel_var_number)
111  {
112  if (_supg)
113  return computePGVelocityJacobian(0);
114  else
115  return 0;
116  }
117  else if (jvar == _v_vel_var_number)
118  {
119  if (_supg)
120  return computePGVelocityJacobian(1);
121  else
122  return 0;
123  }
124  else if (jvar == _w_vel_var_number)
125  {
126  if (_supg)
127  return computePGVelocityJacobian(2);
128  else
129  return 0;
130  }
131  else
132  return 0.0;
133 }
const VariableValue & _disp_z_dot
Definition: ConvectedMesh.h:46
const unsigned int _disp_y_id
Definition: ConvectedMesh.h:45
const VariableGradient & _grad_u
virtual Real tau()
Definition: INSBase.C:321
virtual Real computeQpResidual() override
Definition: ConvectedMesh.C:61
MooseVariable & _var
This class computes strong and weak components of the INS governing equations.
Definition: INSBase.h:18
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int number() const
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: ConvectedMesh.C:95
static InputParameters validParams()
Definition: INSBase.C:15
static const std::string component
Definition: NS.h:153
const VariablePhiGradient & _grad_phi
RealVectorValue relativeVelocity() const
Compute the velocity.
Definition: INSBase.C:120
virtual Real computeQpJacobian() override
Definition: ConvectedMesh.C:79
virtual Real dTauDUComp(unsigned comp)
Definition: INSBase.C:349
ConvectedMesh(const InputParameters &parameters)
Definition: ConvectedMesh.C:29
Real strongResidual()
Compute the strong residual, e.g.
Definition: ConvectedMesh.C:54
const unsigned int _disp_x_id
Definition: ConvectedMesh.h:42
const bool _supg
Whether this kernel should include Streamline-Upwind Petrov-Galerkin stabilization.
Definition: ConvectedMesh.h:53
Real computePGVelocityJacobian(unsigned short component)
Compute the Jacobian of the Petrov-Galerkin stabilization addition with respect to the provided veloc...
Definition: ConvectedMesh.C:71
const unsigned int _disp_z_id
Definition: ConvectedMesh.h:48
const VariableValue & _disp_x_dot
Definition: ConvectedMesh.h:40
static InputParameters validParams()
Definition: ConvectedMesh.C:15
const VariableValue & _d_disp_y_dot
Definition: ConvectedMesh.h:44
unsigned _w_vel_var_number
Definition: INSBase.h:127
const VariableValue & _d_disp_z_dot
Definition: ConvectedMesh.h:47
const VariableTestValue & _test
const VariableValue & _d_disp_x_dot
Definition: ConvectedMesh.h:41
unsigned short _component
The velocity component this kernel is acting on.
Definition: ConvectedMesh.h:56
unsigned int _i
registerMooseObject("FsiApp", ConvectedMesh)
void paramError(const std::string &param, Args... args) const
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
unsigned _u_vel_var_number
Definition: INSBase.h:125
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableTestGradient & _grad_test
const MaterialProperty< Real > & _rho
Definition: ConvectedMesh.h:50
void addClassDescription(const std::string &doc_string)
unsigned _v_vel_var_number
Definition: INSBase.h:126
const VariableValue & _disp_y_dot
Definition: ConvectedMesh.h:43
const VariablePhiValue & _phi
unsigned int _qp
This calculates the time derivative for a coupled variable.
Definition: ConvectedMesh.h:17