LCOV - code coverage report
Current view: top level - src/materials - MaterialData.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 40 44 90.9 %
Date: 2025-07-17 01:28:37 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      192141 : MaterialData::MaterialData(MaterialPropertyStorage & storage, const THREAD_ID tid)
      16      192141 :   : _storage(storage), _tid(tid), _n_qpoints(0), _swapped(false), _resize_only_if_smaller(false)
      17             : {
      18      192141 : }
      19             : 
      20             : void
      21    68739562 : MaterialData::resize(unsigned int n_qpoints)
      22             : {
      23    68739562 :   if (n_qpoints == nQPoints())
      24    68703527 :     return;
      25             : 
      26       36035 :   if (_resize_only_if_smaller && n_qpoints < nQPoints())
      27           0 :     return;
      28             : 
      29      101076 :   for (const auto state : _storage.stateIndexRange())
      30       65041 :     props(state).resizeItems(n_qpoints, {});
      31       36035 :   _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    21081310 : MaterialData::swap(const Elem & elem, unsigned int side /* = 0*/)
      42             : {
      43    21081310 :   if (!_storage.hasStatefulProperties() || isSwapped())
      44    16309693 :     return;
      45             : 
      46     4771617 :   _storage.swap(_tid, elem, side);
      47     4771617 :   _swapped = true;
      48             : }
      49             : 
      50             : void
      51        2749 : MaterialData::reset(const std::vector<std::shared_ptr<MaterialBase>> & mats)
      52             : {
      53        5494 :   for (const auto & mat : mats)
      54        2749 :     mat->resetProperties();
      55        2745 : }
      56             : 
      57             : void
      58   386478263 : MaterialData::swapBack(const Elem & elem, unsigned int side /* = 0*/)
      59             : {
      60   386478263 :   if (isSwapped() && _storage.hasStatefulProperties())
      61             :   {
      62     4771608 :     _storage.swapBack(_tid, elem, side);
      63     4771608 :     _swapped = false;
      64             :   }
      65   386478263 : }
      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       66670 : MaterialData::hasProperty(const std::string & prop_name) const
      75             : {
      76       66670 :   return _storage.hasProperty(prop_name);
      77             : }
      78             : 
      79             : unsigned int
      80      169821 : MaterialData::getPropertyId(const std::string & prop_name) const
      81             : {
      82      169821 :   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      118873 : 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      118873 :   return _storage.addProperty(prop_name, type, state, declarer);
      98             : }
      99             : 
     100             : const MaterialBase &
     101       58673 : MaterialData::castRequestorToDeclarer(const MooseObject & requestor) const
     102             : {
     103       58673 :   const auto declarer = dynamic_cast<const MaterialBase *>(&requestor);
     104             :   mooseAssert(declarer, "Not a MaterialBase");
     105       58673 :   return *declarer;
     106             : }
     107             : 
     108             : unsigned int
     109      118873 : MaterialData::getMaxStateRequested(const unsigned int prop_id) const
     110             : {
     111      118873 :   return _storage.getPropRecord(prop_id).state;
     112             : }

Generated by: LCOV version 1.14