www.mooseframework.org
MaterialData.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "MaterialData.h"
11 #include "Material.h"
12 
14  : _storage(storage), _n_qpoints(0), _swapped(false)
15 {
16 }
17 
19 
20 void
22 {
23  _props.destroy();
26 }
27 
28 void
29 MaterialData::resize(unsigned int n_qpoints)
30 {
31  if (n_qpoints == _n_qpoints)
32  return;
33 
34  _props.resizeItems(n_qpoints);
35  // if there are stateful material properties in the system, also resize
36  // storage for old and older material properties
38  _props_old.resizeItems(n_qpoints);
40  _props_older.resizeItems(n_qpoints);
41  _n_qpoints = n_qpoints;
42 }
43 
44 unsigned int
46 {
47  return _n_qpoints;
48 }
49 
50 void
51 MaterialData::copy(const Elem & elem_to, const Elem & elem_from, unsigned int side)
52 {
53  _storage.copy(*this, elem_to, elem_from, side, _n_qpoints);
54 }
55 
56 void
57 MaterialData::swap(const Elem & elem, unsigned int side /* = 0*/)
58 {
60  return;
61 
62  _storage.swap(*this, elem, side);
63  _swapped = true;
64 }
65 
66 void
67 MaterialData::reinit(const std::vector<std::shared_ptr<Material>> & mats)
68 {
69  for (const auto & mat : mats)
70  mat->computeProperties();
71 }
72 
73 void
74 MaterialData::reset(const std::vector<std::shared_ptr<Material>> & mats)
75 {
76  for (const auto & mat : mats)
77  mat->resetProperties();
78 }
79 
80 void
81 MaterialData::swapBack(const Elem & elem, unsigned int side /* = 0*/)
82 {
84  {
85  _storage.swapBack(*this, elem, side);
86  _swapped = false;
87  }
88 }
89 
90 bool
92 {
93  return _swapped;
94 }
virtual ~MaterialData()
Definition: MaterialData.C:18
void release()
Calls the destroy() methods for the properties currently stored.
Definition: MaterialData.C:21
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:74
void swapBack(const Elem &elem, unsigned int side=0)
material properties for given element (and possible side)
Definition: MaterialData.C:81
MaterialPropertyStorage & _storage
Reference to the MaterialStorage class.
Definition: MaterialData.h:151
Stores the stateful material properties computed by materials.
MaterialProperties _props_old
Definition: MaterialData.h:159
MaterialProperties _props_older
Definition: MaterialData.h:160
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:154
bool isSwapped()
Returns true if the stateful material is in a swapped state.
Definition: MaterialData.C:91
void copy(const Elem &elem_to, const Elem &elem_from, unsigned int side)
copy material properties from one element to another
Definition: MaterialData.C:51
void resizeItems(unsigned int n_qpoints)
Resize items in this array, i.e.
MaterialProperties _props
Definition: MaterialData.h:158
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:13
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:57
bool _swapped
Status of storage swapping (calling swap sets this to true; swapBack sets it to false) ...
Definition: MaterialData.h:170
void destroy()
Deallocates the memory.
unsigned int nQPoints()
Returns the number of quadrature points the material properties support/hold.
Definition: MaterialData.C:45
void resize(unsigned int n_qpoints)
Resize the data to hold properties for n_qpoints quadrature points.
Definition: MaterialData.C:29
void reinit(const std::vector< std::shared_ptr< Material >> &mats)
Reinit material properties for given element (and possible side)
Definition: MaterialData.C:67