LCOV - code coverage report
Current view: top level - include/kernels - ADAllenCahnBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 10 11 90.9 %
Date: 2025-09-04 07:55:36 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 "ADKernelValue.h"
      13             : #include "JvarMapInterface.h"
      14             : #include "DerivativeMaterialInterface.h"
      15             : 
      16             : /**
      17             :  * This is the Allen-Cahn equation base class that implements the bulk or
      18             :  * local energy term of the equation. It is templated on the type of the mobility,
      19             :  * which can be either a number (Real) or a tensor (RealValueTensor).
      20             :  * Note that the function computeDFDOP MUST be overridden in any kernel that inherits from
      21             :  * ADAllenCahnBase. This is the AD equivalent of ACBulk<>.
      22             :  */
      23             : template <typename T>
      24             : class ADAllenCahnBase : public DerivativeMaterialInterface<JvarMapKernelInterface<ADKernelValue>>
      25             : {
      26             : public:
      27             :   ADAllenCahnBase(const InputParameters & parameters);
      28             : 
      29             :   static InputParameters validParams();
      30             : 
      31             : protected:
      32             :   virtual ADReal precomputeQpResidual();
      33             : 
      34             :   /// Compute the derivative of the bulk free energy w.r.t the order parameter
      35             :   virtual ADReal computeDFDOP() = 0;
      36             : 
      37             :   /// Mobility
      38             :   const ADMaterialProperty<T> & _prop_L;
      39             : };
      40             : 
      41             : template <typename T>
      42             : InputParameters
      43         637 : ADAllenCahnBase<T>::validParams()
      44             : {
      45         637 :   InputParameters params = ADKernelValue::validParams();
      46         637 :   params.addClassDescription(
      47             :       "Allen-Cahn bulk contribution Kernel with forward mode automatic differentiation");
      48        1274 :   params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
      49         637 :   return params;
      50           0 : }
      51             : 
      52             : template <typename T>
      53         338 : ADAllenCahnBase<T>::ADAllenCahnBase(const InputParameters & parameters)
      54             :   : DerivativeMaterialInterface<JvarMapKernelInterface<ADKernelValue>>(parameters),
      55         676 :     _prop_L(getADMaterialProperty<T>("mob_name"))
      56             : {
      57         338 : }
      58             : 
      59             : template <typename T>
      60             : ADReal
      61   111806312 : ADAllenCahnBase<T>::precomputeQpResidual()
      62             : {
      63   111806312 :   return _prop_L[_qp] * computeDFDOP();
      64             : }

Generated by: LCOV version 1.14