https://mooseframework.inl.gov
ADMassAdvection.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 "ADMassAdvection.h"
11 
12 registerMooseObject("NavierStokesTestApp", ADMassAdvection);
13 
16 {
18  params.addRequiredCoupledVar("vel_x", "The x-component of velocity");
19  params.addCoupledVar("vel_y", "The y-component of velocity");
20  params.addCoupledVar("vel_z", "The z-component of velocity");
21  return params;
22 }
23 
25  : ADKernel(parameters),
26  _vel_x(adCoupledValue("vel_x")),
27  _vel_y(isCoupled("vel_y") ? adCoupledValue("vel_y") : _ad_zero),
28  _vel_z(isCoupled("vel_z") ? adCoupledValue("vel_z") : _ad_zero),
29  _grad_vel_x(adCoupledGradient("vel_x")),
30  _grad_vel_y(isCoupled("vel_y") ? adCoupledGradient("vel_y") : _ad_grad_zero),
31  _grad_vel_z(isCoupled("vel_z") ? adCoupledGradient("vel_z") : _ad_grad_zero),
32  _coord_sys(_assembly.coordSystem()),
33  _rz_radial_coord(_mesh.getAxisymmetricRadialCoord())
34 {
35 }
36 
37 ADReal
39 {
40  // (div u) * q
41  // Note: we (arbitrarily) multiply this term by -1 so that it matches the -p(div v)
42  // term in the momentum equation. Not sure if that is really important?
43  auto residual =
44  -(_grad_vel_x[_qp](0) + _grad_vel_y[_qp](1) + _grad_vel_z[_qp](2)) * _test[_i][_qp];
46  // Subtract u_r / r
47  residual -=
48  [this]()
49  {
50  switch (_rz_radial_coord)
51  {
52  case 0:
53  return _vel_x[_qp];
54  case 1:
55  return _vel_y[_qp];
56  default:
57  mooseError("Unexpected radial coordinate");
58  }
59  }() /
61  return residual;
62 }
const ADVariableGradient & _grad_vel_y
virtual ADReal computeQpResidual() override
const ADTemplateVariableTestValue< T > & _test
DualNumber< Real, DNDerivativeType, true > ADReal
const ADVariableGradient & _grad_vel_z
const Moose::CoordinateSystemType & _coord_sys
const ADVariableGradient & _grad_vel_x
ADMassAdvection(const InputParameters &parameters)
const ADVariableValue & _vel_y
static InputParameters validParams()
const MooseArray< ADPoint > & _ad_q_point
unsigned int _i
static InputParameters validParams()
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const unsigned int _rz_radial_coord
void mooseError(Args &&... args) const
registerMooseObject("NavierStokesTestApp", ADMassAdvection)
const ADVariableValue & _vel_x
unsigned int _qp