https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
IndexableProperty< T, is_ad > Class Template Reference

IndexableProperty is a helper (proxy) object to obtain a scalar component from a material property. More...

#include <IndexableProperty.h>

Public Member Functions

 IndexableProperty (T *host, const std::string &property_param="property", const std::string &component_param="component")
 
GenericReal< is_ad > operator[] (int qp) const
 get the selected component value for the given quadrature point More...
 
void check () const
 integrity check More...
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

void checkComponents (unsigned int components) const
 

Protected Attributes

T * _host
 pointer to the host object More...
 
const std::string & _property_param
 name of the input parameter containing the material property name More...
 
const std::string & _property_name
 name of the coupled material property (for error reporting) More...
 
const std::string & _component_param
 name of the input parameter containing the component index More...
 
const std::vector< unsigned int_component
 Index of the selected scalar component of the material property. More...
 
const GenericOptionalMaterialProperty< Real, is_ad > & _property_real
 only one of those pointers will be non-null and pointing to the selected property More...
 
const GenericOptionalMaterialProperty< std::vector< Real >, is_ad > & _property_std_vector
 
const GenericOptionalMaterialProperty< RealVectorValue, is_ad > & _property_real_vector_value
 
const GenericOptionalMaterialProperty< RankTwoTensor, is_ad > & _property_rank_two_tensor
 
const GenericOptionalMaterialProperty< RankThreeTensor, is_ad > & _property_rank_three_tensor
 
const GenericOptionalMaterialProperty< RankFourTensor, is_ad > & _property_rank_four_tensor
 

Detailed Description

template<typename T, bool is_ad>
class IndexableProperty< T, is_ad >

IndexableProperty is a helper (proxy) object to obtain a scalar component from a material property.

Use it in objects that process a scalar quantity instead of a Real material property to allow the user to supply any material property of a type from the list below along with a component index parameter to select a scalar component from the property value.

Definition at line 23 of file IndexableProperty.h.

Constructor & Destructor Documentation

◆ IndexableProperty()

template<typename T, bool is_ad>
IndexableProperty< T, is_ad >::IndexableProperty ( T *  host,
const std::string &  property_param = "property",
const std::string &  component_param = "component" 
)

Definition at line 80 of file IndexableProperty.h.

83  : _host(host),
84  _property_param(property_param),
85  _property_name(_host->template getParam<MaterialPropertyName>(_property_param)),
86  _component_param(component_param),
87  _component(host->template getParam<std::vector<unsigned int>>(_component_param)),
89  _host->template getGenericOptionalMaterialProperty<Real, is_ad>(_property_param)),
91  _host->template getGenericOptionalMaterialProperty<std::vector<Real>, is_ad>(
94  _host->template getGenericOptionalMaterialProperty<RealVectorValue, is_ad>(
97  _host->template getGenericOptionalMaterialProperty<RankTwoTensor, is_ad>(_property_param)),
99  _host->template getGenericOptionalMaterialProperty<RankThreeTensor, is_ad>(
100  _property_param)),
102  _host->template getGenericOptionalMaterialProperty<RankFourTensor, is_ad>(_property_param))
103 {
104 }
const std::string & _component_param
name of the input parameter containing the component index
const GenericOptionalMaterialProperty< RankTwoTensor, is_ad > & _property_rank_two_tensor
const std::vector< unsigned int > _component
Index of the selected scalar component of the material property.
const std::string & _property_param
name of the input parameter containing the material property name
const GenericOptionalMaterialProperty< RankThreeTensor, is_ad > & _property_rank_three_tensor
const GenericOptionalMaterialProperty< std::vector< Real >, is_ad > & _property_std_vector
T * _host
pointer to the host object
const GenericOptionalMaterialProperty< Real, is_ad > & _property_real
only one of those pointers will be non-null and pointing to the selected property ...
const std::string & _property_name
name of the coupled material property (for error reporting)
const GenericOptionalMaterialProperty< RealVectorValue, is_ad > & _property_real_vector_value
const GenericOptionalMaterialProperty< RankFourTensor, is_ad > & _property_rank_four_tensor

Member Function Documentation

◆ check()

template<typename T , bool is_ad>
void IndexableProperty< T, is_ad >::check ( ) const

integrity check

Definition at line 128 of file IndexableProperty.h.

Referenced by NodalPatchRecoveryMaterialProperty::initialSetup().

129 {
130  if (_property_real)
131  checkComponents(0);
132  else if (_property_std_vector)
133  checkComponents(1);
135  checkComponents(1);
136  else if (_property_rank_two_tensor)
137  checkComponents(2);
139  checkComponents(3);
141  checkComponents(4);
142  else
143  _host->mooseError("The ",
144  is_ad ? "AD" : "non-AD",
145  " material property '",
147  "' does not exist");
148 }
void checkComponents(unsigned int components) const
const GenericOptionalMaterialProperty< RankTwoTensor, is_ad > & _property_rank_two_tensor
const GenericOptionalMaterialProperty< RankThreeTensor, is_ad > & _property_rank_three_tensor
const GenericOptionalMaterialProperty< std::vector< Real >, is_ad > & _property_std_vector
T * _host
pointer to the host object
const GenericOptionalMaterialProperty< Real, is_ad > & _property_real
only one of those pointers will be non-null and pointing to the selected property ...
const std::string & _property_name
name of the coupled material property (for error reporting)
const GenericOptionalMaterialProperty< RealVectorValue, is_ad > & _property_real_vector_value
const GenericOptionalMaterialProperty< RankFourTensor, is_ad > & _property_rank_four_tensor

