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 checkBlockAndBoundaryCompatibility (std::shared_ptr< Material > discrete)
 Check if block and boundary restrictions of a given material are compatible with the current material. 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<>
MaterialgetMaterialByName (const std::string &name, bool no_warn)
 
template<>
MaterialgetMaterialByName (const std::string &name, bool no_warn)
 
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<ComputeStage >
MaterialgetMaterial (const std::string &name)
 
template<ComputeStage >
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...
 
template<>
const ADMaterialPropertyObject< Real > * defaultADMaterialProperty (const std::string &name)
 
template<>
const ADMaterialPropertyObject< RealVectorValue > * defaultADMaterialProperty (const std::string &name)
 

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::vector< std::unique_ptr< ADMaterialPropertyObject< RealVectorValue > > > _default_ad_real_vector_properties
 Storage vector for ADMaterialPropertyObject<RealVectorValue> 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 49 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:431
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:62
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:126
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

◆ checkBlockAndBoundaryCompatibility()

void MaterialPropertyInterface::checkBlockAndBoundaryCompatibility ( std::shared_ptr< Material discrete)

Check if block and boundary restrictions of a given material are compatible with the current material.

Error out otherwise.

Definition at line 211 of file MaterialPropertyInterface.C.

Referenced by getMaterialByName().

212 {
213  // Check block compatibility
214  if (!discrete->hasBlocks(_mi_block_ids))
215  {
216  std::ostringstream oss;
217  oss << "The Material object '" << discrete->name()
218  << "' is defined on blocks that are incompatible with the retrieving object '" << _mi_name
219  << "':\n";
220  oss << " " << discrete->name();
221  for (const auto & sbd_id : discrete->blockIDs())
222  oss << " " << sbd_id;
223  oss << "\n";
224  oss << " " << _mi_name;
225  for (const auto & block_id : _mi_block_ids)
226  oss << " " << block_id;
227  oss << "\n";
228  mooseError(oss.str());
229  }
230 
231  // Check boundary compatibility
232  if (!discrete->hasBoundary(_mi_boundary_ids))
233  {
234  std::ostringstream oss;
235  oss << "The Material object '" << discrete->name()
236  << "' is defined on boundaries that are incompatible with the retrieving object '"
237  << _mi_name << "':\n";
238  oss << " " << discrete->name();
239  for (const auto & bnd_id : discrete->boundaryIDs())
240  oss << " " << bnd_id;
241  oss << "\n";
242  oss << " " << _mi_name;
243  for (const auto & bnd_id : _mi_boundary_ids)
244  oss << " " << bnd_id;
245  oss << "\n";
246  mooseError(oss.str());
247  }
248 }
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
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.

◆ checkExecutionStage()

void MaterialPropertyInterface::checkExecutionStage ( )
private

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

Definition at line 286 of file MaterialPropertyInterface.C.

Referenced by getADMaterialPropertyByName(), and getMaterialPropertyByName().

287 {
289  mooseError("Material properties must be retrieved during object construction to ensure correct "
290  "problem integrity validation.");
291 }
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 179 of file MaterialPropertyInterface.C.

Referenced by getADMaterialPropertyByName(), and getMaterialPropertyByName().

180 {
181  // If the material property is boundary restrictable, add to the list of materials to check
183  for (const auto & bnd_id : _mi_boundary_ids)
185 
186  // The default is to assume block restrictions
187  else
188  for (const auto & blk_ids : _mi_block_ids)
190 }
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:420
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:428
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

◆ defaultADMaterialProperty() [1/3]

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 394 of file MaterialPropertyInterface.h.

395 {
396  return NULL;
397 }

◆ defaultADMaterialProperty() [2/3]

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

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(
102  libmesh_make_unique<ADMaterialPropertyObject<Real>>(true));
103  auto & default_property = _default_ad_real_properties.back();
104 
105  // resize to accomodate maximum number obf qpoints
106  auto nqp = _mi_feproblem.getMaxQps();
107  default_property->resize(nqp);
108 
109  // set values for all qpoints to the given default
110  for (decltype(nqp) qp = 0; qp < nqp; ++qp)
111  {
112  // This sets the dual number member of the MooseADWrapper for Jacobian calculations
113  (*default_property)[qp] = real_value;
114  // This sets the value member of the MooseADWrapper for residual calculations
115  default_property->set()[qp].value() = real_value;
116  }
117 
118  // return the raw pointer inside the shared pointer
119  return default_property.get();
120  }
121 
122  return nullptr;
123 }
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() [3/3]

const ADMaterialPropertyObject< RealVectorValue > * MaterialPropertyInterface::defaultADMaterialProperty ( const std::string &  name)
protected

Definition at line 127 of file MaterialPropertyInterface.C.

