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

Constructor & Destructor Documentation

◆ MaterialPropertyStorage()

MaterialPropertyStorage::MaterialPropertyStorage ( )

Definition at line 59 of file MaterialPropertyStorage.C.

60  : _has_stateful_props(false), _has_older_prop(false)
61 {
62  _props_elem =
63  libmesh_make_unique<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties>>>();
65  libmesh_make_unique<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties>>>();
67  libmesh_make_unique<HashMap<const Elem *, HashMap<unsigned int, MaterialProperties>>>();
68 }
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 70 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 348 of file MaterialPropertyStorage.C.

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

349 {
350  return getPropertyId(prop_name);
351 }
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 354 of file MaterialPropertyStorage.C.

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

355 {
356  unsigned int prop_id = addProperty(prop_name);
357  _has_stateful_props = true;
358 
359  if (std::find(_stateful_prop_id_to_prop_id.begin(),
361  prop_id) == _stateful_prop_id_to_prop_id.end())
362  _stateful_prop_id_to_prop_id.push_back(prop_id);
363  _prop_names[prop_id] = prop_name;
364 
365  return prop_id;
366 }
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 369 of file MaterialPropertyStorage.C.

Referenced by MaterialData::getPropertyOlder().

370 {
371  _has_older_prop = true;
372  return addPropertyOld(prop_name);
373 }
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 295 of file MaterialPropertyStorage.C.

Referenced by MaterialData::copy().

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

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

377 {
378  auto it = _prop_ids.find(prop_name);
379  if (it != _prop_ids.end())
380  return it->second;
381 
382  auto id = _prop_ids.size();
383  _prop_ids[prop_name] = id;
384  return id;
385 }
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 177 of file MaterialPropertyStorage.h.

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

177 { 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 342 of file MaterialPropertyStorage.C.

Referenced by MaterialData::haveProperty().

343 {
344  return _prop_ids.count(prop_name) > 0;
345 }
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 172 of file MaterialPropertyStorage.h.

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

172 { 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 397 of file MaterialPropertyStorage.C.

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

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

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

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

240  {
241  return _prop_names.count(retrievePropertyId(prop_name)) > 0;
242  }
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 89 of file MaterialPropertyStorage.C.

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

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

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

185  {
186  return *_props_elem;
187  }
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 196 of file MaterialPropertyStorage.h.

197  {
198  return *_props_elem;
199  }
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 208 of file MaterialPropertyStorage.h.

209  {
210  return (*_props_elem)[elem][side];
211  }
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 188 of file MaterialPropertyStorage.h.

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

189  {
190  return *_props_elem_old;
191  }
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 200 of file MaterialPropertyStorage.h.

201  {
202  return *_props_elem_old;
203  }
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 212 of file MaterialPropertyStorage.h.

213  {
214  return (*_props_elem_old)[elem][side];
215  }
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 192 of file MaterialPropertyStorage.h.

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

193  {
194  return *_props_elem_older;
195  }
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 204 of file MaterialPropertyStorage.h.

205  {
206  return *_props_elem_older;
207  }
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 216 of file MaterialPropertyStorage.h.

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

◆ releaseProperties()

void MaterialPropertyStorage::releaseProperties ( )

Definition at line 73 of file MaterialPropertyStorage.C.

Referenced by ~MaterialPropertyStorage().

74 {
75  for (auto & i : *_props_elem)
76  for (auto & j : i.second)
77  j.second.destroy();
78 
79  for (auto & i : *_props_elem_old)
80  for (auto & j : i.second)
81  j.second.destroy();
82 
83  for (auto & i : *_props_elem_older)
84  for (auto & j : i.second)
85  j.second.destroy();
86 }
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 164 of file MaterialPropertyStorage.C.

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

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

Referenced by isStatefulProp().

389 {
390  auto it = _prop_ids.find(prop_name);
391  if (it == _prop_ids.end())
392  mooseError("MaterialPropertyStorage: property " + prop_name + " is not yet declared");
393  return it->second;
394 }
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 268 of file MaterialPropertyStorage.C.

Referenced by FEProblemBase::advanceState().

269 {
276  if (_has_older_prop)
278 
279  // Intentional fall through for case above and for handling just using old properties
281  if (fe_problem.usingADMatProps())
282  {
283  for (auto && elem_pair : (*_props_elem))
284  for (auto && side_pair : elem_pair.second)
285  for (auto && prop_value_ptr : side_pair.second)
286  prop_value_ptr->markAD(true);
287  for (auto && elem_pair : (*_props_elem_old))
288  for (auto && side_pair : elem_pair.second)
289  for (auto && prop_value_ptr : side_pair.second)
290  prop_value_ptr->markAD(false);
291  }
292 }
std::unique_ptr< HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > > _props_elem
void usingADMatProps(bool using_ad_mat_props)
Set the global automatic differentiaion (AD) flag which indicates whether any consumer has requested ...
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 231 of file MaterialPropertyStorage.h.

Referenced by FEProblemBase::checkDependMaterialsHelper().

231 { 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 230 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 315 of file MaterialPropertyStorage.C.

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

316 {
317  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
318 
319  shallowCopyData(_stateful_prop_id_to_prop_id, material_data.props(), props(&elem, side));
320  shallowCopyData(_stateful_prop_id_to_prop_id, material_data.propsOld(), propsOld(&elem, side));
321  if (hasOlderProperties())
323  _stateful_prop_id_to_prop_id, material_data.propsOlder(), propsOlder(&elem, side));
324 }
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 327 of file MaterialPropertyStorage.C.

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

330 {
331  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
332 
333  shallowCopyDataBack(_stateful_prop_id_to_prop_id, props(&elem, side), material_data.props());
335  _stateful_prop_id_to_prop_id, propsOld(&elem, side), material_data.propsOld());
336  if (hasOlderProperties())
338  _stateful_prop_id_to_prop_id, propsOlder(&elem, side), material_data.propsOlder());
339 }
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 266 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 260 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 254 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 269 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 271 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: