NeoPZ
TPZBndCondWithMem.h
Go to the documentation of this file.
1 //
2 // TPZBndCondWithMem.h
3 // pz
4 //
5 // Created by Omar DurĂ¡n on 10/13/18.
6 //
7 
8 #ifndef TPZBndCondWithMem_h
9 #define TPZBndCondWithMem_h
10 
11 #include <stdio.h>
12 #include <memory>
13 #include "TPZMaterial.h"
14 #include "pzbndcond.h"
15 
16 template <class TMEM>
17 class TPZBndCondWithMem : public TPZBndCond {
18 
19 public:
20 
22 
23  }
24 
25 
26  TPZBndCondWithMem(int matid) : TPZBndCond(matid), fMemory(new TPZAdmChunkVector<TMEM>()), fDefaultMem(), fUpdateMem(false){
27 
28  }
29 
32 
33  }
34 
35  TPZBndCondWithMem(TPZMaterial * material,int matid,int type,TPZFMatrix<STATE> &val1,TPZFMatrix<STATE> &val2) : TPZBndCond(material,matid,type,val1,val2),fMemory(new TPZAdmChunkVector<TMEM>()), fDefaultMem(), fUpdateMem(false) {
36  }
37 
39 
40  }
41 
43  *fMemory = *bc.fMemory;
44  }
45 
46  virtual std::string Name() override {
47  return "TPZBndCondWithMem<TMEM>";
48  }
49 
50  virtual void Print(std::ostream &out) override;
51 
52  virtual TMEM &MemItem(const int i) const;
53 
55  int ClassId() const override;
56 
57  void Write(TPZStream &buf, int withclassid) const override;
58 
59  void Read(TPZStream &buf, void *context) override;
60 
61  std::shared_ptr<TPZAdmChunkVector<TMEM>> & GetMemory();
62 
63  void SetMemory(std::shared_ptr<TPZAdmChunkVector<TMEM>> & memory);
64 
65  virtual int PushMemItem(int sourceIndex = -1) override;
66 
67  virtual void FreeMemItem(int index) override;
68 
69  void ResetMemItem(int index) {
70  this->MemItem(index) = fDefaultMem;
71  }
72 
73  void ResetMemory() {
74  int nmem = fMemory->NElements();
75  for (unsigned int im = 0; im < nmem; im++) {
76  ResetMemItem(im);
77  }
78  }
79 
80  virtual void SetDefaultMem(TMEM & defaultMem);
81 
82  virtual void SetUpdateMem(bool update = 1);
83 
84  void Clone(std::map<int, TPZMaterial * > &matvec) override {
85  int matid = Id();
86 
87  TPZMaterial * refmaterial = Material();
88  TPZMaterial * newrefmaterial = NULL;
89  int refmatid = 0;
90  if(refmaterial) {
91  refmaterial->Clone(matvec);
92  refmatid = refmaterial->Id();
93  newrefmaterial = matvec[refmatid];
94  }
95  std::map<int, TPZMaterial * >::iterator matit;
96  matit = matvec.find(matid);
97  if(matit == matvec.end())
98  {
99  TPZMaterial * newmat = (new TPZBndCondWithMem<TMEM>(*this, newrefmaterial));
100  matvec[matid] = newmat;
101  }
102  }
103 
105  DebugStop();
106  }
107 
109 
110  virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override;
111 
112  virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ef) override;
113 
114  virtual void Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override;
115 
116  virtual void Contribute(TPZVec<TPZMaterialData> &datavec, REAL weight, TPZFMatrix<STATE> &ef) override;
117 
118  virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef, TPZBndCond &bc) override {
119  DebugStop();
120  }
121 
122  virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix<STATE> &ef, TPZBndCond &bc) override {
123  DebugStop();
124  }
125 
126  virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override {
127  DebugStop();
128  }
129 
130  virtual void ContributeInterface(TPZMaterialData &data, TPZVec<TPZMaterialData> &dataleft, TPZVec<TPZMaterialData> &dataright, REAL weight, TPZFMatrix<STATE> &ek, TPZFMatrix<STATE> &ef) override {
131  DebugStop();
132  }
133 
134  virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix<STATE> &ef) override {
135  DebugStop();
136  }
137 
138  virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix<STATE> &ek,TPZFMatrix<STATE> &ef,TPZBndCond &bc) override {
139  DebugStop();
140  }
141 
142  virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix<STATE> &ef,TPZBndCond &bc) override {
143  DebugStop();
144  }
145 
146 protected:
147 
149  std::shared_ptr<TPZAdmChunkVector<TMEM>> fMemory;
150 
153 
156 
157 };
158 
159 #endif /* TPZBndCondWithMem_h */
int ClassId() const override
Unique identifier for serialization purposes.
void UpdateBCValues(TPZVec< TPZMaterialData > &datavec)
clarg::argBool bc("-bc", "binary checkpoints", false)
TPZBndCondWithMem(TPZBndCondWithMem< TMEM > &bc, TPZMaterial *ref)
std::shared_ptr< TPZAdmChunkVector< TMEM > > fMemory
Shared pointer to material memory.
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
Implements a chunk vector with free store administration. Utility.
Definition: TPZStream.h:39
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Contribute methods.
TPZBndCondWithMem(int matid)
virtual void SetUpdateMem(bool update=1)
TPZBndCondWithMem(TPZMaterial *material, int matid, int type, TPZFMatrix< STATE > &val1, TPZFMatrix< STATE > &val2)
void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
virtual int PushMemItem(int sourceIndex=-1) override
Pushes a new entry in the context of materials with memory, returning its index at the internal stora...
virtual std::string Name() override
Returns the name of the material.
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to residual vector at one BC integration point.
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
TPZBndCondWithMem(TPZBndCondWithMem< TMEM > &bc)
~TPZBndCondWithMem()
Default destructor.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to the stiffness matrix and load vector at one BC integration point...
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to stiffness matrix and load vector at one BC integration point...
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
std::shared_ptr< TPZAdmChunkVector< TMEM > > & GetMemory()
virtual void Print(std::ostream &out) override
Prints out the data associated with the material.
virtual void FreeMemItem(int index) override
Frees an entry in the material with memory internal history storage.
void SetMemory(std::shared_ptr< TPZAdmChunkVector< TMEM >> &memory)
virtual void SetDefaultMem(TMEM &defaultMem)
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to stiffness matrix and load vector at one integration point...
void ResetMemItem(int index)
void Clone(std::map< int, TPZMaterial * > &matvec) override
Creates a copy of the material object and put it in the vector which is passed on.
void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ef) override
It computes a contribution to residual vector at one integration point.
virtual void Clone(std::map< int, TPZMaterial * > &matvec)
Creates a copy of the material object and put it in the vector which is passed on.
int Id() const
Definition: TPZMaterial.h:170
TMEM fDefaultMem
Default memory settings.
virtual void ContributeInterface(TPZMaterialData &data, TPZVec< TPZMaterialData > &dataleft, TPZVec< TPZMaterialData > &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
It computes a contribution to stiffness matrix and load vector at one integration point...
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
bool fUpdateMem
Flag to indicate whether the memory data are to be updated in an assemble loop.
virtual TMEM & MemItem(const int i) const
TPZMaterial * Material() const
Definition: pzbndcond.h:263
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to the stiffness matrix and load vector at one BC integration point...