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 "FVDiffusion.h" 11 : 12 : registerMooseObject("MooseApp", FVDiffusion); 13 : 14 : InputParameters 15 35419 : FVDiffusion::validParams() 16 : { 17 35419 : InputParameters params = FVFluxKernel::validParams(); 18 35419 : params += FVDiffusionInterpolationInterface::validParams(); 19 35419 : params.addClassDescription("Computes residual for diffusion operator for finite volume method."); 20 35419 : params.addRequiredParam<MooseFunctorName>("coeff", "diffusion coefficient"); 21 35419 : MooseEnum coeff_interp_method("average harmonic", "harmonic"); 22 35419 : params.addParam<MooseEnum>( 23 : "coeff_interp_method", 24 : coeff_interp_method, 25 : "Switch that can select face interpolation method for diffusion coefficients."); 26 : 27 : // We need at least 2 layers here with the least accurate interpolation 28 35419 : params.set<unsigned short>("ghost_layers") = 2; 29 : 30 : // We add the relationship manager here, this will select the right number of 31 : // ghosting layers depending on the chosen interpolation method 32 35419 : params.addRelationshipManager( 33 : "ElementSideNeighborLayers", 34 : Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC | 35 : Moose::RelationshipManagerType::COUPLING, 36 0 : [](const InputParameters & obj_params, InputParameters & rm_params) 37 9481 : { FVRelationshipManagerInterface::setRMParamsDiffusion(obj_params, rm_params, 3); }); 38 : 39 70838 : return params; 40 35419 : } 41 : 42 3380 : FVDiffusion::FVDiffusion(const InputParameters & params) 43 : : FVFluxKernel(params), 44 : FVDiffusionInterpolationInterface(params), 45 3372 : _coeff(getFunctor<ADReal>("coeff")), 46 3372 : _coeff_interp_method( 47 6752 : Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("coeff_interp_method"))) 48 : { 49 3372 : } 50 : 51 : ADReal 52 10686490 : FVDiffusion::computeQpResidual() 53 : { 54 : using namespace Moose::FV; 55 10686490 : const auto state = determineState(); 56 : 57 10686490 : auto dudn = gradUDotNormal(state, _correct_skewness); 58 10686490 : ADReal coeff; 59 : 60 : // If we are on internal faces, we interpolate the diffusivity as usual 61 10686490 : if (_var.isInternalFace(*_face_info)) 62 : { 63 10262119 : const ADReal coeff_elem = _coeff(elemArg(), state); 64 10262119 : const ADReal coeff_neighbor = _coeff(neighborArg(), state); 65 : // If the diffusion coefficients are zero, then we can early return 0 (and avoid warnings if we 66 : // have a harmonic interpolation) 67 10262119 : if (!coeff_elem.value() && !coeff_neighbor.value()) 68 0 : return 0; 69 : 70 10262119 : interpolate(_coeff_interp_method, coeff, coeff_elem, coeff_neighbor, *_face_info, true); 71 10262119 : } 72 : // Else we just use the boundary values (which depend on how the diffusion 73 : // coefficient is constructed) 74 : else 75 : { 76 424371 : const auto face = singleSidedFaceArg(); 77 424371 : coeff = _coeff(face, state); 78 : } 79 : 80 21372980 : return -1 * coeff * dudn; 81 10686490 : }