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 "INSFVScalarFieldAdvection.h" 11 : 12 : registerMooseObject("NavierStokesApp", INSFVScalarFieldAdvection); 13 : 14 : InputParameters 15 1680 : INSFVScalarFieldAdvection::validParams() 16 : { 17 1680 : auto params = INSFVAdvectionKernel::validParams(); 18 1680 : params.addClassDescription("Advects an arbitrary quantity, the associated nonlinear 'variable'."); 19 3360 : params.addParam<MooseFunctorName>("u_slip", "The velocity in the x direction."); 20 3360 : params.addParam<MooseFunctorName>("v_slip", "The velocity in the y direction."); 21 3360 : params.addParam<MooseFunctorName>("w_slip", "The velocity in the z direction."); 22 1680 : return params; 23 0 : } 24 : 25 959 : INSFVScalarFieldAdvection::INSFVScalarFieldAdvection(const InputParameters & params) 26 : : INSFVAdvectionKernel(params), 27 959 : _dim(_subproblem.mesh().dimension()), 28 2254 : _u_slip(isParamValid("u_slip") ? &getFunctor<ADReal>("u_slip") : nullptr), 29 2254 : _v_slip(isParamValid("v_slip") ? &getFunctor<ADReal>("v_slip") : nullptr), 30 1918 : _w_slip(isParamValid("w_slip") ? &getFunctor<ADReal>("w_slip") : nullptr), 31 2877 : _add_slip_model(isParamValid("u_slip") ? true : false) 32 : { 33 959 : if (_add_slip_model) 34 : { 35 168 : if (_dim >= 2 && !_v_slip) 36 0 : mooseError( 37 : "In two or more dimensions, the v_slip velocity must be supplied using the 'v_slip' " 38 : "parameter"); 39 168 : if (_dim >= 3 && !_w_slip) 40 0 : mooseError( 41 : "In three dimensions, the w_slip velocity must be supplied using the 'w_slip' parameter"); 42 : } 43 959 : } 44 : 45 : ADReal 46 3721748 : INSFVScalarFieldAdvection::computeQpResidual() 47 : { 48 3721748 : const auto state = determineState(); 49 3721748 : const auto & limiter_time = _subproblem.isTransient() 50 3721748 : ? Moose::StateArg(1, Moose::SolutionIterationType::Time) 51 : : Moose::StateArg(1, Moose::SolutionIterationType::Nonlinear); 52 : 53 : ADRealVectorValue advection_velocity; 54 3721748 : if (_add_slip_model) 55 : { 56 : 57 : Moose::FaceArg face_arg; 58 947021 : if (onBoundary(*_face_info)) 59 18342 : face_arg = singleSidedFaceArg(); 60 : else 61 928679 : face_arg = Moose::FaceArg{_face_info, 62 : Moose::FV::LimiterType::CentralDifference, 63 : true, 64 : false, 65 : nullptr, 66 : &limiter_time}; 67 : 68 : ADRealVectorValue velocity_slip_vel_vec; 69 947021 : if (_dim >= 1) 70 947021 : velocity_slip_vel_vec(0) = (*_u_slip)(face_arg, state); 71 947021 : if (_dim >= 2) 72 947021 : velocity_slip_vel_vec(1) = (*_v_slip)(face_arg, state); 73 947021 : if (_dim >= 3) 74 0 : velocity_slip_vel_vec(2) = (*_w_slip)(face_arg, state); 75 : advection_velocity += velocity_slip_vel_vec; 76 : } 77 : 78 3721748 : const auto v = velocity(); 79 : advection_velocity += v; 80 3721748 : const auto var_face = _var(makeFace(*_face_info, 81 : limiterType(_advected_interp_method), 82 3721748 : MetaPhysicL::raw_value(v) * _normal > 0, 83 : false, 84 : &limiter_time), 85 7443496 : state); 86 : 87 3721748 : return _normal * advection_velocity * var_face; 88 : }