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