https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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
35void
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}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
registerMooseObject("NavierStokesApp", WCNSFVMomentumTimeDerivative)
Real elementVolume(const Elem *elem) const
MooseVariableFV< Real > & _var
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
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.
All navier-stokes momentum time derivative terms should inherit from this class.
static InputParameters validParams()
void addResidualAndJacobian(const ADReal &residual, dof_id_type dof)
Process into either the system residual or Jacobian.
const bool _contribute_to_rc_coeffs
Whether to contribute to RC coefficients.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
unsigned int number() const
DotType dot(const ElemArg &elem, const StateArg &state) 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
Computes the momentum time derivative for the weakly compressible formulation of the momentum equatio...
void gatherRCData(const Elem &) override
Should be a non-empty implementation if the residual object is a FVElementalKernel and introduces res...
const Moose::Functor< ADReal > & _rho_dot
The time derivative of density.
WCNSFVMomentumTimeDerivative(const InputParameters &params)
const Moose::Functor< ADReal > & _rho
The density.
static const std::string density
Definition NS.h:34
std::string time_deriv(const std::string &var)
Definition NS.h:98