NeoPZ
TPZPlasticStateTranslator.h
Go to the documentation of this file.
1 /*
2  * File: TPZPlasticStateTranslator.h
3  * Author: thiago
4  *
5  * Created on 12 de Março de 2018, 14:54
6  */
7 
8 #ifndef TPZPLASTICSTATETRANSLATOR_H
9 #define TPZPLASTICSTATETRANSLATOR_H
10 
11 #include "TPZChunkTranslator.h"
12 #include "TPZTensorTranslator.h"
13 
14 template <typename T>
16 public:
19 
20  virtual void UpdateStream(TPZChunkInTranslation &chunk, const std::map<std::string, uint64_t> &toVersion);
21  void UpdateAttributes(TPZChunkInTranslation &chunk, const std::map<std::string, uint64_t> &toVersion);
22 
24 private:
25  void UpdateFromV1(TPZChunkInTranslation &chunk, const std::map<std::string, uint64_t> &toVersion);
27 };
28 
29 
30 template <typename T>
32 }
33 
34 template <typename T>
36 }
37 
38 template <typename T>
39 void TPZPlasticStateTranslator<T>::UpdateStream(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion) {
40  auto old_version = chunk.mOldVersion["NeoPZ"];
41  switch (old_version) {
42  case 1:
43  UpdateFromV1(chunk, toVersion);
44  break;
45  default:
46  UpdateAttributes(chunk, toVersion);
47  break;
48  }
49 }
50 
51 template <typename T>
52 void TPZPlasticStateTranslator<T>::UpdateFromV1(TPZChunkInTranslation &chunk, const std::map<std::string, uint64_t> &toVersion) {
53  tpzTensorTranslatorT.UpdateStream(chunk, toVersion); // m_eps_t
54  tpzTensorTranslatorT.UpdateStream(chunk, toVersion); // m_eps_p
55  T m_hardening;
56  chunk.mOldStream.Read(&m_hardening);
57  chunk.mNewStream.Write(&m_hardening);
58  int m_m_type = 1;
59  chunk.mNewStream.Write(&m_m_type);
60 }
61 
62 template <typename T>
63 void TPZPlasticStateTranslator<T>::UpdateAttributes(TPZChunkInTranslation& chunk, const std::map<std::string, uint64_t>& toVersion) {
64  tpzTensorTranslatorT.UpdateStream(chunk, toVersion); // m_eps_t
65  tpzTensorTranslatorT.UpdateStream(chunk, toVersion); // m_eps_p
66  T m_hardening;
67  chunk.mOldStream.Read(&m_hardening);
68  chunk.mNewStream.Write(&m_hardening);
69  int m_m_type;
70  chunk.mOldStream.Read(&m_m_type);
71  chunk.mNewStream.Write(&m_m_type);
72 }
73 
74 template <typename T>
76 }
77 
78 #endif /* TPZPLASTICSTATETRANSLATOR_H */
79 
virtual void Read(int *p, int howMany=1)
TPZTensorTranslator< T > tpzTensorTranslatorT
virtual void Write(const int *p, int howMany=1)
std::map< std::string, uint64_t > mOldVersion
void UpdateFromV1(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
TPZContBufferedStream mOldStream
void UpdateAttributes(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
virtual void UpdateStream(TPZChunkInTranslation &chunk, const std::map< std::string, uint64_t > &toVersion)
TPZContBufferedStream mNewStream