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 14313 : FVAnisotropicDiffusion::validParams() 16 : { 17 14313 : InputParameters params = FVFluxKernel::validParams(); 18 14313 : params += FVDiffusionInterpolationInterface::validParams(); 19 14313 : params.addClassDescription( 20 : "Computes residual for anisotropic diffusion operator for finite volume method."); 21 14313 : params.addRequiredParam<MooseFunctorName>("coeff", 22 : "The diagonal coefficients of a diffusion tensor."); 23 14313 : MooseEnum coeff_interp_method("average harmonic", "harmonic"); 24 14313 : params.addParam<MooseEnum>( 25 : "coeff_interp_method", 26 : coeff_interp_method, 27 : "Switch that can select face interpolation method for diffusion coefficients."); 28 14313 : 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 14313 : 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 69 : { FVRelationshipManagerInterface::setRMParamsDiffusion(obj_params, rm_params, 3); }); 38 : 39 28626 : return params; 40 14313 : } 41 : 42 25 : FVAnisotropicDiffusion::FVAnisotropicDiffusion(const InputParameters & params) 43 : : FVFluxKernel(params), 44 : FVDiffusionInterpolationInterface(params), 45 25 : _coeff(getFunctor<ADRealVectorValue>("coeff")), 46 25 : _coeff_interp_method( 47 50 : Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("coeff_interp_method"))) 48 : { 49 25 : } 50 : 51 : ADReal 52 46086 : FVAnisotropicDiffusion::computeQpResidual() 53 : { 54 46086 : const auto state = determineState(); 55 46086 : const auto & grad_T = _var.adGradSln(*_face_info, state, _correct_skewness); 56 : 57 46086 : ADRealVectorValue coeff; 58 : // If we are on internal faces, we interpolate the diffusivity as usual 59 46086 : if (_var.isInternalFace(*_face_info)) 60 44760 : interpolate(_coeff_interp_method, 61 : coeff, 62 89520 : _coeff(elemArg(), state), 63 89520 : _coeff(neighborArg(), state), 64 44760 : *_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 1326 : const auto face = singleSidedFaceArg(); 71 1326 : coeff = _coeff(face, state); 72 : } 73 : 74 46086 : ADReal r = 0; 75 184344 : for (const auto i : make_range(Moose::dim)) 76 138258 : r += _normal(i) * coeff(i) * grad_T(i); 77 92172 : return -r; 78 46086 : }