NeoPZ
TPZPlasticState.h
Go to the documentation of this file.
1 // $Id: TPZPlasticState.h,v 1.8 2009-07-19 05:47:18 erick Exp $
2 
3 #ifndef TPZPLASTICSTATE_H
4 #define TPZPLASTICSTATE_H
5 
6 #include "fadType.h"
7 #include "TPZTensor.h"
8 #include <iostream>
9 
13 template <class T>
14 class TPZPlasticState : public TPZSavable {
15 
16 public:
17 
20 
23 
25  int m_m_type;
26 
27 public:
28 
30  TPZPlasticState(): m_eps_t(), m_eps_p(), m_hardening(T(0.)), m_m_type(0) { }
31 
33  TPZPlasticState(const T & hardening):m_eps_t(T(0.)), m_eps_p(T(0.)), m_hardening(hardening), m_m_type(0) { }
34 
37  m_eps_t(source.m_eps_t), m_eps_p(source.m_eps_p), m_hardening(source.m_hardening), m_m_type(source.m_m_type){ }
38 
41 
43  const TPZPlasticState<T> & operator=(const TPZPlasticState<T> & source);
44 
46  const TPZPlasticState<T> & operator-=(const TPZPlasticState<T> & source);
47 
49  const TPZPlasticState<T> & operator+=(const TPZPlasticState<T> & source);
50 
52  const TPZPlasticState<T> & operator*=(const TPZPlasticState<T> & source);
53 
55  friend std::ostream& operator<<( std::ostream& Out, const TPZPlasticState<T> & s )
56  {
57  s.Print(Out);
58  return Out;
59  }
60 
62  void Print(std::ostream& Out, int fadDerivatives = 1)const;
63 
64  // class Access Members (needed for const PlasticState access)
65 
66  const TPZTensor<T> & EpsT() const
67  { return m_eps_t; }
68 
69  const TPZTensor<T> & EpsP() const
70  { return m_eps_p; }
71 
72  const T & VolHardening() const
73  { return m_hardening; }
74 
75  const int & MType() const
76  { return m_m_type; }
77  int ClassId() const override;
78 
79  void Read(TPZStream& buf, void* context) override {
80  m_eps_t.Read(buf,context);
81  m_eps_p.Read(buf,context);
82 
83  buf.Read(&m_hardening);
84  buf.Read(&m_m_type);
85  }
86 
87  void Write(TPZStream &buf, int withclassid) const override{
88  m_eps_t.Write(buf,withclassid);
89  m_eps_p.Write(buf,withclassid);
90 
91  buf.Write(&m_hardening);
92  buf.Write(&m_m_type);
93  }
94 
95  void CleanUp() {
96  m_eps_t.Zero();
97  m_eps_p.Zero();
98  m_hardening = T(0.);
99  m_m_type = 0;
100  }
101 
107  template <class T1>
108  void CopyTo(TPZPlasticState<T1> & target) const;
109 
110 };
111 
112 template <class T>
114  return Hash("TPZPlasticState") ^ ClassIdOrHash<T>() << 1;
115 }
116 
117 template <class T>
119 {
120  m_eps_t = source.EpsT();
121  m_eps_p = source.EpsP();
122  m_hardening = source.VolHardening();
123  m_m_type = source.MType();
124 
125  return *this;
126 }
127 
128 template <class T>
130 {
131  m_eps_t += source.EpsT();
132  m_eps_p += source.EpsP();
133  m_hardening+= source.VolHardening();
134  return *this;
135 }
136 
137 template <class T>
139 {
140  m_eps_t -= source.EpsT();
141  m_eps_p -= source.EpsP();
142  m_hardening-= source.VolHardening();
143  return *this;
144 }
145 
146 template <class T>
148 {
149  m_eps_t *= source.EpsT();
150  m_eps_p *= source.EpsP();
151  m_hardening*= source.VolHardening();
152  return *this;
153 }
154 
155 template <class T>
156 inline void TPZPlasticState<T>::Print(std::ostream& Out, int fadDerivatives)const {
157  if (fadDerivatives) {
158  Out << "\tm_eps_t = ";
159  for (int i = 0; i < 6; i++)Out << m_eps_t[i] << " ";
160  Out << std::endl;
161  Out << "\tm_eps_p = ";
162  for (int i = 0; i < 6; i++)Out << m_eps_p[i] << " ";
163  Out << std::endl;
164  Out << "\tm_hardening = " << m_hardening << std::endl;
165  } else {
166  Out << "\tm_eps_t = ";
167  for (int i = 0; i < 6; i++)Out << TPZExtractVal::val(m_eps_t[i]) << " ";
168  Out << std::endl;
169  Out << "\tm_eps_p = ";
170  for (int i = 0; i < 6; i++)Out << TPZExtractVal::val(m_eps_p[i]) << " ";
171  Out << std::endl;
172  Out << "\tm_hardening = " << TPZExtractVal::val(m_hardening) << std::endl;
173  }
174  Out << "\tm_m_type = " << m_m_type << std::endl;
175 }
176 
177 template <class T>
178 template <class T1>
180 {
181  EpsT().CopyTo(target.m_eps_t);
182  EpsP().CopyTo(target.m_eps_p);
184  target.m_m_type = MType();
185 }
186 
187 
188 #endif
189 
const TPZPlasticState< T > & operator+=(const TPZPlasticState< T > &source)
Operator +=.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
const TPZPlasticState< T > & operator*=(const TPZPlasticState< T > &source)
Operator *=.
void Print(std::ostream &Out, int fadDerivatives=1) const
More complete then Operator << because it allows derivatives supression.
TPZTensor< T > m_eps_t
Tensors representing the total and plastic strain states.
void Write(TPZStream &buf, int withclassid) const override
Method to write to a pzstream.
Definition: TPZTensor.h:688
T m_hardening
Plastic volumetric hardeing variable.
void Read(TPZStream &buf, void *context) override
Method to read the object from a pzstream.
Definition: TPZTensor.h:683
void Zero()
Definition: TPZTensor.h:801
TPZPlasticState(const T &hardening)
Constructor enabling predefinition of hardening.
const TPZPlasticState< T > & operator=(const TPZPlasticState< T > &source)
Operator =.
void CopyTo(TPZPlasticState< T1 > &target) const
TPZPlasticState()
Default constructor - all values set to zero.
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
TPZPlasticState(const TPZPlasticState< T > &source)
Copy constructor.
int m_m_type
Identifier for the regime of the material behaviour.
void Read(TPZStream &buf, void *context) override
read objects from the stream
static REAL val(const int number)
Definition: pzextractval.h:21
TPZTensor< T > m_eps_p
const TPZPlasticState< T > & operator-=(const TPZPlasticState< T > &source)
Operator -=.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
const T & VolHardening() const
const TPZTensor< T > & EpsT() const
const TPZTensor< T > & EpsP() const
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
const int & MType() const
int ClassId() const override
Define the class id associated with the class.
~TPZPlasticState()
Destructor.
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
virtual void Read(bool &val)
Definition: TPZStream.cpp:91