NeoPZ
pzgmesh.h
Go to the documentation of this file.
1 
6 #ifndef PZGEOMESHH
7 #define PZGEOMESHH
8 
9 
10 #include "TPZSavable.h"
11 #include "pzreal.h"
12 #include "pzeltype.h"
13 #include "pzgnode.h"
14 #include "pzadmchunk.h"
15 #include "tpzautopointer.h"
16 #include "pzgeoel.h"
17 
18 #include <iostream>
19 #include <string>
20 #include <map>
21 #include <list>
22 
24 #define GMESHNOMATERIAL -9999
25 
26 class TPZMaterial;
27 class TPZGeoNode;
28 class TPZCompMesh;
29 class TPZRefPattern;
31 
32 template<class T>
33 class TPZVec;
34 
35 template <class TGeo> class TPZGeoElRefPattern;
36 
48 class TPZGeoMesh : public TPZSavable {
49 
50 protected:
52  std::string fName;
53 
56 
59 
62 
64  int64_t fNodeMaxId;
65 
67  int64_t fElementMaxId;
68 
70  int fDim;
71 
72  typedef std::map<std::pair<int,int>, int> InterfaceMaterialsMap;
73 
78  InterfaceMaterialsMap fInterfaceMaterials;
79 
80 public:
82  TPZGeoMesh();
83 
85  TPZGeoMesh(const TPZGeoMesh &cp);
86 
88  TPZGeoMesh & operator= (const TPZGeoMesh &cp );
89 
91  virtual ~TPZGeoMesh();
92 
94  void CleanUp();
95 
97  void ResetConnectivities();
98 
99  public:
100 int ClassId() const override;
101 
102 
103  void Read(TPZStream &buf, void *context) override;
104 
105  void Write(TPZStream &buf, int withclassid) const override;
106 
108  void SetNodeIdUsed(int64_t id) { fNodeMaxId = (id > fNodeMaxId) ? id : fNodeMaxId; }
109 
111  void SetElementIdUsed(int64_t id) { fElementMaxId = (id > fElementMaxId) ? id : fElementMaxId; }
112 
114  int64_t CreateUniqueNodeId() { return ++fNodeMaxId; }
115 
117  int64_t CreateUniqueElementId() { return ++fElementMaxId; }
118 
120  void SetMaxNodeId(int64_t id) { fNodeMaxId = (id > fNodeMaxId) ? id : fNodeMaxId; }
121 
123  void SetMaxElementId(int64_t id) { fElementMaxId = (id > fElementMaxId) ? id : fElementMaxId; }
124 
126  int64_t NNodes() const {return fNodeVec.NElements();}
127 
129  int64_t NElements() const {return fElementVec.NElements();}
130 
131  int64_t ReallyNEl() {return (fElementVec.NElements() - fElementVec.NFreeElements()) ; }
132 
133  void SetName(const std::string &nm);
134 
135  std::string &Name() { return fName; }
136 
139  TPZGeoEl * Element(int64_t iel) { return fElementVec[iel]; }
142  const TPZAdmChunkVector<TPZGeoNode> &NodeVec() const { return fNodeVec; }
143 
145  REAL Area();
146 
148  REAL Area(int matid);
149 
151  REAL Area(std::set<int> &matids);
152 
154  void ResetReference();
155 
158  void RestoreReference(TPZCompMesh *cmesh);
159 
162  {
163  fReference = ref;
164  }
165 
167  TPZCompMesh *Reference() const {return fReference;}
168 
170  virtual void Print(std::ostream & out = std::cout) const;
171  virtual void PrintTopologicalInfo(std::ostream & out = std::cout) const;
172 
175 
176  TPZGeoNode* FindNode(TPZVec<REAL> &co, int &nodeFoundIndex);
177 
180  TPZGeoEl * FindElement(TPZVec<REAL> &x, TPZVec<REAL> & qsi, int64_t & InitialElIndex, int targetDim) const;
181 
184  TPZGeoEl * FindElementCaju(TPZVec<REAL> &x, TPZVec<REAL> & qsi, int64_t & InitialElIndex, int targetDim);
185 
187  TPZGeoEl *FindApproxElement(TPZVec<REAL> &x, TPZVec<REAL> & qsi, int64_t & InitialElIndex, int targetDim) const;
188 
191  TPZGeoEl * FindSubElement(TPZGeoEl * gel, TPZVec<REAL> &x, TPZVec<REAL> & qsi, int64_t & InitialElIndex) const;
192 
195  TPZGeoEl * FindCloseElement(TPZVec<REAL> &x, int64_t & InitialElIndex, int targetDim) const;
196 
198  void BuildConnectivityOld();
199 
201  void BuildConnectivity();
202 
205 
214  void GetBoundaryElements(int64_t IndexNodeFrom,int64_t IndexNodeTo,TPZStack<TPZGeoEl *> &ElementVec,TPZStack<int> &Sides);
215 
217  TPZGeoEl * FindElement(int64_t elid);
218 
221  int64_t ElementIndex(TPZGeoEl * gel);
222 
225  int64_t NodeIndex(TPZGeoNode * nod);
226 
235  virtual TPZGeoEl *CreateGeoElementMapped(MElementType type, TPZVec<int64_t>& nodeindexes, int matid, int64_t& index);
236 
246  virtual TPZGeoEl *CreateGeoElement(MElementType type,TPZVec<int64_t> &cornerindexes,int matid,int64_t &index, int reftype = 1);
247 
249  virtual TPZGeoEl *CreateGeoBlendElement(MElementType type, TPZVec<int64_t>& nodeindexes, int matid, int64_t& index);
250 
256  void DeleteElement(TPZGeoEl *gel, int64_t index = -1);
257 
266  int AddInterfaceMaterial(int leftmaterial, int rightmaterial, int interfacematerial);
267 
273  int InterfaceMaterial(int leftmaterial, int rightmaterial);
274 
280 
285  void SetDimension(int dim){fDim = dim;}
286 
291  int Dimension(){return fDim;}
292 
293 private:
294 
296  void BuildElementsAroundNode(int64_t currentnode,std::map<int64_t,TPZGeoEl *> &elmap);
297 
300  void FindElement(std::map<int64_t,TPZGeoEl *> &elmap,int64_t currentnode,TPZGeoEl* &candidate,int &candidateside);
301 };
302 
303 #endif
void GetNodePtr(TPZVec< int64_t > &nos, TPZVec< TPZGeoNode *> &nodep)
Fills the nodep vector with pointers to the nodes identified by their indexes.
Definition: pzgmesh.cpp:191
int fDim
dimension of the geometric domain
Definition: pzgmesh.h:70
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
void SetMaxElementId(int64_t id)
Used in patch meshes.
Definition: pzgmesh.h:123
TPZCompMesh * Reference() const
Returns the currently loaded computational grid.
Definition: pzgmesh.h:167
int64_t CreateUniqueNodeId()
Returns ++fNodeMaxId.
Definition: pzgmesh.h:114
TPZGeoEl * FindSubElement(TPZGeoEl *gel, TPZVec< REAL > &x, TPZVec< REAL > &qsi, int64_t &InitialElIndex) const
Returns the subelement that contains the given point x and it respective point in parametric domain q...
Definition: pzgmesh.cpp:900
void BuildElementsAroundNode(int64_t currentnode, std::map< int64_t, TPZGeoEl *> &elmap)
Find all elements in elmap or neighbour of elements in elmap which contain a node.
Definition: pzgmesh.cpp:304
virtual TPZGeoEl * CreateGeoElement(MElementType type, TPZVec< int64_t > &cornerindexes, int matid, int64_t &index, int reftype=1)
Generic method for creating a geometric element. Putting this method centrally facilitates the modifi...
Definition: pzgmesh.cpp:1296
TPZAdmChunkVector< TPZGeoEl * > fElementVec
List of pointers to finite elements.
Definition: pzgmesh.h:58
Contains declaration of TPZGeoNode class which defines a geometrical node.
int64_t ReallyNEl()
Definition: pzgmesh.h:131
void CleanUp()
Deletes all items in the TPZGeoMesh.
Definition: pzgmesh.cpp:106
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzgmesh.cpp:1505
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
int64_t fNodeMaxId
Maximum id used by all nodes of this mesh.
Definition: pzgmesh.h:64
Declarates the TPZBlock<REAL>class which implements block matrices.
int64_t fElementMaxId
Maximum id used by all elements of this mesh.
Definition: pzgmesh.h:67
InterfaceMaterialsMap fInterfaceMaterials
Datastructure which indicates the index of the interface material which needs to be created between t...
Definition: pzgmesh.h:78
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
int64_t NElements() const
Access method to query the number of elements of the vector.
Implements a chunk vector with free store administration. Utility.
Definition: TPZStream.h:39
int ClassId() const override
Define the class id associated with the class.
Definition: pzgmesh.cpp:1452
std::string & Name()
Definition: pzgmesh.h:135
void SetDimension(int dim)
Set Dimension.
Definition: pzgmesh.h:285
virtual TPZGeoEl * CreateGeoBlendElement(MElementType type, TPZVec< int64_t > &nodeindexes, int matid, int64_t &index)
Creates a geometric element in same fashion of CreateGeoElement but here the elements are blend...
Definition: pzgmesh.cpp:1400
const TPZAdmChunkVector< TPZGeoEl * > & ElementVec() const
Definition: pzgmesh.h:141
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzgmesh.cpp:1487
void SetElementIdUsed(int64_t id)
Indicates that an element with id was created.
Definition: pzgmesh.h:111
int64_t NodeIndex(TPZGeoNode *nod)
Returns the index of the given node into the fNodeVec.
Definition: pzgmesh.cpp:1185
TPZGeoNode * FindNode(TPZVec< REAL > &co)
Returns the nearest node to the coordinate. This method is VERY INEFFICIENT.
Definition: pzgmesh.cpp:419
const TPZAdmChunkVector< TPZGeoNode > & NodeVec() const
Definition: pzgmesh.h:142
void RestoreReference(TPZCompMesh *cmesh)
Restore all reference in elements from computational mesh criated from current geometrical mesh previ...
Definition: pzgmesh.cpp:209
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
std::map< std::pair< int, int >, int > InterfaceMaterialsMap
Definition: pzgmesh.h:72
void ClearInterfaceMaterialsMap()
Delete all interface materials in map.
Definition: pzgmesh.cpp:1568
Defines data base of patterns. Refine.
int64_t CreateUniqueElementId()
Returns ++fElementMaxId.
Definition: pzgmesh.h:117
void SetMaxNodeId(int64_t id)
Used in patch meshes.
Definition: pzgmesh.h:120
std::string fName
TPZGeoMesh name for model identification.
Definition: pzgmesh.h:52
void BuildConnectivityOld()
Alternative method for computing the connectivity.
Definition: pzgmesh.cpp:1056
virtual void Print(std::ostream &out=std::cout) const
Print the information of the grid to an ostream.
Definition: pzgmesh.cpp:130
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
TPZGeoEl * Element(int64_t iel)
Definition: pzgmesh.h:139
int64_t NNodes() const
Number of nodes of the mesh.
Definition: pzgmesh.h:126
int64_t NFreeElements() const
Access method to return the number of free elements.
Definition: pzadmchunk.h:87
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
TPZCompMesh * fReference
Computational mesh associated.
Definition: pzgmesh.h:55
TPZGeoEl * FindElement(TPZVec< REAL > &x, TPZVec< REAL > &qsi, int64_t &InitialElIndex, int targetDim) const
Returns the element that contains the given point x and it respective point in parametric domain qsi...
Definition: pzgmesh.cpp:579
virtual void PrintTopologicalInfo(std::ostream &out=std::cout) const
Definition: pzgmesh.cpp:169
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
REAL co[8][3]
Coordinates of the eight nodes.
TPZGeoMesh()
Constructors and destructor.
Definition: pzgmesh.cpp:47
TPZGeoMesh & operator=(const TPZGeoMesh &cp)
Operator of copy.
Definition: pzgmesh.cpp:62
void GetBoundaryElements(int64_t IndexNodeFrom, int64_t IndexNodeTo, TPZStack< TPZGeoEl *> &ElementVec, TPZStack< int > &Sides)
GetBoundaryElements returns all elements beweeen NodFrom and NodTo counterclock wise this method uses...
Definition: pzgmesh.cpp:238
void BuildConnectivity()
Build the connectivity of the grid.
Definition: pzgmesh.cpp:967
void DeleteElement(TPZGeoEl *gel, int64_t index=-1)
Centralized method to delete elements.
Definition: pzgmesh.cpp:1456
void SetNodeIdUsed(int64_t id)
Indicates that a node with id was created.
Definition: pzgmesh.h:108
Defines the topology of the current refinement pattern to a mesh. Refine.
Definition: TPZRefPattern.h:77
int AddInterfaceMaterial(int leftmaterial, int rightmaterial, int interfacematerial)
Add an interface material associated to left and right element materials.
Definition: pzgmesh.cpp:1534
int Dimension()
Get Dimension.
Definition: pzgmesh.h:291
Implements a geometric node in the pz environment. Geometry.
Definition: pzgnode.h:31
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
MElementType
Define the element types.
Definition: pzeltype.h:52
This class implements a stack object. Utility.
Definition: pzcheckmesh.h:14
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual TPZGeoEl * CreateGeoElementMapped(MElementType type, TPZVec< int64_t > &nodeindexes, int matid, int64_t &index)
Generic method for creating a geometric element. Putting this method centrally facilitates the modifi...
Definition: pzgmesh.cpp:1229
REAL Area()
Compute the area of the domain.
Definition: pzgmesh.cpp:1604
void ResetConnectivities()
Reset all connectivities.
Definition: pzgmesh.cpp:1576
void SetReference(TPZCompMesh *ref)
Sets the reference of the geometric grid to ref.
Definition: pzgmesh.h:161
virtual ~TPZGeoMesh()
Destructor.
Definition: pzgmesh.cpp:97
int InterfaceMaterial(int leftmaterial, int rightmaterial)
Returns the interface material associated to left and right element materials. If no interface materi...
Definition: pzgmesh.cpp:1548
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
TPZGeoEl * FindApproxElement(TPZVec< REAL > &x, TPZVec< REAL > &qsi, int64_t &InitialElIndex, int targetDim) const
find an element/parameter close to the point
Definition: pzgmesh.cpp:747
TPZGeoEl * FindCloseElement(TPZVec< REAL > &x, int64_t &InitialElIndex, int targetDim) const
Returns the element that is close to the given point x.
Definition: pzgmesh.cpp:472
TPZAdmChunkVector< TPZGeoNode > fNodeVec
List of nodes.
Definition: pzgmesh.h:61
void ResetReference()
Resets all load references in elements and nodes.
Definition: pzgmesh.cpp:197
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
int64_t ElementIndex(TPZGeoEl *gel)
Returns the index of the given element into the fElementVec.
Definition: pzgmesh.cpp:1169
TPZGeoEl * FindElementCaju(TPZVec< REAL > &x, TPZVec< REAL > &qsi, int64_t &InitialElIndex, int targetDim)
Returns the element that contains the given point x and it respective point in parametric domain qsi...
Definition: pzgmesh.cpp:603
void SetName(const std::string &nm)
Definition: pzgmesh.cpp:125
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138