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 "LinearFVAdvection.h" 11 : #include "Assembly.h" 12 : #include "SubProblem.h" 13 : #include "LinearFVAdvectionDiffusionBC.h" 14 : 15 : registerMooseObject("MooseApp", LinearFVAdvection); 16 : 17 : InputParameters 18 15427 : LinearFVAdvection::validParams() 19 : { 20 15427 : InputParameters params = LinearFVFluxKernel::validParams(); 21 15427 : params.addClassDescription("Represents the matrix and right hand side contributions of an " 22 : "advection term in a partial differential equation."); 23 15427 : params.addRequiredParam<RealVectorValue>("velocity", "Constant advection velocity"); 24 15427 : params += Moose::FV::advectedInterpolationParameter(); 25 15427 : return params; 26 0 : } 27 : 28 581 : LinearFVAdvection::LinearFVAdvection(const InputParameters & params) 29 581 : : LinearFVFluxKernel(params), _velocity(getParam<RealVectorValue>("velocity")) 30 : 31 : { 32 581 : Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method"); 33 581 : } 34 : 35 : void 36 0 : LinearFVAdvection::initialSetup() 37 : { 38 0 : for (const auto bc : _var.getBoundaryConditionMap()) 39 0 : if (!dynamic_cast<const LinearFVAdvectionDiffusionBC *>(bc.second)) 40 0 : mooseError( 41 0 : bc.second->type(), " is not a compatible boundary condition with ", this->type(), "!"); 42 0 : } 43 : 44 : Real 45 1872955 : LinearFVAdvection::computeElemMatrixContribution() 46 : { 47 1872955 : const Real face_flux = _velocity * _current_face_info->normal(); 48 : const auto interp_coeffs = 49 1872955 : interpCoeffs(_advected_interp_method, *_current_face_info, true, face_flux); 50 1872955 : return interp_coeffs.first * face_flux * _current_face_area; 51 : } 52 : 53 : Real 54 1872955 : LinearFVAdvection::computeNeighborMatrixContribution() 55 : { 56 1872955 : const Real face_flux = _velocity * _current_face_info->normal(); 57 : const auto interp_coeffs = 58 1872955 : interpCoeffs(_advected_interp_method, *_current_face_info, true, face_flux); 59 1872955 : return interp_coeffs.second * face_flux * _current_face_area; 60 : } 61 : 62 : Real 63 1872955 : LinearFVAdvection::computeElemRightHandSideContribution() 64 : { 65 1872955 : return 0.0; 66 : } 67 : 68 : Real 69 1872955 : LinearFVAdvection::computeNeighborRightHandSideContribution() 70 : { 71 1872955 : return 0.0; 72 : } 73 : 74 : Real 75 118398 : LinearFVAdvection::computeBoundaryMatrixContribution(const LinearFVBoundaryCondition & bc) 76 : { 77 118398 : const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc); 78 : mooseAssert(adv_bc, "This should be a valid BC!"); 79 : 80 118398 : const auto boundary_value_matrix_contrib = adv_bc->computeBoundaryValueMatrixContribution(); 81 : 82 : // We support internal boundaries too so we have to make sure the normal points always outward 83 118398 : const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0; 84 : 85 118398 : return boundary_value_matrix_contrib * factor * (_velocity * _current_face_info->normal()) * 86 118398 : _current_face_area; 87 : } 88 : 89 : Real 90 118398 : LinearFVAdvection::computeBoundaryRHSContribution(const LinearFVBoundaryCondition & bc) 91 : { 92 118398 : const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc); 93 : mooseAssert(adv_bc, "This should be a valid BC!"); 94 : 95 : // We support internal boundaries too so we have to make sure the normal points always outward 96 118398 : const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0); 97 : 98 118398 : const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution(); 99 118398 : return -boundary_value_rhs_contrib * factor * (_velocity * _current_face_info->normal()) * 100 118398 : _current_face_area; 101 : }