www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
MaterialPropertyInterface Class Reference

An interface for accessing Materials. More...

#include <MaterialPropertyInterface.h>

Inheritance diagram for MaterialPropertyInterface:
[legend]

Public Member Functions

 MaterialPropertyInterface (const MooseObject *moose_object, const std::set< SubdomainID > &block_ids, const std::set< BoundaryID > &boundary_ids)
 
template<typename T >
std::pair< const MaterialProperty< T > *, std::set< SubdomainID > > getBlockMaterialProperty (const MaterialPropertyName &name)
 Retrieve pointer to a material property with the mesh blocks where it is defined The name required by this method is the name defined in the input file. More...
 
template<typename T >
const MaterialProperty< T > & getZeroMaterialProperty (const std::string &prop_name)
 Return a material property that is initialized to zero by default and does not need to (but can) be declared by another material. More...
 
std::set< SubdomainIDgetMaterialPropertyBlocks (const std::string &name)
 Retrieve the block ids that the material property is defined. More...
 
std::vector< SubdomainName > getMaterialPropertyBlockNames (const std::string &name)
 Retrieve the block names that the material property is defined. More...
 
std::set< BoundaryIDgetMaterialPropertyBoundaryIDs (const std::string &name)
 Retrieve the boundary ids that the material property is defined. More...
 
std::vector< BoundaryName > getMaterialPropertyBoundaryNames (const std::string &name)
 Retrieve the boundary namess that the material property is defined. More...
 
void statefulPropertiesAllowed (bool)
 Derived classes can declare whether or not they work with stateful material properties. More...
 
bool getMaterialPropertyCalled () const
 Returns true if getMaterialProperty() has been called, false otherwise. More...
 
const std::set< unsigned int > & getMatPropDependencies () const
 Retrieve the set of material properties that this object depends on. More...
 
template<>
const MaterialProperty< Real > * defaultMaterialProperty (const std::string &name)
 
template<>
const ADMaterialPropertyObject< Real > * defaultADMaterialProperty (const std::string &name)
 
template<typename T >
const MaterialProperty< T > & getMaterialProperty (const std::string &name)
 Retrieve reference to material property or one of it's old or older values. More...
 
template<typename T >
const ADMaterialPropertyObject< T > & getADMaterialProperty (const std::string &name)
 
template<typename T >
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
template<typename T >
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
template<typename T >
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name)
 Retrieve reference to material property or its old or older value The name required by this method is the name defined in the input file. More...
 
template<typename T >
const ADMaterialPropertyObject< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
template<typename T >
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
template<typename T >
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
MaterialgetMaterial (const std::string &name)
 Return a Material reference - usable for computing directly. More...
 
MaterialgetMaterialByName (const std::string &name, bool no_warn=false)
 
template<typename T >
bool hasMaterialProperty (const std::string &name)
 Check if the material property exists. More...
 
template<typename T >
bool hasMaterialPropertyByName (const std::string &name)
 

Protected Member Functions

void checkMaterialProperty (const std::string &name)
 A helper method for checking material properties This method was required to avoid a compiler problem with the template getMaterialProperty method. More...
 
void markMatPropRequested (const std::string &)
 A proxy method for _mi_feproblem.markMatPropRequested(name) More...
 
std::string deducePropertyName (const std::string &name)
 Small helper to look up a material property name through the input parameter keys. More...
 
template<typename T >
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 Helper function to parse default material property values. More...
 
template<typename T >
const ADMaterialPropertyObject< T > * defaultADMaterialProperty (const std::string &name)
 Helper function to parse default material property values. More...
 

Protected Attributes

const InputParameters_mi_params
 Parameters of the object with this interface. More...
 
const std::string _mi_name
 The name of the object that this interface belongs to. More...
 
Moose::MaterialDataType _material_data_type
 The type of data. More...
 
std::shared_ptr< MaterialData_material_data
 Pointer to the material data class that stores properties. More...
 
FEProblemBase_mi_feproblem
 Reference to the FEProblemBase class. More...
 
const THREAD_ID _mi_tid
 Current threaded it. More...
 
bool _stateful_allowed
 True by default. More...
 
bool _get_material_property_called
 Initialized to false. More...
 
std::vector< std::unique_ptr< MaterialProperty< Real > > > _default_real_properties
 Storage vector for MaterialProperty<Real> default objects. More...
 
