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 "FVAnisotropicDiffusion.h" 11 : 12 : registerMooseObject("MooseApp", FVAnisotropicDiffusion); 13 : 14 : InputParameters 15 3105 : FVAnisotropicDiffusion::validParams() 16 : { 17 3105 : InputParameters params = FVFluxKernel::validParams(); 18 3105 : params += FVDiffusionInterpolationInterface::validParams(); 19 6210 : params.addClassDescription( 20 : "Computes residual for anisotropic diffusion operator for finite volume method."); 21 12420 : params.addRequiredParam<MooseFunctorName>("coeff", 22 : "The diagonal coefficients of a diffusion tensor."); 23 12420 : MooseEnum coeff_interp_method("average harmonic", "harmonic"); 24 12420 : params.addParam<MooseEnum>( 25 : "coeff_interp_method", 26 : coeff_interp_method, 27 : "Switch that can select face interpolation method for diffusion coefficients."); 28 3105 : 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 9315 : 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 63 : { FVRelationshipManagerInterface::setRMParamsDiffusion(obj_params, rm_params, 3); }); 38 : 39 6210 : return params; 40 3105 : } 41 : 42 23 : FVAnisotropicDiffusion::FVAnisotropicDiffusion(const InputParameters & params) 43 : : FVFluxKernel(params), 44 : FVDiffusionInterpolationInterface(params), 45 23 : _coeff(getFunctor<ADRealVectorValue>("coeff")), 46 23 : _coeff_interp_method( 47 69 : Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("coeff_interp_method"))) 48 : { 49 23 : } 50 : 51 : ADReal 52 39548 : FVAnisotropicDiffusion::computeQpResidual() 53 : { 54 39548 : const auto state = determineState(); 55 39548 : const auto & grad_T = _var.adGradSln(*_face_info, state, _correct_skewness); 56 : 57 39548 : ADRealVectorValue coeff; 58 : // If we are on internal faces, we interpolate the diffusivity as usual 59 39548 : if (_var.isInternalFace(*_face_info)) 60 38400 : interpolate(_coeff_interp_method, 61 : coeff, 62 76800 : _coeff(elemArg(), state), 63 76800 : _coeff(neighborArg(), state), 64 38400 : *_face_info, 65 : true); 66 : // Else we just use the boundary values (which depend on how the diffusion 67 : // coefficient is constructed) 68 : else 69 : { 70 1148 : const auto face = singleSidedFaceArg(); 71 1148 : coeff = _coeff(face, state); 72 : } 73 : 74 39548 : ADReal r = 0; 75 158192 : for (const auto i : make_range(Moose::dim)) 76 118644 : r += _normal(i) * coeff(i) * grad_T(i); 77 79096 : return -r; 78 39548 : }