https://mooseframework.inl.gov
ConvectedMeshPSPG.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 "ConvectedMeshPSPG.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  return params;
25 }
26 
28  : INSBase(parameters),
29  _disp_x_dot(coupledDot("disp_x")),
30  _d_disp_x_dot(coupledDotDu("disp_x")),
31  _disp_x_id(coupled("disp_x")),
32  _disp_y_dot(isCoupled("disp_y") ? coupledDot("disp_y") : _zero),
33  _d_disp_y_dot(isCoupled("disp_y") ? coupledDotDu("disp_y") : _zero),
34  _disp_y_id(coupled("disp_y")),
35  _disp_z_dot(isCoupled("disp_z") ? coupledDot("disp_z") : _zero),
36  _d_disp_z_dot(isCoupled("disp_z") ? coupledDotDu("disp_z") : _zero),
37  _disp_z_id(coupled("disp_z")),
38  _rho(getMaterialProperty<Real>("rho_name"))
39 {
40 }
41 
44 {
45  const auto minus_rho_ddisp_dt =
47  return RealVectorValue(minus_rho_ddisp_dt * _grad_u_vel[_qp],
48  minus_rho_ddisp_dt * _grad_v_vel[_qp],
49  minus_rho_ddisp_dt * _grad_w_vel[_qp]);
50 }
51 
54 {
55  const auto & ddisp_dot = [&]() -> const VariableValue &
56  {
57  switch (component)
58  {
59  case 0:
60  return _d_disp_x_dot;
61  case 1:
62  return _d_disp_y_dot;
63  case 2:
64  return _d_disp_z_dot;
65  default:
66  mooseError("Invalid component");
67  }
68  }();
69 
70  // Only non-zero component will be from 'component'
71  RealVectorValue ddisp_dt;
72  ddisp_dt(component) = _phi[_j][_qp] * ddisp_dot[_qp];
73 
74  const auto minus_rho_ddisp_dt = -_rho[_qp] * ddisp_dt;
75  return RealVectorValue(minus_rho_ddisp_dt * _grad_u_vel[_qp],
76  minus_rho_ddisp_dt * _grad_v_vel[_qp],
77  minus_rho_ddisp_dt * _grad_w_vel[_qp]);
78 }
79 
82 {
83  const auto minus_rho_ddisp_dt =
85 
86  // Only non-zero component will be from 'component'
87  RealVectorValue ret;
88  ret(component) = minus_rho_ddisp_dt * _grad_phi[_j][_qp];
89  return ret;
90 }
91 
92 Real
94 {
95  return -tau() / _rho[_qp] * _grad_test[_i][_qp] * strongResidual();
96 }
97 
98 Real
100 {
101  // No derivative with respect to pressure
102  return 0;
103 }
104 
105 Real
107 {
108  mooseAssert(jvar != _var.number(), "Making sure I understand how old hand-coded Jacobians work.");
109 
110  if (jvar == _disp_x_id)
111  return -tau() / _rho[_qp] * _grad_test[_i][_qp] * dStrongResidualDDisp(0);
112  else if (jvar == _disp_y_id)
113  return -tau() / _rho[_qp] * _grad_test[_i][_qp] * dStrongResidualDDisp(1);
114  else if (jvar == _disp_z_id)
115  return -tau() / _rho[_qp] * _grad_test[_i][_qp] * dStrongResidualDDisp(2);
116  else if (jvar == _u_vel_var_number)
117  return -dTauDUComp(0) / _rho[_qp] * _grad_test[_i][_qp] * strongResidual() -
119  else if (jvar == _v_vel_var_number)
120  return -dTauDUComp(1) / _rho[_qp] * _grad_test[_i][_qp] * strongResidual() -
122  else if (jvar == _w_vel_var_number)
123  return -dTauDUComp(2) / _rho[_qp] * _grad_test[_i][_qp] * strongResidual() -
125  else
126  return 0.0;
127 }
virtual Real tau()
Definition: INSBase.C:321
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
const unsigned int _disp_z_id
static InputParameters validParams()
Definition: INSBase.C:15
virtual Real computeQpResidual() override
static const std::string component
Definition: NS.h:153
const VariablePhiGradient & _grad_phi
const VariableValue & _disp_z_dot
RealVectorValue strongResidual()
Compute the strong residual, e.g.
registerMooseObject("FsiApp", ConvectedMeshPSPG)
virtual Real dTauDUComp(unsigned comp)
Definition: INSBase.C:349
virtual Real computeQpJacobian() override
const VariableGradient & _grad_v_vel
Definition: INSBase.h:105
const VariableValue & _disp_x_dot
const VariableValue & _d_disp_x_dot
unsigned _w_vel_var_number
Definition: INSBase.h:127
static InputParameters validParams()
const VariableGradient & _grad_u_vel
Definition: INSBase.h:104
const VariableValue & _d_disp_y_dot
unsigned int _i
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
OutputTools< Real >::VariableValue VariableValue
unsigned int _j
unsigned _u_vel_var_number
Definition: INSBase.h:125
Computes residual and Jacobian contributions for the PSPG stabilization term for mesh advection...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableGradient & _grad_w_vel
Definition: INSBase.h:106
const VariableTestGradient & _grad_test
const unsigned int _disp_y_id
RealVectorValue dStrongResidualDDisp(unsigned short component)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
unsigned _v_vel_var_number
Definition: INSBase.h:126
const MaterialProperty< Real > & _rho
ConvectedMeshPSPG(const InputParameters &parameters)
RealVectorValue dStrongResidualDVel(unsigned short component)
const VariablePhiValue & _phi
const VariableValue & _d_disp_z_dot
const VariableValue & _disp_y_dot
unsigned int _qp
const unsigned int _disp_x_id