NeoPZ
tpzgeoelrefpattern.h.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOELREFPATTERN_H_H
7 #define TPZGEOELREFPATTERN_H_H
8 
9 #include "pzlog.h"
10 
11 #include "tpzgeoelrefpattern.h"
12 #include "TPZRefPatternDataBase.h"
13 
14 template <class TGeo>
15 void TPZGeoElRefPattern<TGeo>::Read(TPZStream &str, void *context) {
16  TPZGeoElRefLess<TGeo>::Read(str, context);
17  str.Read(this->fSubEl);
18  int refpatternindex;
19  str.Read(&refpatternindex, 1);
20  if (refpatternindex != -1) {
21  const std::list< TPZAutoPointer<TPZRefPattern> > &RefPatternList = gRefDBase.RefPatternList(this->Type());
22  std::list< TPZAutoPointer<TPZRefPattern> >::const_iterator it;
23 
24  for (it = RefPatternList.begin(); it != RefPatternList.end(); it++) {
25  if ((*it)->Id() == refpatternindex) {
26  break;
27  }
28  }
29 
30  if (it != RefPatternList.end()) {
31  fRefPattern = *it;
32  } else {
33  DebugStop();
34  }
35  }
36 }
37 
38 template <class TGeo>
39 void TPZGeoElRefPattern<TGeo>::Write(TPZStream &str, int withclassid) const {
40  TPZGeoElRefLess<TGeo>::Write(str, withclassid);
41  str.Write(this->fSubEl);
42  int refpatternindex = -1;
43  if (fRefPattern) refpatternindex = fRefPattern->Id();
44  str.Write(&refpatternindex, 1);
45 }
46 
47 template<class TGeo>
49 TPZGeoElRefLess<TGeo>(), fSubEl(0), fRefPattern(0)
50 {
51 }
52 
53 template<class TGeo>
55  //#warning "Acredito que os objetos deste tipo devem ser administrados pela malha"
56  // if (fRefPattern) delete fRefPattern;
57 }
58 
59 template<class TGeo>
61 TPZRegisterClassId(&TPZGeoElRefPattern<TGeo>::ClassId),TPZGeoElRefLess<TGeo>(nodeindices,matind,mesh) {
62 }
63 template<class TGeo>
64 TPZGeoElRefPattern<TGeo>::TPZGeoElRefPattern(TPZVec<int64_t> &nodeindices,int matind,TPZGeoMesh &mesh, int64_t &index) :
65 TPZRegisterClassId(&TPZGeoElRefPattern<TGeo>::ClassId),TPZGeoElRefLess<TGeo>(nodeindices,matind,mesh,index)
66 {
67 }
68 
69 template<class TGeo>
70 TPZGeoElRefPattern<TGeo>::TPZGeoElRefPattern(int64_t id,TPZVec<int64_t> &nodeindexes,int matind,TPZGeoMesh &mesh) :
71 TPZRegisterClassId(&TPZGeoElRefPattern<TGeo>::ClassId),TPZGeoElRefLess<TGeo>(id,nodeindexes,matind,mesh) {
72 }
73 
74 
75 template <class TGeo>
79 
80  this->fSubEl = cp.fSubEl;
81 }
82 
83 template <class TGeo>
85  if(&DestMesh == this->Mesh())
86  {
87  return new TPZGeoElRefPattern<TGeo>(*this);
88  }
89  else
90  {
91  return new TPZGeoElRefPattern<TGeo>(DestMesh, *this);
92  }
93 }
94 
95 
96 template <class TGeo>
98  const TPZGeoElRefPattern<TGeo> &cp,
99  std::map<int64_t,int64_t> &gl2lcNdMap,
100  std::map<int64_t,int64_t> &gl2lcElMap):
101 TPZRegisterClassId(&TPZGeoElRefPattern<TGeo>::ClassId),TPZGeoElRefLess<TGeo>(DestMesh,cp,gl2lcNdMap,gl2lcElMap),
103 {
104  int i;
105  this->fSubEl.Resize(cp.fSubEl.size(),0);
106  for (i=0;i<cp.fSubEl.NElements();i++)
107  {
108  if (cp.fSubEl[i] == -1)
109  {
110  this->fSubEl[i] = -1;
111  continue;
112  }
113  if (gl2lcElMap.find(cp.fSubEl[i]) == gl2lcElMap.end())
114  {
115  std::stringstream sout;
116  sout << "ERROR in - " << __PRETTY_FUNCTION__
117  << " subelement " << i << " index = " << cp.fSubEl[i] << " is not in the map.";
118  LOGPZ_ERROR (loggerrefpattern,sout.str().c_str());
119  DebugStop();
120  }
121  this->fSubEl[i] = gl2lcElMap[cp.fSubEl[i]];
122  }
123 }
124 
125 template <class TGeo>
127  std::map<int64_t,int64_t> &gl2lcNdMap,
128  std::map<int64_t,int64_t> &gl2lcElMap) const{
129  return new TPZGeoElRefPattern<TGeo>(DestMesh, *this, gl2lcNdMap, gl2lcElMap);
130 }
131 
132 #include "TPZGeoCube.h"
133 #include "TPZGeoLinear.h"
134 #include "pzgeoquad.h"
135 #include "pzgeotriangle.h"
136 #include "pzgeoprism.h"
137 #include "pzgeotetrahedra.h"
138 #include "pzgeopyramid.h"
139 #include "pzgeopoint.h"
140 
141 
142 #define INSERTCLASS(TCL) \
143 template class \
144 TPZRestoreClass<TPZGeoElRefPattern<TCL > >; \
145 template class TPZGeoElRefPattern<TCL>;
146 
155 
156 #endif
virtual void Read(TPZStream &str, void *context) override
read objects from the stream
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.
#define INSERTCLASS(TCL)
const std::list< TPZAutoPointer< TPZRefPattern > > & RefPatternList(MElementType eltype)
Return the complete set of refinement patterns availabe.
Implements the mapping between the master element and deformed element. Geometry. ...
TPZGeoMesh * Mesh() const
Returns the mesh to which the element belongs.
Definition: pzgeoel.h:220
Implements the geometry of a one dimensional linear element. Geometry.
Definition: TPZGeoLinear.h:30
TPZRefPatternDataBase gRefDBase
External variable to data base of patterns.
TPZVec< int64_t > fSubEl
virtual TPZGeoEl * ClonePatchEl(TPZGeoMesh &DestMesh, std::map< int64_t, int64_t > &gl2lcNdIdx, std::map< int64_t, int64_t > &gl2lcElIdx) const override
Creates a clone of this element into a new patch mesh.
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
void Write(TPZStream &str, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
void Read(TPZStream &str, void *context) override
read objects from the stream
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
virtual TPZGeoEl * Clone(TPZGeoMesh &DestMesh) const override
Implements a generic geometric element which is refined according to a generic refinement pattern...
Definition: pzgmesh.h:35
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
Contains the TPZGeoTetrahedra class which implements the geometry of a tetrahedral element...
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
Implements the geometry of a quadrilateral element. Geometry.
Definition: pzgeoquad.h:26
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
TPZGeoElRefPattern()
Default constructor.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
Definition: pzlog.h:93
Implements the geometry of pyramid element. Geometry.
Definition: pzgeopyramid.h:24
Contains the TPZGeoCube class which implements the geometry of hexahedra element. ...
Contains the TPZGeoPoint class which implements the geometry of a point element or 0-D element...
Implements the geometry of a point element. Geometry.
Definition: pzgeopoint.h:39
Implements the geometry of a triangle element. Geometry.
Definition: pzgeotriangle.h:28
~TPZGeoElRefPattern()
Default destructor.
Implements the geometry of a tetrahedral element. Geometry.
Contains the TPZRefPatternDataBase class which defines data base of patterns.
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
Implements the geometry of a prism element. Geometry.
Definition: pzgeoprism.h:27
Contains the TPZGeoPyramid class which implements the geometry of pyramid element.
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
Contains the TPZGeoPrism class which implements the geometry of a prism element.
int ClassId() const override
Define the class id associated with the class.
Implements the geometry of hexahedra element. Geometry.
Definition: TPZGeoCube.h:28
virtual void Write(TPZStream &str, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
virtual void Read(bool &val)
Definition: TPZStream.cpp:91
TPZAutoPointer< TPZRefPattern > fRefPattern