Line data Source code
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 "INSFVMeshAdvection.h" 11 : #include "NS.h" 12 : 13 : registerMooseObject("NavierStokesApp", INSFVMeshAdvection); 14 : 15 : InputParameters 16 225 : INSFVMeshAdvection::validParams() 17 : { 18 225 : InputParameters params = FVElementalKernel::validParams(); 19 225 : params.addClassDescription( 20 : "Implements a source/sink term for this object's variable/advected-quantity " 21 : "proportional to the divergence of the mesh velocity"); 22 225 : params.addRequiredParam<MooseFunctorName>(NS::density, "The density. This should be constant"); 23 450 : params.addRequiredParam<MooseFunctorName>("disp_x", "The x-displacement"); 24 450 : params.addParam<MooseFunctorName>("disp_y", 0, "The y-displacement"); 25 450 : params.addParam<MooseFunctorName>("disp_z", 0, "The z-displacement"); 26 450 : params.addParam<MooseFunctorName>( 27 : "advected_quantity", 28 : "An optional parameter for a functor describing the advected quantity. If this is not " 29 : "provided, then the 'variable' will be used"); 30 225 : return params; 31 0 : } 32 : 33 114 : INSFVMeshAdvection::INSFVMeshAdvection(const InputParameters & parameters) 34 : : FVElementalKernel(parameters), 35 228 : _rho(getFunctor<ADReal>(NS::density)), 36 228 : _disp_x(getFunctor<ADReal>("disp_x")), 37 228 : _disp_y(getFunctor<ADReal>("disp_y")), 38 228 : _disp_z(getFunctor<ADReal>("disp_z")), 39 238 : _adv_quant(isParamValid("advected_quantity") ? static_cast<const Moose::FunctorBase<ADReal> &>( 40 134 : getFunctor<ADReal>("advected_quantity")) 41 218 : : static_cast<Moose::FunctorBase<ADReal> &>(_var)) 42 : { 43 114 : } 44 : 45 : ADReal 46 40584 : INSFVMeshAdvection::advQuantCoeff(const Moose::ElemArg & elem_arg, 47 : const Moose::StateArg & state) const 48 : { 49 40584 : const auto div_mesh_velocity = _disp_x.gradDot(elem_arg, state)(0) + 50 40584 : _disp_y.gradDot(elem_arg, state)(1) + 51 40584 : _disp_z.gradDot(elem_arg, state)(2); 52 40584 : return _rho(elem_arg, state) * div_mesh_velocity; 53 : } 54 : 55 : ADReal 56 32262 : INSFVMeshAdvection::computeQpResidual() 57 : { 58 32262 : const auto elem_arg = makeElemArg(_current_elem); 59 32262 : const auto state = determineState(); 60 32262 : return advQuantCoeff(elem_arg, state) * _adv_quant(elem_arg, state); 61 : }