std::vector< std::unique_ptr< ADMaterialPropertyObject< Real > > > _default_ad_real_properties
 Storage vector for ADMaterialPropertyObject<Real> default objects. More...
 
std::set< unsigned int > _material_property_dependencies
 The set of material properties (as given by their IDs) that this object depends on. More...
 

Private Member Functions

void checkExecutionStage ()
 Check and throw an error if the execution has progressed past the construction stage. More...
 

Private Attributes

const bool _mi_boundary_restricted
 BoundaryRestricted flag. More...
 
const std::set< SubdomainID > & _mi_block_ids
 Storage for the block ids created by BlockRestrictable. More...
 
const std::set< BoundaryID > & _mi_boundary_ids
 Storage for the boundary ids created by BoundaryRestrictable. More...
 

Detailed Description

An interface for accessing Materials.

Any object that needs material properties should inherit this interface. If your object is also restricted to blocks and/or boundaries via the BlockRestrictable and/or BoundaryRestrictable class, then MaterialPropertyInterface must be inherited following these two classes for the material property checks to operate correctly.

Definition at line 46 of file MaterialPropertyInterface.h.

Constructor & Destructor Documentation

◆ MaterialPropertyInterface()

MaterialPropertyInterface::MaterialPropertyInterface ( const MooseObject moose_object,
const std::set< SubdomainID > &  block_ids,
const std::set< BoundaryID > &  boundary_ids 
)

Definition at line 25 of file MaterialPropertyInterface.C.

