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 51 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:460
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:162
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:429
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:437
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 396 of file MaterialPropertyInterface.h.

397 {
398  return NULL;
399 }

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

389 {
390  return NULL;
391 }

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

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

435 {
437 
439  checkMaterialProperty(name);
440 
441  // mark property as requested
442  markMatPropRequested(name);
443 
444  // Update the boolean flag.
446 
447  _material_property_dependencies.insert(_material_data->getPropertyId(name));
448 
449  return _material_data->getADProperty<T>(name);
450 }
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 490 of file MaterialPropertyInterface.h.

491 {
492  if (_mi_block_ids.empty())
493  mooseError("getBlockMaterialProperty must be called by a block restrictable object");
494 
495  if (!hasMaterialPropertyByName<T>(name))
496  return std::pair<const MaterialProperty<T> *, std::set<SubdomainID>>(NULL,
497  std::set<SubdomainID>());
498 
499  _material_property_dependencies.insert(_material_data->getPropertyId(name));
500 
501  return std::pair<const MaterialProperty<T> *, std::set<SubdomainID>>(
502  &_material_data->getProperty<T>(name), _mi_feproblem.getMaterialPropertyBlocks(name));
503 }
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:290
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 315 of file MaterialPropertyInterface.h.

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

◆ 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:290

◆ 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:347

◆ 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:363

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

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

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

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

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

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

Referenced by NodalPatchRecovery::reinitPatch().

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

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

508 {
509  // Check if the supplied parameter is a valid input parameter key
510  std::string prop_name = deducePropertyName(name);
511  return hasMaterialPropertyByName<T>(prop_name);
512 }
std::string deducePropertyName(const std::string &name)
Small helper to look up a material property name through the input parameter keys.

◆ hasMaterialPropertyByName()

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

Definition at line 516 of file MaterialPropertyInterface.h.

517 {
518  return _material_data->haveProperty<T>(name);
519 }
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:545

◆ 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 268 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 271 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 266 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 263 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 274 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 287 of file MaterialPropertyInterface.h.

Referenced by checkBlockAndBoundaryCompatibility(), and checkMaterialProperty().

◆ _mi_boundary_restricted

const bool MaterialPropertyInterface::_mi_boundary_restricted
private

BoundaryRestricted flag.

Definition at line 281 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 207 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 204 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 219 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 256 of file MaterialPropertyInterface.h.

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


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