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

Stores the stateful material properties computed by materials. More...

#include <MaterialPropertyStorage.h>

Public Member Functions

 MaterialPropertyStorage ()
 
virtual ~MaterialPropertyStorage ()
 
void releaseProperties ()
 
void prolongStatefulProps (const std::vector< std::vector< QpMap >> &refinement_map, QBase &qrule, QBase &qrule_face, MaterialPropertyStorage &parent_material_props, MaterialData &child_material_data, const Elem &elem, const int input_parent_side, const int input_child, const int input_child_side)
 Creates storage for newly created elements from mesh Adaptivity. More...
 
void restrictStatefulProps (const std::vector< std::pair< unsigned int, QpMap >> &coarsening_map, const std::vector< const Elem *> &coarsened_element_children, QBase &qrule, QBase &qrule_face, MaterialData &material_data, const Elem &elem, int input_side=-1)
 Creates storage for newly created elements from mesh Adaptivity. More...
 
void initStatefulProps (MaterialData &material_data, const std::vector< std::shared_ptr< Material >> &mats, unsigned int n_qpoints, const Elem &elem, unsigned int side=0)
 Initialize stateful material properties. More...
 
void shift (const FEProblemBase &fe_problem)
 Shift the material properties in time. More...
 
void copy (MaterialData &material_data, const Elem &elem_to, const Elem &elem_from, unsigned int side, unsigned int n_qpoints)
 Copy material properties from elem_from to elem_to. More...
 
void swap (MaterialData &material_data, const Elem &elem, unsigned int side)
 Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe. More...
 
void swapBack (MaterialData &material_data, const Elem &elem, unsigned int side)
 Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe. More...
 
bool hasStatefulProperties () const
 
bool hasOlderProperties () const
 
bool hasProperty (const std::string &prop_name) const
 
unsigned int addProperty (const std::string &prop_name)
 The addProperty functions are idempotent - calling multiple times with the same name will provide the same id and works fine. More...
 
unsigned int addPropertyOld (const std::string &prop_name)
 
unsigned int addPropertyOlder (const std::string &prop_name)
 
std::vector< unsigned int > & statefulProps ()
 
const std::map< unsigned int, std::string > statefulPropNames () const
 
unsigned int getPropertyId (const std::string &prop_name)
 Returns the property ID for the given prop_name, adding the property and creating a new ID if it hasn't already been created. More...
 
unsigned int retrievePropertyId (const std::string &prop_name) const
 
bool isStatefulProp (const std::string &prop_name) const
 
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props ()
 Access methods to the stored material property data. More...
 
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld ()
 
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder ()
 
const HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props () const
 
const HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld () const
 
const HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder () const
 
MaterialPropertiesprops (const Elem *elem, unsigned int side)
 
MaterialPropertiespropsOld (const Elem *elem, unsigned int side)
 
MaterialPropertiespropsOlder (const Elem *elem, unsigned int side)
 

Protected Member Functions

void sizeProps (MaterialProperties &mp, unsigned int size)
 

Protected Attributes

std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem
 
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old
 
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older
 
bool _has_stateful_props
 Whether or not we have stateful properties. More...
 
bool _has_older_prop
 True if any material requires older properties to be computed. More...
 
std::map< unsigned int, std::string > _prop_names
 mapping from property ID to property name More...
 
std::vector< unsigned int > _stateful_prop_id_to_prop_id
 the vector of stateful property ids (the vector index is the map to stateful prop_id) More...
 

Static Protected Attributes

static std::map< std::string, unsigned int > _prop_ids
 mapping from property name to property ID NOTE: this is static so the property numbering is global within the simulation (not just FEProblemBase - should be useful when we will use material properties from one FEPRoblem in another one - if we will ever do it) More...
 

Private Member Functions

void initProps (MaterialData &material_data, const Elem &elem, unsigned int side, unsigned int n_qpoints)
 Initializes hashmap entries for element and side to proper qpoint and property count sizes. More...
 

Detailed Description

Stores the stateful material properties computed by materials.

Thread-safe

Definition at line 33 of file MaterialPropertyStorage.h.

Constructor & Destructor Documentation

◆ MaterialPropertyStorage()

MaterialPropertyStorage::MaterialPropertyStorage ( )

Definition at line 58 of file MaterialPropertyStorage.C.