28  : _mi_params(moose_object->parameters()),
29  _mi_name(_mi_params.get<std::string>("_object_name")),
31  _mi_tid(_mi_params.get<THREAD_ID>("_tid")),
32  _stateful_allowed(true),
34  _mi_boundary_restricted(!boundary_ids.empty() &&
35  BoundaryRestrictable::restricted(boundary_ids)),
36  _mi_block_ids(block_ids),
37  _mi_boundary_ids(boundary_ids)
38 {
39 
40  // Set the MaterialDataType flag
41  if (_mi_params.isParamValid("_material_data_type"))
42  _material_data_type = _mi_params.get<Moose::MaterialDataType>("_material_data_type");
43 
44  else if (_mi_boundary_restricted)
46 
47  else
49 
52 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
const THREAD_ID _mi_tid
Current threaded it.
const std::set< SubdomainID > & _mi_block_ids
Storage for the block ids created by BlockRestrictable.
MaterialDataType
MaterialData types.
Definition: MooseTypes.h:331
Moose::MaterialDataType _material_data_type
The type of data.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
const bool _mi_boundary_restricted
BoundaryRestricted flag.
const std::set< BoundaryID > & _mi_boundary_ids
Storage for the boundary ids created by BoundaryRestrictable.
const std::string _mi_name
The name of the object that this interface belongs to.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
static bool restricted(const std::set< BoundaryID > &ids)
Helper for determining if the object is boundary restricted.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:57
const InputParameters & _mi_params
Parameters of the object with this interface.
std::shared_ptr< MaterialData > getMaterialData(Moose::MaterialDataType type, THREAD_ID tid=0)
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
bool _get_material_property_called
Initialized to false.
bool _stateful_allowed
True by default.
unsigned int THREAD_ID
Definition: MooseTypes.h:97
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

Member Function Documentation

◆ checkExecutionStage()

void MaterialPropertyInterface::checkExecutionStage ( )
private

Check and throw an error if the execution has progressed past the construction stage.

Definition at line 221 of file MaterialPropertyInterface.C.

Referenced by getADMaterialPropertyByName(), and getMaterialPropertyByName().

222 {
224  mooseError("Material properties must be retrieved during object construction to ensure correct "
225  "problem integrity validation.");
226 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
virtual bool startedInitialSetup()
Returns true if we are in or beyond the initialSetup stage.

◆ checkMaterialProperty()

void MaterialPropertyInterface::checkMaterialProperty ( const std::string &  name)
protected

A helper method for checking material properties This method was required to avoid a compiler problem with the template getMaterialProperty method.

Definition at line 144 of file MaterialPropertyInterface.C.

Referenced by getADMaterialPropertyByName(), and getMaterialPropertyByName().

145 {
146  // If the material property is boundary restrictable, add to the list of materials to check
148  for (const auto & bnd_id : _mi_boundary_ids)
150 
151  // The default is to assume block restrictions
152  else
153  for (const auto & blk_ids : _mi_block_ids)
155 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
const std::set< SubdomainID > & _mi_block_ids
Storage for the block ids created by BlockRestrictable.
virtual void storeSubdomainDelayedCheckMatProp(const std::string &requestor, SubdomainID block_id, const std::string &name)
Adds to a map based on block ids of material properties to validate.
Definition: SubProblem.C:419
const bool _mi_boundary_restricted
BoundaryRestricted flag.
virtual void storeBoundaryDelayedCheckMatProp(const std::string &requestor, BoundaryID boundary_id, const std::string &name)
Adds to a map based on boundary ids of material properties to validate.
Definition: SubProblem.C:427
const std::set< BoundaryID > & _mi_boundary_ids
Storage for the boundary ids created by BoundaryRestrictable.
const std::string _mi_name
The name of the object that this interface belongs to.

◆ deducePropertyName()

std::string MaterialPropertyInterface::deducePropertyName ( const std::string &  name)
protected

Small helper to look up a material property name through the input parameter keys.

Definition at line 55 of file MaterialPropertyInterface.C.

Referenced by getADMaterialProperty(), Material::getADMaterialProperty(), getMaterialProperty(), Material::getMaterialProperty(), getMaterialPropertyOld(), Material::getMaterialPropertyOld(), getMaterialPropertyOlder(), Material::getMaterialPropertyOlder(), TwoMaterialPropertyInterface::getNeighborMaterialProperty(), TwoMaterialPropertyInterface::getNeighborMaterialPropertyOld(), TwoMaterialPropertyInterface::getNeighborMaterialPropertyOlder(), and hasMaterialProperty().

56 {
57  if (_mi_params.have_parameter<MaterialPropertyName>(name))
58  return _mi_params.get<MaterialPropertyName>(name);
59  else
60  return name;
61 }
const InputParameters & _mi_params
Parameters of the object with this interface.

◆ defaultADMaterialProperty() [1/2]

template<>
const ADMaterialPropertyObject<Real>* MaterialPropertyInterface::defaultADMaterialProperty ( const std::string &  name)

Definition at line 93 of file MaterialPropertyInterface.C.

94 {
95  std::istringstream ss(name);
96  Real real_value;
97 
98  // check if the string parsed cleanly into a Real number
99  if (ss >> real_value && ss.eof())
100  {
101  _default_ad_real_properties.emplace_back(libmesh_make_unique<ADMaterialPropertyObject<Real>>());
102  auto & default_property = _default_ad_real_properties.back();
103 
104  // resize to accomodate maximum number obf qpoints
105  auto nqp = _mi_feproblem.getMaxQps();
106  default_property->resize(nqp);
107 
108  // set values for all qpoints to the given default
109  for (decltype(nqp) qp = 0; qp < nqp; ++qp)
110  (*default_property)[qp] = real_value;
111 
112  // return the raw pointer inside the shared pointer
113  return default_property.get();
114  }
115 
116  return nullptr;
117 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
std::vector< std::unique_ptr< ADMaterialPropertyObject< Real > > > _default_ad_real_properties
Storage vector for ADMaterialPropertyObject<Real> default objects.
unsigned int getMaxQps() const

◆ defaultADMaterialProperty() [2/2]

template<typename T >
const ADMaterialPropertyObject< T > * MaterialPropertyInterface::defaultADMaterialProperty ( const std::string &  name)
protected

Helper function to parse default material property values.

This is implemented as a specialization for supported types and returns NULL in all other cases.

Definition at line 378 of file MaterialPropertyInterface.h.

379 {
380  return NULL;
381 }

◆ defaultMaterialProperty() [1/2]

template<typename T >
const MaterialProperty< T > * MaterialPropertyInterface::defaultMaterialProperty ( const std::string &  name)
protected

Helper function to parse default material property values.

This is implemented as a specialization for supported types and returns NULL in all other cases.

Definition at line 370 of file MaterialPropertyInterface.h.

371 {
372  return NULL;
373 }

◆ defaultMaterialProperty() [2/2]

const MaterialProperty< Real > * MaterialPropertyInterface::defaultMaterialProperty ( const std::string &  name)

Definition at line 65 of file MaterialPropertyInterface.C.

66 {
67  std::istringstream ss(name);
68  Real real_value;
69 
70  // check if the string parsed cleanly into a Real number
71  if (ss >> real_value && ss.eof())
72  {
73  _default_real_properties.emplace_back(libmesh_make_unique<MaterialProperty<Real>>());
74  auto & default_property = _default_real_properties.back();
75 
76  // resize to accomodate maximum number obf qpoints
77  auto nqp = _mi_feproblem.getMaxQps();
78  default_property->resize(nqp);
79 
80  // set values for all qpoints to the given default
81  for (decltype(nqp) qp = 0; qp < nqp; ++qp)
82  (*default_property)[qp] = real_value;
83 
84  // return the raw pointer inside the shared pointer
85  return default_property.get();
86  }
87 
88  return nullptr;
89 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
std::vector< std::unique_ptr< MaterialProperty< Real > > > _default_real_properties
Storage vector for MaterialProperty<Real> default objects.
unsigned int getMaxQps() const

◆ getADMaterialProperty()

template<typename T >
const ADMaterialPropertyObject< T > & MaterialPropertyInterface::getADMaterialProperty ( const std::string &  name)

Definition at line 312 of file MaterialPropertyInterface.h.

313 {
314  // Check if the supplied parameter is a valid input parameter key
315  std::string prop_name = deducePropertyName(name);
316 
317  // Check if it's just a constant
318  const ADMaterialPropertyObject<T> * default_property = defaultADMaterialProperty<T>(prop_name);
319  if (default_property)
320  return *default_property;
321 
322  return getADMaterialPropertyByName<T>(prop_name);
323 }
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.

◆ getADMaterialPropertyByName()

template<typename T >
const ADMaterialPropertyObject< T > & MaterialPropertyInterface::getADMaterialPropertyByName ( const MaterialPropertyName &  name)

Definition at line 408 of file MaterialPropertyInterface.h.

409 {
411 
413  checkMaterialProperty(name);
414 
415  // mark property as requested
416  markMatPropRequested(name);
417 
418  // Update the boolean flag.
420 
421  _material_property_dependencies.insert(_material_data->getPropertyId(name));
422 
423  return _material_data->getADProperty<T>(name);
424 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
void setUsingADFlag(bool using_ad)
Set the global automatic differentiaion (AD) flag which indicates whether any consumer has requested ...
std::set< unsigned int > _material_property_dependencies
The set of material properties (as given by their IDs) that this object depends on.
void markMatPropRequested(const std::string &)
A proxy method for _mi_feproblem.markMatPropRequested(name)
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
void checkMaterialProperty(const std::string &name)
A helper method for checking material properties This method was required to avoid a compiler problem...
bool _get_material_property_called
Initialized to false.
void checkExecutionStage()
Check and throw an error if the execution has progressed past the construction stage.

◆ getBlockMaterialProperty()

template<typename T >
std::pair< const MaterialProperty< T > *, std::set< SubdomainID > > MaterialPropertyInterface::getBlockMaterialProperty ( const MaterialPropertyName &  name)

Retrieve pointer to a material property with the mesh blocks where it is defined The name required by this method is the name defined in the input file.

This function can be thought as the combination of getMaterialPropertyByName and getMaterialPropertyBlocks. It can be called after the action of all actions.

Parameters
nameThe name of the material property to retrieve
Returns
Pointer to the material property with the name 'name' and the set of blocks where the property is valid

Definition at line 464 of file MaterialPropertyInterface.h.

465 {
466  if (_mi_block_ids.empty())
467  mooseError("getBlockMaterialProperty must be called by a block restrictable object");
468 
469  if (!hasMaterialPropertyByName<T>(name))
470  return std::pair<const MaterialProperty<T> *, std::set<SubdomainID>>(NULL,
471  std::set<SubdomainID>());
472 
473  _material_property_dependencies.insert(_material_data->getPropertyId(name));
474 
475  return std::pair<const MaterialProperty<T> *, std::set<SubdomainID>>(
476  &_material_data->getProperty<T>(name), _mi_feproblem.getMaterialPropertyBlocks(name));
477 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
const std::set< SubdomainID > & _mi_block_ids
Storage for the block ids created by BlockRestrictable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::set< unsigned int > _material_property_dependencies
The set of material properties (as given by their IDs) that this object depends on.
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
virtual std::set< SubdomainID > getMaterialPropertyBlocks(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:280
Concrete definition of a parameter value for a specified type.

◆ getMaterial()

Material & MaterialPropertyInterface::getMaterial ( const std::string &  name)

Return a Material reference - usable for computing directly.

Parameters
nameThe name of the input parameter or explicit material name.
no_warnIf true, suppress warning about retrieving the material potentially during its calculation. If you don't know what this is/means, then you don't need it.

Definition at line 170 of file MaterialPropertyInterface.C.

171 {
172  return getMaterialByName(_mi_params.get<MaterialName>(name));
173 }
Material & getMaterialByName(const std::string &name, bool no_warn=false)
const InputParameters & _mi_params
Parameters of the object with this interface.

◆ getMaterialByName()

Material & MaterialPropertyInterface::getMaterialByName ( const std::string &  name,
bool  no_warn = false 
)

Definition at line 176 of file MaterialPropertyInterface.C.

Referenced by getMaterial(), and MaterialVectorPostprocessor::MaterialVectorPostprocessor().

177 {
178  std::shared_ptr<Material> discrete =
180 
181  // Check block compatibility
182  if (!discrete->hasBlocks(_mi_block_ids))
183  {
184  std::ostringstream oss;
185  oss << "The Material object '" << discrete->name()
186  << "' is defined on blocks that are incompatible with the retrieving object '" << _mi_name
187  << "':\n";
188  oss << " " << discrete->name();
189  for (const auto & sbd_id : discrete->blockIDs())
190  oss << " " << sbd_id;
191  oss << "\n";
192  oss << " " << _mi_name;
193  for (const auto & block_id : _mi_block_ids)
194  oss << " " << block_id;
195  oss << "\n";
196  mooseError(oss.str());
197  }
198 
199  // Check boundary compatibility
200  if (!discrete->hasBoundary(_mi_boundary_ids))
201  {
202  std::ostringstream oss;
203  oss << "The Material object '" << discrete->name()
204  << "' is defined on boundaries that are incompatible with the retrieving object '"
205  << _mi_name << "':\n";
206  oss << " " << discrete->name();
207  for (const auto & bnd_id : discrete->boundaryIDs())
208  oss << " " << bnd_id;
209  oss << "\n";
210  oss << " " << _mi_name;
211  for (const auto & bnd_id : _mi_boundary_ids)
212  oss << " " << bnd_id;
213  oss << "\n";
214  mooseError(oss.str());
215  }
216 
217  return *discrete;
218 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
const THREAD_ID _mi_tid
Current threaded it.
const std::set< SubdomainID > & _mi_block_ids
Storage for the block ids created by BlockRestrictable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
Moose::MaterialDataType _material_data_type
The type of data.
std::shared_ptr< Material > getMaterial(std::string name, Moose::MaterialDataType type, THREAD_ID tid=0, bool no_warn=false)
Return a pointer to a Material object.
const std::set< BoundaryID > & _mi_boundary_ids
Storage for the boundary ids created by BoundaryRestrictable.
const std::string _mi_name
The name of the object that this interface belongs to.

◆ getMaterialProperty()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getMaterialProperty ( const std::string &  name)

Retrieve reference to material property or one of it's old or older values.

The name required by this method is the name that is hard-coded into your source code as the input parameter key. If no input parameter is found this behaves like the getMaterialPropertyByName family as a fall back.

Parameters
nameThe name of the parameter key of the material property to retrieve
Returns
Reference to the desired material property

Definition at line 297 of file MaterialPropertyInterface.h.

298 {
299  // Check if the supplied parameter is a valid input parameter key
300  std::string prop_name = deducePropertyName(name);
301 
302  // Check if it's just a constant
303  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
304  if (default_property)
305  return *default_property;
306 
307  return getMaterialPropertyByName<T>(prop_name);
308 }
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.
Concrete definition of a parameter value for a specified type.

◆ getMaterialPropertyBlockNames()

std::vector< SubdomainName > MaterialPropertyInterface::getMaterialPropertyBlockNames ( const std::string &  name)

Retrieve the block names that the material property is defined.

Parameters
nameThe name of the material property
Returns
A vector the the block names for the property

Definition at line 126 of file MaterialPropertyInterface.C.

127 {
129 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
virtual std::vector< SubdomainName > getMaterialPropertyBlockNames(const std::string &prop_name)
Get a vector of block id equivalences that the material property is defined on.
Definition: SubProblem.C:296

◆ getMaterialPropertyBlocks()

std::set< SubdomainID > MaterialPropertyInterface::getMaterialPropertyBlocks ( const std::string &  name)

Retrieve the block ids that the material property is defined.

Parameters
nameThe name of the material property
Returns
A vector the the block ids for the property

Definition at line 120 of file MaterialPropertyInterface.C.

121 {
123 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
virtual std::set< SubdomainID > getMaterialPropertyBlocks(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:280

◆ getMaterialPropertyBoundaryIDs()

std::set< BoundaryID > MaterialPropertyInterface::getMaterialPropertyBoundaryIDs ( const std::string &  name)

Retrieve the boundary ids that the material property is defined.

Parameters
nameThe name of the material property
Returns
A vector the the boundary ids for the property

Definition at line 132 of file MaterialPropertyInterface.C.

133 {
135 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
virtual std::set< BoundaryID > getMaterialPropertyBoundaryIDs(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:337

◆ getMaterialPropertyBoundaryNames()

std::vector< BoundaryName > MaterialPropertyInterface::getMaterialPropertyBoundaryNames ( const std::string &  name)

Retrieve the boundary namess that the material property is defined.

Parameters
nameThe name of the material property
Returns
A vector the the boundary names for the property

Definition at line 138 of file MaterialPropertyInterface.C.

139 {
141 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
virtual std::vector< BoundaryName > getMaterialPropertyBoundaryNames(const std::string &prop_name)
Get a vector of block id equivalences that the material property is defined on.
Definition: SubProblem.C:353

◆ getMaterialPropertyByName()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getMaterialPropertyByName ( const MaterialPropertyName &  name)

Retrieve reference to material property or its old or older value The name required by this method is the name defined in the input file.

Parameters
nameThe name of the material property to retrieve
Returns
Reference to the material property with the name 'name'

Definition at line 390 of file MaterialPropertyInterface.h.

391 {
393  checkMaterialProperty(name);
394 
395  // mark property as requested
396  markMatPropRequested(name);
397 
398  // Update the boolean flag.
400 
401  _material_property_dependencies.insert(_material_data->getPropertyId(name));
402 
403  return _material_data->getProperty<T>(name);
404 }
std::set< unsigned int > _material_property_dependencies
The set of material properties (as given by their IDs) that this object depends on.
void markMatPropRequested(const std::string &)
A proxy method for _mi_feproblem.markMatPropRequested(name)
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
void checkMaterialProperty(const std::string &name)
A helper method for checking material properties This method was required to avoid a compiler problem...
bool _get_material_property_called
Initialized to false.
void checkExecutionStage()
Check and throw an error if the execution has progressed past the construction stage.

◆ getMaterialPropertyCalled()

bool MaterialPropertyInterface::getMaterialPropertyCalled ( ) const
inline

Returns true if getMaterialProperty() has been called, false otherwise.

Definition at line 174 of file MaterialPropertyInterface.h.

bool _get_material_property_called
Initialized to false.

◆ getMaterialPropertyOld()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getMaterialPropertyOld ( const std::string &  name)

Definition at line 327 of file MaterialPropertyInterface.h.

328 {
329  if (!_stateful_allowed)
330  mooseError("Stateful material properties not allowed for this object."
331  " Old property for \"",
332  name,
333  "\" was requested.");
334 
335  // Check if the supplied parameter is a valid input parameter key
336  std::string prop_name = deducePropertyName(name);
337 
338  // Check if it's just a constant
339  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
340  if (default_property)
341  return *default_property;
342 
343  return getMaterialPropertyOldByName<T>(prop_name);
344 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.
Concrete definition of a parameter value for a specified type.
bool _stateful_allowed
True by default.

◆ getMaterialPropertyOldByName()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getMaterialPropertyOldByName ( const MaterialPropertyName &  name)

Definition at line 428 of file MaterialPropertyInterface.h.

429 {
430  if (!_stateful_allowed)
431  mooseError("Stateful material properties not allowed for this object."
432  " Old property for \"",
433  name,
434  "\" was requested.");
435 
436  // mark property as requested
437  markMatPropRequested(name);
438 
439  _material_property_dependencies.insert(_material_data->getPropertyId(name));
440 
441  return _material_data->getPropertyOld<T>(name);
442 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::set< unsigned int > _material_property_dependencies
The set of material properties (as given by their IDs) that this object depends on.
void markMatPropRequested(const std::string &)
A proxy method for _mi_feproblem.markMatPropRequested(name)
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
bool _stateful_allowed
True by default.

◆ getMaterialPropertyOlder()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getMaterialPropertyOlder ( const std::string &  name)

Definition at line 348 of file MaterialPropertyInterface.h.

349 {
350  if (!_stateful_allowed)
351  mooseError("Stateful material properties not allowed for this object."
352  " Older property for \"",
353  name,
354  "\" was requested.");
355 
356  // Check if the supplied parameter is a valid input parameter key
357  std::string prop_name = deducePropertyName(name);
358 
359  // Check if it's just a constant
360  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
361  if (default_property)
362  return *default_property;
363 
364  return getMaterialPropertyOlderByName<T>(prop_name);
365 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.
Concrete definition of a parameter value for a specified type.
bool _stateful_allowed
True by default.

◆ getMaterialPropertyOlderByName()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getMaterialPropertyOlderByName ( const MaterialPropertyName &  name)

Definition at line 446 of file MaterialPropertyInterface.h.

447 {
448  if (!_stateful_allowed)
449  mooseError("Stateful material properties not allowed for this object."
450  " Older property for \"",
451  name,
452  "\" was requested.");
453 
454  // mark property as requested
455  markMatPropRequested(name);
456 
457  _material_property_dependencies.insert(_material_data->getPropertyId(name));
458 
459  return _material_data->getPropertyOlder<T>(name);
460 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::set< unsigned int > _material_property_dependencies
The set of material properties (as given by their IDs) that this object depends on.
void markMatPropRequested(const std::string &)
A proxy method for _mi_feproblem.markMatPropRequested(name)
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
bool _stateful_allowed
True by default.

◆ getMatPropDependencies()

const std::set<unsigned int>& MaterialPropertyInterface::getMatPropDependencies ( ) const
inline

Retrieve the set of material properties that this object depends on.

Returns
The IDs corresponding to the material properties that MUST be reinited before evaluating this object

Definition at line 182 of file MaterialPropertyInterface.h.

Referenced by NodalPatchRecovery::reinitPatch().

183  {
185  }
std::set< unsigned int > _material_property_dependencies
The set of material properties (as given by their IDs) that this object depends on.

◆ getZeroMaterialProperty()

template<typename T >
const MaterialProperty< T > & MaterialPropertyInterface::getZeroMaterialProperty ( const std::string &  prop_name)

Return a material property that is initialized to zero by default and does not need to (but can) be declared by another material.

Definition at line 497 of file MaterialPropertyInterface.h.

498 {
499  // static zero property storage
500  static MaterialProperty<T> zero;
501 
502  // resize to accomodate maximum number of qpoints
503  // (in multiapp scenarios getMaxQps can return different values in each app; we need the max)
504  unsigned int nqp = _mi_feproblem.getMaxQps();
505  if (nqp > zero.size())
506  zero.resize(nqp);
507 
508  // set values for all qpoints to zero
509  for (unsigned int qp = 0; qp < nqp; ++qp)
510  mooseSetToZero<T>(zero[qp]);
511 
512  return zero;
513 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
virtual void resize(int n) override
Resizes the property to the size n.
Concrete definition of a parameter value for a specified type.
virtual unsigned int size() const override
unsigned int getMaxQps() const

◆ hasMaterialProperty()

template<typename T >
bool MaterialPropertyInterface::hasMaterialProperty ( const std::string &  name)

Check if the material property exists.

Parameters
namethe name of the property to query
Returns
true if the property exists, otherwise false

Definition at line 481 of file MaterialPropertyInterface.h.

482 {
483  // Check if the supplied parameter is a valid input parameter key
484  std::string prop_name = deducePropertyName(name);
485  return _material_data->haveProperty<T>(prop_name);
486 }
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.

◆ hasMaterialPropertyByName()

template<typename T >
bool MaterialPropertyInterface::hasMaterialPropertyByName ( const std::string &  name)

Definition at line 490 of file MaterialPropertyInterface.h.

491 {
492  return _material_data->haveProperty<T>(name);
493 }
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.

◆ markMatPropRequested()

void MaterialPropertyInterface::markMatPropRequested ( const std::string &  name)
protected

A proxy method for _mi_feproblem.markMatPropRequested(name)

Definition at line 158 of file MaterialPropertyInterface.C.

Referenced by getADMaterialPropertyByName(), getMaterialPropertyByName(), getMaterialPropertyOldByName(), and getMaterialPropertyOlderByName().

159 {
161 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
virtual void markMatPropRequested(const std::string &)
Helper method for adding a material property name to the _material_property_requested set...
Definition: SubProblem.C:535

◆ statefulPropertiesAllowed()

void MaterialPropertyInterface::statefulPropertiesAllowed ( bool  stateful_allowed)

Derived classes can declare whether or not they work with stateful material properties.

See, for example, DiracKernel. By default, they are allowed.

Definition at line 164 of file MaterialPropertyInterface.C.

Referenced by DiracKernel::DiracKernel().

165 {
166  _stateful_allowed = stateful_allowed;
167 }
bool _stateful_allowed
True by default.

Member Data Documentation

◆ _default_ad_real_properties

std::vector<std::unique_ptr<ADMaterialPropertyObject<Real> > > MaterialPropertyInterface::_default_ad_real_properties
protected

Storage vector for ADMaterialPropertyObject<Real> default objects.

Definition at line 253 of file MaterialPropertyInterface.h.

Referenced by defaultADMaterialProperty().

◆ _default_real_properties

std::vector<std::unique_ptr<MaterialProperty<Real> > > MaterialPropertyInterface::_default_real_properties
protected

Storage vector for MaterialProperty<Real> default objects.

Definition at line 251 of file MaterialPropertyInterface.h.

Referenced by defaultMaterialProperty().

◆ _get_material_property_called

bool MaterialPropertyInterface::_get_material_property_called
protected

Initialized to false.

Gets set to true when getMaterialProperty() is called. Clients of this class can inquire whether getMaterialProperty() has been called by calling getMaterialPropertyCalled().

Definition at line 248 of file MaterialPropertyInterface.h.

Referenced by getADMaterialPropertyByName(), getMaterialPropertyByName(), and getMaterialPropertyCalled().

◆ _material_data

std::shared_ptr<MaterialData> MaterialPropertyInterface::_material_data
protected

◆ _material_data_type

Moose::MaterialDataType MaterialPropertyInterface::_material_data_type
protected

◆ _material_property_dependencies

std::set<unsigned int> MaterialPropertyInterface::_material_property_dependencies
protected

The set of material properties (as given by their IDs) that this object depends on.

Definition at line 256 of file MaterialPropertyInterface.h.

Referenced by getADMaterialPropertyByName(), getBlockMaterialProperty(), getMaterialPropertyByName(), getMaterialPropertyOldByName(), getMaterialPropertyOlderByName(), and getMatPropDependencies().

◆ _mi_block_ids

const std::set<SubdomainID>& MaterialPropertyInterface::_mi_block_ids
private

Storage for the block ids created by BlockRestrictable.

Definition at line 266 of file MaterialPropertyInterface.h.

Referenced by checkMaterialProperty(), getBlockMaterialProperty(), and getMaterialByName().

◆ _mi_boundary_ids

const std::set<BoundaryID>& MaterialPropertyInterface::_mi_boundary_ids
private

Storage for the boundary ids created by BoundaryRestrictable.

Definition at line 269 of file MaterialPropertyInterface.h.

Referenced by checkMaterialProperty(), and getMaterialByName().

◆ _mi_boundary_restricted

const bool MaterialPropertyInterface::_mi_boundary_restricted
private

BoundaryRestricted flag.

Definition at line 263 of file MaterialPropertyInterface.h.

Referenced by checkMaterialProperty(), and MaterialPropertyInterface().

◆ _mi_feproblem

FEProblemBase& MaterialPropertyInterface::_mi_feproblem
protected

◆ _mi_name

const std::string MaterialPropertyInterface::_mi_name
protected

The name of the object that this interface belongs to.

Definition at line 192 of file MaterialPropertyInterface.h.

Referenced by checkMaterialProperty(), and getMaterialByName().

◆ _mi_params

const InputParameters& MaterialPropertyInterface::_mi_params
protected

Parameters of the object with this interface.

Definition at line 189 of file MaterialPropertyInterface.h.

Referenced by deducePropertyName(), getMaterial(), and MaterialPropertyInterface().

◆ _mi_tid

const THREAD_ID MaterialPropertyInterface::_mi_tid
protected

Current threaded it.

Definition at line 204 of file MaterialPropertyInterface.h.

Referenced by getMaterialByName().

◆ _stateful_allowed

bool MaterialPropertyInterface::_stateful_allowed
protected

True by default.

If false, this class throws an error if any of the stateful material properties interfaces are used.

Definition at line 241 of file MaterialPropertyInterface.h.

Referenced by getMaterialPropertyOld(), getMaterialPropertyOldByName(), getMaterialPropertyOlder(), getMaterialPropertyOlderByName(), and statefulPropertiesAllowed().


The documentation for this class was generated from the following files: