LCOV - code coverage report
Current view: top level - include/materials - InterfaceMaterial.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 6f668f Lines: 39 50 78.0 %
Date: 2025-09-22 20:01:15 Functions: 16 23 69.6 %
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             : // MOOOSE includes
      13             : #include "MaterialBase.h"
      14             : #include "NeighborCoupleable.h"
      15             : #include "TwoMaterialPropertyInterface.h"
      16             : 
      17             : #define usingInterfaceMaterialMembers                                                              \
      18             :   usingMaterialBaseMembers;                                                                        \
      19             :   usingNeighborCoupleableMembers;                                                                  \
      20             :   using InterfaceMaterial::_q_point;                                                               \
      21             :   using InterfaceMaterial::_qrule;                                                                 \
      22             :   using InterfaceMaterial::_JxW;                                                                   \
      23             :   using InterfaceMaterial::_current_elem;                                                          \
      24             :   using InterfaceMaterial::_neighbor_elem;                                                         \
      25             :   using InterfaceMaterial::_current_side;                                                          \
      26             :   using InterfaceMaterial::_neighbor_side
      27             : 
      28             : /**
      29             :  * Interface materials compute MaterialProperties.
      30             :  */
      31             : class InterfaceMaterial : public MaterialBase,
      32             :                           public NeighborCoupleable,
      33             :                           public TwoMaterialPropertyInterface
      34             : {
      35             : public:
      36             :   static InputParameters validParams();
      37             : 
      38             :   InterfaceMaterial(const InputParameters & parameters);
      39             : 
      40           0 :   virtual bool isInterfaceMaterial() override { return true; };
      41             :   void computeProperties() override;
      42             : 
      43             :   ///@{
      44             :   /**
      45             :    * Retrieve the property through a given input parameter key with a fallback
      46             :    * to getting it by name
      47             :    *
      48             :    * \p state is the property state; 0 = current, 1 = old, 2 = older, etc.
      49             :    */
      50             :   template <typename T, bool is_ad>
      51             :   const GenericMaterialProperty<T, is_ad> &
      52             :   getGenericMaterialProperty(const std::string & name, const unsigned int state = 0);
      53             :   template <typename T>
      54             :   const MaterialProperty<T> & getMaterialProperty(const std::string & name,
      55             :                                                   const unsigned int state = 0)
      56             :   {
      57             :     return getGenericMaterialProperty<T, false>(name, state);
      58             :   }
      59             :   template <typename T>
      60          28 :   const ADMaterialProperty<T> & getADMaterialProperty(const std::string & name)
      61             :   {
      62          28 :     return getGenericMaterialProperty<T, true>(name, 0);
      63             :   }
      64             :   template <typename T>
      65         576 :   const MaterialProperty<T> & getMaterialPropertyOld(const std::string & name)
      66             :   {
      67         576 :     return getGenericMaterialProperty<T, false>(name, 1);
      68             :   }
      69             :   template <typename T>
      70             :   const MaterialProperty<T> & getMaterialPropertyOlder(const std::string & name)
      71             :   {
      72             :     return getGenericMaterialProperty<T, false>(name, 2);
      73             :   }
      74             :   ///@}
      75             : 
      76             :   ///@{
      77             :   /**
      78             :    * Retrieve the property named "name"
      79             :    *
      80             :    * \p state is the property state; 0 = current, 1 = old, 2 = older, etc.
      81             :    */
      82             :   template <typename T, bool is_ad>
      83             :   const GenericMaterialProperty<T, is_ad> &
      84             :   getGenericMaterialPropertyByName(const std::string & name, const unsigned int state = 0);
      85             :   template <typename T>
      86         288 :   const MaterialProperty<T> & getMaterialPropertyByName(const std::string & prop_name,
      87             :                                                         const unsigned int state = 0)
      88             :   {
      89             : 
      90         288 :     return getGenericMaterialPropertyByName<T, false>(prop_name, state);
      91             :   }
      92             :   template <typename T>
      93             :   const ADMaterialProperty<T> & getADMaterialPropertyByName(const std::string & prop_name)
      94             :   {
      95             : 
      96             :     return getGenericMaterialPropertyByName<T, true>(prop_name, 0);
      97             :   }
      98             :   template <typename T>
      99          60 :   const MaterialProperty<T> & getMaterialPropertyOldByName(const std::string & prop_name)
     100             :   {
     101             : 
     102          60 :     return getGenericMaterialPropertyByName<T, false>(prop_name, 1);
     103             :   }
     104             :   template <typename T>
     105             :   const MaterialProperty<T> & getMaterialPropertyOlderByName(const std::string & prop_name)
     106             :   {
     107             : 
     108             :     return getGenericMaterialPropertyByName<T, false>(prop_name, 2);
     109             :   }
     110             :   ///@}
     111             : 
     112             :   ///@{
     113             :   /**
     114             :    * Retrieve the neighbor property through a given input parameter key with a fallback
     115             :    * to getting it by name
     116             :    *
     117             :    * \p state is the property state; 0 = current, 1 = old, 2 = older, etc.
     118             :    */
     119             :   template <typename T, bool is_ad>
     120             :   const GenericMaterialProperty<T, is_ad> &
     121             :   getGenericNeighborMaterialProperty(const std::string & name, const unsigned int state = 0);
     122             :   template <typename T>
     123             :   const MaterialProperty<T> & getNeighborMaterialProperty(const std::string & name,
     124             :                                                           const unsigned int state = 0)
     125             :   {
     126             :     return getGenericNeighborMaterialProperty<T, false>(name, state);
     127             :   }
     128             :   template <typename T>
     129          14 :   const ADMaterialProperty<T> & getNeighborADMaterialProperty(const std::string & name)
     130             :   {
     131          14 :     return getGenericNeighborMaterialProperty<T, true>(name, 0);
     132             :   }
     133             :   template <typename T>
     134          60 :   const MaterialProperty<T> & getNeighborMaterialPropertyOld(const std::string & name)
     135             :   {
     136          60 :     return getGenericNeighborMaterialProperty<T, false>(name, 1);
     137             :   }
     138             :   template <typename T>
     139             :   const MaterialProperty<T> & getNeighborMaterialPropertyOlder(const std::string & name)
     140             :   {
     141             :     return getGenericNeighborMaterialProperty<T, false>(name, 2);
     142             :   }
     143             :   ///@}
     144             : 
     145             :   ///@{
     146             :   /**
     147             :    * Retrieve the neighbor property named "name"
     148             :    *
     149             :    * \p state is the property state; 0 = current, 1 = old, 2 = older, etc.
     150             :    */
     151             :   template <typename T, bool is_ad>
     152             :   const GenericMaterialProperty<T, is_ad> &
     153             :   getGenericNeighborMaterialPropertyByName(const std::string & name, const unsigned int state = 0);
     154             :   template <typename T>
     155         288 :   const MaterialProperty<T> & getNeighborMaterialPropertyByName(const std::string & prop_name,
     156             :                                                                 const unsigned int state = 0)
     157             :   {
     158         288 :     return getGenericNeighborMaterialPropertyByName<T, false>(prop_name, state);
     159             :   }
     160             :   template <typename T>
     161           0 :   const ADMaterialProperty<T> & getNeighborADMaterialPropertyByName(const std::string & prop_name)
     162             :   {
     163           0 :     return getGenericNeighborMaterialPropertyByName<T, true>(prop_name, 0);
     164             :   }
     165             :   ///@}
     166             : 
     167             :   using MaterialBase::getZeroMaterialProperty;
     168             : 
     169           0 :   virtual bool isBoundaryMaterial() const override { return true; }
     170             : 
     171           0 :   virtual const std::unordered_set<unsigned int> & getMatPropDependencies() const override
     172             :   {
     173           0 :     return TwoMaterialPropertyInterface::getMatPropDependencies();
     174             :   }
     175             : 
     176             : protected:
     177           0 :   virtual const MaterialData & materialData() const override { return _material_data; }
     178        8348 :   virtual MaterialData & materialData() override { return _material_data; }
     179           0 :   virtual Moose::MaterialDataType materialDataType() override { return _material_data_type; }
     180             : 
     181           0 :   virtual const QBase & qRule() const override { return *_qrule; }
     182             : 
     183             :   bool _bnd;
     184             :   const MooseArray<Point> & _q_point;
     185             :   const QBase * const & _qrule;
     186             :   const MooseArray<Real> & _JxW;
     187             : 
     188             :   /// Current element
     189             :   const Elem * const & _current_elem;
     190             :   /// Current neighbor element
     191             :   const Elem * const & _neighbor_elem;
     192             :   /// current side of the current element
     193             :   const unsigned int & _current_side;
     194             :   /// current side of the neighbor element
     195             :   const unsigned int & _neighbor_side;
     196             : };
     197             : 
     198             : template <typename T, bool is_ad>
     199             : const GenericMaterialProperty<T, is_ad> &
     200         604 : InterfaceMaterial::getGenericMaterialProperty(const std::string & name, const unsigned int state)
     201             : {
     202             :   // Check if the supplied parameter is a valid input parameter key
     203         604 :   const auto prop_name = getMaterialPropertyName(name);
     204             : 
     205             :   // Check if it's just a constant.
     206         604 :   if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
     207           0 :     return *default_property;
     208             : 
     209         604 :   return getGenericMaterialPropertyByName<T, is_ad>(prop_name, state);
     210         604 : }
     211             : 
     212             : template <typename T, bool is_ad>
     213             : const GenericMaterialProperty<T, is_ad> &
     214         952 : InterfaceMaterial::getGenericMaterialPropertyByName(const std::string & prop_name,
     215             :                                                     const unsigned int state)
     216             : {
     217         952 :   MaterialBase::checkExecutionStage();
     218             : 
     219             :   // The property may not exist yet, so declare it (declare/getMaterialProperty are referencing the
     220             :   // same memory)
     221         952 :   if (state == 0)
     222         316 :     _requested_props.insert(prop_name);
     223             : 
     224             :   // Do this before hand so that the propery id is defined
     225             :   auto & prop =
     226         952 :       TwoMaterialPropertyInterface::getGenericMaterialPropertyByName<T, is_ad>(prop_name, state);
     227             : 
     228         952 :   registerPropName(prop_name, true, state);
     229             : 
     230         952 :   return prop;
     231             : }
     232             : 
     233             : template <typename T, bool is_ad>
     234             : const GenericMaterialProperty<T, is_ad> &
     235          74 : InterfaceMaterial::getGenericNeighborMaterialProperty(const std::string & name,
     236             :                                                       const unsigned int state)
     237             : {
     238             :   // Check if the supplied parameter is a valid input parameter key
     239          74 :   const auto prop_name = getMaterialPropertyName(name);
     240             : 
     241             :   // Check if it's just a constant.
     242          74 :   if (const auto * default_property = defaultGenericMaterialProperty<T, is_ad>(prop_name))
     243           0 :     return *default_property;
     244             : 
     245          74 :   return getGenericNeighborMaterialPropertyByName<T, is_ad>(prop_name, state);
     246          74 : }
     247             : 
     248             : template <typename T, bool is_ad>
     249             : const GenericMaterialProperty<T, is_ad> &
     250         362 : InterfaceMaterial::getGenericNeighborMaterialPropertyByName(const std::string & name,
     251             :                                                             const unsigned int state)
     252             : {
     253         362 :   MaterialBase::checkExecutionStage();
     254             : 
     255             :   // The property may not exist yet, so declare it (declare/getMaterialProperty are referencing the
     256             :   // same memory)
     257         362 :   if (state == 0)
     258         302 :     _requested_props.insert(name);
     259             : 
     260             :   // Do this before hand so that the propery id is defined
     261             :   auto & prop =
     262         362 :       TwoMaterialPropertyInterface::getGenericNeighborMaterialPropertyByName<T, is_ad>(name, state);
     263             : 
     264         362 :   registerPropName(name, true, state);
     265             : 
     266         362 :   return prop;
     267             : }

Generated by: LCOV version 1.14