59  : _has_stateful_props(false), _has_older_prop(false)
60 {
61  _props_elem =
62  libmesh_make_unique<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties>>>();
64  libmesh_make_unique<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties>>>();
66  libmesh_make_unique<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties>>>();
67 }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem
bool _has_stateful_props
Whether or not we have stateful properties.
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old
bool _has_older_prop
True if any material requires older properties to be computed.
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older

◆ ~MaterialPropertyStorage()

MaterialPropertyStorage::~MaterialPropertyStorage ( )
virtual

Definition at line 69 of file MaterialPropertyStorage.C.

Member Function Documentation

◆ addProperty()

unsigned int MaterialPropertyStorage::addProperty ( const std::string &  prop_name)

The addProperty functions are idempotent - calling multiple times with the same name will provide the same id and works fine.

Definition at line 347 of file MaterialPropertyStorage.C.

Referenced by addPropertyOld(), MaterialData::declareADProperty(), and MaterialData::declareProperty().

348 {
349  return getPropertyId(prop_name);
350 }
unsigned int getPropertyId(const std::string &prop_name)
Returns the property ID for the given prop_name, adding the property and creating a new ID if it hasn...

◆ addPropertyOld()

unsigned int MaterialPropertyStorage::addPropertyOld ( const std::string &  prop_name)

Definition at line 353 of file MaterialPropertyStorage.C.

Referenced by addPropertyOlder(), and MaterialData::getPropertyOld().

354 {
355  unsigned int prop_id = addProperty(prop_name);
356  _has_stateful_props = true;
357 
358  if (std::find(_stateful_prop_id_to_prop_id.begin(),
360  prop_id) == _stateful_prop_id_to_prop_id.end())
361  _stateful_prop_id_to_prop_id.push_back(prop_id);
362  _prop_names[prop_id] = prop_name;
363 
364  return prop_id;
365 }
bool _has_stateful_props
Whether or not we have stateful properties.
unsigned int addProperty(const std::string &prop_name)
The addProperty functions are idempotent - calling multiple times with the same name will provide the...
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
std::map< unsigned int, std::string > _prop_names
mapping from property ID to property name

◆ addPropertyOlder()

unsigned int MaterialPropertyStorage::addPropertyOlder ( const std::string &  prop_name)

Definition at line 368 of file MaterialPropertyStorage.C.

Referenced by MaterialData::getPropertyOlder().

369 {
370  _has_older_prop = true;
371  return addPropertyOld(prop_name);
372 }
unsigned int addPropertyOld(const std::string &prop_name)
bool _has_older_prop
True if any material requires older properties to be computed.

◆ copy()

void MaterialPropertyStorage::copy ( MaterialData material_data,
const Elem &  elem_to,
const Elem &  elem_from,
unsigned int  side,
unsigned int  n_qpoints 
)

Copy material properties from elem_from to elem_to.

Thread safe.

WARNING: This is not capable of copying material data to/from elements on other processors. It only works if both elem_to and elem_from are both on the local processor. We can't currently check to ensure that they're on processor here because this isn't a ParallelObject.

Parameters
material_dataMaterialData object to work with
elem_toElement to copy data to
elem_fromElement to copy data from
sideSide number (elemental material properties have this equal to zero)

Definition at line 294 of file MaterialPropertyStorage.C.

Referenced by MaterialData::copy().

