NeoPZ
pzcompelwithmem.h
Go to the documentation of this file.
1 
6 #ifndef PZCOMPELWITHMEM_H
7 #define PZCOMPELWITHMEM_H
8 
9 class TPZMaterialData;
10 
11 #include "pzinterpolationspace.h"
12 #include "pzstack.h"
13 #include "pzcmesh.h"
14 #include "pzquad.h"
15 #include "TPZMaterial.h"
16 #include "pzelctemp.h"
17 #include "pzmultiphysicscompel.h"
18 
19 //#include "tpzpoint.h"
20 
21 #include "pzlog.h"
22 
23 
24 
25 #ifdef LOG4CXX
26 static LoggerPtr CompElWMemlogger(Logger::getLogger("mesh.TPZCompElWithMem"));
27 #endif
28 
36 template <class TBASE>
37 class TPZCompElWithMem : public TBASE
38 {
39 public:
40 
42 
43  virtual ~TPZCompElWithMem();
44 
45  TPZCompElWithMem(TPZCompMesh &mesh, TPZGeoEl *gel, int64_t &index);
46 
47  TPZCompElWithMem(TPZCompMesh &mesh, TPZGeoEl *ref, int64_t &index, TPZCompElSide left, TPZCompElSide right);
48 
50 
53  const TPZCompElWithMem<TBASE> &copy,
54  std::map<int64_t,int64_t> & gl2lcConMap,
55  std::map<int64_t,int64_t> & gl2lcElMap);
56 
57  virtual TPZCompEl *Clone(TPZCompMesh &mesh) const override{
58  return new TPZCompElWithMem<TBASE> (mesh, *this);
59  }
60 
62  virtual void SetCreateFunctions(TPZCompMesh *mesh) override{
64  }
65 
72  virtual TPZCompEl *ClonePatchEl(TPZCompMesh &mesh,std::map<int64_t,int64_t> & gl2lcConMap,std::map<int64_t,int64_t>&gl2lcElMap) const override
73  {
74  return new TPZCompElWithMem<TBASE> (mesh, *this, gl2lcConMap, gl2lcElMap);
75  }
76 
77 
78  virtual void ComputeRequiredData(TPZMaterialData &data, TPZVec<REAL> &qsi) override;
79 
80  virtual void ComputeRequiredData(TPZVec<REAL> &intpointtemp, TPZVec<TPZTransform<> > &trvec, TPZVec<TPZMaterialData> &datavec) override;
81 
83 
84 protected:
85 
87  virtual void PrepareIntPtIndices() override;
88 
90  virtual void ForcePrepareIntPtIndices() override;
91 
93  virtual void SetMemoryIndices(TPZVec<int64_t> &indices) override;
94 
96  virtual void SetFreeIntPtIndices() override;
97 
99 
100 public:
101 
107  void GetMemoryIndices(TPZVec<int64_t> &indices) const override;
108 
110  virtual void SetIntegrationRule(int ord) override;
111 
113  virtual void Write(TPZStream &buf, int withclassid) const override;
114 
116  virtual void Read(TPZStream &buf, void *context) override;
117 
119  public:
120 virtual int ClassId() const override;
121 
132  virtual void Print(std::ostream & out = std::cout) const override
133  {
134  TBASE::Print(out);
135  out << "Integration point indexes " << fIntPtIndices << std::endl;
136  }
137 
140 private:
141 
143 
144 };
145 
146 template<class TBASE>
148 TBASE() {
149  //PrepareIntPtIndices();
150 }
151 
152 template<class TBASE>
155 TBASE(mesh, gel, index){
157 }
158 
159 template<class TBASE>
162 TBASE(mesh, ref, index, left, right){
164 }
165 
166 template<class TBASE>
169 TBASE(mesh, copy) {
170  CopyIntPtIndicesFrom(copy);
171 }
172 
173 
174 template<class TBASE>
176  const TPZCompElWithMem<TBASE> &copy,
177  std::map<int64_t,int64_t> & gl2lcConMap,
178  std::map<int64_t,int64_t> & gl2lcElMap) :
180 TBASE(mesh,copy,gl2lcConMap,gl2lcElMap)
181 {
182  CopyIntPtIndicesFrom(copy);
183 }
184 
185 
186 
187 template <class TBASE>
189 
190  TPZMaterial * material = TBASE::Material();
191  if(!material){
192  PZError << "Error at " << __PRETTY_FUNCTION__ << " this->Material() == NULL\n";
193  return;
194  }
195 
196  if (this->NumberOfCompElementsInsideThisCompEl() == 0) {
197  // This is suposed to happen if in the constructor of a multiphysics element. The CompEl vector is only initialized after the autobuild
198  return;
199  }
200 
201  const TPZIntPoints &intrule = TBASE::GetIntegrationRule();
202 
203  int intrulepoints = intrule.NPoints();
204 
205  fIntPtIndices.Resize(intrulepoints);
206 
207  for(int int_ind = 0; int_ind < intrulepoints; ++int_ind){
208  fIntPtIndices[int_ind] = this->Material()->PushMemItem();
209  // Pushing a new entry in the material memory
210  } //Loop over integratin points generating a reference vector of memory
211  //entries in the related pzmatwithmem for further use.
212 
213 }
214 
215 template <class TBASE>
217  int n = indices.size();
219  for (int i = 0; i < n; i++) {
220  fIntPtIndices[i] = indices[i];
221  }
222 }
223 
224 template <class TBASE>
226 
227  TPZMaterial * material = TBASE::Material();
228 
229  if (material) {
230  int64_t n = fIntPtIndices.NElements();
231 
232  for (int64_t i = 0; i < n; i++) {
233  this->Material()->FreeMemItem(fIntPtIndices[i]);
234  }
235  }
237 }
238 
239 template <class TBASE>
241 {
242  TBASE::SetIntegrationRule(ord);
243  // verify if the number of integration points changed
244  const TPZIntPoints &intrule = TBASE::GetIntegrationRule();
245  int intrulepoints = intrule.NPoints();
246  if (intrulepoints != fIntPtIndices.size()) {
249  }
250 
251 }
252 
253 
259 template<class TBASE>
261 {
262  indices = fIntPtIndices;
263 }
264 
265 
266 template <class TBASE>
268 {
269 
270  TPZMaterial * material = TBASE::Material();
271  if(!material){
272  PZError << "Error at " << __PRETTY_FUNCTION__ << " this->Material() == NULL\n";
273  return;
274  }
275 
276  int64_t i, n = copy.fIntPtIndices.NElements();
278 
279  for(i = 0; i < n; i++)
280  {
281  fIntPtIndices[i] = copy.fIntPtIndices[i];
282  }
283 }
284 
286 template <class TBASE>
288  TPZVec<REAL> &qsi){
289  TBASE::ComputeRequiredData(data, qsi);
291  //material index for the n-th CompEl integration point
292 }
293 
294 template <class TBASE>
296 {
297  TBASE::ComputeRequiredData(intpointtemp,trvec,datavec);
298 
299  int nelofthismphysics = this->NumberOfCompElementsInsideThisCompEl();
300  for (int icel = 0; icel < nelofthismphysics; icel++) {
301  datavec[icel].intGlobPtIndex = GetGlobalIntegrationPointIndex(datavec[icel]);
302  }
303 }
304 
305 template <class TBASE>
307 {
308  int64_t glIntegralPt = -1;
309  if (data.intLocPtIndex >= 0) {
310  glIntegralPt = fIntPtIndices[ data.intLocPtIndex ]; // returning the
311  }
312  return glIntegralPt;
313 }
314 
315 template <class TBASE>
316 inline void TPZCompElWithMem<TBASE>::Write(TPZStream &buf, int withclassid) const
317 {
318  TBASE::Write(buf,withclassid);
319  buf.Write( fIntPtIndices);
320  int classid = ClassId();
321  buf.Write(&classid);
322 }
323 
325 template <class TBASE>
326 inline void TPZCompElWithMem<TBASE>::Read(TPZStream &buf, void *context)
327 {
328  TBASE::Read(buf,context);
329  buf.Read( fIntPtIndices);
330  int classid;
331  buf.Read(&classid);
332  if (classid != ClassId()) {
333  DebugStop();
334  }
335 }
336 
337 template <class TBASE>
339  return Hash("TPZCompElWithMem") ^ TBASE::ClassId() << 1;
340 }
341 
342 #endif
virtual void SetIntegrationRule(int ord) override
Modify the maximum order an integration rule can integrate.
Contains the TPZInt1d, TPZIntTriang, TPZIntQuad, TPZIntCube3D, TPZIntTetra3D, TPZIntPyram3D and TPZIn...
Contains declaration of TPZIntelGen class which implements a generic computational element...
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
Implements computational element and a side. Computational Element.
Definition: pzcompel.h:632
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
virtual void SetMemoryIndices(TPZVec< int64_t > &indices) override
PrepareIntPtIndices initializes the material damage varibles memory in the proper material class...
Contains declaration of TPZInterpolationSpace class which implements the interface for interpolated c...
virtual void Print(std::ostream &out=std::cout) const override
Prints element data.
virtual void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
virtual void SetCreateFunctions(TPZCompMesh *mesh) override
Set create function in TPZCompMesh to create elements of this type.
virtual ~TPZCompElWithMem()
virtual void PrepareIntPtIndices() override
PrepareIntPtIndices initializes the material damage varibles memory in the proper material class...
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
It has the declaration of the TPZMultiphysicsCompEl class.
Abstract class defining integration rules. Numerical Integration.
Definition: tpzintpoints.h:19
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual int ClassId() const override
ClassId of the class. Is implemented for each type of compel in this .h.
virtual TPZCompEl * ClonePatchEl(TPZCompMesh &mesh, std::map< int64_t, int64_t > &gl2lcConMap, std::map< int64_t, int64_t > &gl2lcElMap) const override
Create a copy of the given element. The clone copy have the connect indexes mapped to the local clone...
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
virtual void SetFreeIntPtIndices() override
Frees the material damage varibles memory in the proper material class.
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
TPZStack< int64_t, 128 > fIntPtIndices
void SetAllCreateFunctionsContinuousWithMem()
Definition: pzcmesh.h:552
This class implements the TPZCompEl structure to enable material memory feature. It should be instan...
int intGlobPtIndex
global point index
Contains declaration of TPZCompMesh class which is a repository for computational elements...
int intLocPtIndex
Index of the current integration point being evaluated.
A simple stack.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
int64_t GetGlobalIntegrationPointIndex(TPZMaterialData &data)
void CopyIntPtIndicesFrom(const TPZCompElWithMem< TBASE > &copy)
virtual void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
virtual void ComputeRequiredData(TPZMaterialData &data, TPZVec< REAL > &qsi) override
virtual void ForcePrepareIntPtIndices() override
PrepareIntPtIndices initializes the material damage varibles memory in the proper material class...
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
void GetMemoryIndices(TPZVec< int64_t > &indices) const override
Get the indices of the vector of element memory associated with the integration points.
virtual TPZCompEl * Clone(TPZCompMesh &mesh) const override
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
virtual void Read(bool &val)
Definition: TPZStream.cpp:91