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 "FVAdvection.h" 11 : #include "Steady.h" 12 : #include "FEProblemBase.h" 13 : 14 : registerADMooseObject("MooseApp", FVAdvection); 15 : 16 : InputParameters 17 15793 : FVAdvection::validParams() 18 : { 19 15793 : InputParameters params = FVFluxKernel::validParams(); 20 15793 : params.addClassDescription( 21 : "Residual contribution from advection operator for finite volume method."); 22 15793 : params.addRequiredParam<RealVectorValue>("velocity", "Constant advection velocity"); 23 15793 : params += Moose::FV::advectedInterpolationParameter(); 24 : 25 : // We add the relationship manager here, this will select the right number of 26 : // ghosting layers depending on the chosen interpolation method 27 15793 : params.addRelationshipManager( 28 : "ElementSideNeighborLayers", 29 : Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC | 30 : Moose::RelationshipManagerType::COUPLING, 31 0 : [](const InputParameters & obj_params, InputParameters & rm_params) 32 2260 : { FVRelationshipManagerInterface::setRMParamsAdvection(obj_params, rm_params, 2); }); 33 : 34 15793 : return params; 35 0 : } 36 : 37 772 : FVAdvection::FVAdvection(const InputParameters & params) 38 772 : : FVFluxKernel(params), _velocity(getParam<RealVectorValue>("velocity")) 39 : { 40 : const bool need_more_ghosting = 41 772 : Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method"); 42 772 : if (need_more_ghosting && _tid == 0) 43 : // If we need more ghosting, then we are a second-order nonlinear limiting scheme whose stencil 44 : // is liable to change upon wind-direction change. Consequently we need to tell our problem that 45 : // it's ok to have new nonzeros which may crop-up after PETSc has shrunk the matrix memory 46 : getCheckedPointerParam<FEProblemBase *>("_fe_problem_base") 47 296 : ->setErrorOnJacobianNonzeroReallocation(false); 48 : 49 772 : if (dynamic_cast<Steady *>(_app.getExecutioner())) 50 : { 51 342 : const MooseEnum not_available_with_steady("sou min_mod vanLeer quick venkatakrishnan"); 52 : const std::string chosen_scheme = 53 342 : static_cast<std::string>(getParam<MooseEnum>("advected_interp_method")); 54 342 : if (not_available_with_steady.find(chosen_scheme) != not_available_with_steady.items().end()) 55 0 : paramError("advected_interp_method", 56 : "The given advected interpolation cannot be used with steady-state runs!"); 57 342 : } 58 772 : } 59 : 60 : ADReal 61 14246352 : FVAdvection::computeQpResidual() 62 : { 63 14246352 : const auto state = determineState(); 64 14246352 : const auto & limiter_time = _subproblem.isTransient() 65 14246352 : ? Moose::StateArg(1, Moose::SolutionIterationType::Time) 66 14246352 : : Moose::StateArg(1, Moose::SolutionIterationType::Nonlinear); 67 : 68 14246352 : const bool elem_is_upwind = _velocity * _normal >= 0; 69 14246352 : const auto face = makeFace(*_face_info, 70 : Moose::FV::limiterType(_advected_interp_method), 71 : elem_is_upwind, 72 : false, 73 : &limiter_time); 74 14246352 : ADReal u_interface = _var(face, state); 75 : 76 28492704 : return _normal * _velocity * u_interface; 77 14246352 : }