NeoPZ
pzgraphelq2d.cpp
Go to the documentation of this file.
1 
6 #include "pzgraphelq2d.h"
7 #include "pzgraphmesh.h"
8 #include "pzcompel.h"
9 #include "pzgeoel.h"
10 
11 using namespace std;
12 
13 TPZGraphElQ2d::TPZGraphElQ2d(TPZCompEl *cel, TPZGraphMesh *gmesh) : TPZGraphEl(cel,gmesh,fConnects)
14 {
15 }
16 
18  return fConnects[i];
19 }
20 
22 {
23 }
24 
25 
27 {
28  int in = ConnectNum(n);
29  int res = fGraphMesh->Res();
30  switch(in)
31  {
32  case 0:
33  case 1:
34  case 2:
35  case 3:
36  return(1);
37  case 4:
38  case 5:
39  case 6:
40  case 7:
41  return((1 << res)-1);
42  case 8:
43  {
44  int a = ((1 << res)-1);
45  return(a*a);
46  }
47  };
48  return(0);
49 }
50 
52  int res = fGraphMesh->Res();
53  int imax = (1<<res);
54  return imax*imax;
55 }
56 
58  int orient[4];
59  int loc;
60  int res = fGraphMesh->Res();
61  int imax = (1<<res);
62  for(int is=0;is<4;is++) {
63  orient[is] = (fConnects[is]->SequenceNumber() > fConnects[(is+1)%4]->SequenceNumber()) ? 1 : 0;
64  }
65  if(co[0]==0 && co[1]==0) return fConnects[0]->FirstPoint();
66  if(co[0]==imax && co[1]==0) return fConnects[1]->FirstPoint();
67  if(co[0]==imax && co[1]==imax) return fConnects[2]->FirstPoint();
68  if(co[0]==0 && co[1]==imax) return fConnects[3]->FirstPoint();
69 
70  if(co[1]==0) loc = 0;
71  else if(co[0]==imax) loc=1;
72  else if(co[1]==imax) loc=2;
73  else if(co[0]==0) loc=3;
74  else loc=4;
75  int64_t first = fConnects[4+loc]->FirstPoint();
76  int64_t neq;
77  switch(loc) {
78  case 0:
79  neq = first + (co[0]-1) + orient[loc]*(imax-1-co[0]-co[0]+1);
80  break;
81  case 1:
82  neq = first + (co[1]-1) + orient[loc]*(imax-1-co[1]-co[1]+1);
83  break;
84  case 2:
85  neq = first + (imax-1-co[0]) + orient[loc]*(co[0]-1-imax+1+co[0]);
86  break;
87  case 3:
88  neq = first + (imax-1-co[1]) + orient[loc]*(co[1]-1-imax+1+co[1]);
89  break;
90  case 4:
91  neq = first + (co[1]-1) + (co[0]-1)*(imax-1);
92  break;
93  default:
94  neq = 0;
95  break;
96  }
97  return neq;
98 }
99 
100 void TPZGraphElQ2d::FirstIJ(int connect,TPZVec<int> &co, int &incr) {
101 
102  int res = fGraphMesh->Res();
103  int imax, i;
104  imax = 1 << res;
105  switch(connect)
106  {
107  case 0:
108  {
109  for (i=0;i<3;i++) co[i]=0;
110  incr = 1;
111  }
112  break;
113  case 1:
114  {
115  co[0] = imax;
116  for (i=1;i<3;i++) co[i]=0;
117  incr = 1;
118  }
119  break;
120  case 2:
121  {
122  for (i=0;i<2;i++) co[i]= imax;
123  incr = 1;
124  }
125  break;
126  case 3:
127  {
128  co[0] = 0;
129  co[1] = imax;
130  incr = 1;
131  }
132  break;
133  case 4:
134  {
135  co[1] = 0;
136  if(fConnects[0]->SequenceNumber() > fConnects[1]->SequenceNumber())
137  {
138  co[0] = imax-1;
139  incr = -1;
140  }
141  else
142  {
143  incr = 1;
144  co[0] = 1;//ifirst
145  }
146  }
147  break;
148  case 5:
149  {
150  co[0] = imax;
151  if(fConnects[1]->SequenceNumber() > fConnects[2]->SequenceNumber())
152  {
153  incr = -1;
154  co[1] = imax-1;//jfirst
155  }
156  else
157  {
158  incr = 1;
159  co[1] = 1;//jfirst
160  }
161  }
162  break;
163  case 6:
164  {
165  co[1] = imax;
166  if(fConnects[3]->SequenceNumber() > fConnects[2]->SequenceNumber())
167  {
168  incr = -1;
169  co[0] = imax-1;//ifirst
170  }
171  else
172  {
173  incr = 1;
174  co[0] = 1;//ifirst
175  }
176  }
177  break;
178  case 7:
179  {
180  co[0] = 0;
181  if(fConnects[0]->SequenceNumber() > fConnects[3]->SequenceNumber())
182  {
183  incr = -1;
184  co[1] = imax-1;//jfirst
185  }
186  else
187  {
188  incr = 1;
189  co[1] = 1;//jfirst
190  }
191  }
192  break;
193  case 8:
194  {
195  incr = 1;
196  for (i=0;i<2;i++) co[i]= 1;
197  }
198  }
199  return;
200 }
201 
202 void TPZGraphElQ2d::NextIJ(int connect, TPZVec<int> &co, int incr) {
203 
204  int res = fGraphMesh->Res();
205  int imax;
206  imax = 1 << res;
207  switch(connect) {
208  case 0:
209  case 1:
210  case 2:
211  case 3:
212  return;
213  case 4:
214  case 6:
215  co[0] += incr;
216  break;
217  case 5:
218  case 7:
219  co[1]+= incr;
220  break;
221  case 8:
222  co[1]++;
223  if(co[1]>= imax) {
224  co[1] = 1;
225  co[0]++;
226  }
227  break;
228  }
229 }
230 
232  int res = fGraphMesh->Res();
233  int imax = 1 << res;
234  ostream &out = fGraphMesh->Out();
235  int64_t ip = fId;
236  TPZVec<int> co0(3,0),co1(3,0),co2(3,0),co3(3,0);
237  if(st == EV3DStyle) ip++;
238  for(int i=0;i<imax;i++) {
239  for(int j=0;j<imax;j++) {
240  if(st == EV3DStyle) out << ip << " 4 ";
241  if(st == EMVStyle) out << ip << " 1 1 1 ";
242  ip++;
243  if(st == EDXStyle) {
244  co0[0]=i; co0[1]=j;
245  co1[0]=i+1; co1[1]=j;
246  co2[0]=i; co2[1]=j+1;
247  co3[0]=i+1; co3[1]=j+1;
248  } else {
249  co0[0]=i; co0[1]=j;
250  co1[0]=i+1; co1[1]=j;
251  co2[0]=i+1; co2[1]=j+1;
252  co3[0]=i; co3[1]=j+1;
253  }
254  out << EqNum(co0) << " " << EqNum(co1) << " " <<
255  EqNum(co2) << " " << EqNum(co3) << endl;
256  }
257  }
258 }
259 
260 void TPZGraphElQ2d::SetNode(int64_t i,TPZGraphNode *gno) {
261  fConnects[i] = gno;
262 }
263 
264 
266  switch(st)
267  {
268  case(EVTKStyle):
269  return 9;
270  default:
271  return -1;
272  }
273 }
274 
276 {
277  return 4;
278 }
virtual int NNodes()
Number of corner nodes (geometric information)
Represents a graphical mesh used for post processing purposes. Post processing.
Definition: pzgraphmesh.h:34
virtual int ExportType(TPZDrawStyle st)
Sets the style to export (format)
Contains the TPZGraphElQ2d class which implements the graphical two dimensional element.
std::ostream & Out()
Definition: pzgraphmesh.h:80
virtual ~TPZGraphElQ2d(void)
virtual void FirstIJ(int connect, TPZVec< int > &co, int &incr)
Contains declaration of TPZCompEl class which defines the interface of a computational element...
virtual void SetNode(int64_t i, TPZGraphNode *n)
Sets a ith graphical node.
virtual int NElements()
int64_t FirstPoint()
Definition: pzgraphnode.cpp:55
int64_t fId
Id of the graphical element.
Definition: pzgraphel.h:98
Definition: TPZDrawStyle.h:12
virtual void Connectivity(TPZDrawStyle st=EDXStyle)
Set dx style for connectivity information.
Definition: TPZDrawStyle.h:12
int Res()
Get the resolution of the draw.
Definition: pzgraphmesh.h:64
virtual int NPoints(TPZGraphNode *n)
Number of points to graphical resolution.
Definition: TPZDrawStyle.h:12
TPZGraphMesh * fGraphMesh
Graphical mesh associated with graphical element.
Definition: pzgraphel.h:87
int64_t SequenceNumber()
Definition: pzgraphnode.h:38
string res
Definition: test.py:151
Definition: TPZDrawStyle.h:12
Contains the TPZGraphMesh class which represents a graphical mesh used for post processing purposes...
REAL co[8][3]
Coordinates of the eight nodes.
virtual TPZGraphNode * Connect(int64_t i)
Return the graphical connect.
TPZGraphNode * fConnects[9]
Graphical nodes vector (by connect of the computational element)
Definition: pzgraphelq2d.h:58
int ConnectNum(TPZGraphNode *n)
Returns the number of the graphical node in the vector of connects.
Definition: pzgraphel.cpp:72
TPZGraphElQ2d(TPZCompEl *cel, TPZGraphMesh *gmesh)
Constructor for graphical element to computational quadrilateral element.
virtual int64_t EqNum(TPZVec< int > &co)
Number of equations.
virtual void NextIJ(int connect, TPZVec< int > &co, int incr)
Abstract class to graphical one-, two- and three-dimensional element. Post processing.
Definition: pzgraphel.h:23
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
To export a graphical node. Post processing.
Definition: pzgraphnode.h:24
TPZDrawStyle
Definition: TPZDrawStyle.h:12