NeoPZ
TPZGeoElement.h.h
Go to the documentation of this file.
1 
6 #include "TPZGeoElement.h"
7 #include <sstream>
8 #include "pzlog.h"
9 #ifdef LOG4CXX
10 static LoggerPtr logger(Logger::getLogger("pz.mesh.tpzgeoelement"));
11 #endif
12 
13 template<class TGeo, class TRef>
15 TPZRegisterClassId(&TPZGeoElement::ClassId),TPZGeoElRefLess<TGeo>(nodeindices,matind,mesh) {
16  int i;
17  for(i=0;i<TRef::NSubEl;i++) fSubEl[i] = -1;
18 }
19 
20 template<class TGeo, class TRef>
21 TPZGeoElement<TGeo,TRef>::TPZGeoElement(TPZVec<int64_t> &nodeindices,int matind,TPZGeoMesh &mesh, int64_t &index) :
22 TPZRegisterClassId(&TPZGeoElement::ClassId),TPZGeoElRefLess<TGeo>(nodeindices,matind,mesh,index) {
23  int i;
24  for(i=0;i<TRef::NSubEl;i++) fSubEl[i] = -1;
25 }
26 
27 template<class TGeo, class TRef>
29 TPZRegisterClassId(&TPZGeoElement::ClassId),TPZGeoElRefLess<TGeo>(geo,matind,mesh) {
30  int i;
31  for(i=0;i<TRef::NSubEl;i++) fSubEl[i] = -1;
32 }
33 
34 template<class TGeo, class TRef>
35 TPZGeoElement<TGeo,TRef>::TPZGeoElement(int64_t id,TPZVec<int64_t> &nodeindexes,int matind,TPZGeoMesh &mesh) :
36 TPZRegisterClassId(&TPZGeoElement::ClassId),TPZGeoElRefLess<TGeo>(id,nodeindexes,matind,mesh) {
37  int i;
38  for(i=0;i<TRef::NSubEl;i++) fSubEl[i] = -1;
39 }
40 
41 template<class TGeo, class TRef>
43  int i;
44  for(i=0;i<TRef::NSubEl;i++) fSubEl[i] = -1;
45 }
46 
47 template<class TGeo, class TRef>
49 
50  if (id<0 || id >(TRef::NSubEl - 1)){
51  PZError << "TPZGeoElement::Trying do define subelement :"
52  << id << "Max Allowed = " << TRef::NSubEl - 1 << std::endl;
53  return;
54  }
55  if (el)
56  {
57  fSubEl[id] = el->Index();
58  }
59  else
60  {
61  fSubEl[id] = -1;
62  }
63  return;
64 }
65 
66 template<class TGeo, class TRef>
68  return TGeo::RefElVolume();
69 }
70 
71 template<class TGeo, class TRef>
72 void TPZGeoElement<TGeo,TRef>::MidSideNodeIndex(int side,int64_t &index) const
73 {
74  TRef::MidSideNodeIndex(this,side,index);
75 }
76 
77 
78 template<class TGeo, class TRef>
80 {
81  return TRef::NSubEl;
82 }
83 
84 template<class TGeo, class TRef>
86 {
87  return TRef::NSideSubElements(side);
88 }
89 
90 template<class TGeo, class TRef>
92 {
93  if(is<0 || is>(TRef::NSubEl - 1)){
94  std::cout << "TPZGeoElement::SubElement index error is= " << is << std::endl;
95  }
96  if(fSubEl[is] == -1) return 0;
97  return this->Mesh()->ElementVec()[fSubEl[is]];
98 }
102 template<class TGeo, class TRef>
104  for (unsigned int i = 0; i < NSubElements(); ++i) {
105  TPZGeoEl *gel = SubElement(i);
106  if (gel) {
107  gel->SetFatherIndex(-1);
108  }
109  fSubEl[i] = -1;
110  }
111 }
112 
113 template<class TGeo, class TRef>
116  TRef::GetSubElements(this,side,subs);
117  return subs[position];
118 }
119 
120 template<class TGeo, class TRef>
122  return TRef::GetTransform(side,son);
123 }
124 
125 template<class TGeo, class TRef>
127 
128  TRef::Divide(this,pv);
129 }
130 
131 template<class TGeo, class TRef>
133 {
134 
135  TRef::GetSubElements(this,side,subel);
136 }
137 
138 template<class TGeo, class TRef>
139 void TPZGeoElement<TGeo,TRef>::Read(TPZStream &buf, void *context) {
140  TPZGeoElRefLess<TGeo>::Read(buf,context);
141  buf.Read(fSubEl,TRef::NSubEl);
142 }
143 
144 template<class TGeo, class TRef>
145 void TPZGeoElement<TGeo,TRef>::Write(TPZStream &buf, int withclassid) const{
146  TPZGeoElRefLess<TGeo>::Write(buf,withclassid);
147  buf.Write(fSubEl,TRef::NSubEl);
148 }
149 
150 template<class TGeo, class TRef>
152  if(&DestMesh == this->Mesh())
153  {
154  return new TPZGeoElement<TGeo,TRef>(*this);
155  }
156  else
157  {
158  return new TPZGeoElement<TGeo,TRef>(DestMesh, *this);
159  }
160 }//Clone method
161 
162 template<class TGeo, class TRef>
164  std::map<int64_t,int64_t> & gl2lcNdMap,
165  std::map<int64_t,int64_t> & gl2lcElMap) const{
166  return new TPZGeoElement<TGeo,TRef>(DestMesh, *this, gl2lcNdMap, gl2lcElMap);
167 }//Clone method
168 
169 
170 template<class TGeo, class TRef>
173 TPZGeoElRefLess<TGeo>(DestMesh, cp){
174  int i, n = TRef::NSubEl;
175  for(i = 0; i < n; i++){
176  this->fSubEl[i] = cp.fSubEl[i];
177  }
178 }
179 
180 template<class TGeo, class TRef>
182  const TPZGeoElement &cp,
183  std::map<int64_t,int64_t> &gl2lcNdMap,
184  std::map<int64_t,int64_t> &gl2lcElMap):
186 TPZGeoElRefLess<TGeo>(DestMesh, cp, gl2lcNdMap, gl2lcElMap)
187 {
188  int i, n = TRef::NSubEl;
189  for(i = 0; i < n; i++)
190  {
191  if (cp.fSubEl[i] == -1)
192  {
193  this->fSubEl[i]=-1;
194  continue;
195  }
196  if (gl2lcElMap.find(cp.fSubEl[i]) == gl2lcElMap.end())
197  {
198  std::stringstream sout;
199  sout << "ERROR in - " << __PRETTY_FUNCTION__
200  << " subelement index is not in map from original to clone indexes! Son index = "
201  << fSubEl[i];
202  LOGPZ_ERROR(logger,sout.str().c_str());
203  exit(-1);
204  }
205  this->fSubEl[i] = gl2lcElMap[cp.fSubEl[i]];
206  }
207 }
TPZGeoEl * SubElement(int is) const override
Returns a pointer to the subelement is.
REAL RefElVolume() override
Volume of the master element.
virtual void ResetSubElements() override
Reset all subelements to NULL.
virtual void Read(TPZStream &str, void *context) override
read objects from the stream
TPZTransform GetTransform(int side, int son) override
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.
void Read(TPZStream &str, void *context) override
read objects from the stream
Implements a generic geometric element with a uniform refinement pattern. Geometry.
Definition: TPZGeoElement.h:22
void Write(TPZStream &str, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
Implements the mapping between the master element and deformed element. Geometry. ...
int NSubElements() const override
Returns the number of subelements of the element independent of the fact hether the element has alrea...
TPZGeoMesh * Mesh() const
Returns the mesh to which the element belongs.
Definition: pzgeoel.h:220
virtual TPZGeoEl * ClonePatchEl(TPZGeoMesh &DestMesh, std::map< int64_t, int64_t > &gl2lcNdIdx, std::map< int64_t, int64_t > &gl2lcElIdx) const override
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
virtual void SetFatherIndex(int64_t fatherindex)
Sets the father element index This method is not called SetFather in order to avoid implicit conversi...
Definition: pzgeoel.h:490
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
Definition: pzgeoel.h:730
virtual void Divide(TPZVec< TPZGeoEl *> &pv) override
Divides the element and puts the resulting elements in the vector.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
Definition: pzlog.h:93
virtual TPZGeoEl * Clone(TPZGeoMesh &DestMesh) const override
void MidSideNodeIndex(int side, int64_t &index) const override
Returns the midside node index along a side of the element.
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
This class implements a stack object. Utility.
Definition: pzcheckmesh.h:14
void SetSubElement(int id, TPZGeoEl *el) override
Sets the subelement of index i.
int64_t fSubEl[TRef::NSubEl]
Definition: TPZGeoElement.h:24
TPZGeoElement()
Default constructor.
int ClassId() const override
Define the class id associated with the class.
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
Contains declaration of TPZGeoElement class which implements a generic geometric element with a unifo...
TPZGeoElSide SideSubElement(int side, int position)
Return a pointer and a side of the subelement of the element at the side and the indicated position...
virtual void Write(TPZStream &str, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
virtual void GetSubElements2(int side, TPZStack< TPZGeoElSide > &subel) const override
This method will return a partition of the side of the current element as the union of sub elements/...
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
int NSideSubElements(int side) const override
Returns the number of subelements as returned by GetSubElements2(side)
virtual void Read(bool &val)
Definition: TPZStream.cpp:91
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138