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 ()
 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

HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
 
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
 
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 38 of file MaterialPropertyStorage.h.

Constructor & Destructor Documentation

MaterialPropertyStorage::MaterialPropertyStorage ( )

Definition at line 63 of file MaterialPropertyStorage.C.

64  : _has_stateful_props(false), _has_older_prop(false)
65 {
69 }
bool _has_stateful_props
Whether or not we have stateful properties.
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
Definition: HashMap.h:24
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
bool _has_older_prop
True if any material requires older properties to be computed.
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
MaterialPropertyStorage::~MaterialPropertyStorage ( )
virtual

Definition at line 71 of file MaterialPropertyStorage.C.

72 {
74 
75  delete _props_elem;
76  delete _props_elem_old;
77  delete _props_elem_older;
78 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old

Member Function Documentation

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 346 of file MaterialPropertyStorage.C.

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

347 {
348  return getPropertyId(prop_name);
349 }
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...
unsigned int MaterialPropertyStorage::addPropertyOld ( const std::string &  prop_name)

Definition at line 352 of file MaterialPropertyStorage.C.

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

353 {
354  unsigned int prop_id = addProperty(prop_name);
355  _has_stateful_props = true;
356 
357  if (std::find(_stateful_prop_id_to_prop_id.begin(),
359  prop_id) == _stateful_prop_id_to_prop_id.end())
360  _stateful_prop_id_to_prop_id.push_back(prop_id);
361  _prop_names[prop_id] = prop_name;
362 
363  return prop_id;
364 }
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
unsigned int MaterialPropertyStorage::addPropertyOlder ( const std::string &  prop_name)

Definition at line 367 of file MaterialPropertyStorage.C.

Referenced by MaterialData::getPropertyOlder().

368 {
369  _has_older_prop = true;
370  return addPropertyOld(prop_name);
371 }
unsigned int addPropertyOld(const std::string &prop_name)
bool _has_older_prop
True if any material requires older properties to be computed.
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 293 of file MaterialPropertyStorage.C.

Referenced by MaterialData::copy().

298 {
299  initProps(material_data, elem_to, side, n_qpoints);
300  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
301  {
302  for (unsigned int qp = 0; qp < n_qpoints; ++qp)
303  {
304  props(&elem_to, side)[i]->qpCopy(qp, props(&elem_from, side)[i], qp);
305  propsOld(&elem_to, side)[i]->qpCopy(qp, propsOld(&elem_from, side)[i], qp);
306  if (hasOlderProperties())
307  propsOlder(&elem_to, side)[i]->qpCopy(qp, propsOlder(&elem_from, side)[i], qp);
308  }
309  }
310 }
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.
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 374 of file MaterialPropertyStorage.C.

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

375 {
376  auto it = _prop_ids.find(prop_name);
377  if (it != _prop_ids.end())
378  return it->second;
379 
380  auto id = _prop_ids.size();
381  _prop_ids[prop_name] = id;
382  return id;
383 }
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...
bool MaterialPropertyStorage::hasOlderProperties ( ) const
inline
Returns
a Boolean indicating whether or not this material has older properties declared

Definition at line 180 of file MaterialPropertyStorage.h.

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

180 { return _has_older_prop; }
bool _has_older_prop
True if any material requires older properties to be computed.
bool MaterialPropertyStorage::hasProperty ( const std::string &  prop_name) const

Definition at line 340 of file MaterialPropertyStorage.C.

Referenced by MaterialData::haveProperty().

341 {
342  return _prop_ids.count(prop_name) > 0;
343 }
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...
bool MaterialPropertyStorage::hasStatefulProperties ( ) const
inline
Returns
a Boolean indicating whether stateful properties exist on this material

Definition at line 175 of file MaterialPropertyStorage.h.

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

175 { return _has_stateful_props; }
bool _has_stateful_props
Whether or not we have stateful properties.
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 395 of file MaterialPropertyStorage.C.

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

399 {
400  material_data.resize(n_qpoints);
401  auto n = _stateful_prop_id_to_prop_id.size();
402 
403  if (props(&elem, side).size() < n)
404  props(&elem, side).resize(n, nullptr);
405  if (propsOld(&elem, side).size() < n)
406  propsOld(&elem, side).resize(n, nullptr);
407  if (propsOlder(&elem, side).size() < n)
408  propsOlder(&elem, side).resize(n, nullptr);
409 
410  // init properties (allocate memory. etc)
411  for (unsigned int i = 0; i < n; i++)
412  {
413  auto prop_id = _stateful_prop_id_to_prop_id[i];
414  // duplicate the stateful property in property storage (all three states - we will reuse the
415  // allocated memory there)
416  // also allocating the right amount of memory, so we do not have to resize, etc.
417  if (props(&elem, side)[i] == nullptr)
418  props(&elem, side)[i] = material_data.props()[prop_id]->init(n_qpoints);
419  if (propsOld(&elem, side)[i] == nullptr)
420  propsOld(&elem, side)[i] = material_data.propsOld()[prop_id]->init(n_qpoints);
421  if (hasOlderProperties() && propsOlder(&elem, side)[i] == nullptr)
422  propsOlder(&elem, side)[i] = material_data.propsOlder()[prop_id]->init(n_qpoints);
423  }
424 }
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:98
MaterialProperties & propsOlder()
Definition: MaterialData.h:99
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:97
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:34
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 229 of file MaterialPropertyStorage.C.

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

234 {
235  // NOTE: since materials are storing their computed properties in MaterialData class, we need to
236  // juggle the memory between MaterialData and MaterialProperyStorage classes
237 
238  initProps(material_data, elem, side, n_qpoints);
239 
240  // copy from storage to material data
241  swap(material_data, elem, side);
242  // run custom init on properties
243  for (const auto & mat : mats)
244  mat->initStatefulProperties(n_qpoints);
245 
246  swapBack(material_data, elem, side);
247 
248  if (!hasStatefulProperties())
249  return;
250 
251  // This second call to initProps covers cases where code in
252  // "init[Qp]StatefulProperties" may have called a get/declare for a stateful
253  // property affecting the _stateful_prop_id_to_prop_id vector among other
254  // things. This is necessary because a call to
255  // getMaterialProperty[Old/Older] can potentially trigger a material to
256  // become stateful that previously wasn't. This needs to go after the
257  // swapBack.
258  initProps(material_data, elem, side, n_qpoints);
259 
260  // Copy the properties to Old and Older as needed
261  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
262  {
263  auto curr = props(&elem, side)[i];
264  auto old = propsOld(&elem, side)[i];
265  auto older = propsOlder(&elem, side)[i];
266  for (unsigned int qp = 0; qp < n_qpoints; ++qp)
267  {
268  old->qpCopy(qp, curr, qp);
269  if (hasOlderProperties())
270  older->qpCopy(qp, curr, qp);
271  }
272  }
273 }
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.
bool MaterialPropertyStorage::isStatefulProp ( const std::string &  prop_name) const
inline

Definition at line 242 of file MaterialPropertyStorage.h.

243  {
244  return _prop_names.count(retrievePropertyId(prop_name)) > 0;
245  }
unsigned int retrievePropertyId(const std::string &prop_name) const
std::map< unsigned int, std::string > _prop_names
mapping from property ID to property name
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 97 of file MaterialPropertyStorage.C.

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

107 {
108  mooseAssert(input_child != -1 || input_parent_side == input_child_side, "Invalid inputs!");
109 
110  unsigned int n_qpoints = 0;
111 
112  // If we passed in -1 for these then we really need to store properties at 0
113  unsigned int parent_side = input_parent_side == -1 ? 0 : input_parent_side;
114  unsigned int child_side = input_child_side == -1 ? 0 : input_child_side;
115 
116  if (input_child_side == -1) // Not doing side projection (ie, doing volume projection)
117  n_qpoints = qrule.n_points();
118  else
119  n_qpoints = qrule_face.n_points();
120 
121  child_material_data.resize(n_qpoints);
122 
123  unsigned int n_children = elem.n_children();
124 
125  std::vector<unsigned int> children;
126 
127  if (input_child != -1) // Passed in a child explicitly
128  children.push_back(input_child);
129  else
130  {
131  children.resize(n_children);
132  for (unsigned int child = 0; child < n_children; child++)
133  children[child] = child;
134  }
135 
136  for (const auto & child : children)
137  {
138  // If we're not projecting an internal child side, but we are projecting sides, see if this
139  // child is on that side
140  if (input_child == -1 && input_child_side != -1 && !elem.is_child_on_side(child, parent_side))
141  continue;
142 
143  const Elem * child_elem = elem.child(child);
144 
145  mooseAssert(child < refinement_map.size(), "Refinement_map vector not initialized");
146  const std::vector<QpMap> & child_map = refinement_map[child];
147 
148  initProps(child_material_data, *child_elem, child_side, n_qpoints);
149 
150  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
151  {
152  // Copy from the parent stateful properties
153  for (unsigned int qp = 0; qp < refinement_map[child].size(); qp++)
154  {
155  PropertyValue * child_property = props(child_elem, child_side)[i];
156  mooseAssert(props().contains(&elem),
157  "Parent pointer is not in the MaterialProps data structure");
158  PropertyValue * parent_property = parent_material_props.props(&elem, parent_side)[i];
159 
160  child_property->qpCopy(qp, parent_property, child_map[qp]._to);
161  propsOld(child_elem, child_side)[i]->qpCopy(
162  qp, parent_material_props.propsOld(&elem, parent_side)[i], child_map[qp]._to);
163  if (hasOlderProperties())
164  propsOlder(child_elem, child_side)[i]->qpCopy(
165  qp, parent_material_props.propsOlder(&elem, parent_side)[i], child_map[qp]._to);
166  }
167  }
168  }
169 }
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:34
HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::props ( )
inline

Access methods to the stored material property data.

Definition at line 187 of file MaterialPropertyStorage.h.

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

188  {
189  return *_props_elem;
190  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
const HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::props ( ) const
inline

Definition at line 199 of file MaterialPropertyStorage.h.

200  {
201  return *_props_elem;
202  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
MaterialProperties& MaterialPropertyStorage::props ( const Elem *  elem,
unsigned int  side 
)
inline

Definition at line 211 of file MaterialPropertyStorage.h.

212  {
213  return (*_props_elem)[elem][side];
214  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOld ( )
inline

Definition at line 191 of file MaterialPropertyStorage.h.

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

192  {
193  return *_props_elem_old;
194  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
const HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOld ( ) const
inline

Definition at line 203 of file MaterialPropertyStorage.h.

204  {
205  return *_props_elem_old;
206  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
MaterialProperties& MaterialPropertyStorage::propsOld ( const Elem *  elem,
unsigned int  side 
)
inline

Definition at line 215 of file MaterialPropertyStorage.h.

216  {
217  return (*_props_elem_old)[elem][side];
218  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOlder ( )
inline

Definition at line 195 of file MaterialPropertyStorage.h.

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

196  {
197  return *_props_elem_older;
198  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
const HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >& MaterialPropertyStorage::propsOlder ( ) const
inline

Definition at line 207 of file MaterialPropertyStorage.h.

208  {
209  return *_props_elem_older;
210  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
MaterialProperties& MaterialPropertyStorage::propsOlder ( const Elem *  elem,
unsigned int  side 
)
inline

Definition at line 219 of file MaterialPropertyStorage.h.

220  {
221  return (*_props_elem_older)[elem][side];
222  }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
void MaterialPropertyStorage::releaseProperties ( )

Definition at line 81 of file MaterialPropertyStorage.C.

Referenced by ~MaterialPropertyStorage().

82 {
83  for (auto & i : *_props_elem)
84  for (auto & j : i.second)
85  j.second.destroy();
86 
87  for (auto & i : *_props_elem_old)
88  for (auto & j : i.second)
89  j.second.destroy();
90 
91  for (auto & i : *_props_elem_older)
92  for (auto & j : i.second)
93  j.second.destroy();
94 }
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
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 172 of file MaterialPropertyStorage.C.

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

180 {
181  unsigned int side;
182 
183  bool doing_a_side = input_side != -1;
184 
185  unsigned int n_qpoints = 0;
186 
187  if (!doing_a_side)
188  {
189  side = 0; // Use 0 for the elem
190  n_qpoints = qrule.n_points();
191  }
192  else
193  {
194  side = input_side;
195  n_qpoints = qrule_face.n_points();
196  }
197 
198  initProps(material_data, elem, side, n_qpoints);
199 
200  // Copy from the child stateful properties
201  for (unsigned int qp = 0; qp < coarsening_map.size(); qp++)
202  {
203  const std::pair<unsigned int, QpMap> & qp_pair = coarsening_map[qp];
204  unsigned int child = qp_pair.first;
205 
206  mooseAssert(child < coarsened_element_children.size(),
207  "Coarsened element children vector not initialized");
208  const Elem * child_elem = coarsened_element_children[child];
209  const QpMap & qp_map = qp_pair.second;
210 
211  for (unsigned int i = 0; i < _stateful_prop_id_to_prop_id.size(); ++i)
212  {
213  mooseAssert(props().contains(child_elem),
214  "Child element pointer is not in the MaterialProps data structure");
215 
216  PropertyValue * child_property = props(child_elem, side)[i];
217  PropertyValue * parent_property = props(&elem, side)[i];
218 
219  parent_property->qpCopy(qp, child_property, qp_map._to);
220 
221  propsOld(&elem, side)[i]->qpCopy(qp, propsOld(child_elem, side)[i], qp_map._to);
222  if (hasOlderProperties())
223  propsOlder(&elem, side)[i]->qpCopy(qp, propsOlder(child_elem, side)[i], qp_map._to);
224  }
225  }
226 }
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:55
unsigned int _to
The qp to map to.
Definition: MooseMesh.h:64
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.
unsigned int MaterialPropertyStorage::retrievePropertyId ( const std::string &  prop_name) const

Definition at line 386 of file MaterialPropertyStorage.C.

387 {
388  auto it = _prop_ids.find(prop_name);
389  if (it == _prop_ids.end())
390  mooseError("MaterialPropertyStorage: property " + prop_name + " is not yet declared");
391  return it->second;
392 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
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...
void MaterialPropertyStorage::shift ( )

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.

Definition at line 276 of file MaterialPropertyStorage.C.

Referenced by FEProblemBase::advanceState().

277 {
278  if (_has_older_prop)
279  {
280  // shift the properties back in time and reuse older for current (save reallocations etc.)
284  _props_elem = tmp;
285  }
286  else
287  {
289  }
290 }
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
Definition: HashMap.h:24
X_global swap(X_sys)
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
bool _has_older_prop
True if any material requires older properties to be computed.
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old
void MaterialPropertyStorage::sizeProps ( MaterialProperties mp,
unsigned int  size 
)
protected
const std::map<unsigned int, std::string> MaterialPropertyStorage::statefulPropNames ( ) const
inline

Definition at line 234 of file MaterialPropertyStorage.h.

Referenced by FEProblemBase::checkDependMaterialsHelper().

234 { return _prop_names; }
std::map< unsigned int, std::string > _prop_names
mapping from property ID to property name
std::vector<unsigned int>& MaterialPropertyStorage::statefulProps ( )
inline

Definition at line 233 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) ...
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 313 of file MaterialPropertyStorage.C.

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

314 {
315  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
316 
317  shallowCopyData(_stateful_prop_id_to_prop_id, material_data.props(), props(&elem, side));
318  shallowCopyData(_stateful_prop_id_to_prop_id, material_data.propsOld(), propsOld(&elem, side));
319  if (hasOlderProperties())
321  _stateful_prop_id_to_prop_id, material_data.propsOlder(), propsOlder(&elem, side));
322 }
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:98
MaterialProperties & propsOlder()
Definition: MaterialData.h:99
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:97
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 325 of file MaterialPropertyStorage.C.

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

328 {
329  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
330 
331  shallowCopyDataBack(_stateful_prop_id_to_prop_id, props(&elem, side), material_data.props());
333  _stateful_prop_id_to_prop_id, propsOld(&elem, side), material_data.propsOld());
334  if (hasOlderProperties())
336  _stateful_prop_id_to_prop_id, propsOlder(&elem, side), material_data.propsOlder());
337 }
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:98
MaterialProperties & propsOlder()
Definition: MaterialData.h:99
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:97

Member Data Documentation

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 268 of file MaterialPropertyStorage.h.

Referenced by addPropertyOlder(), and shift().

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 262 of file MaterialPropertyStorage.h.

Referenced by addPropertyOld().

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 256 of file MaterialPropertyStorage.h.

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

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

mapping from property ID to property name

Definition at line 271 of file MaterialPropertyStorage.h.

Referenced by addPropertyOld().

HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >* MaterialPropertyStorage::_props_elem
protected
HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >* MaterialPropertyStorage::_props_elem_old
protected
HashMap<const Elem *, HashMap<unsigned int, MaterialProperties> >* MaterialPropertyStorage::_props_elem_older
protected
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 273 of file MaterialPropertyStorage.h.

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


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