https://mooseframework.inl.gov
WCNSFVMomentumTimeDerivative.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 #include "SystemBase.h"
12 #include "NS.h"
13 
15 
18 {
20  params.addClassDescription(
21  "Adds the time derivative term to the incompressible Navier-Stokes momentum equation.");
22  params.addRequiredParam<MooseFunctorName>(NS::density, "The density material property");
23  params.addRequiredParam<MooseFunctorName>(NS::time_deriv(NS::density),
24  "The time derivative of the density material property");
25  return params;
26 }
27 
29  : INSFVTimeKernel(params),
30  _rho(getFunctor<ADReal>(NS::density)),
31  _rho_dot(getFunctor<ADReal>(NS::time_deriv(NS::density)))
32 {
33 }
34 
35 void
37 {
38  // _rho and _rho_dot could ultimately be functions of the nonlinear variables making our residual
39  // nonlinear so we cannot do the simple treatment that is done in
40  // INSFVMomentumTimeDerivative::gatherRCData
41 
42  const auto elem_arg = makeElemArg(&elem);
43  const auto state = determineState();
44  const auto rho_dot = _rho_dot(elem_arg, state);
45  const auto var_dot = _var.dot(elem_arg, state);
46  const auto rho = _rho(elem_arg, state);
47  const auto var = _var(elem_arg, state);
48 
49  const auto dof_number = elem.dof_number(_sys.number(), _var.number(), 0);
50  mooseAssert(var.derivatives()[dof_number] == 1.,
51  "This is an implicit assumption in our coefficient calculation.");
52 
53  const auto strong_resid = rho_dot * var + rho * var_dot;
54 
55  // For the first term in the above strong residual we know that var.derivatives()[dof_number] = 1
56  // so there is no need to explicitly index here
57  ADReal a = rho_dot;
58  // but there is a need here
59  a += rho * var_dot.derivatives()[dof_number];
60 
61  const auto volume = _assembly.elementVolume(&elem);
63  _rc_uo.addToA(&elem, _index, a * volume);
64  addResidualAndJacobian(strong_resid * volume, dof_number);
65 }
void addResidualAndJacobian(const ADReal &residual, dof_id_type dof)
Process into either the system residual or Jacobian.
void gatherRCData(const Elem &) override
Should be a non-empty implementation if the residual object is a FVElementalKernel and introduces res...
unsigned int number() const
Computes the momentum time derivative for the weakly compressible formulation of the momentum equatio...
Moose::StateArg determineState() const
const bool _contribute_to_rc_coeffs
Whether to contribute to RC coefficients.
const unsigned int _index
index x|y|z
static const std::string density
Definition: NS.h:33
const Moose::Functor< ADReal > & _rho
The density.
All navier-stokes momentum time derivative terms should inherit from this class.
static InputParameters validParams()
const Moose::Functor< ADReal > & _rho_dot
The time derivative of density.
void addRequiredParam(const std::string &name, const std::string &doc_string)
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms...
SystemBase & _sys
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
Real elementVolume(const Elem *elem) const
WCNSFVMomentumTimeDerivative(const InputParameters &params)
unsigned int number() const
registerMooseObject("NavierStokesApp", WCNSFVMomentumTimeDerivative)
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
Assembly & _assembly
DotType dot(const ElemArg &elem, const StateArg &state) const
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.
void addClassDescription(const std::string &doc_string)
MooseVariableFV< Real > & _var
std::string time_deriv(const std::string &var)
Definition: NS.h:97