www.mooseframework.org
MaterialPropertyStorage.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef MATERIALPROPERTYSTORAGE_H
16 #define MATERIALPROPERTYSTORAGE_H
17 
18 #include "Moose.h"
19 #include "MaterialProperty.h"
20 #include "HashMap.h"
21 
22 // Forward declarations
23 class Material;
24 class MaterialData;
25 class QpMap;
26 
27 // libMesh forward declarations
28 namespace libMesh
29 {
30 class QBase;
31 }
32 
39 {
40 public:
42  virtual ~MaterialPropertyStorage();
43 
44  void releaseProperties();
45 
82  void prolongStatefulProps(const std::vector<std::vector<QpMap>> & refinement_map,
83  QBase & qrule,
84  QBase & qrule_face,
85  MaterialPropertyStorage & parent_material_props,
86  MaterialData & child_material_data,
87  const Elem & elem,
88  const int input_parent_side,
89  const int input_child,
90  const int input_child_side);
91 
104  void restrictStatefulProps(const std::vector<std::pair<unsigned int, QpMap>> & coarsening_map,
105  const std::vector<const Elem *> & coarsened_element_children,
106  QBase & qrule,
107  QBase & qrule_face,
108  MaterialData & material_data,
109  const Elem & elem,
110  int input_side = -1);
111 
120  void initStatefulProps(MaterialData & material_data,
121  const std::vector<std::shared_ptr<Material>> & mats,
122  unsigned int n_qpoints,
123  const Elem & elem,
124  unsigned int side = 0);
125 
133  void shift();
134 
148  void copy(MaterialData & material_data,
149  const Elem & elem_to,
150  const Elem & elem_from,
151  unsigned int side,
152  unsigned int n_qpoints);
153 
161  void swap(MaterialData & material_data, const Elem & elem, unsigned int side);
162 
170  void swapBack(MaterialData & material_data, const Elem & elem, unsigned int side);
171 
175  bool hasStatefulProperties() const { return _has_stateful_props; }
176 
180  bool hasOlderProperties() const { return _has_older_prop; }
181 
183 
188  {
189  return *_props_elem;
190  }
192  {
193  return *_props_elem_old;
194  }
196  {
197  return *_props_elem_older;
198  }
200  {
201  return *_props_elem;
202  }
204  {
205  return *_props_elem_old;
206  }
208  {
209  return *_props_elem_older;
210  }
211  MaterialProperties & props(const Elem * elem, unsigned int side)
212  {
213  return (*_props_elem)[elem][side];
214  }
215  MaterialProperties & propsOld(const Elem * elem, unsigned int side)
216  {
217  return (*_props_elem_old)[elem][side];
218  }
219  MaterialProperties & propsOlder(const Elem * elem, unsigned int side)
220  {
221  return (*_props_elem_older)[elem][side];
222  }
224 
225  bool hasProperty(const std::string & prop_name) const;
226 
229  unsigned int addProperty(const std::string & prop_name);
230  unsigned int addPropertyOld(const std::string & prop_name);
231  unsigned int addPropertyOlder(const std::string & prop_name);
232 
233  std::vector<unsigned int> & statefulProps() { return _stateful_prop_id_to_prop_id; }
234  const std::map<unsigned int, std::string> statefulPropNames() const { return _prop_names; }
235 
238  unsigned int getPropertyId(const std::string & prop_name);
239 
240  unsigned int retrievePropertyId(const std::string & prop_name) const;
241 
242  bool isStatefulProp(const std::string & prop_name) const
243  {
244  return _prop_names.count(retrievePropertyId(prop_name)) > 0;
245  }
246 
247 protected:
248  // indexing: [element][side]->material_properties
252 
256  static std::map<std::string, unsigned int> _prop_ids;
257 
263 
269 
271  std::map<unsigned int, std::string> _prop_names;
273  std::vector<unsigned int> _stateful_prop_id_to_prop_id;
274 
275  void sizeProps(MaterialProperties & mp, unsigned int size);
276 
277 private:
280  void initProps(MaterialData & material_data,
281  const Elem & elem,
282  unsigned int side,
283  unsigned int n_qpoints);
284 };
285 
286 template <>
287 inline void
288 dataStore(std::ostream & stream, MaterialPropertyStorage & storage, void * context)
289 {
290  dataStore(stream, storage.props(), context);
291  dataStore(stream, storage.propsOld(), context);
292 
293  if (storage.hasOlderProperties())
294  dataStore(stream, storage.propsOlder(), context);
295 }
296 
297 template <>
298 inline void
299 dataLoad(std::istream & stream, MaterialPropertyStorage & storage, void * context)
300 {
301  dataLoad(stream, storage.props(), context);
302  dataLoad(stream, storage.propsOld(), context);
303 
304  if (storage.hasOlderProperties())
305  dataLoad(stream, storage.propsOlder(), context);
306 }
307 
308 #endif /* MATERIALPROPERTYSTORAGE_H */
bool _has_stateful_props
Whether or not we have stateful properties.
MaterialProperties & propsOld(const Elem *elem, unsigned int side)
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
Definition: HashMap.h:24
Container for storing material properties.
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld()
Stores the stateful material properties computed by materials.
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) ...
const HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props() const
Helper object for holding qp mapping info.
Definition: MooseMesh.h:55
MaterialProperties & props(const Elem *elem, unsigned int side)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const std::map< unsigned int, std::string > statefulPropNames() const
void dataStore(std::ostream &stream, MaterialPropertyStorage &storage, void *context)
MaterialProperties & propsOlder(const Elem *elem, unsigned int side)
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder()
X_global swap(X_sys)
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...
std::map< unsigned int, std::string > _prop_names
mapping from property ID to property name
Materials compute MaterialProperties.
Definition: Material.h:53
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & props()
Access methods to the stored material property data.
bool _has_older_prop
True if any material requires older properties to be computed.
bool isStatefulProp(const std::string &prop_name) const
Proxy for accessing MaterialPropertyStorage.
Definition: MaterialData.h:33
const HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOlder() const
const HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > & propsOld() const
std::vector< unsigned int > & statefulProps()
void dataLoad(std::istream &stream, MaterialPropertyStorage &storage, void *context)
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_older
HashMap< const Elem *, HashMap< unsigned int, MaterialProperties > > * _props_elem_old