https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSFVMomentumViscousSourceRZ.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
11
12#include "NS.h"
13#include "SystemBase.h"
14
16
19{
21 params.addClassDescription("Adds the -\\mu u_r / r^2 viscous source term (sign for RHS) that "
22 "appears in the cylindrical form of the "
23 "Navier-Stokes momentum equations (axisymmetric, no swirl).");
24 params.addRequiredParam<MooseFunctorName>(
25 NS::mu, "The dynamic viscosity that multiplies the viscous source term.");
26 params.addParam<bool>("complete_expansion",
27 false,
28 "Mirror of the INSFVMomentumDiffusion 'complete_expansion' switch. When "
29 "true, the viscous contribution is multiplied by 2.");
30 return params;
31}
32
34 : INSFVElementalKernel(params),
35 _mu(getFunctor<ADReal>(NS::mu)),
36 _rz_radial_coord(_subproblem.getAxisymmetricRadialCoord()),
37 _expansion_multiplier(getParam<bool>("complete_expansion") ? 2.0 : 1.0)
38{
40 mooseError(name(), " is only valid on blocks that use an RZ coordinate system.");
41
43 paramError("momentum_component",
44 "INSFVMomentumViscousSourceRZ only applies to the radial momentum component in an "
45 "axisymmetric coordinate system.");
46}
47
50 const Moose::StateArg & state) const
51{
52 mooseAssert(elem_arg.elem, "The element pointer must be valid for INSFVMomentumViscousSourceRZ.");
53 const auto radius = elem_arg.elem->vertex_average()(_rz_radial_coord);
54 mooseAssert(radius > 0.0, "Axisymmetric radial coordinate should be positive inside a cell.");
55 return _expansion_multiplier * _mu(elem_arg, state) / (radius * radius);
56}
57
60{
61 const auto elem_arg = makeElemArg(_current_elem);
62 const auto state = determineState();
63 return computeCoefficient(elem_arg, state) * _u_functor(elem_arg, state);
64}
65
66void
68{
69 const auto elem_arg = makeElemArg(&elem);
70 const auto state = determineState();
71 const auto coefficient = computeCoefficient(elem_arg, state);
72 const auto volume_coefficient = coefficient * _assembly.elementVolume(&elem);
73 _rc_uo.addToA(&elem, _index, volume_coefficient);
74
75 const auto dof_number = elem.dof_number(_sys.number(), _var.number(), 0);
76 addResidualAndJacobian(volume_coefficient * _u_functor(elem_arg, state), dof_number);
77}
DualNumber< Real, DNDerivativeType, true > ADReal
const double mu
registerMooseObject("NavierStokesApp", INSFVMomentumViscousSourceRZ)
Real elementVolume(const Elem *elem) const
Moose::CoordinateSystemType getBlockCoordSystem()
MooseVariableFV< Real > & _var
const Moose::Functor< ADReal > & _u_functor
const Elem *const & _current_elem
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
An elemental kernel that momentum residual objects that add body forces should inherit from.
static InputParameters validParams()
void addResidualAndJacobian(const ADReal &residual, dof_id_type dof)
Process into either the system residual or Jacobian.
const unsigned int _index
index x|y|z
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms.
Adds the axisymmetric viscous source term (-mu * u_r / r^2) that appears in the Laplacian of the radi...
void gatherRCData(const Elem &) override
Should be a non-empty implementation if the residual object is a FVElementalKernel and introduces res...
ADReal computeSegregatedContribution() override
Compute the contribution which goes into the residual of the segregated system.
ADReal computeCoefficient(const Moose::ElemArg &elem_arg, const Moose::StateArg &state) const
Compute the diagonal multiplier for this dof.
const unsigned int _rz_radial_coord
Index of the radial coordinate in an RZ system.
INSFVMomentumViscousSourceRZ(const InputParameters &params)
const Real _expansion_multiplier
Multiplier applied when the complete expansion form is requested.
const Moose::Functor< ADReal > & _mu
Viscosity functor.
void addRequiredParam(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)
const std::string & name() const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
unsigned int number() const
Assembly & _assembly
SystemBase & _sys
virtual void addToA(const libMesh::Elem *elem, unsigned int component, const ADReal &value)=0
API for momentum residual objects that have on-diagonals for velocity call.
unsigned int number() const
Moose::StateArg determineState() const
Point vertex_average() const
static const std::string mu
Definition NS.h:127
const libMesh::Elem * elem
const Real radius