128 {
129  std::istringstream ss(name);
130  Real real_value;
131 
132  // check if the string parsed cleanly into a Real number
133  if (ss >> real_value && ss.eof())
134  {
136  libmesh_make_unique<ADMaterialPropertyObject<RealVectorValue>>());
137  auto & default_property = _default_ad_real_vector_properties.back();
138 
139  // resize to accomodate maximum number obf qpoints
140  auto nqp = _mi_feproblem.getMaxQps();
141  default_property->resize(nqp);
142 
143  // set values for all qpoints to the given default
144  for (decltype(nqp) qp = 0; qp < nqp; ++qp)
145  (*default_property)[qp] = real_value;
146 
147  // return the raw pointer inside the shared pointer
148  return default_property.get();
149  }
150 
151  return nullptr;
152 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
std::vector< std::unique_ptr< ADMaterialPropertyObject< RealVectorValue > > > _default_ad_real_vector_properties
Storage vector for ADMaterialPropertyObject<RealVectorValue> default objects.
unsigned int getMaxQps() const

◆ 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 386 of file MaterialPropertyInterface.h.

387 {
388  return NULL;
389 }

◆ 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 328 of file MaterialPropertyInterface.h.

329 {
330  // Check if the supplied parameter is a valid input parameter key
331  std::string prop_name = deducePropertyName(name);
332 
333  // Check if it's just a constant
334  const ADMaterialPropertyObject<T> * default_property = defaultADMaterialProperty<T>(prop_name);
335  if (default_property)
336  return *default_property;
337 
338  return getADMaterialPropertyByName<T>(prop_name);
339 }
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 432 of file MaterialPropertyInterface.h.

433 {
435 
437  checkMaterialProperty(name);
438 
439  // mark property as requested
440  markMatPropRequested(name);
441 
442  // Update the boolean flag.
444 
445  _material_property_dependencies.insert(_material_data->getPropertyId(name));
446 
447  return _material_data->getADProperty<T>(name);
448 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
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)
void usingADMatProps(bool using_ad_mat_props)
Set the global automatic differentiaion (AD) flag which indicates whether any consumer has requested ...
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 488 of file MaterialPropertyInterface.h.

489 {
490  if (_mi_block_ids.empty())
491  mooseError("getBlockMaterialProperty must be called by a block restrictable object");
492 
493  if (!hasMaterialPropertyByName<T>(name))
494  return std::pair<const MaterialProperty<T> *, std::set<SubdomainID>>(NULL,
495  std::set<SubdomainID>());
496 
497  _material_property_dependencies.insert(_material_data->getPropertyId(name));
498 
499  return std::pair<const MaterialProperty<T> *, std::set<SubdomainID>>(
500  &_material_data->getProperty<T>(name), _mi_feproblem.getMaterialPropertyBlocks(name));
501 }
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:281
Concrete definition of a parameter value for a specified type.

◆ getMaterial() [1/2]

