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 "LinearFVAdvectionDiffusionFunctorNeumannBC.h" 11 : 12 : registerMooseObject("MooseApp", LinearFVAdvectionDiffusionFunctorNeumannBC); 13 : 14 : InputParameters 15 3317 : LinearFVAdvectionDiffusionFunctorNeumannBC::validParams() 16 : { 17 3317 : InputParameters params = LinearFVAdvectionDiffusionBC::validParams(); 18 6634 : params.addClassDescription( 19 : "Adds a fixed diffusive flux BC which can be used for the assembly of linear " 20 : "finite volume system and whose normal face gradient values are determined " 21 : "using a functor. This kernel is only designed to work with advection-diffusion problems."); 22 13268 : params.addRequiredParam<MooseFunctorName>( 23 : "functor", "The diffusive flux functor for this boundary condition."); 24 9951 : params.addParam<MooseFunctorName>("diffusion_coeff", 1.0, "The diffusion coefficient."); 25 3317 : return params; 26 0 : } 27 : 28 114 : LinearFVAdvectionDiffusionFunctorNeumannBC::LinearFVAdvectionDiffusionFunctorNeumannBC( 29 114 : const InputParameters & parameters) 30 : : LinearFVAdvectionDiffusionBC(parameters), 31 114 : _functor(getFunctor<Real>("functor")), 32 342 : _diffusion_coeff(getFunctor<Real>("diffusion_coeff")) 33 : { 34 114 : _var.computeCellGradients(); 35 114 : } 36 : 37 : Real 38 9012 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValue() const 39 : { 40 9012 : const auto state = determineState(); 41 9012 : const auto face_arg = makeCDFace(*_current_face_info); 42 9012 : const auto elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM 43 9012 : ? _current_face_info->elemInfo() 44 0 : : _current_face_info->neighborInfo(); 45 9012 : const Real distance = computeCellToFaceDistance(); 46 9012 : const auto d_cf = computeCellToFaceVector(); 47 : // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy 48 : // correction_vector is a vector orthogonal to the boundary normal 49 : const auto correction_vector = 50 9012 : (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal()); 51 9012 : return _var.getElemValue(*elem_info, state) + 52 9012 : _functor(singleSidedFaceArg(_current_face_info), state) / 53 9012 : _diffusion_coeff(face_arg, state) * distance + 54 9012 : _var.gradSln(*elem_info, state) * correction_vector; 55 : } 56 : 57 : Real 58 0 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryNormalGradient() const 59 : { 60 0 : const auto state = determineState(); 61 0 : const auto face_arg = makeCDFace(*_current_face_info); 62 0 : return _functor(singleSidedFaceArg(_current_face_info), state) / 63 0 : _diffusion_coeff(face_arg, state); 64 : } 65 : 66 : Real 67 396 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueMatrixContribution() const 68 : { 69 396 : return 1.0; 70 : } 71 : 72 : Real 73 396 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryValueRHSContribution() const 74 : { 75 396 : const auto state = determineState(); 76 396 : const auto face_arg = makeCDFace(*_current_face_info); 77 396 : const auto elem_info = _current_face_type == FaceInfo::VarFaceNeighbors::ELEM 78 396 : ? _current_face_info->elemInfo() 79 0 : : _current_face_info->neighborInfo(); 80 : 81 : // Fetch the boundary value from the provided functor. 82 396 : const Real distance = computeCellToFaceDistance(); 83 396 : const auto d_cf = computeCellToFaceVector(); 84 : // For non-orthogonal meshes we compute an extra correction vector to increase order accuracy 85 : // correction_vector is a vector orthogonal to the boundary normal 86 : const auto correction_vector = 87 396 : (d_cf - (d_cf * _current_face_info->normal()) * _current_face_info->normal()); 88 396 : return _functor(singleSidedFaceArg(_current_face_info), state) / 89 396 : _diffusion_coeff(face_arg, state) * distance + 90 396 : _var.gradSln(*elem_info, state) * correction_vector; 91 : } 92 : 93 : Real 94 4506 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientMatrixContribution() const 95 : { 96 4506 : return 0.0; 97 : } 98 : 99 : Real 100 4506 : LinearFVAdvectionDiffusionFunctorNeumannBC::computeBoundaryGradientRHSContribution() const 101 : { 102 4506 : return _functor(singleSidedFaceArg(_current_face_info), determineState()); 103 : }