https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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{
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
53Real
55{
56 return -_rho[_qp] * RealVectorValue(_disp_x_dot[_qp], _disp_y_dot[_qp], _disp_z_dot[_qp]) *
57 _grad_u[_qp];
58}
59
60Real
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
70Real
71ConvectedMesh::computePGVelocityJacobian(const unsigned short component)
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
78Real
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] *
86 RealVectorValue(_disp_x_dot[_qp], _disp_y_dot[_qp], _disp_z_dot[_qp]) *
88 if (_supg)
90
91 return jac;
92}
93
94Real
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)
114 else
115 return 0;
116 }
117 else if (jvar == _v_vel_var_number)
118 {
119 if (_supg)
121 else
122 return 0;
123 }
124 else if (jvar == _w_vel_var_number)
125 {
126 if (_supg)
128 else
129 return 0;
130 }
131 else
132 return 0.0;
133}
registerMooseObject("FsiApp", ConvectedMesh)
This calculates the time derivative for a coupled variable.
ConvectedMesh(const InputParameters &parameters)
const VariableValue & _disp_y_dot
const bool _supg
Whether this kernel should include Streamline-Upwind Petrov-Galerkin stabilization.
unsigned short _component
The velocity component this kernel is acting on.
const unsigned int _disp_y_id
virtual Real computeQpJacobian() override
const VariableValue & _disp_x_dot
const unsigned int _disp_z_id
const unsigned int _disp_x_id
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const VariableValue & _disp_z_dot
Real strongResidual()
Compute the strong residual, e.g.
const VariableValue & _d_disp_y_dot
const MaterialProperty< Real > & _rho
virtual Real computeQpResidual() override
const VariableValue & _d_disp_x_dot
static InputParameters validParams()
Real computePGVelocityJacobian(unsigned short component)
Compute the Jacobian of the Petrov-Galerkin stabilization addition with respect to the provided veloc...
const VariableValue & _d_disp_z_dot
This class computes strong and weak components of the INS governing equations.
Definition INSBase.h:19
virtual Real tau()
Definition INSBase.C:321
unsigned _w_vel_var_number
Definition INSBase.h:127
static InputParameters validParams()
Definition INSBase.C:15
virtual Real dTauDUComp(unsigned comp)
Definition INSBase.C:349
unsigned _v_vel_var_number
Definition INSBase.h:126
unsigned _u_vel_var_number
Definition INSBase.h:125
RealVectorValue relativeVelocity() const
Compute the velocity.
Definition INSBase.C:120
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _qp
unsigned int _j
unsigned int _i
const VariableGradient & _grad_u
MooseVariable & _var
const VariablePhiValue & _phi
const VariableTestValue & _test
const VariablePhiGradient & _grad_phi
const VariableTestGradient & _grad_test
void paramError(const std::string &param, Args... args) const
unsigned int number() const