NeoPZ
pzidentifyrefpattern.cpp
Go to the documentation of this file.
1 
6 #include "pzidentifyrefpattern.h"
7 #include "pzgeoel.h"
8 #include "pzeltype.h"
10 
11 #include "pzrefpoint.h"
12 #include "TPZRefLinear.h"
13 #include "pzreftriangle.h"
14 #include "pzrefquad.h"
15 #include "pzrefpyram.h"
16 #include "pzrefprism.h"
17 #include "pzreftetrahedra.h"
18 #include "TPZRefCube.h"
19 #include "tpzautopointer.h"
20 #include <algorithm>
21 #include <iterator>
22 
23 using namespace std;
24 
26  fPath = path;
27 }
29 }
32  MElementType eltype = father->Type();
33  int nelem = subelem.NElements();
35  switch (eltype) {
36  case (EPoint) : {
37  if (nelem != 1){
38  PZError << "TPZIdentifyRefPattern::GetRefPattern ERROR : point partition detected!" << endl;
39  DebugStop();
40  }
41  return 0;// return refpattern for point!!
42  }
43  case (EOned) :{
44  if (nelem != 2){
45  PZError << "TPZIdentifyRefPattern::GetRefPattern ERROR : wrong linear partition detected!" << endl;
46  DebugStop();
47  }
48  TPZRefPattern * newRef = new TPZRefPattern ("/home/pos/cesar/RefPattern/Unif_Linear.rpt");
49  rp = newRef;
50  }
51  default : {
52  //return a uniform refinement pattern
53  if (nelem == UniformSubElem(eltype)) {
54  rp = GetUniform(father);
55  } else {
56  //identify the side refinement pattern
57  int side = IdentifySide(father,subelem);
58  rp = GetSideRefPattern(father,side);
59  }
60  }
61  }
63  //If the refinement pattern is already defined delete the created refinement pattern
64  if (mesh_rp) {
65  return mesh_rp.operator->();
66  }
67  //Insert a new refinement pattern into mesh
69  return rp;
70 }
71 
74  set< TSide > Father;
75  set< TSide > Sons;
76  set< TSide > Result;
77  int iside,isub;
78 
79  for (iside=0;iside<father->NSides();iside++){
80  if (father->SideDimension(iside) != 1) continue;
81  TPZGeoElSide gelside (father,iside);
82  TSide sidefat(gelside);
83  Father.insert(sidefat);
84  }
85  for (isub=0;isub<subelem.NElements();isub++) {
86  for (iside=0;iside<subelem[isub]->NSides();iside++) {
87  if (subelem[isub]->SideDimension(iside) != 1) continue;
88  TPZGeoElSide gelside (subelem[isub],iside);
89  TSide sideson(gelside);
90  Sons.insert(sideson);
91  }
92  }
93 
94  set_difference(Father.begin(),Father.end(),Sons.begin(),Sons.end(),inserter(Result,Result.begin()));
95  if (Result.size() != 1) return -1;
96 
97  TSide side_result = *Result.begin();
98  int side = side_result.fSide;
99  return side;
100 }
101 
102 using namespace pzrefine;
103 
105  switch (eltype) {
106  case (EPoint) : return TPZRefPoint::NSubEl;
107  case (EOned) : return TPZRefLinear::NSubEl;
108  case (ETriangle) : return TPZRefTriangle::NSubEl;
109  case (EQuadrilateral) : return TPZRefQuad::NSubEl;
110  case (ETetraedro) : return TPZRefTetrahedra::NSubEl;
111  case (EPiramide) : return TPZRefPyramid::NSubEl;
112  case (EPrisma) : return TPZRefPrism::NSubEl;
113  case (ECube) : return TPZRefCube::NSubEl;
114  }
115  PZError << "TPZIdentifyRefPattern::UniformSubElem ERROR unknown eltype : " << eltype << endl;
116  return (-1);
117 }
118 
120  MElementType eltype = gel->Type();
121  string fullfilename = fPath;
122  fullfilename += "/";
123  switch (eltype) {
124  case (EPoint) : {
125  fullfilename += "Point_";
126  break;
127  }
128  case (EOned) : {
129  fullfilename += "Linear_";
130  break;
131  }
132  case (ETriangle) : {
133  fullfilename += "Triang_";
134  break;
135  }
136  case (EQuadrilateral) : {
137  fullfilename += "Quad_";
138  break;
139  }
140  case (ETetraedro) : {
141  fullfilename += "Tetra_";
142  break;
143  }
144  case (EPiramide) : {
145  fullfilename += "Piram_";
146  break;
147  }
148  case (EPrisma) : {
149  fullfilename += "Prism_";
150  break;
151  }
152  case (ECube) : {
153  fullfilename += "Hexa_";
154  break;
155  }
156  default:{
157  PZError << "TPZIdentifyRefPattern::GetUniform ERROR unknown eltype : " << eltype << endl;
158  return (0);
159  }
160  }
161  fullfilename += "Unif.rpt";
162  TPZRefPattern *rp = new TPZRefPattern(fullfilename);
163  return rp;
164 }
165 
167  MElementType eltype = gel->Type();
168  string fullfilename = fPath;
169  fullfilename += "/";
170  switch (eltype) {
171  case (EPoint) : {
172  fullfilename += "Point_";
173  break;
174  }
175  case (EOned) : {
176  fullfilename += "Linear_";
177  break;
178  }
179  case (ETriangle) : {
180  fullfilename += "Triang_";
181  break;
182  }
183  case (EQuadrilateral) : {
184  fullfilename += "Quad_";
185  break;
186  }
187  case (ETetraedro) : {
188  fullfilename += "Tetra_";
189  break;
190  }
191  case (EPiramide) : {
192  fullfilename += "Piram_";
193  break;
194  }
195  case (EPrisma) : {
196  fullfilename += "Prism_";
197  break;
198  }
199  case (ECube) : {
200  fullfilename += "Hexa_";
201  break;
202  }
203  default:{
204  PZError << "TPZIdentifyRefPattern::GetUniform ERROR unknown eltype : " << eltype << endl;
205  return (0);
206  }
207  }
208  fullfilename += "Unif.rpt";
209  TPZRefPattern *rp = new TPZRefPattern(fullfilename);
210  return rp;
211 }
int IdentifySide(TPZGeoEl *father, TPZVec< TPZGeoEl *> subelem)
Identify the side of the refinement pattern.
void InsertRefPattern(TPZAutoPointer< TPZRefPattern > &refpat)
Insert the refinement pattern in the list of availabe refinement patterns assigns an Id to refPattern...
Contains the TPZRefQuad class which implements the uniform refinement of a geometric quadrilateral el...
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
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
Contains the TPZIdentifyRefPattern class which identifies the refinement pattern given the father ele...
virtual int NSides() const =0
Returns the number of connectivities of the element.
virtual int SideDimension(int side) const =0
Return the dimension of side.
TPZAutoPointer< TPZRefPattern > FindRefPattern(TPZAutoPointer< TPZRefPattern > &refpat)
Check whether the refinement pattern already exists.
Contains the TPZRefPyramid class which implements the uniform refinement of a geometric hexahedral el...
TPZRefPatternDataBase gRefDBase
External variable to data base of patterns.
TPZAutoPointer< TPZRefPattern > GetUniform(TPZGeoEl *gel)
Contains the TPZRefPrism class which implements the uniform refinement of a geometric prism element...
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
int UniformSubElem(int eltype)
Returns the number of subelements of a uniform refinement \ pattern for the specified element type...
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
virtual MElementType Type() const =0
Returns the element type acording to pzeltype.h.
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
Groups all classes which model the h refinement These classes are used as template arguments of...
Definition: pzrefpoint.cpp:15
Contains the TPZRefTriangle class which implements the uniform refinement of a geometric triangular e...
Contains the TPZRefTetrahedra class which implements the uniform refinement of a geometric tetrahedra...
Contains the TPZRefPatternDataBase class which defines data base of patterns.
Defines the topology of the current refinement pattern to a mesh. Refine.
Definition: TPZRefPattern.h:77
MElementType
Define the element types.
Definition: pzeltype.h:52
To store a side and its nodes indexes. Getting data.
Definition: pzeltype.h:61
TPZIdentifyRefPattern(std::string &path)
Contains the TPZRefLinear class which implements the uniform refinement of a geometric linear element...
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Definition: pzeltype.h:55
Contains the TPZRefCube class which implements the uniform refinement of a geometric hexahedral eleme...
Contains the TPZRefPoint class which implements the uniform refinement of a geometric point element...
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
TPZAutoPointer< TPZRefPattern > GetRefPattern(TPZGeoEl *father, TPZVec< TPZGeoEl *> subelem)
Returns the refinement pattern that generates the given refinement.
TPZAutoPointer< TPZRefPattern > GetSideRefPattern(TPZGeoEl *gel, int side)