LCOV - code coverage report
Current view: top level - include/kernels - ADMatDiffusionBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 12 13 92.3 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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             : #pragma once
      11             : 
      12             : #include "ADKernelGrad.h"
      13             : 
      14             : /**
      15             :  * This class template implements a diffusion kernel with a mobility that can vary
      16             :  * spatially and can depend on variables in the simulation. Two classes are derived from
      17             :  * this template, MatDiffusion for isotropic diffusion and MatAnisoDiffusion for
      18             :  * anisotropic diffusion.
      19             :  *
      20             :  * \tparam T Type of the diffusion coefficient parameter. This can be Real for
      21             :  *           isotropic diffusion or RealTensorValue for the general anisotropic case.
      22             :  */
      23             : template <typename T>
      24             : class ADMatDiffusionBase : public ADKernelGrad
      25             : {
      26             : public:
      27             :   static InputParameters validParams();
      28             : 
      29             :   ADMatDiffusionBase(const InputParameters & parameters);
      30             : 
      31             : protected:
      32             :   virtual ADRealVectorValue precomputeQpResidual() override;
      33             : 
      34             :   /// diffusion coefficient
      35             :   const ADMaterialProperty<T> & _diffusivity;
      36             : 
      37             :   /// Gradient of the concentration
      38             :   const ADVariableGradient & _grad_v;
      39             : };
      40             : 
      41             : template <typename T>
      42         384 : ADMatDiffusionBase<T>::ADMatDiffusionBase(const InputParameters & parameters)
      43             :   : ADKernelGrad(parameters),
      44         384 :     _diffusivity(getADMaterialProperty<T>("diffusivity")),
      45         768 :     _grad_v(isCoupled("v") ? adCoupledGradient("v") : _grad_u)
      46             : {
      47         384 : }
      48             : 
      49             : template <typename T>
      50             : ADRealVectorValue
      51     7578240 : ADMatDiffusionBase<T>::precomputeQpResidual()
      52             : {
      53     7578240 :   return _diffusivity[_qp] * _grad_v[_qp];
      54             : }
      55             : 
      56             : template <typename T>
      57             : InputParameters
      58       14999 : ADMatDiffusionBase<T>::validParams()
      59             : {
      60       14999 :   InputParameters params = ADKernelGrad::validParams();
      61       14999 :   params.addClassDescription("Diffusion kernel with a material property as diffusivity and "
      62             :                              "automatic differentiation to provide perfect Jacobians");
      63       14999 :   params.addParam<MaterialPropertyName>(
      64             :       "diffusivity", "D", "The diffusivity value or material property");
      65       14999 :   params.addCoupledVar("v",
      66             :                        "Coupled concentration variable for kernel to operate on; if this "
      67             :                        "is not specified, the kernel's nonlinear variable will be used as "
      68             :                        "usual");
      69       14999 :   return params;
      70           0 : }

Generated by: LCOV version 1.14