www.mooseframework.org
MaterialData.C
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 #include "MaterialData.h"
16 #include "Material.h"
17 
19  : _storage(storage), _n_qpoints(0), _swapped(false)
20 {
21 }
22 
24 
25 void
27 {
28  _props.destroy();
31 }
32 
33 void
34 MaterialData::resize(unsigned int n_qpoints)
35 {
36  if (n_qpoints == _n_qpoints)
37  return;
38 
39  _props.resizeItems(n_qpoints);
40  // if there are stateful material properties in the system, also resize
41  // storage for old and older material properties
43  _props_old.resizeItems(n_qpoints);
45  _props_older.resizeItems(n_qpoints);
46  _n_qpoints = n_qpoints;
47 }
48 
49 unsigned int
51 {
52  return _n_qpoints;
53 }
54 
55 void
56 MaterialData::copy(const Elem & elem_to, const Elem & elem_from, unsigned int side)
57 {
58  _storage.copy(*this, elem_to, elem_from, side, _n_qpoints);
59 }
60 
61 void
62 MaterialData::swap(const Elem & elem, unsigned int side /* = 0*/)
63 {
65  return;
66 
67  _storage.swap(*this, elem, side);
68  _swapped = true;
69 }
70 
71 void
72 MaterialData::reinit(const std::vector<std::shared_ptr<Material>> & mats)
73 {
74  for (const auto & mat : mats)
75  mat->computeProperties();
76 }
77 
78 void
79 MaterialData::reset(const std::vector<std::shared_ptr<Material>> & mats)
80 {
81  for (const auto & mat : mats)
82  mat->resetProperties();
83 }
84 
85 void
86 MaterialData::swapBack(const Elem & elem, unsigned int side /* = 0*/)
87 {
89  {
90  _storage.swapBack(*this, elem, side);
91  _swapped = false;
92  }
93 }
94 
95 bool
97 {
98  return _swapped;
99 }
virtual ~MaterialData()
Definition: MaterialData.C:23
void release()
Calls the destroy() methods for the properties currently stored.
Definition: MaterialData.C:26
void reset(const std::vector< std::shared_ptr< Material >> &mats)
Calls the reset method of Materials to ensure that they are in a proper state.
Definition: MaterialData.C:79
void swapBack(const Elem &elem, unsigned int side=0)
material properties for given element (and possible side)
Definition: MaterialData.C:86
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:146
Stores the stateful material properties computed by materials.
MaterialProperties _props_old
Definition: MaterialData.h:154
MaterialProperties _props_older
Definition: MaterialData.h:155
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.
unsigned int _n_qpoints
Number of quadrature points.
Definition: MaterialData.h:149
bool isSwapped()
Returns true if the stateful material is in a swapped state.
Definition: MaterialData.C:96
void copy(const Elem &elem_to, const Elem &elem_from, unsigned int side)
copy material properties from one element to another
Definition: MaterialData.C:56
void resizeItems(unsigned int n_qpoints)
Resize items in this array, i.e.
MaterialProperties _props
Definition: MaterialData.h:153
void swap(MaterialData &material_data, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialData and MaterialPropertyStorage Thread safe...
MaterialData(MaterialPropertyStorage &storage)
Definition: MaterialData.C:18
void swapBack(MaterialData &material_data, const Elem &elem, unsigned int side)
Swap (shallow copy) material properties in MaterialPropertyStorage and MaterialDat Thread safe...
void swap(const Elem &elem, unsigned int side=0)
material properties for given element (and possible side)
Definition: MaterialData.C:62
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false) ...
Definition: MaterialData.h:167
void destroy()
Deallocates the memory.
unsigned int nQPoints()
Returns the number of quadrature points the material properties support/hold.
Definition: MaterialData.C:50
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:34
void reinit(const std::vector< std::shared_ptr< Material >> &mats)
Reinit material properties for given element (and possible side)
Definition: MaterialData.C:72