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 "GuaranteeConsumer.h" 11 : #include "GuaranteeProvider.h" 12 : 13 : #include "MooseObject.h" 14 : #include "MaterialBase.h" 15 : #include "MooseMesh.h" 16 : #include "FEProblemBase.h" 17 : #include "InputParameters.h" 18 : #include "BlockRestrictable.h" 19 : 20 12672 : GuaranteeConsumer::GuaranteeConsumer(MooseObject * moose_object) 21 12672 : : _gc_params(moose_object->parameters()), 22 12672 : _gc_feproblem(_gc_params.get<FEProblemBase *>("_fe_problem_base")), 23 12672 : _gc_block_restrict(dynamic_cast<BlockRestrictable *>(moose_object)) 24 : { 25 12672 : } 26 : 27 : bool 28 37980798 : GuaranteeConsumer::hasGuaranteedMaterialProperty(const MaterialPropertyName & prop_name, 29 : Guarantee guarantee) 30 : { 31 37980798 : if (!_gc_feproblem->startedInitialSetup()) 32 0 : mooseError("hasGuaranteedMaterialProperty() needs to be called in initialSetup()"); 33 : 34 : // Reference to MaterialWarehouse for testing and retrieving block ids 35 37980798 : const auto & warehouse = _gc_feproblem->getMaterialWarehouse(); 36 : 37 : // Complete set of ids that this object is active 38 37980798 : const auto & ids = (_gc_block_restrict && _gc_block_restrict->blockRestricted()) 39 42523006 : ? _gc_block_restrict->blockIDs() 40 33438590 : : _gc_feproblem->mesh().meshSubdomains(); 41 : 42 : // Loop over each id for this object 43 79428688 : for (const auto & id : ids) 44 : { 45 : // If block materials exist, look if any issue the required guarantee 46 41548462 : if (warehouse.hasActiveBlockObjects(id)) 47 : { 48 41548462 : const std::vector<std::shared_ptr<MaterialBase>> & mats = warehouse.getActiveBlockObjects(id); 49 299834728 : for (const auto & mat : mats) 50 : { 51 258386838 : const auto & mat_props = mat->getSuppliedItems(); 52 258386838 : if (mat_props.count(prop_name)) 53 : { 54 41548462 : auto guarantee_mat = dynamic_cast<GuaranteeProvider *>(mat.get()); 55 41548462 : if (guarantee_mat && !guarantee_mat->hasGuarantee(prop_name, guarantee)) 56 : { 57 : // we found at least one material on the set of block we operate on 58 : // that does _not_ provide the requested guarantee 59 : return false; 60 : } 61 : } 62 : } 63 : } 64 : } 65 : 66 : return true; 67 : }