299 {
300  initProps(material_data, elem_to, side, n_qpoints);
301  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
302  {
303  for (unsigned int qp = 0; qp < n_qpoints; ++qp)
304  {
305  props(&elem_to, side)[i]->qpCopy(qp, props(&elem_from, side)[i], qp);
306  propsOld(&elem_to, side)[i]->qpCopy(qp, propsOld(&elem_from, side)[i], qp);
307  if (hasOlderProperties())
308  propsOlder(&elem_to, side)[i]->qpCopy(qp, propsOlder(&elem_from, side)[i], qp);
309  }
310  }
311 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
void initProps(MaterialData &material_data, const Elem &elem, unsigned int side, unsigned int n_qpoints)
Initializes hashmap entries for element and side to proper qpoint and property count sizes...
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.

◆ getPropertyId()

unsigned int MaterialPropertyStorage::getPropertyId ( const std::string &  prop_name)

Returns the property ID for the given prop_name, adding the property and creating a new ID if it hasn't already been created.

Definition at line 375 of file MaterialPropertyStorage.C.

Referenced by addProperty(), and MaterialData::getPropertyId().

376 {
377  auto it = _prop_ids.find(prop_name);
378  if (it != _prop_ids.end())
379  return it->second;
380 
381  auto id = _prop_ids.size();
382  _prop_ids[prop_name] = id;
383  return id;
384 }
static std::map< std::string, unsigned int > _prop_ids
mapping from property name to property ID NOTE: this is static so the property numbering is global wi...

◆ hasOlderProperties()

bool MaterialPropertyStorage::hasOlderProperties ( ) const
inline
Returns
a Boolean indicating whether or not this material has older properties declared

Definition at line 175 of file MaterialPropertyStorage.h.

Referenced by copy(), dataLoad(), dataStore(), initProps(), initStatefulProps(), prolongStatefulProps(), MaterialData::resize(), restrictStatefulProps(), swap(), and swapBack().

175 { return _has_older_prop; }
bool _has_older_prop
True if any material requires older properties to be computed.

◆ hasProperty()

bool MaterialPropertyStorage::hasProperty ( const std::string &  prop_name) const

Definition at line 341 of file MaterialPropertyStorage.C.

Referenced by MaterialData::haveProperty().

342 {
343  return _prop_ids.count(prop_name) > 0;
344 }
static std::map< std::string, unsigned int > _prop_ids
mapping from property name to property ID NOTE: this is static so the property numbering is global wi...

◆ hasStatefulProperties()

bool MaterialPropertyStorage::hasStatefulProperties ( ) const
inline
Returns
a Boolean indicating whether stateful properties exist on this material

Definition at line 170 of file MaterialPropertyStorage.h.

Referenced by FEProblemBase::advanceState(), FEProblemBase::checkProblemIntegrity(), FEProblemBase::initialSetup(), initStatefulProps(), FEProblemBase::meshChangedHelper(), MaterialData::resize(), MaterialData::swap(), and MaterialData::swapBack().

170 { return _has_stateful_props; }
bool _has_stateful_props
Whether or not we have stateful properties.

◆ initProps()

void MaterialPropertyStorage::initProps ( MaterialData material_data,
const Elem &  elem,
unsigned int  side,
unsigned int  n_qpoints 
)
private

Initializes hashmap entries for element and side to proper qpoint and property count sizes.

Definition at line 396 of file MaterialPropertyStorage.C.

Referenced by copy(), initStatefulProps(), prolongStatefulProps(), and restrictStatefulProps().

400 {
401  material_data.resize(n_qpoints);
402  auto n = _stateful_prop_id_to_prop_id.size();
403 
404  if (props(&elem, side).size() < n)
405  props(&elem, side).resize(n, nullptr);
406  if (propsOld(&elem, side).size() < n)
407  propsOld(&elem, side).resize(n, nullptr);
408  if (propsOlder(&elem, side).size() < n)
409  propsOlder(&elem, side).resize(n, nullptr);
410 
411  // init properties (allocate memory. etc)
412  for (unsigned int i = 0; i < n; i++)
413  {
414  auto prop_id = _stateful_prop_id_to_prop_id[i];
415  // duplicate the stateful property in property storage (all three states - we will reuse the
416  // allocated memory there)
417  // also allocating the right amount of memory, so we do not have to resize, etc.
418  if (props(&elem, side)[i] == nullptr)
419  props(&elem, side)[i] = material_data.props()[prop_id]->init(n_qpoints);
420  if (propsOld(&elem, side)[i] == nullptr)
421  propsOld(&elem, side)[i] = material_data.propsOld()[prop_id]->init(n_qpoints);
422  if (hasOlderProperties() && propsOlder(&elem, side)[i] == nullptr)
423  propsOlder(&elem, side)[i] = material_data.propsOlder()[prop_id]->init(n_qpoints);
424  }
425 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
MaterialProperties & propsOld()
Definition: MaterialData.h:102
MaterialProperties & propsOlder()
Definition: MaterialData.h:103
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
PetscInt n
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.
MaterialProperties & props()
Methods for retrieving MaterialProperties object.
Definition: MaterialData.h:101
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:29

◆ initStatefulProps()

void MaterialPropertyStorage::initStatefulProps ( MaterialData material_data,
const std::vector< std::shared_ptr< Material >> &  mats,
unsigned int  n_qpoints,
const Elem &  elem,
unsigned int  side = 0 
)

Initialize stateful material properties.

Parameters
material_dataMaterilData object used for computing the data
matsMaterials that will compute the initial values
n_qpointsNumber of quadrature points
elemElement we are on
sideSide of the element 'elem' (0 for volumetric material properties)

Definition at line 220 of file MaterialPropertyStorage.C.

Referenced by ComputeMaterialsObjectThread::onBoundary(), ComputeMaterialsObjectThread::onElement(), and ComputeMaterialsObjectThread::onInternalSide().

225 {
226  // NOTE: since materials are storing their computed properties in MaterialData class, we need to
227  // juggle the memory between MaterialData and MaterialProperyStorage classes
228 
229  initProps(material_data, elem, side, n_qpoints);
230 
231  // copy from storage to material data
232  swap(material_data, elem, side);
233  // run custom init on properties
234  for (const auto & mat : mats)
235  mat->initStatefulProperties(n_qpoints);
236 
237  swapBack(material_data, elem, side);
238 
239  if (!hasStatefulProperties())
240  return;
241 
242  // This second call to initProps covers cases where code in
243  // "init[Qp]StatefulProperties" may have called a get/declare for a stateful
244  // property affecting the _stateful_prop_id_to_prop_id vector among other
245  // things. This is necessary because a call to
246  // getMaterialProperty[Old/Older] can potentially trigger a material to
247  // become stateful that previously wasn't. This needs to go after the
248  // swapBack.
249  initProps(material_data, elem, side, n_qpoints);
250 
251  // Copy the properties to Old and Older as needed
252  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
253  {
254  auto curr = props(&elem, side)[i];
255  auto old = propsOld(&elem, side)[i];
256  auto older = propsOlder(&elem, side)[i];
257  for (unsigned int qp = 0; qp < n_qpoints; ++qp)
258  {
259  old->qpCopy(qp, curr, qp);
260  if (hasOlderProperties())
261  older->qpCopy(qp, curr, qp);
262  }
263  }
264 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
void initProps(MaterialData &material_data, const Elem &elem, unsigned int side, unsigned int n_qpoints)
Initializes hashmap entries for element and side to proper qpoint and property count sizes...
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
void swap(MaterialData &material_data, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe...
void swapBack(MaterialData &material_data, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe...
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.

◆ isStatefulProp()

bool MaterialPropertyStorage::isStatefulProp ( const std::string &  prop_name) const
inline

Definition at line 237 of file MaterialPropertyStorage.h.

238  {
239  return _prop_names.count(retrievePropertyId(prop_name)) > 0;
240  }
std::map< unsigned int, std::string > _prop_names
mapping from property ID to property name
unsigned int retrievePropertyId(const std::string &prop_name) const

◆ prolongStatefulProps()

void MaterialPropertyStorage::prolongStatefulProps ( const std::vector< std::vector< QpMap >> &  refinement_map,
QBase &  qrule,
QBase &  qrule_face,
MaterialPropertyStorage parent_material_props,
MaterialData child_material_data,
const Elem &  elem,
const int  input_parent_side,
const int  input_child,
const int  input_child_side 
)

Creates storage for newly created elements from mesh Adaptivity.

Also, copies values from the parent qps to the new children.

Note - call this on the MaterialPropertyStorage object for the children that you want to project to. ie, if you are trying to project to the sides of the children, then call this on the boundary MaterialPropertyStorage. Pass in the parent MaterialPropertyStorage you are projecting from. ie the volume one if you are projecting to "internal" child element faces.

There are 3 cases here:

  1. Volume to volume (parent_side = -1, child = -1, child_side = -1) Call on volume MaterialPropertyStorage and pass volume MaterialPropertyStorage for parent_material_props
  2. Parent side to child side (parent_side = 0+, child = -1, child_side = 0+) where parent_side == child_side Call on boundary MaterialPropertyStorage and pass boundary MaterialPropertyStorage for parent_material_props
  3. Child side to parent volume (parent_side = -1, child = 0+, child_side = 0+) Call on boundary MaterialPropertyStorage and pass volume MaterialPropertyStorage for parent_material_props
Parameters
refinement_map- 2D array of QpMap objects
qruleThe current quadrature rule
qrule_faceThe current face qrule
parent_material_propsThe place to pull parent material property values from
child_material_dataMaterialData object used for computing the data
elemThe parent element that was just refined
input_parent_side- the side of the parent for which material properties are prolonged
input_child- the number of the child
input_child_side- the side on the child where material properties will be prolonged

Definition at line 88 of file MaterialPropertyStorage.C.

Referenced by ProjectMaterialProperties::onBoundary(), ProjectMaterialProperties::onElement(), and ProjectMaterialProperties::onInternalSide().

98 {
99  mooseAssert(input_child != -1 || input_parent_side == input_child_side, "Invalid inputs!");
100 
101  unsigned int n_qpoints = 0;
102 
103  // If we passed in -1 for these then we really need to store properties at 0
104  unsigned int parent_side = input_parent_side == -1 ? 0 : input_parent_side;
105  unsigned int child_side = input_child_side == -1 ? 0 : input_child_side;
106 
107  if (input_child_side == -1) // Not doing side projection (ie, doing volume projection)
108  n_qpoints = qrule.n_points();
109  else
110  n_qpoints = qrule_face.n_points();
111 
112  child_material_data.resize(n_qpoints);
113 
114  unsigned int n_children = elem.n_children();
115 
116  std::vector<unsigned int> children;
117 
118  if (input_child != -1) // Passed in a child explicitly
119  children.push_back(input_child);
120  else
121  {
122  children.resize(n_children);
123  for (unsigned int child = 0; child < n_children; child++)
124  children[child] = child;
125  }
126 
127  for (const auto & child : children)
128  {
129  // If we're not projecting an internal child side, but we are projecting sides, see if this
130  // child is on that side
131  if (input_child == -1 && input_child_side != -1 && !elem.is_child_on_side(child, parent_side))
132  continue;
133 
134  const Elem * child_elem = elem.child_ptr(child);
135 
136  mooseAssert(child < refinement_map.size(), "Refinement_map vector not initialized");
137  const std::vector<QpMap> & child_map = refinement_map[child];
138 
139  initProps(child_material_data, *child_elem, child_side, n_qpoints);
140 
141  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
142  {
143  // Copy from the parent stateful properties
144  for (unsigned int qp = 0; qp < refinement_map[child].size(); qp++)
145  {
146  PropertyValue * child_property = props(child_elem, child_side)[i];
147  mooseAssert(props().contains(&elem),
148  "Parent pointer is not in the MaterialProps data structure");
149  PropertyValue * parent_property = parent_material_props.props(&elem, parent_side)[i];
150 
151  child_property->qpCopy(qp, parent_property, child_map[qp]._to);
152  propsOld(child_elem, child_side)[i]->qpCopy(
153  qp, parent_material_props.propsOld(&elem, parent_side)[i], child_map[qp]._to);
154  if (hasOlderProperties())
155  propsOlder(child_elem, child_side)[i]->qpCopy(
156  qp, parent_material_props.propsOlder(&elem, parent_side)[i], child_map[qp]._to);
157  }
158  }
159  }
160 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
virtual void qpCopy(const unsigned int to_qp, PropertyValue *rhs, const unsigned int from_qp)=0
Copy the value of a Property from one specific to a specific qp in this Property. ...
void initProps(MaterialData &material_data, const Elem &elem, unsigned int side, unsigned int n_qpoints)
Initializes hashmap entries for element and side to proper qpoint and property count sizes...
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
Abstract definition of a property value.
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:29

◆ props() [1/3]

HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::props ( )
inline

Access methods to the stored material property data.

Definition at line 182 of file MaterialPropertyStorage.h.

Referenced by copy(), dataLoad(), dataStore(), initProps(), initStatefulProps(), prolongStatefulProps(), restrictStatefulProps(), swap(), and swapBack().

183  {
184  return *_props_elem;
185  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem

◆ props() [2/3]

const HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::props ( ) const
inline

Definition at line 194 of file MaterialPropertyStorage.h.

195  {
196  return *_props_elem;
197  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem

◆ props() [3/3]

MaterialProperties& MaterialPropertyStorage::props ( const Elem *  elem,
unsigned int  side 
)
inline

Definition at line 206 of file MaterialPropertyStorage.h.

207  {
208  return (*_props_elem)[elem][side];
209  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem

◆ propsOld() [1/3]

HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOld ( )
inline

Definition at line 186 of file MaterialPropertyStorage.h.

Referenced by copy(), dataLoad(), dataStore(), initProps(), initStatefulProps(), prolongStatefulProps(), restrictStatefulProps(), swap(), and swapBack().

187  {
188  return *_props_elem_old;
189  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old

◆ propsOld() [2/3]

const HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOld ( ) const
inline

Definition at line 198 of file MaterialPropertyStorage.h.

199  {
200  return *_props_elem_old;
201  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old

◆ propsOld() [3/3]

MaterialProperties& MaterialPropertyStorage::propsOld ( const Elem *  elem,
unsigned int  side 
)
inline

Definition at line 210 of file MaterialPropertyStorage.h.

211  {
212  return (*_props_elem_old)[elem][side];
213  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old

◆ propsOlder() [1/3]

HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOlder ( )
inline

Definition at line 190 of file MaterialPropertyStorage.h.

Referenced by copy(), dataLoad(), dataStore(), initProps(), initStatefulProps(), prolongStatefulProps(), restrictStatefulProps(), swap(), and swapBack().

191  {
192  return *_props_elem_older;
193  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older

◆ propsOlder() [2/3]

const HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOlder ( ) const
inline

Definition at line 202 of file MaterialPropertyStorage.h.

203  {
204  return *_props_elem_older;
205  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older

◆ propsOlder() [3/3]

MaterialProperties& MaterialPropertyStorage::propsOlder ( const Elem *  elem,
unsigned int  side 
)
inline

Definition at line 214 of file MaterialPropertyStorage.h.

215  {
216  return (*_props_elem_older)[elem][side];
217  }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older

◆ releaseProperties()

void MaterialPropertyStorage::releaseProperties ( )

Definition at line 72 of file MaterialPropertyStorage.C.

Referenced by ~MaterialPropertyStorage().

73 {
74  for (auto & i : *_props_elem)
75  for (auto & j : i.second)
76  j.second.destroy();
77 
78  for (auto & i : *_props_elem_old)
79  for (auto & j : i.second)
80  j.second.destroy();
81 
82  for (auto & i : *_props_elem_older)
83  for (auto & j : i.second)
84  j.second.destroy();
85 }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older

◆ restrictStatefulProps()

void MaterialPropertyStorage::restrictStatefulProps ( const std::vector< std::pair< unsigned int, QpMap >> &  coarsening_map,
const std::vector< const Elem *> &  coarsened_element_children,
QBase &  qrule,
QBase &  qrule_face,
MaterialData material_data,
const Elem &  elem,
int  input_side = -1 
)

Creates storage for newly created elements from mesh Adaptivity.

Also, copies values from the children to the parent.

Parameters
coarsening_map- map from unsigned ints to QpMap's
coarsened_element_children- a pointer to a vector of coarsened element children
qruleThe current quadrature rule
qrule_faceThe current face qrule
material_dataMaterialData object used for computing the data
elemThe parent element that was just refined
input_sideSide of the element 'elem' (0 for volumetric material properties)

Definition at line 163 of file MaterialPropertyStorage.C.

Referenced by ProjectMaterialProperties::onBoundary(), and ProjectMaterialProperties::onElement().

171 {
172  unsigned int side;
173 
174  bool doing_a_side = input_side != -1;
175 
176  unsigned int n_qpoints = 0;
177 
178  if (!doing_a_side)
179  {
180  side = 0; // Use 0 for the elem
181  n_qpoints = qrule.n_points();
182  }
183  else
184  {
185  side = input_side;
186  n_qpoints = qrule_face.n_points();
187  }
188 
189  initProps(material_data, elem, side, n_qpoints);
190 
191  // Copy from the child stateful properties
192  for (unsigned int qp = 0; qp < coarsening_map.size(); qp++)
193  {
194  const std::pair<unsigned int, QpMap> & qp_pair = coarsening_map[qp];
195  unsigned int child = qp_pair.first;
196 
197  mooseAssert(child < coarsened_element_children.size(),
198  "Coarsened element children vector not initialized");
199  const Elem * child_elem = coarsened_element_children[child];
200  const QpMap & qp_map = qp_pair.second;
201 
202  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
203  {
204  mooseAssert(props().contains(child_elem),
205  "Child element pointer is not in the MaterialProps data structure");
206 
207  PropertyValue * child_property = props(child_elem, side)[i];
208  PropertyValue * parent_property = props(&elem, side)[i];
209 
210  parent_property->qpCopy(qp, child_property, qp_map._to);
211 
212  propsOld(&elem, side)[i]->qpCopy(qp, propsOld(child_elem, side)[i], qp_map._to);
213  if (hasOlderProperties())
214  propsOlder(&elem, side)[i]->qpCopy(qp, propsOlder(child_elem, side)[i], qp_map._to);
215  }
216  }
217 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
Helper object for holding qp mapping info.
Definition: MooseMesh.h:53
unsigned int _to
The qp to map to.
Definition: MooseMesh.h:62
virtual void qpCopy(const unsigned int to_qp, PropertyValue *rhs, const unsigned int from_qp)=0
Copy the value of a Property from one specific to a specific qp in this Property. ...
void initProps(MaterialData &material_data, const Elem &elem, unsigned int side, unsigned int n_qpoints)
Initializes hashmap entries for element and side to proper qpoint and property count sizes...
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
Abstract definition of a property value.
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.

◆ retrievePropertyId()

unsigned int MaterialPropertyStorage::retrievePropertyId ( const std::string &  prop_name) const

Definition at line 387 of file MaterialPropertyStorage.C.

Referenced by isStatefulProp().

388 {
389  auto it = _prop_ids.find(prop_name);
390  if (it == _prop_ids.end())
391  mooseError("MaterialPropertyStorage: property " + prop_name + " is not yet declared");
392  return it->second;
393 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
static std::map< std::string, unsigned int > _prop_ids
mapping from property name to property ID NOTE: this is static so the property numbering is global wi...

◆ shift()

void MaterialPropertyStorage::shift ( const FEProblemBase fe_problem)

Shift the material properties in time.

Old material properties become older, current material properties become old. Older material properties are reused for computing current properties. This is called when solve succeeded.

Shift properties back in time and reuse older data for current (save reallocations etc.) With current, old, and older this can be accomplished by two swaps: older <-> old old <-> current

Definition at line 267 of file MaterialPropertyStorage.C.

Referenced by FEProblemBase::advanceState().

268 {
275  if (_has_older_prop)
277 
278  // Intentional fall through for case above and for handling just using old properties
280  if (fe_problem.usingAD())
281  {
282  for (auto && elem_pair : (*_props_elem))
283  for (auto && side_pair : elem_pair.second)
284  for (auto && prop_value_ptr : side_pair.second)
285  prop_value_ptr->markAD(true);
286  for (auto && elem_pair : (*_props_elem_old))
287  for (auto && side_pair : elem_pair.second)
288  for (auto && prop_value_ptr : side_pair.second)
289  prop_value_ptr->markAD(false);
290  }
291 }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem
bool usingAD() const
Whether any object has requested/supplied an AD material property.
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_old
X_global swap(X_sys)
bool _has_older_prop
True if any material requires older properties to be computed.
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem_older

◆ sizeProps()

void MaterialPropertyStorage::sizeProps ( MaterialProperties mp,
unsigned int  size 
)
protected

◆ statefulPropNames()

const std::map<unsigned int, std::string> MaterialPropertyStorage::statefulPropNames ( ) const
inline

Definition at line 229 of file MaterialPropertyStorage.h.

Referenced by FEProblemBase::checkDependMaterialsHelper().

229 { return _prop_names; }
std::map< unsigned int, std::string > _prop_names
mapping from property ID to property name

◆ statefulProps()

std::vector<unsigned int>& MaterialPropertyStorage::statefulProps ( )
inline

Definition at line 228 of file MaterialPropertyStorage.h.

std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...

◆ swap()

void MaterialPropertyStorage::swap ( MaterialData material_data,
const Elem &  elem,
unsigned int  side 
)

Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe.

Parameters
material_dataMaterialData object to work with
elemElement id
sideSide number (elemental material properties have this equal to zero)

Definition at line 314 of file MaterialPropertyStorage.C.

Referenced by initStatefulProps(), and MaterialData::swap().

315 {
316  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
317 
318  shallowCopyData(_stateful_prop_id_to_prop_id, material_data.props(), props(&elem, side));
319  shallowCopyData(_stateful_prop_id_to_prop_id, material_data.propsOld(), propsOld(&elem, side));
320  if (hasOlderProperties())
322  _stateful_prop_id_to_prop_id, material_data.propsOlder(), propsOlder(&elem, side));
323 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
MaterialProperties & propsOld()
Definition: MaterialData.h:102
MaterialProperties & propsOlder()
Definition: MaterialData.h:103
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.
void shallowCopyData(const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)
Shallow copy the material properties.
MaterialProperties & props()
Methods for retrieving MaterialProperties object.
Definition: MaterialData.h:101

◆ swapBack()

void MaterialPropertyStorage::swapBack ( MaterialData material_data,
const Elem &  elem,
unsigned int  side 
)

Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe.

Parameters
material_dataMaterialData object to work with
elemElement id
sideSide number (elemental material properties have this equal to zero)

Definition at line 326 of file MaterialPropertyStorage.C.

Referenced by initStatefulProps(), and MaterialData::swapBack().

329 {
330  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
331 
332  shallowCopyDataBack(_stateful_prop_id_to_prop_id, props(&elem, side), material_data.props());
334  _stateful_prop_id_to_prop_id, propsOld(&elem, side), material_data.propsOld());
335  if (hasOlderProperties())
337  _stateful_prop_id_to_prop_id, propsOlder(&elem, side), material_data.propsOlder());
338 }
void shallowCopyDataBack(const std::vector< unsigned int > &stateful_prop_ids, MaterialProperties &data, MaterialProperties &data_from)
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
std::vector< unsigned int > _stateful_prop_id_to_prop_id
the vector of stateful property ids (the vector index is the map to stateful prop_id) ...
MaterialProperties & propsOld()
Definition: MaterialData.h:102
MaterialProperties & propsOlder()
Definition: MaterialData.h:103
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.
MaterialProperties & props()
Methods for retrieving MaterialProperties object.
Definition: MaterialData.h:101

Member Data Documentation

◆ _has_older_prop

bool MaterialPropertyStorage::_has_older_prop
protected

True if any material requires older properties to be computed.

This will get automatically set to true if a older stateful property is declared.

Definition at line 264 of file MaterialPropertyStorage.h.

Referenced by addPropertyOlder(), hasOlderProperties(), and shift().

◆ _has_stateful_props

bool MaterialPropertyStorage::_has_stateful_props
protected

Whether or not we have stateful properties.

This will get automatically set to true if a stateful property is declared.

Definition at line 258 of file MaterialPropertyStorage.h.

Referenced by addPropertyOld(), and hasStatefulProperties().

◆ _prop_ids

std::map< std::string, unsigned int > MaterialPropertyStorage::_prop_ids
staticprotected

mapping from property name to property ID NOTE: this is static so the property numbering is global within the simulation (not just FEProblemBase - should be useful when we will use material properties from one FEPRoblem in another one - if we will ever do it)

Definition at line 252 of file MaterialPropertyStorage.h.

Referenced by getPropertyId(), hasProperty(), and retrievePropertyId().

◆ _prop_names

std::map<unsigned int, std::string> MaterialPropertyStorage::_prop_names
protected

mapping from property ID to property name

Definition at line 267 of file MaterialPropertyStorage.h.

Referenced by addPropertyOld(), isStatefulProp(), and statefulPropNames().

◆ _props_elem

std::unique_ptr<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> > > MaterialPropertyStorage::_props_elem
protected

◆ _props_elem_old

std::unique_ptr<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> > > MaterialPropertyStorage::_props_elem_old
protected

◆ _props_elem_older

std::unique_ptr<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> > > MaterialPropertyStorage::_props_elem_older
protected

◆ _stateful_prop_id_to_prop_id

std::vector<unsigned int> MaterialPropertyStorage::_stateful_prop_id_to_prop_id
protected

the vector of stateful property ids (the vector index is the map to stateful prop_id)

Definition at line 269 of file MaterialPropertyStorage.h.

Referenced by addPropertyOld(), copy(), initProps(), initStatefulProps(), prolongStatefulProps(), restrictStatefulProps(), statefulProps(), swap(), and swapBack().


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