LCOV - code coverage report
Current view: top level - include/materials - DerivativeFunctionMaterialBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 0 9 0.0 %
Date: 2025-07-17 01:28:37 Functions: 0 8 0.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 "FunctionMaterialBase.h"
      13             : 
      14             : #define usingDerivativeFunctionMaterialBaseMembers(T)                                              \
      15             :   usingFunctionMaterialBaseMembers(T);                                                             \
      16             :   using DerivativeFunctionMaterialBaseTempl<T>::computeF;                                          \
      17             :   using DerivativeFunctionMaterialBaseTempl<T>::computeDF;                                         \
      18             :   using DerivativeFunctionMaterialBaseTempl<T>::computeD2F;                                        \
      19             :   using DerivativeFunctionMaterialBaseTempl<T>::computeD3F;                                        \
      20             :   using DerivativeFunctionMaterialBaseTempl<T>::_third_derivatives;                                \
      21             :   using DerivativeFunctionMaterialBaseTempl<T>::_prop_dF;                                          \
      22             :   using DerivativeFunctionMaterialBaseTempl<T>::_prop_d2F;                                         \
      23             :   using DerivativeFunctionMaterialBaseTempl<T>::_prop_d3F
      24             : 
      25             : /**
      26             :  * Material base class to compute a function and its derivatives.
      27             :  *
      28             :  * A DerivativeFunctionMaterialBaseTempl provides numerous material properties which contain
      29             :  * the free energy and its derivatives. The material property names are
      30             :  * constructed dynamically by the helper functions derivativePropertyNameFirst(),
      31             :  * derivativePropertyNameSecond(), and derivativePropertyNameThird() in
      32             :  * DerivativeMaterialPropertyNameInterface.
      33             :  *
      34             :  * A derived class needs to implement the computeF(), computeDF(),
      35             :  * computeD2F(), and (optionally) computeD3F() methods.
      36             :  *
      37             :  * \see DerivativeParsedMaterial
      38             :  * \see DerivativeMaterialInterface
      39             :  */
      40             : template <bool is_ad = false>
      41             : class DerivativeFunctionMaterialBaseTempl : public FunctionMaterialBase<is_ad>
      42             : {
      43             : public:
      44             :   static InputParameters validParams();
      45             : 
      46             :   DerivativeFunctionMaterialBaseTempl(const InputParameters & parameters);
      47             : 
      48             : protected:
      49             :   usingFunctionMaterialBaseMembers(is_ad);
      50             : 
      51             :   void computeProperties() override;
      52             : 
      53             :   /**
      54             :    * Check if we got the right number of components in the 'coupled_variables' vector.
      55             :    */
      56             :   void initialSetup() override;
      57             : 
      58             :   /**
      59             :    * Override this method to provide the free energy function.
      60             :    */
      61           0 :   virtual GenericReal<is_ad> computeF() { return 0.0; }
      62             : 
      63             :   /**
      64             :    * Override this method for calculating the first derivatives.
      65             :    * The parameter is the libMesh variable number of the coupled variable.
      66             :    * These numbers can be obtained using the coupled() method for each coupled variable.
      67             :    *
      68             :    * @param arg The index of the function argument the derivative is taken of
      69             :    */
      70           0 :   virtual GenericReal<is_ad> computeDF(unsigned int arg)
      71             :   {
      72           0 :     libmesh_ignore(arg);
      73           0 :     return 0.0;
      74             :   }
      75             : 
      76             :   /**
      77             :    * Override this method to calculate the second derivatives.
      78             :    *
      79             :    * \f$ \frac{d^2F}{dc_{arg1} dc_{arg2}} \f$
      80             :    *
      81             :    * @param arg1 The variable the first derivative is taken of
      82             :    * @param arg2 The variable the second derivative is taken of
      83             :    */
      84           0 :   virtual GenericReal<is_ad> computeD2F(unsigned int arg1, unsigned int arg2)
      85             :   {
      86           0 :     libmesh_ignore(arg1);
      87           0 :     libmesh_ignore(arg2);
      88           0 :     return 0.0;
      89             :   }
      90             : 
      91             :   /**
      92             :    * Override this method to calculate the third derivatives.
      93             :    *
      94             :    * @note The implementation of this method is optional. It is only evaluated when
      95             :    *       the 'derivative_order' parameter is set to 3.
      96             :    */
      97           0 :   virtual GenericReal<is_ad> computeD3F(unsigned int, unsigned int, unsigned int) { return 0.0; }
      98             : 
      99             :   /// Calculate (and allocate memory for) the third derivatives of the free energy.
     100             :   bool _third_derivatives;
     101             : 
     102             :   /// Material properties to store the derivatives of f with respect to arg[i]
     103             :   std::vector<GenericMaterialProperty<Real, is_ad> *> _prop_dF;
     104             : 
     105             :   /// Material properties to store the second derivatives.
     106             :   std::vector<std::vector<GenericMaterialProperty<Real, is_ad> *>> _prop_d2F;
     107             : 
     108             :   /// Material properties to store the third derivatives.
     109             :   std::vector<std::vector<std::vector<GenericMaterialProperty<Real, is_ad> *>>> _prop_d3F;
     110             : };
     111             : 
     112             : typedef DerivativeFunctionMaterialBaseTempl<false> DerivativeFunctionMaterialBase;
     113             : typedef DerivativeFunctionMaterialBaseTempl<true> ADDerivativeFunctionMaterialBase;

Generated by: LCOV version 1.14