https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GuaranteeConsumer.C
Go to the documentation of this file.
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
21 : _gc_params(moose_object->parameters()),
22 _gc_feproblem(_gc_params.get<FEProblemBase *>("_fe_problem_base")),
23 _gc_block_restrict(dynamic_cast<BlockRestrictable *>(moose_object))
24{
25}
26
27bool
28GuaranteeConsumer::hasGuaranteedMaterialProperty(const MaterialPropertyName & prop_name,
29 Guarantee guarantee)
30{
32 mooseError("hasGuaranteedMaterialProperty() needs to be called in initialSetup()");
33
34 // Reference to MaterialWarehouse for testing and retrieving block ids
35 const auto & warehouse = _gc_feproblem->getMaterialWarehouse();
36
37 // Complete set of ids that this object is active
41
42 // Loop over each id for this object
43 for (const auto & id : ids)
44 {
45 // If block materials exist, look if any issue the required guarantee
46 if (warehouse.hasActiveBlockObjects(id))
47 {
48 const std::vector<std::shared_ptr<MaterialBase>> & mats = warehouse.getActiveBlockObjects(id);
49 for (const auto & mat : mats)
50 {
51 const auto & mat_props = mat->getSuppliedItems();
52 if (mat_props.count(prop_name))
53 {
54 auto guarantee_mat = dynamic_cast<GuaranteeProvider *>(mat.get());
55 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}
Guarantee
Enum values for guarantees that can be demanded for material properties.
Definition Guarantee.h:17
void mooseError(Args &&... args)
virtual const std::set< SubdomainID > & blockIDs() const
virtual bool blockRestricted() const
const MaterialWarehouse & getMaterialWarehouse() const
virtual MooseMesh & mesh() override
virtual bool startedInitialSetup()
BlockRestrictable *const _gc_block_restrict
Access block restrictions of the object with this interface.
FEProblemBase *const _gc_feproblem
Reference to the FEProblemBase class.
bool hasGuaranteedMaterialProperty(const MaterialPropertyName &prop, Guarantee guarantee)
GuaranteeConsumer(MooseObject *moose_object)
Add-on class that provides the functionality to issue guarantees for declared material properties.
const std::set< SubdomainID > & meshSubdomains() const