LCOV - code coverage report
Current view: top level - src/materials - MaterialData.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 40 44 90.9 %
Date: 2026-05-29 20:35:17 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      365187 : MaterialData::MaterialData(MaterialPropertyStorage & storage, const THREAD_ID tid)
      16      365187 :   : _storage(storage), _tid(tid), _n_qpoints(0), _swapped(false), _resize_only_if_smaller(false)
      17             : {
      18      365187 : }
      19             : 
      20             : void
      21    51136966 : MaterialData::resize(unsigned int n_qpoints)
      22             : {
      23    51136966 :   if (n_qpoints == nQPoints())
      24    51102415 :     return;
      25             : 
      26       34551 :   if (_resize_only_if_smaller && n_qpoints < nQPoints())
      27           0 :     return;
      28             : 
      29       98352 :   for (const auto state : _storage.stateIndexRange())
      30       63801 :     props(state).resizeItems(n_qpoints, {});
      31       34551 :   _n_qpoints = n_qpoints;
      32             : }
      33             : 
      34             : void
      35           5 : MaterialData::copy(const Elem & elem_to, const Elem & elem_from, unsigned int side)
      36             : {
      37           5 :   _storage.copy(_tid, &elem_to, &elem_from, side, nQPoints());
      38           5 : }
      39             : 
      40             : void
      41    17652679 : MaterialData::swap(const Elem & elem, unsigned int side /* = 0*/)
      42             : {
      43    17652679 :   if (!_storage.hasStatefulProperties() || isSwapped())
      44    14943789 :     return;
      45             : 
      46     2708890 :   _storage.swap(_tid, elem, side);
      47     2708890 :   _swapped = true;
      48             : }
      49             : 
      50             : void
      51        2748 : MaterialData::reset(const std::vector<std::shared_ptr<MaterialBase>> & mats)
      52             : {
      53        5493 :   for (const auto & mat : mats)
      54        2748 :     mat->resetProperties();
      55        2745 : }
      56             : 
      57             : void
      58   373815832 : MaterialData::swapBack(const Elem & elem, unsigned int side /* = 0*/)
      59             : {
      60   373815832 :   if (isSwapped() && _storage.hasStatefulProperties())
      61             :   {
      62     2708878 :     _storage.swapBack(_tid, elem, side);
      63     2708878 :     _swapped = false;
      64             :   }
      65   373815832 : }
      66             : 
      67             : void
      68          12 : MaterialData::mooseErrorHelper(const MooseObject & object, const std::string_view & error)
      69             : {
      70          12 :   object.mooseError(error);
      71             : }
      72             : 
      73             : bool
      74       76169 : MaterialData::hasProperty(const std::string & prop_name) const
      75             : {
      76       76169 :   return _storage.hasProperty(prop_name);
      77             : }
      78             : 
      79             : unsigned int
      80      186278 : MaterialData::getPropertyId(const std::string & prop_name) const
      81             : {
      82      186278 :   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      121832 : 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      121832 :   return _storage.addProperty(prop_name, type, state, declarer);
      98             : }
      99             : 
     100             : const MaterialBase &
     101       60396 : MaterialData::castRequestorToDeclarer(const MooseObject & requestor) const
     102             : {
     103       60396 :   const auto declarer = dynamic_cast<const MaterialBase *>(&requestor);
     104             :   mooseAssert(declarer, "Not a MaterialBase");
     105       60396 :   return *declarer;
     106             : }
     107             : 
     108             : unsigned int
     109      121832 : MaterialData::getMaxStateRequested(const unsigned int prop_id) const
     110             : {
     111      121832 :   return _storage.getPropRecord(prop_id).state;
     112             : }

Generated by: LCOV version 1.14