◆ checkComponents()

template<typename T , bool is_ad>
void IndexableProperty< T, is_ad >::checkComponents ( unsigned int  components) const
protected

Definition at line 152 of file IndexableProperty.h.

153 {
154  if (_component.size() != components)
155  _host->mooseError("Material property '",
157  "' is ",
158  components,
159  "-dimensional, but an index vector of size ",
160  _component.size(),
161  " was supplied to select a component. It looks like you were expecting the "
162  "material property to have a different type.");
163 }
const std::vector< unsigned int > _component
Index of the selected scalar component of the material property.
T * _host
pointer to the host object
const std::string & _property_name
name of the coupled material property (for error reporting)

◆ operator[]()

template<typename T , bool is_ad>
GenericReal< is_ad > IndexableProperty< T, is_ad >::operator[] ( int  qp) const

get the selected component value for the given quadrature point

Definition at line 108 of file IndexableProperty.h.

109 {
110  if (_property_real)
111  return _property_real[qp];
113  return _property_std_vector[qp][_component[0]];
121  return _property_rank_four_tensor[qp](
122  _component[0], _component[1], _component[2], _component[3]);
123  _host->mooseError("internal error in IndexableProperty");
124 }
const GenericOptionalMaterialProperty< RankTwoTensor, is_ad > & _property_rank_two_tensor
const std::vector< unsigned int > _component
Index of the selected scalar component of the material property.
const GenericOptionalMaterialProperty< RankThreeTensor, is_ad > & _property_rank_three_tensor
const GenericOptionalMaterialProperty< std::vector< Real >, is_ad > & _property_std_vector
T * _host
pointer to the host object
const GenericOptionalMaterialProperty< Real, is_ad > & _property_real
only one of those pointers will be non-null and pointing to the selected property ...
const GenericOptionalMaterialProperty< RealVectorValue, is_ad > & _property_real_vector_value
const GenericOptionalMaterialProperty< RankFourTensor, is_ad > & _property_rank_four_tensor

◆ validParams()

template<typename T , bool is_ad>
InputParameters IndexableProperty< T, is_ad >::validParams ( )
static

Definition at line 66 of file IndexableProperty.h.

Referenced by NodalPatchRecoveryMaterialProperty::validParams(), and SideIntegralMaterialPropertyTempl< is_ad >::validParams().

67 {
68  auto params = T::validParams();
69  params.template addRequiredParam<MaterialPropertyName>("property",
70  "The name of the material property");
71  params.template addParam<std::vector<unsigned int>>(
72  "component",
73  {},
74  "Index vector of the scalar component to extract from "
75  "the material property (empty for scalar properties)");
76  return params;
77 }
InputParameters validParams()

Member Data Documentation

◆ _component

template<typename T, bool is_ad>
const std::vector<unsigned int> IndexableProperty< T, is_ad >::_component
protected

Index of the selected scalar component of the material property.

Definition at line 52 of file IndexableProperty.h.

◆ _component_param

template<typename T, bool is_ad>
const std::string& IndexableProperty< T, is_ad >::_component_param
protected

name of the input parameter containing the component index

Definition at line 49 of file IndexableProperty.h.

◆ _host

template<typename T, bool is_ad>
T* IndexableProperty< T, is_ad >::_host
protected

pointer to the host object

Definition at line 42 of file IndexableProperty.h.

◆ _property_name

template<typename T, bool is_ad>
const std::string& IndexableProperty< T, is_ad >::_property_name
protected

name of the coupled material property (for error reporting)

Definition at line 47 of file IndexableProperty.h.

◆ _property_param

template<typename T, bool is_ad>
const std::string& IndexableProperty< T, is_ad >::_property_param
protected

name of the input parameter containing the material property name

Definition at line 45 of file IndexableProperty.h.

◆ _property_rank_four_tensor

template<typename T, bool is_ad>
const GenericOptionalMaterialProperty<RankFourTensor, is_ad>& IndexableProperty< T, is_ad >::_property_rank_four_tensor
protected

Definition at line 60 of file IndexableProperty.h.

◆ _property_rank_three_tensor

template<typename T, bool is_ad>
const GenericOptionalMaterialProperty<RankThreeTensor, is_ad>& IndexableProperty< T, is_ad >::_property_rank_three_tensor
protected

Definition at line 59 of file IndexableProperty.h.

◆ _property_rank_two_tensor

template<typename T, bool is_ad>
const GenericOptionalMaterialProperty<RankTwoTensor, is_ad>& IndexableProperty< T, is_ad >::_property_rank_two_tensor
protected

Definition at line 58 of file IndexableProperty.h.

◆ _property_real

template<typename T, bool is_ad>
const GenericOptionalMaterialProperty<Real, is_ad>& IndexableProperty< T, is_ad >::_property_real
protected

only one of those pointers will be non-null and pointing to the selected property

Definition at line 55 of file IndexableProperty.h.

◆ _property_real_vector_value

template<typename T, bool is_ad>
const GenericOptionalMaterialProperty<RealVectorValue, is_ad>& IndexableProperty< T, is_ad >::_property_real_vector_value
protected

Definition at line 57 of file IndexableProperty.h.

◆ _property_std_vector

template<typename T, bool is_ad>
const GenericOptionalMaterialProperty<std::vector<Real>, is_ad>& IndexableProperty< T, is_ad >::_property_std_vector
protected

Definition at line 56 of file IndexableProperty.h.


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