LCOV - code coverage report
Current view: top level - src/materials - MaterialData.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 40 44 90.9 %
Date: 2025-08-08 20:01:16 Functions: 12 13 92.3 %
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             : #include "MaterialData.h"
      11             : #include "Material.h"
      12             : #include "MaterialPropertyStorage.h"
      13             : #include "MaterialBase.h"
      14             : 
      15      205860 : MaterialData::MaterialData(MaterialPropertyStorage & storage, const THREAD_ID tid)
      16      205860 :   : _storage(storage), _tid(tid), _n_qpoints(0), _swapped(false), _resize_only_if_smaller(false)
      17             : {
      18      205860 : }
      19             : 
      20             : void
      21    74391845 : MaterialData::resize(unsigned int n_qpoints)
      22             : {
      23    74391845 :   if (n_qpoints == nQPoints())
      24    74352219 :     return;
      25             : 
      26       39626 :   if (_resize_only_if_smaller && n_qpoints < nQPoints())
      27           0 :     return;
      28             : 
      29      111998 :   for (const auto state : _storage.stateIndexRange())
      30       72372 :     props(state).resizeItems(n_qpoints, {});
      31       39626 :   _n_qpoints = n_qpoints;
      32             : }
      33             : 
      34             : void
      35           8 : MaterialData::copy(const Elem & elem_to, const Elem & elem_from, unsigned int side)
      36             : {
      37           8 :   _storage.copy(_tid, &elem_to, &elem_from, side, nQPoints());
      38           8 : }
      39             : 
      40             : void
      41    22936748 : MaterialData::swap(const Elem & elem, unsigned int side /* = 0*/)
      42             : {
      43    22936748 :   if (!_storage.hasStatefulProperties() || isSwapped())
      44    17458096 :     return;
      45             : 
      46     5478652 :   _storage.swap(_tid, elem, side);
      47     5478652 :   _swapped = true;
      48             : }
      49             : 
      50             : void
      51        3038 : MaterialData::reset(const std::vector<std::shared_ptr<MaterialBase>> & mats)
      52             : {
      53        6073 :   for (const auto & mat : mats)
      54        3038 :     mat->resetProperties();
      55        3035 : }
      56             : 
      57             : void
      58   430597899 : MaterialData::swapBack(const Elem & elem, unsigned int side /* = 0*/)
      59             : {
      60   430597899 :   if (isSwapped() && _storage.hasStatefulProperties())
      61             :   {
      62     5478643 :     _storage.swapBack(_tid, elem, side);
      63     5478643 :     _swapped = false;
      64             :   }
      65   430597899 : }
      66             : 
      67             : void
      68          16 : MaterialData::mooseErrorHelper(const MooseObject & object, const std::string_view & error)
      69             : {
      70          16 :   object.mooseError(error);
      71             : }
      72             : 
      73             : bool
      74       71373 : MaterialData::hasProperty(const std::string & prop_name) const
      75             : {
      76       71373 :   return _storage.hasProperty(prop_name);
      77             : }
      78             : 
      79             : unsigned int
      80      181057 : MaterialData::getPropertyId(const std::string & prop_name) const
      81             : {
      82      181057 :   return _storage.getMaterialPropertyRegistry().getID(prop_name);
      83             : }
      84             : 
      85             : void
      86           0 : MaterialData::eraseProperty(const Elem * elem)
      87             : {
      88           0 :   _storage.eraseProperty(elem);
      89           0 : }
      90             : 
      91             : unsigned int
      92      126571 : MaterialData::addPropertyHelper(const std::string & prop_name,
      93             :                                 const std::type_info & type,
      94             :                                 const unsigned int state,
      95             :                                 const MaterialBase * const declarer)
      96             : {
      97      126571 :   return _storage.addProperty(prop_name, type, state, declarer);
      98             : }
      99             : 
     100             : const MaterialBase &
     101       62479 : MaterialData::castRequestorToDeclarer(const MooseObject & requestor) const
     102             : {
     103       62479 :   const auto declarer = dynamic_cast<const MaterialBase *>(&requestor);
     104             :   mooseAssert(declarer, "Not a MaterialBase");
     105       62479 :   return *declarer;
     106             : }
     107             : 
     108             : unsigned int
     109      126571 : MaterialData::getMaxStateRequested(const unsigned int prop_id) const
     110             : {
     111      126571 :   return _storage.getPropRecord(prop_id).state;
     112             : }

Generated by: LCOV version 1.14