template Material & MaterialPropertyInterface::getMaterial< JACOBIAN > ( 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 205 of file MaterialPropertyInterface.C.

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

◆ getMaterial() [2/2]

template<ComputeStage compute_stage>
Material & MaterialPropertyInterface::getMaterial ( const std::string &  name)

Definition at line 261 of file MaterialPropertyInterface.C.

262 {
263  return getMaterialByName<compute_stage>(_mi_params.get<MaterialName>(name));
264 }
const InputParameters & _mi_params
Parameters of the object with this interface.

◆ getMaterialByName() [1/4]

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

Definition at line 251 of file MaterialPropertyInterface.C.

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

252 {
253  std::shared_ptr<Material> discrete =
256  return *discrete;
257 }
FEProblemBase & _mi_feproblem
Reference to the FEProblemBase class.
const THREAD_ID _mi_tid
Current threaded it.
void checkBlockAndBoundaryCompatibility(std::shared_ptr< Material > discrete)
Check if block and boundary restrictions of a given material are compatible with the current material...
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.

◆ getMaterialByName() [2/4]

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

◆ getMaterialByName() [3/4]

template<>
Material& MaterialPropertyInterface::getMaterialByName ( const std::string &  name,
bool  no_warn 
)

Definition at line 268 of file MaterialPropertyInterface.C.

269 {
270  const std::string new_name = name + "_residual";
271  return getMaterialByName(new_name, no_warn);
272 }
Material & getMaterialByName(const std::string &name, bool no_warn=false)

◆ getMaterialByName() [4/4]

template<>
Material& MaterialPropertyInterface::getMaterialByName ( const std::string &  name,
bool  no_warn 
)

Definition at line 276 of file MaterialPropertyInterface.C.

277 {
278  const std::string new_name = name + "_jacobian";
279  return getMaterialByName(new_name, no_warn);
280 }
Material & getMaterialByName(const std::string &name, bool no_warn=false)

◆ 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 313 of file MaterialPropertyInterface.h.

314 {
315  // Check if the supplied parameter is a valid input parameter key
316  std::string prop_name = deducePropertyName(name);
317 
318  // Check if it's just a constant
319  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
320  if (default_property)
321  return *default_property;
322 
323  return getMaterialPropertyByName<T>(prop_name);
324 }
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 161 of file MaterialPropertyInterface.C.

162 {
164 }
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:297

◆ 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 155 of file MaterialPropertyInterface.C.

156 {
158 }
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:281

◆ 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 167 of file MaterialPropertyInterface.C.

168 {
170 }
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:338

◆ 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 173 of file MaterialPropertyInterface.C.

174 {
176 }
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:354

◆ 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 414 of file MaterialPropertyInterface.h.

415 {
417  checkMaterialProperty(name);
418 
419  // mark property as requested
420  markMatPropRequested(name);
421 
422  // Update the boolean flag.
424 
425  _material_property_dependencies.insert(_material_data->getPropertyId(name));
426 
427  return _material_data->getProperty<T>(name);
428 }
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 187 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 343 of file MaterialPropertyInterface.h.

344 {
345  if (!_stateful_allowed)
346  mooseError("Stateful material properties not allowed for this object."
347  " Old property for \"",
348  name,
349  "\" was requested.");
350 
351  // Check if the supplied parameter is a valid input parameter key
352  std::string prop_name = deducePropertyName(name);
353 
354  // Check if it's just a constant
355  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
356  if (default_property)
357  return *default_property;
358 
359  return getMaterialPropertyOldByName<T>(prop_name);
360 }
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 452 of file MaterialPropertyInterface.h.

453 {
454  if (!_stateful_allowed)
455  mooseError("Stateful material properties not allowed for this object."
456  " Old property for \"",
457  name,
458  "\" was requested.");
459 
460  // mark property as requested
461  markMatPropRequested(name);
462 
463  _material_property_dependencies.insert(_material_data->getPropertyId(name));
464 
465  return _material_data->getPropertyOld<T>(name);
466 }
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 364 of file MaterialPropertyInterface.h.

365 {
366  if (!_stateful_allowed)
367  mooseError("Stateful material properties not allowed for this object."
368  " Older property for \"",
369  name,
370  "\" was requested.");
371 
372  // Check if the supplied parameter is a valid input parameter key
373  std::string prop_name = deducePropertyName(name);
374 
375  // Check if it's just a constant
376  const MaterialProperty<T> * default_property = defaultMaterialProperty<T>(prop_name);
377  if (default_property)
378  return *default_property;
379 
380  return getMaterialPropertyOlderByName<T>(prop_name);
381 }
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 470 of file MaterialPropertyInterface.h.

471 {
472  if (!_stateful_allowed)
473  mooseError("Stateful material properties not allowed for this object."
474  " Older property for \"",
475  name,
476  "\" was requested.");
477 
478  // mark property as requested
479  markMatPropRequested(name);
480 
481  _material_property_dependencies.insert(_material_data->getPropertyId(name));
482 
483  return _material_data->getPropertyOlder<T>(name);
484 }
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 195 of file MaterialPropertyInterface.h.

Referenced by NodalPatchRecovery::reinitPatch().

196  {
198  }
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 521 of file MaterialPropertyInterface.h.

522 {
523  // static zero property storage
524  static MaterialProperty<T> zero;
525 
526  // resize to accomodate maximum number of qpoints
527  // (in multiapp scenarios getMaxQps can return different values in each app; we need the max)
528  unsigned int nqp = _mi_feproblem.getMaxQps();
529  if (nqp > zero.size())
530  zero.resize(nqp);
531 
532  // set values for all qpoints to zero
533  for (unsigned int qp = 0; qp < nqp; ++qp)
534  mooseSetToZero<T>(zero[qp]);
535 
536  return zero;
537 }
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 505 of file MaterialPropertyInterface.h.

506 {
507  // Check if the supplied parameter is a valid input parameter key
508  std::string prop_name = deducePropertyName(name);
509  return _material_data->haveProperty<T>(prop_name);
510 }
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 514 of file MaterialPropertyInterface.h.

515 {
516  return _material_data->haveProperty<T>(name);
517 }
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 193 of file MaterialPropertyInterface.C.

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

194 {
196 }
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:536

◆ 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 199 of file MaterialPropertyInterface.C.

Referenced by DiracKernel::DiracKernel().

200 {
201  _stateful_allowed = stateful_allowed;
202 }
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 266 of file MaterialPropertyInterface.h.

Referenced by defaultADMaterialProperty().

◆ _default_ad_real_vector_properties

std::vector<std::unique_ptr<ADMaterialPropertyObject<RealVectorValue> > > MaterialPropertyInterface::_default_ad_real_vector_properties
protected

Storage vector for ADMaterialPropertyObject<RealVectorValue> default objects.

Definition at line 269 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 264 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 261 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 272 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

◆ _mi_boundary_ids

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

Storage for the boundary ids created by BoundaryRestrictable.

Definition at line 285 of file MaterialPropertyInterface.h.

Referenced by checkBlockAndBoundaryCompatibility(), and checkMaterialProperty().

◆ _mi_boundary_restricted

const bool MaterialPropertyInterface::_mi_boundary_restricted
private

BoundaryRestricted flag.

Definition at line 279 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 205 of file MaterialPropertyInterface.h.

Referenced by checkBlockAndBoundaryCompatibility(), and checkMaterialProperty().

◆ _mi_params

const InputParameters& MaterialPropertyInterface::_mi_params
protected

Parameters of the object with this interface.

Definition at line 202 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 217 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 254 of file MaterialPropertyInterface.h.

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


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