NeoPZ
pzgengrid.cpp
Go to the documentation of this file.
1 
6 #include "pzgengrid.h"
7 #include "pzcmesh.h"
8 #include "pzgmesh.h"
9 
10 #include "pzgnode.h"
11 #include "pzgeoel.h"
12 #include "pzgeoelbc.h"
13 #include "pzconnect.h"
14 
15 #include "pzfmatrix.h"
16 
17 #include "pzvec.h"
18 #include "pzstack.h"
19 
20 #include <fstream>
21 
22 #include "pzlog.h"
23 #include "tpzquadraticquad.h"
24 #include "tpzquadraticline.h"
25 #include "tpzgeoelrefpattern.h"
26 
27 #ifdef LOG4CXX
28 static LoggerPtr logger(Logger::getLogger("pz.gengrid.tpzgengrid"));
29 #endif
30 
31 using namespace std;
32 
33 TPZGenGrid::TPZGenGrid(TPZVec<int> &nx, TPZVec<REAL> &x0, TPZVec<REAL> &x1, int numl, REAL rot) : fNx(nx), fX0(x0), fX1(x1),
34 fDelx(2), fGeometricProgression(2, 1.), fNumLayers(numl), fRotAngle(rot), fZigZag(false), fTrapeze(false), fDistortion(0.), fRefPattern(false) {
35  fDelx[0] = (x1[0] - x0[0]) / (nx[0]); // Delta x
36  fDelx[1] = (x1[1] - x0[1]) / (nx[1]); // Delta y
37  fNumNodes = (nx[0] + 1)*(nx[1] + 1)+(fNumLayers - 1)*(nx[0])*(nx[1] + 1);
39 }
40 
42 }
43 
44 void TPZGenGrid::SetData(TPZVec<int> &nx, TPZVec<REAL> &x0, TPZVec<REAL> &x1, MElementType eltype, int numl, REAL rot) {
45  int i;
46  fNx.Resize(nx.NElements());
47  for (i = 0; i < fNx.NElements(); i++)
48  fNx[i] = nx[i];
49  fX0.Resize(x0.NElements());
50  for (i = 0; i < fX0.NElements(); i++)
51  fX0[i] = x0[i];
52  fX1.Resize(x1.NElements());
53  for (i = 0; i < fX1.NElements(); i++)
54  fX1[i] = x1[i];
55  fDelx.Resize(2);
56  fDelx[0] = (x1[0] - x0[0]) / (nx[0]); // Delta x
57  fDelx[1] = (x1[1] - x0[1]) / (nx[1]); // Delta y
58  fNumNodes = (nx[0] + 1)*(nx[1] + 1)+(fNumLayers - 1)*(nx[0])*(nx[1] + 1);
59  fElementType = eltype;
60  fNumLayers = numl;
61  fRotAngle = rot;
62 }
63 
64 short TPZGenGrid::Read(TPZGeoMesh *grid, int matid) {
65  if (!grid) return 1;
66  grid->SetDimension(2);
67  if (!GenerateNodes(grid))
68  return 1;
69  if (!GenerateElements(grid, matid))
70  return 1;
71  // computing the connectivity
72  grid->ResetConnectivities();
73  grid->BuildConnectivity();
74  return 0;
75 }
76 
78  if (!grid) {
79  DebugStop();
80  }
81  grid->SetDimension(2);
82  if (!GenerateNodes(grid.operator->()))
83  return 1;
84  if (!GenerateElements(grid.operator->(), matid))
85  return 1;
86  // computing the connectivity
87  grid->ResetConnectivities();
88  grid->BuildConnectivity();
89  return 0;
90 }
91 
92 /* This method merge gridtomerge into the gridinitial. The process is as follow:
93  * 1. Each node in gridtomerge is checked wether it is in meshinitial. If it is then the node has its id modified as the id in gridinitial.
94  * Elsewhere a new node is created into the gridinitial, then we get the id of the new node and change the id node (old) by the id of the new node in all the elements of the gridtomerge.
95  * 2. For each node repeated in the gridtomerge (case 1. true), we get the id and is substitutied in the elements of the gridinitial.
96  * 3. For each element in meshtomerge is constructed a new element copy in meshinitial.
97  * 4. Constructed the connectivity again to meshinitial.
98  */
99 bool TPZGenGrid::ReadAndMergeGeoMesh(TPZGeoMesh * gridinitial, TPZGeoMesh * tomerge) {
100  // gridinitial is created by TPZGenGrid current
101  if (Read(gridinitial))
102  return false;
103  if (!tomerge->NNodes() && !tomerge->NElements())
104  return true;
105 
106  // Copy vectors for nodes and elements of the gridtomerge, then the original data is preserved
107  TPZGeoMesh gtomerge(*tomerge);
108  TPZGeoMesh *gridtomerge = &gtomerge;
109 
110  int64_t i, j, k, nnodestomerge = gridtomerge->NNodes();
111  int64_t nnodesinitial = gridinitial->NNodes();
112  // int nneltomerge = gridtomerge->NElements();
113  TPZVec<REAL> coordinitial(3, 0.);
114  TPZVec<REAL> coordtomerge(3, 0.);
115  TPZGeoNode *nodetomerge;
116  TPZGeoEl *gel;
117  // Verifing each node in gridtomerge if exist into the gridinitial (as same coordinates). It is inefficient.
118  for (i = 0; i < nnodestomerge; i++) {
119  nodetomerge = &(gridtomerge->NodeVec()[i]);
120  if (!nodetomerge) continue;
121  nodetomerge->GetCoordinates(coordtomerge);
122  for (j = 0; j < nnodesinitial; j++) {
123  gridinitial->NodeVec()[j].GetCoordinates(coordinitial);
124  if (IsZero(Distance(coordtomerge, coordinitial))) {
125  // In this case exists a node with same coordinates, then the id is update as id of the gridinitial with same coordinates
126  // and the old id is stored in coord[0]
127  nodetomerge->SetCoord(0, nodetomerge->Id());
128  nodetomerge->SetNodeId(gridinitial->NodeVec()[j].Id());
129  break;
130  }
131  }
132 
133  // If the node (i) not exists into the gridinitial is created a new node copy in this grid, and is substitutived in all the
134  // elements in gridinitial the id as old node with the id of the new node. At last the id of the node duplicated is put as -1
135  if (j == nnodesinitial) {
136  // resizing the vector of the nodes
137  int64_t index = gridinitial->NodeVec().AllocateNewElement();
138  gridinitial->NodeVec()[index].Initialize(coordtomerge, *gridinitial);
139  index = gridinitial->NodeVec()[index].Id();
140  int64_t oldid = nodetomerge->Id();
141  for (k = 0; k < gridtomerge->NElements(); k++) {
142  gel = gridtomerge->ElementVec()[k];
143  if (!gel) continue;
144  for (int p = 0; p < gel->NNodes(); p++)
145  if (gel->NodeIndex(p) == oldid)
146  gel->SetNodeIndex(p, index);
147  }
148  nodetomerge->SetNodeId(-1);
149  }
150  }
151 
152  // changing the id of the repeated nodes into the geometric elements of the gridtomerge
153  for (i = 0; i < nnodestomerge; i++) {
154  nodetomerge = &(gridtomerge->NodeVec()[i]);
155  if (!nodetomerge || nodetomerge->Id() == -1) continue;
156  int64_t idnew = nodetomerge->Id(), idold = (int64_t) (nodetomerge->Coord(0));
157  for (k = 0; k < gridtomerge->NElements(); k++) {
158  gel = gridtomerge->ElementVec()[k];
159  if (!gel) continue;
160  for (int p = 0; p < gel->NNodes(); p++)
161  if (gel->NodeIndex(p) == idold)
162  gel->SetNodeIndex(p, idnew);
163  }
164  }
165 
166  // creating new element into gridinitial corresponding for each element in gridtomerge
167  int64_t nelmerge = gridtomerge->NElements();
168  for (i = 0; i < nelmerge; i++) {
169  gel = gridtomerge->ElementVec()[i];
170  if (!gel) continue;
171  TPZVec<int64_t> nos;
172  int64_t ngelnodes = gel->NNodes(), index;
173  nos.Resize(gel->NNodes());
174  for (j = 0; j < ngelnodes; j++)
175  nos[j] = gel->NodeIndex(j);
176  int eltype = 1;
177  if (fRefPattern == false) {
178  eltype = 0;
179  }
180  if (!gridinitial->CreateGeoElement(gel->Type(), nos, gel->MaterialId(), index, eltype))
181  DebugStop();
182  }
183 
184  // computing the connectivity
185  gridinitial->ResetConnectivities();
186  gridinitial->BuildConnectivity();
187  return true;
188 }
189 
190 bool TPZGenGrid::ReadAndMergeGeoMesh(TPZGeoMesh* gridinitial, TPZGeoMesh* tomerge, int matid) {
191  // gridinitial is created by TPZGenGrid current
192  if (Read(gridinitial, matid))
193  return false;
194  if (!tomerge->NNodes() && !tomerge->NElements())
195  return true;
196 
197  // Copy vectors for nodes and elements of the gridtomerge, then the original data is preserved
198  TPZGeoMesh gtomerge(*tomerge);
199  TPZGeoMesh *gridtomerge = &gtomerge;
200 
201  int64_t i, j, k, nnodestomerge = gridtomerge->NNodes();
202  int64_t nnodesinitial = gridinitial->NNodes();
203  // int nneltomerge = gridtomerge->NElements();
204  TPZVec<REAL> coordinitial(3, 0.);
205  TPZVec<REAL> coordtomerge(3, 0.);
206  TPZGeoNode *nodetomerge;
207  TPZGeoEl *gel;
208  // Verifing each node in gridtomerge if exist into the gridinitial (as same coordinates). It is inefficient.
209  for (i = 0; i < nnodestomerge; i++) {
210  nodetomerge = &(gridtomerge->NodeVec()[i]);
211  if (!nodetomerge) continue;
212  nodetomerge->GetCoordinates(coordtomerge);
213  for (j = 0; j < nnodesinitial; j++) {
214  gridinitial->NodeVec()[j].GetCoordinates(coordinitial);
215  if (IsZero(Distance(coordtomerge, coordinitial))) {
216  // In this case exists a node with same coordinates, then the id is update as id of the gridinitial with same coordinates
217  // and the old id is stored in coord[0]
218  nodetomerge->SetCoord(0, nodetomerge->Id());
219  nodetomerge->SetNodeId(gridinitial->NodeVec()[j].Id());
220  break;
221  }
222  }
223 
224  // If the node (i) not exists into the gridinitial is created a new node copy in this grid, and is substitutived in all the
225  // elements in gridinitial the id as old node with the id of the new node. At last the id of the node duplicated is put as -1
226  if (j == nnodesinitial) {
227  // resizing the vector of the nodes
228  int64_t index = gridinitial->NodeVec().AllocateNewElement();
229  gridinitial->NodeVec()[index].Initialize(coordtomerge, *gridinitial);
230  index = gridinitial->NodeVec()[index].Id();
231  int64_t oldid = nodetomerge->Id();
232  for (k = 0; k < gridtomerge->NElements(); k++) {
233  gel = gridtomerge->ElementVec()[k];
234  if (!gel) continue;
235  for (int p = 0; p < gel->NNodes(); p++)
236  if (gel->NodeIndex(p) == oldid)
237  gel->SetNodeIndex(p, index);
238  }
239  nodetomerge->SetNodeId(-1);
240  }
241  }
242 
243  // changing the id of the repeated nodes into the geometric elements of the gridtomerge
244  for (i = 0; i < nnodestomerge; i++) {
245  nodetomerge = &(gridtomerge->NodeVec()[i]);
246  if (!nodetomerge || nodetomerge->Id() == -1) continue;
247  int64_t idnew = nodetomerge->Id(), idold = (int64_t) (nodetomerge->Coord(0));
248  for (k = 0; k < gridtomerge->NElements(); k++) {
249  gel = gridtomerge->ElementVec()[k];
250  if (!gel) continue;
251  for (int p = 0; p < gel->NNodes(); p++)
252  if (gel->NodeIndex(p) == idold)
253  gel->SetNodeIndex(p, idnew);
254  }
255  }
256 
257  // creating new element into gridinitial corresponding for each element in gridtomerge
258  int64_t nelmerge = gridtomerge->NElements();
259  for (i = 0; i < nelmerge; i++) {
260  gel = gridtomerge->ElementVec()[i];
261  if (!gel) continue;
262  TPZVec<int64_t> nos;
263  int64_t ngelnodes = gel->NNodes(), index;
264  nos.Resize(gel->NNodes());
265  for (j = 0; j < ngelnodes; j++)
266  nos[j] = gel->NodeIndex(j);
267  int eltype = 1;
268  if (fRefPattern == false) {
269  eltype = 0;
270  }
271 
272  if (!gridinitial->CreateGeoElement(gel->Type(), nos, gel->MaterialId(), index, eltype))
273  DebugStop();
274  }
275 
276  // computing the connectivity
277  gridinitial->ResetConnectivities();
278  gridinitial->BuildConnectivity();
279  return true;
280 }
281 
282 bool TPZGenGrid::MergeGeoMesh(TPZGeoMesh* gridinitial, TPZGeoMesh* tomerge, int matid) {
283  if (!tomerge->NNodes() && !tomerge->NElements())
284  return true;
285 
286  // Copy vectors for nodes and elements of the gridtomerge, then the original data is preserved
287  TPZGeoMesh gtomerge(*tomerge);
288  TPZGeoMesh *gridtomerge = &gtomerge;
289 
290  int64_t j, k, nnodestomerge = gridtomerge->NNodes();
291  int64_t nnodesinitial = gridinitial->NNodes();
292  // int nneltomerge = gridtomerge->NElements();
293  TPZManVector<REAL, 3> coordinitial(3, 0.);
294  TPZManVector<REAL, 3> coordtomerge(3, 0.);
295  TPZGeoNode *nodetomerge;
296  TPZGeoEl *gel;
297  int64_t newid = -1, oldid = -1;
298  // Verifying whether each node in gridtomerge exists into the gridinitial (i.e., has same coordinates of an existing node). This is inefficient.
299  for (int64_t i = 0; i < nnodestomerge; i++) {
300  nodetomerge = &(gridtomerge->NodeVec()[i]);
301  if (!nodetomerge) continue;
302  nodetomerge->GetCoordinates(coordtomerge);
303  bool found = false;
304  for (j = 0; j < nnodesinitial; j++) {
305  gridinitial->NodeVec()[j].GetCoordinates(coordinitial);
306  if (IsZero(Distance(coordtomerge, coordinitial))) {
307  // In this case exists a node with same coordinates, then the id is updated as the id of the node in gridinitial
308  // and the old id is stored
309  // nodetomerge->SetCoord(0,oldid);
310  newid = j;
311  // nodetomerge->SetNodeId(gridinitial->NodeVec()[j].Id());
312  found = true;
313  break;
314  }
315  }
316 
317  // If the node (i) does not exist into the gridinitial a copy if it is created in this grid, and is substituted in all the
318  // elements in gridinitial the id as old node with the id of the new node. At last, the id of the node duplicated is set to -1
319  if (!found) {
320  // resizing the vector of nodes
321  newid = gridinitial->NodeVec().AllocateNewElement();
322  gridinitial->NodeVec()[newid].Initialize(coordtomerge, *gridinitial);
323  }
324  for (k = 0; k < gridtomerge->NElements(); k++) {
325  gel = tomerge->ElementVec()[k];
326  if (!gel) continue;
327  for (int p = 0; p < gel->NNodes(); p++) {
328  if (gel->NodeIndex(p) == i) {
329  gel = gridtomerge->ElementVec()[k];
330  gel->SetNodeIndex(p, newid);
331  }
332  }
333  }
334  }
335 
336  // Must check if geometric elements into gridtomerge are boundary elements and whether merged it is not boundary anymore
337  int64_t nelmerge = gridtomerge->NElements();
338  for (int64_t i = 0; i < nelmerge; i++) {
339  gel = gridtomerge->ElementVec()[i];
340  if (!gel) continue;
342  int ngelnodes = gel->NNodes();
343  nodes.Resize(ngelnodes);
344  for (j = 0; j < ngelnodes; j++){
345  nodes[j] = gel->NodeIndex(j);
346  }
347  int64_t ii, jj, kk;
348  // Comparing with all elements into gridinitial
349  bool found_element_with_all_nodes = true;
350  for (ii = 0; ii < gridinitial->NElements(); ii++) {
351  found_element_with_all_nodes = true;
352  TPZGeoEl *gelinit = gridinitial->ElementVec()[ii];
353  if (!gelinit) continue;
354  for (kk = 0; kk < nodes.size(); kk++) {
355  bool found = false;
356  for (jj = 0; jj < gelinit->NNodes(); jj++) {
357  int64_t nodegelinit = gelinit->NodeIndex(jj);
358  if (nodes[kk] == nodegelinit){
359  found = true;
360  break;
361  }
362  }
363  if (!found){
364  found_element_with_all_nodes = false;
365  break;
366  }
367  }
368  if (found_element_with_all_nodes) {
369  break;
370  }
371  }
372  if (found_element_with_all_nodes) {
373  delete gel;
374  gridtomerge->ElementVec()[i] = NULL;
375  }
376  }
377 
378  // creating new element into gridinitial corresponding for each element in gridtomerge
379  nelmerge = gridtomerge->NElements();
380  for (int64_t i = 0; i < nelmerge; i++) {
381  gel = gridtomerge->ElementVec()[i];
382  if (!gel) continue;
383  TPZVec<int64_t> nos;
384  int64_t ngelnodes = gel->NNodes();
385  nos.Resize(ngelnodes);
386  for (j = 0; j < ngelnodes; j++)
387  nos[j] = gel->NodeIndex(j);
388  int eltype = 1;
389  if (fRefPattern == false) {
390  eltype = 0;
391  }
392 
393  if (gel->IsLinearMapping()) {
394  int64_t index;
395  if (!gridinitial->CreateGeoElement(gel->Type(), nos, gel->MaterialId(), index, eltype)) {
396  DebugStop();
397  }
398  } else {
399  switch (gel->Type()) {
400  case EOned:
401  {
403  if (gel_quadratic_line) {
404  int64_t id = gridinitial->CreateUniqueElementId();
405  new TPZGeoElRefPattern<pzgeom::TPZQuadraticLine>(id, nos, gel->MaterialId(), *gridinitial);
406  } else {
407  DebugStop();
408  }
409  break;
410  }
411  case EQuadrilateral:
412  {
414  if (gel_quadratic_quad) {
415  int64_t id = gridinitial->CreateUniqueElementId();
416  new TPZGeoElRefPattern< pzgeom::TPZQuadraticQuad> (id, nos, gel->MaterialId(), *gridinitial);
417  } else {
418  DebugStop();
419  }
420  break;
421  }
422  default:
423  DebugStop();
424  }
425  }
426  }
427 
428  // computing the connectivity
429  gridinitial->ResetConnectivities();
430  gridinitial->BuildConnectivity();
431  return true;
432 }
433 
435  if (!grid) return false;
436  // create the geometric nodes
437  TPZManVector<REAL, 3> coor(3,0.);
438  int64_t i;
439  // grid can not to contain other nodes and elements
440  if(grid->NNodes()) {
441 #ifdef LOG4CXX
442  LOGPZ_DEBUG(logger, "Mesh is not empty");
443 #endif
444  return false;
445  }
446 
447  // resizing the vector of the nodes
448  grid->NodeVec().Resize(fNumNodes);
449  for (i = 0; i < fNumNodes; i++) {
450  // computes the coordinates of the ith-node, depends on fElementType, layer and fRotAngle.
451  Coord(i, coor);
452  grid->NodeVec()[i].Initialize(coor, (*grid));
453  }
454  return true;
455 }
456 
457 bool TPZGenGrid::GenerateElements(TPZGeoMesh *grid, int matid) {
458  if (!grid) return false;
459  if (fZigZag) {
460  bool res;
461  res = GenerateElementsZigZag(grid, matid);
462  return res;
463  }
464  // create the geometric elements (retangular)
465  int num_rectangles = fNx[0] * fNx[1] * fNumLayers;
466  TPZVec<int64_t> nos(9);
467  if (fElementType == EQuadrilateral) nos.Resize(4);
468  int64_t i, index;
469 
470  // grid can not to contain other elements
471  if (grid->NElements()) {
472 #ifdef LOG4CXX
473  LOGPZ_DEBUG(logger, "Mesh is not empty");
474 #endif
475  return false;
476  }
477  int eltype = 1;
478  if (fRefPattern == 0) {
479  eltype = 0;
480  }
481  for (i = 0; i < num_rectangles; i++) {
482  ElementConnectivity(i, nos);
483  if (fElementType == EQuadrilateral) {
484  grid->CreateGeoElement(EQuadrilateral, nos, matid, index, eltype);
485  } else if (fElementType == ETriangle) {
486  TPZManVector<int64_t> nodloc(3);
487  nodloc[0] = nos[0];
488  nodloc[1] = nos[1];
489  nodloc[2] = nos[2];
490  grid->CreateGeoElement(ETriangle, nodloc, matid, index, eltype);
491  nodloc[0] = nos[0];
492  nodloc[1] = nos[2];
493  nodloc[2] = nos[3];
494  grid->CreateGeoElement(ETriangle, nodloc, matid, index, eltype);
495  } else if (fElementType == ENoType) {
496  std::cout << __PRETTY_FUNCTION__ << " - Quadratic interpolation is not available";
497  DebugStop();
498  grid->CreateGeoElement(EQuadrilateral, nos, matid, index, eltype);
499  }
500  }
501  grid->BuildConnectivity();
502  return true;
503 }
504 
506  if (!grid) return false;
507  if (fNumLayers != 1 || fElementType != EQuadrilateral) {
508  DebugStop();
509  }
510  // create the geometric elements (retangular)
511  int num_rectangles = (fNx[0] + 1) * fNx[1] * fNumLayers;
513  if (fElementType == EQuadrilateral) nos.Resize(4);
514  int64_t i, index;
515 
516  // grid can not to contain other elements
517  if (grid->NElements()) {
518 #ifdef LOG4CXX
519  LOGPZ_DEBUG(logger, "Mesh is not empty");
520 #endif
521  DebugStop();
522  return false;
523  }
524  int eltype = 1;
525  if (fRefPattern == false) {
526  eltype = 0;
527  }
528  for (i = 0; i < num_rectangles; i++) {
530  if (fElementType == EQuadrilateral && nos.size() == 4) {
531  grid->CreateGeoElement(EQuadrilateral, nos, matid, index, eltype);
532  } else {
533  TPZManVector<int64_t> nodloc(3);
534  nodloc[0] = nos[0];
535  nodloc[1] = nos[1];
536  nodloc[2] = nos[2];
537  grid->CreateGeoElement(ETriangle, nodloc, matid, index, eltype);
538  }
539  }
540  grid->BuildConnectivity();
541  return true;
542 
543 }
544 
545 void TPZGenGrid::Coord(int i, TPZVec<REAL> &coor) {
546  int ix = 0;
547  int iy = 0;
548  int ilayer = 0;
550  if (i < (fNx[0] + 1)*(fNx[1] + 1)) {
551  ilayer = 0;
552  } else {
553  ilayer = (i - (fNx[0] + 1)*(fNx[1] + 1)) / ((fNx[0])*(fNx[1] + 1)) + 1;
554  }
555  } else if (fElementType == ENoType) {
556  if (i < (2 * fNx[0] + 1)*(2 * fNx[1] + 1)) {
557  ilayer = 0;
558  } else {
559  ilayer = (i - (2 * fNx[0] + 1)*(2 * fNx[1] + 1)) / ((2 * fNx[0])*(2 * fNx[1] + 1)) + 1;
560  }
561  }
562  REAL Rot = fRotAngle*ilayer;
563  if (ilayer != 0 && (fElementType == EQuadrilateral || fElementType == ETriangle)) {
564  i -= ((fNx[0] + 1)*(fNx[1] + 1))+(ilayer - 1)*((fNx[0])*(fNx[1] + 1));
565  } else if (ilayer != 0 && fElementType == ENoType) {
566  i -= ((2 * fNx[0] + 1)*(2 * fNx[1] + 1))+(ilayer - 1)*((2 * fNx[0])*(2 * fNx[1] + 1));
567  }
568  if (ilayer == 0) {
570  ix = i % (fNx[0] + 1);
571  iy = i / (fNx[0] + 1);
572  } else if (fElementType == ENoType) {
573  ix = i % (2 * fNx[0] + 1);
574  iy = i / (2 * fNx[0] + 1);
575  }
576  } else {
578  ix = i % (fNx[0]) + 1;
579  iy = i / (fNx[0]);
580  } else if (fElementType == ENoType) {
581  ix = i % (2 * fNx[0]) + 1;
582  iy = i / (2 * fNx[0]);
583  }
584  }
585  //cout << "Coord i = " << i << " ix = " << ix << " iy = " << iy << " layer = " << ilayer << endl;
586  //cout.flush();
587  REAL coorold[2] = {fX0[0], fX0[1]};
588  REAL elsize[2] = {fDelx[0], fDelx[1]};
589  if (fGeometricProgression[0] == 1.) {
590  coorold[0] += ix * elsize[0];
591  } else {
592  for (int i = 0; i < ix; i++) {
593  coorold[0] += elsize[0];
594  elsize[0] *= fGeometricProgression[0];
595  }
596  }
597  if (fGeometricProgression[1] == 1.) {
598  coorold[1] += iy * elsize[1];
599  } else {
600  for (int j = 0; j < iy; j++) {
601  coorold[1] += elsize[1];
602  elsize[1] *= fGeometricProgression[1];
603  }
604  }
605  // coorold[1] = fX0[1]+fDelx[1]*iy;
606 
607  if (ilayer == 0 /*&&ix%2*/ && iy % 2) {
608  if (ix % 2) coorold[1] += fDistortion * elsize[1];
609  else coorold[1] -= fDistortion * elsize[1];
610  }
611  if (Rot == 0.) {
612  coor[0] = coorold[0];
613  coor[1] = coorold[1];
614  coor[2] = 0.;
615  } else {
616  // rotate along the y axis
617  coor[0] = fX0[0]+(coorold[0] - fX0[0]) * cos(Rot);
618  coor[2] = fX0[2] + coorold[0] * sin(Rot);
619  // coor[0] = coorold[0];
620  coor[1] = coorold[1];
621  // coor[2] = 0.;// 0.1*(coorold[0]-fX0[0])*(fX1[0]-coorold[0]);
622  }
623 }
624 
625 void TPZGenGrid::ElementConnectivity(int64_t i, TPZVec<int64_t> &rectangle_nodes) {
626  int xel = i % (fNx[0]);
627  int yel = (i / (fNx[0])) % (fNx[1]);
628  int layer = i / (fNx[0] * fNx[1]);
629  //cout << "ElConnectivity : xel = " << xel << " yel = " << yel << " layer = " << layer << endl;
630  //cout.flush();
632  rectangle_nodes[0] = GlobalI(xel, yel, layer);
633  rectangle_nodes[1] = GlobalI(xel + 1, yel, layer);
634  rectangle_nodes[2] = GlobalI(xel + 1, yel + 1, layer);
635  rectangle_nodes[3] = GlobalI(xel, yel + 1, layer);
636  //cout << "ElConnectivity : " << rectangle_nodes[0] << ' '<< rectangle_nodes[1] << ' '<<rectangle_nodes[2] << ' '<<rectangle_nodes[3] << endl;
637  //cout.flush();
638  } else if (fElementType == ENoType) {
639  rectangle_nodes[0] = GlobalI(2 * xel, 2 * yel, layer);
640  rectangle_nodes[1] = GlobalI(2 * xel + 2, 2 * yel, layer);
641  rectangle_nodes[2] = GlobalI(2 * xel + 2, 2 * yel + 2, layer);
642  rectangle_nodes[3] = GlobalI(2 * xel, 2 * yel + 2, layer);
643  rectangle_nodes[4] = GlobalI(2 * xel + 1, 2 * yel, layer);
644  rectangle_nodes[5] = GlobalI(2 * xel + 2, 2 * yel + 1, layer);
645  rectangle_nodes[6] = GlobalI(2 * xel + 1, 2 * yel + 2, layer);
646  rectangle_nodes[7] = GlobalI(2 * xel, 2 * yel + 1, layer);
647  rectangle_nodes[8] = GlobalI(2 * xel + 1, 2 * yel + 1, layer);
648  }
649 }
650 
651 void TPZGenGrid::ElementConnectivityZigZag(int64_t i, TPZVec<int64_t> &rectangle_nodes) {
652  int yel = i / (fNx[0] + 1);
653  // int firstnode = yel*(fNx[0]+2);
654  int xel = i % (fNx[0] + 1);
655  int layer = 0;
656  if (xel < fNx[0] - 1) {
657  rectangle_nodes.resize(4);
658  rectangle_nodes[0] = GlobalI(xel, yel, layer);
659  rectangle_nodes[1] = GlobalI(xel + 1, yel, layer);
660  rectangle_nodes[2] = GlobalI(xel + 1, yel + 1, layer);
661  rectangle_nodes[3] = GlobalI(xel, yel + 1, layer);
662  if (yel % 2 == 0) {
663  rectangle_nodes[2]++;
664  rectangle_nodes[3]++;
665  } else {
666  rectangle_nodes[0]++;
667  rectangle_nodes[1]++;
668  }
669  } else if (xel == fNx[0] - 1 && yel % 2 == 0) {
670  rectangle_nodes.resize(3);
671  rectangle_nodes[0] = GlobalI(0, yel, layer);
672  rectangle_nodes[2] = GlobalI(0 + 1, yel + 1, layer);
673  rectangle_nodes[1] = GlobalI(0, yel + 1, layer);
674  // std::cout << "yel = " << yel << " nodes " << rectangle_nodes << std::endl;
675  } else if (xel == fNx[0] && yel % 2 == 0) {
676  rectangle_nodes.resize(3);
677  xel = fNx[0] - 1;
678  rectangle_nodes[0] = GlobalI(xel, yel, layer);
679  rectangle_nodes[1] = GlobalI(xel + 1, yel, layer);
680  rectangle_nodes[2] = GlobalI(xel + 1, yel + 1, layer);
681  // std::cout << "yel = " << yel << " nodes " << rectangle_nodes << std::endl;
682  } else if (xel == fNx[0] - 1 && yel % 2 == 1) {
683  rectangle_nodes.resize(3);
684  rectangle_nodes[0] = GlobalI(0, yel, layer);
685  rectangle_nodes[1] = GlobalI(0 + 1, yel, layer);
686  rectangle_nodes[2] = GlobalI(0, yel + 1, layer);
687  // std::cout << "yel = " << yel << " nodes " << rectangle_nodes << std::endl;
688  } else if (xel == fNx[0] && yel % 2 == 1) {
689  rectangle_nodes.resize(3);
690  xel = fNx[0] - 1;
691  rectangle_nodes[0] = GlobalI(xel + 1, yel, layer);
692  rectangle_nodes[1] = GlobalI(xel + 1, yel + 1, layer);
693  rectangle_nodes[2] = GlobalI(xel, yel + 1, layer);
694  // std::cout << "yel = " << yel << " nodes " << rectangle_nodes << std::endl;
695  }
696 }
697 
698 void TPZGenGrid::Print(char *name, ostream &out) {
699  out << "\n" << name << "\n";
700  out << "element type = " << fElementType << endl;
701  out << "Number of divisions " << fNx[0] << ' ' << fNx[1] << endl;
702  out << "Corner Coordinates " << endl << fX0[0] << ' ' << fX0[1] << endl;
703  out << fX1[0] << ' ' << fX1[1] << endl;
704 }
705 
706 void TPZGenGrid::SetBC(TPZGeoMesh*g, int side, int bc) {
707  if (fZigZag) {
708  DebugStop();
709  }
710  int64_t ielfirst = 0;
711  int64_t iellast = 0;
712  int64_t ielinc;
713  int layer;
714  int64_t iel;
715  TPZGeoEl *gel;
716  int elementside = side;
717  for (layer = 0; layer < fNumLayers; layer++) {
718  switch (side) {
719  case 4:
720  ielfirst = layer * fNx[0] * fNx[1];
721  iellast = ielfirst + fNx[0];
722  ielinc = 1;
723  break;
724  case 5:
725  ielfirst = layer * fNx[0] * fNx[1] + fNx[0] - 1;
726  iellast = (layer + 1) * fNx[0] * fNx[1];
727  ielinc = fNx[0];
728  break;
729  case 6:
730  ielfirst = layer * fNx[0] * fNx[1] + fNx[0]*(fNx[1] - 1);
731  ielinc = 1;
732  iellast = (layer + 1) * fNx[0] * fNx[1];
733  break;
734  case 7:
735  ielfirst = layer * fNx[0] * fNx[1];
736  ielinc = fNx[0];
737  iellast = ielfirst + fNx[1] * ielinc;
738  break;
739  default:
740  cout << "It is not implemented for side = " << side << endl;
741  DebugStop();
742  return;
743  }
744  if (fElementType == ETriangle) {
745  elementside -= 1;
746  ielfirst *= 2;
747  iellast *= 2;
748  ielinc *= 2;
749  if (side > 5) {
750  ielfirst += 1;
751  iellast += 1;
752  side -= 1;
753  elementside--;
754  }
755  }
756  for (iel = ielfirst; iel < iellast; iel += ielinc) {
757  if (iel >= g->NElements()) {
758  DebugStop();
759  }
760  gel = g->ElementVec()[iel];
761  if (gel->HasSubElement()) continue;
762  TPZGeoElBC(gel, elementside, bc);
763  }
764  }
765 }
766 
768  TPZGeoNode *gn1 = g->FindNode(start);
769  TPZGeoNode *gn2 = g->FindNode(end);
770 
771  TPZStack<TPZGeoEl *> ElementVec;
772  TPZStack<int> Sides;
773  g->GetBoundaryElements(gn1->Id(), gn2->Id(), ElementVec, Sides);
774  int64_t numel = ElementVec.NElements();
775  for (int64_t el = 0; el < numel; el++) {
776  TPZGeoEl *gel = (TPZGeoEl *) ElementVec[el];
777  if (gel) {
778  TPZGeoElBC(gel, Sides[el], bc);
779  }
780  }
781 }
782 
783 int TPZGenGrid::GlobalI(int ix, int iy, int layer) {
784  if (layer == 0 || ix == 0) {
786  return ix + iy * (fNx[0] + 1);
787  } else if (fElementType == ENoType) {
788  return ix + iy * (2 * fNx[0] + 1);
789  }
790  } else {
792  return (fNx[0] + 1)*(fNx[1] + 1)+(fNx[0])*(fNx[1] + 1)*(layer - 1) + ix - 1 + iy * (fNx[0]);
793  } else if (fElementType == ENoType) {
794  return (2 * fNx[0] + 1)*(2 * fNx[1] + 1)+(2 * fNx[0])*(2 * fNx[1] + 1)*(layer - 1) + ix - 1 + iy * (2 * fNx[0]);
795  }
796  }
797  return 0;
798 }
799 
800 int64_t TPZGenGrid::ElemId(int64_t iel, int64_t jel, int layer) {
801  return (fElementType == EQuadrilateral || fElementType == ENoType) ? (iel * fNx[0] + jel + fNx[0] * fNx[1] * layer) : (iel * 2 * fNx[0] + jel + layer * 2 * fNx[0] * fNx[1]);
802 }
803 
805  REAL l1, l2, l3;
806  l1 = x1[0] - x2[0];
807  l2 = x1[1] - x2[1];
808  l3 = x1[2] - x2[2];
809  return ( sqrt(l1 * l1 + l2 * l2 + l3 * l3));
810 }
811 
813 
814  if (type != EQuadrilateral && type != ETriangle) {
815  DebugStop();
816  }
817  fElementType = type;
819  fNumNodes = (fNx[0] + 1)*(fNx[1] + 1)+(fNumLayers - 1)*(fNx[0])*(fNx[1] + 1);
820  fDelx[0] = (fX1[0] - fX0[0]) / (fNx[0]);
821  fDelx[1] = (fX1[1] - fX0[1]) / (fNx[1]);
822  } else if (fElementType == ENoType) {
823  fNumNodes = (2 * fNx[0] + 1)*(2 * fNx[1] + 1)+(fNumLayers - 1)*(2 * fNx[0])*(2 * fNx[1] + 1);
824  fDelx[0] = (fX1[0] - fX0[0]) / (2 * fNx[0]);
825  fDelx[1] = (fX1[1] - fX0[1]) / (2 * fNx[1]);
826  }
827 }
828 
830 
831 REAL TPZGenGrid::GeometricProgression(REAL minsize, REAL domainsize, int numdiv) {
832  REAL progression = 1.;
833  REAL factor = domainsize / minsize;
834  REAL func = 0.; //pow(progression[idim],fNx[idim])-1.+factor[idim]*(1.-progression[idim]);
835  REAL nextsize = 1.;
836  for (int i = 0; i < numdiv; i++) {
837  func += nextsize;
838  nextsize *= progression;
839  }
840  func -= factor;
841  int iter = 0;
842  int maxiter = 200;
843  while (fabs(func / factor) >= 1.e-10 && iter < 200) {
844  REAL dfunc = 0.; // fNx[idim]*pow(progression[idim], fNx[idim]-1)-factor[idim];
845  func = 0.;
846  nextsize = 1.;
847  for (int i = 0; i < numdiv; i++) {
848  func += nextsize;
849  dfunc += i * nextsize / progression;
850  nextsize *= progression;
851  }
852  func -= factor;
853  //std::cout << "func = " << func << std::endl;
854  progression -= func / dfunc;
855  func = 0.; //pow(progression[idim],fNx[idim])-1.+factor[idim]*(1.-progression[idim]);
856  nextsize = 1.;
857  dfunc = 0.;
858  for (int i = 0; i < numdiv; i++) {
859  func += nextsize;
860  dfunc += i * nextsize / progression;
861  nextsize *= progression;
862  }
863  func -= factor;
864 
865  iter++;
866  }
867  if (iter == maxiter) {
868  DebugStop();
869  }
870  return progression;
871 
872 }
873 
874 
875 
877 
879  int idim;
880  progression.Resize(2, 1.);
881  progression[0] = 1.;
882  progression[1] = 1.;
883  REAL factor[2];
884  for (idim = 0; idim < 2; idim++) {
885  // apply a simple newton method to find the geometric progression factors
886  factor[idim] = (fX1[idim] - fX0[idim]) / minsizes[idim];
887  REAL func = 0.; //pow(progression[idim],fNx[idim])-1.+factor[idim]*(1.-progression[idim]);
888  REAL nextsize = 1.;
889  for (int i = 0; i < fNx[idim]; i++) {
890  func += nextsize;
891  nextsize *= progression[idim];
892  }
893  func -= factor[idim];
894  int iter = 0;
895  int maxiter = 200;
896  while (fabs(func / factor[idim]) >= 1.e-10 && iter < 200) {
897  REAL dfunc = 0.; // fNx[idim]*pow(progression[idim], fNx[idim]-1)-factor[idim];
898  func = 0.;
899  nextsize = 1.;
900  for (int i = 0; i < fNx[idim]; i++) {
901  func += nextsize;
902  dfunc += i * nextsize / progression[idim];
903  nextsize *= progression[idim];
904  }
905  func -= factor[idim];
906  //std::cout << "func = " << func << std::endl;
907  progression[idim] -= func / dfunc;
908  func = 0.; //pow(progression[idim],fNx[idim])-1.+factor[idim]*(1.-progression[idim]);
909  nextsize = 1.;
910  for (int i = 0; i < fNx[idim]; i++) {
911  func += nextsize;
912  dfunc += i * nextsize / progression[idim];
913  nextsize *= progression[idim];
914  }
915  func -= factor[idim];
916 
917  iter++;
918  }
919  if (iter == maxiter) {
920  DebugStop();
921  }
922  }
923 }
924 
926 
928  for (int idim = 0; idim < 2; idim++) {
929  REAL totalsize = 0;
930  REAL nextsize = 1.;
931  for (int i = 0; i < fNx[idim]; i++) {
932  totalsize += nextsize;
933  nextsize *= progression[idim];
934  }
935  fDelx[idim] = (fX1[idim] - fX0[idim]) / totalsize;
936  }
937  fGeometricProgression = progression;
938 }
939 
941 
943  // look for an element/corner node whose distance is close to start
944  TPZGeoNode *gn1 = gr->FindNode(x);
945  int64_t iel;
946  int64_t nelem = gr->ElementVec().NElements();
947  TPZGeoEl *gel;
948  for (iel = 0; iel < nelem; iel++) {
949  gel = gr->ElementVec()[iel];
950  if (!gel) continue;
951  int nc = gel->NCornerNodes();
952  int c;
953  for (c = 0; c < nc; c++) {
954  TPZGeoNode *gn = gel->NodePtr(c);
955  if (gn == gn1) {
956  break;
957  }
958  }
959  if (c < nc) {
960  TPZGeoElBC(gel, c, bc);
961  return;
962  }
963  }
964 }
965 
void ComputeGeometricProgression(TPZVec< REAL > &minsizes, TPZVec< REAL > &progression)
Compute the geometric progression such that the first elements have this size.
Definition: pzgengrid.cpp:878
void SetPointBC(TPZGeoMesh *gr, TPZVec< REAL > &x, int bc)
Generate a boundary geometric element at the indicated node.
Definition: pzgengrid.cpp:942
void ElementConnectivityZigZag(int64_t iel, TPZVec< int64_t > &nodes)
compute the nodes of the ith Element
Definition: pzgengrid.cpp:651
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
int AllocateNewElement()
Makes more room for new elements.
Definition: pzadmchunk.h:184
REAL fDistortion
Definition: pzgengrid.h:277
void SetCoord(const TPZVec< REAL > &x)
Sets all coordinates into the current node. It gets the dim values from x.
Definition: pzgnode.cpp:60
const int64_t numel
Number of elements to test.
Definition: pzsubcmesh.cpp:47
TPZManVector< REAL > fGeometricProgression
Geometric progression coeficients in the x and y direction.
Definition: pzgengrid.h:258
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Definition: pzgeoel.cpp:2566
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
Definition: pzreal.h:668
virtual bool GenerateElements(TPZGeoMesh *grid, int matid)
Creates the geometric element: triangles or quadrilaterals.
Definition: pzgengrid.cpp:457
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.
REAL fRotAngle
Rotation angle between the layers.
Definition: pzgengrid.h:270
bool fRefPattern
Uniform or refpattern elements.
Definition: pzgengrid.h:280
int MaterialId() const
Returns the material index of the element.
Definition: pzgeoel.h:250
clarg::argBool bc("-bc", "binary checkpoints", false)
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
Contains declaration of TPZGeoNode class which defines a geometrical node.
virtual void resize(const int64_t newsize)
Definition: pzvec.h:213
REAL Coord(int i) const
Returns i-th coordinate of the current node.
Definition: pzgnode.h:99
TPZManVector< REAL > fDelx
Size of the lower left element.
Definition: pzgengrid.h:256
bool MergeGeoMesh(TPZGeoMesh *grid, TPZGeoMesh *grid2, int matid=1)
Merges two geometrical mesh created for TPZGenGrid as separated, both meshes must to exist...
Definition: pzgengrid.cpp:282
Templated vector implementation.
Contains the TPZQuadraticQuad class which defines a quadrilateral geometric element with quadratic ma...
static REAL Distance(TPZVec< REAL > &x1, TPZVec< REAL > &x2)
Computes the euclidean distance between two points, or the measure of the interval between two points...
Definition: pzgengrid.cpp:804
virtual int NCornerNodes() const =0
Returns the number of corner nodes of the element.
virtual void SetElementType(MElementType type)
Set the element type.
Definition: pzgengrid.cpp:812
virtual bool GenerateElementsZigZag(TPZGeoMesh *grid, int matid)
Creates the geometric element: triangles or quadrilaterals.
Definition: pzgengrid.cpp:505
TPZManVector< REAL > fX0
Coordinate of the lower left point.
Definition: pzgengrid.h:252
int64_t NElements() const
Number of elements of the mesh.
Definition: pzgmesh.h:129
Contains declaration of TPZGeoElBC class, it is a structure to help the construction of geometric ele...
int64_t NElements() const
Access method to query the number of elements of the vector.
virtual int64_t NodeIndex(int i) const =0
Returns the index of the ith node the index is the location of the node in the nodevector of the mesh...
virtual void Print(char *name=NULL, std::ostream &out=std::cout)
Prints the data structure of the class.
Definition: pzgengrid.cpp:698
void SetDimension(int dim)
Set Dimension.
Definition: pzgmesh.h:285
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
static TPZGraphNode gn
Definition: pzgraphmesh.cpp:76
virtual int GlobalI(int ix, int iy, int layer)
Returns the geometric node id for the element addressed by the parameters.
Definition: pzgengrid.cpp:783
TPZGeoNode * FindNode(TPZVec< REAL > &co)
Returns the nearest node to the coordinate. This method is VERY INEFFICIENT.
Definition: pzgmesh.cpp:419
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 Resize(const int newsize)
Increase the size of the chunk vector.
Definition: pzadmchunk.h:280
sin
Definition: fadfunc.h:63
int64_t CreateUniqueElementId()
Returns ++fElementMaxId.
Definition: pzgmesh.h:117
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
TPZManVector< int > fNx
Number of elements in both directions.
Definition: pzgengrid.h:250
virtual void SetNodeIndex(int i, int64_t nodeindex)=0
Initializes the node i of the element.
Implements a generic geometric element which is refined according to a generic refinement pattern...
Definition: pzgmesh.h:35
static REAL GeometricProgression(REAL minsize, REAL size, int numdiv)
Compute the geometric progression such that the first elements have this size.
Definition: pzgengrid.cpp:831
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
int fNumLayers
Number of meshes which will be generated hinging along an axis.
Definition: pzgengrid.h:268
TPZManVector< REAL > fX1
coordinate of the upper right point
Definition: pzgengrid.h:254
MElementType fElementType
Variable which indicates the type of element that should be generated Only EQuadrilateral or ETriangl...
Definition: pzgengrid.h:265
virtual void SetBC(TPZGeoMesh *gr, int side, int bc)
Generate boundary geometric elements associated with the side of the rectangular domain.
Definition: pzgengrid.cpp:706
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
int64_t NNodes() const
Number of nodes of the mesh.
Definition: pzgmesh.h:126
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
void SetGeometricProgression(TPZVec< REAL > &progression)
Sets the geometric progression of the mesh to be generated.
Definition: pzgengrid.cpp:927
Contains declaration of TPZConnect class which represents a set of shape functions associated with a ...
TPZGenGrid(TPZVec< int > &nx, TPZVec< REAL > &x0, TPZVec< REAL > &x1, int numl=1, REAL rot=0.5)
Constructor of the rectangular domain.
Definition: pzgengrid.cpp:33
virtual MElementType Type() const =0
Returns the element type acording to pzeltype.h.
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
Contains the TPZGenGrid class which implements the generation of a multilayered geometric grid (two-d...
string res
Definition: test.py:151
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
virtual void Coord(int i, TPZVec< REAL > &coord)
Computes the coordinates of the ith geometric node generated.
Definition: pzgengrid.cpp:545
int64_t fNumNodes
Number of nodes of the mesh.
Definition: pzgengrid.h:260
Contains the TPZQuadraticLine class which defines a linear geometric element with quadratic map...
Contains declaration of TPZCompMesh class which is a repository for computational elements...
void SetData(TPZVec< int > &nx, TPZVec< REAL > &x0, TPZVec< REAL > &x1, MElementType eltype=EQuadrilateral, int numl=1, REAL rot=0.5)
Change points and all data to generate geometric mesh.
Definition: pzgengrid.cpp:44
A simple stack.
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
virtual int NNodes() const =0
Returns the number of nodes of the element.
virtual bool IsLinearMapping() const
Definition: pzgeoel.h:268
bool ReadAndMergeGeoMesh(TPZGeoMesh *grid, TPZGeoMesh *grid2)
Merges two geometrical mesh created for TPZGenGrid as separated.
Definition: pzgengrid.cpp:99
Structure to help the construction of geometric elements along side of a given geometric element...
Definition: pzgeoelbc.h:21
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
bool fZigZag
variable to generate a zigzag grid
Definition: pzgengrid.h:273
Implements a geometric node in the pz environment. Geometry.
Definition: pzgnode.h:31
int64_t ElemId(int64_t iel, int64_t jel, int layer)
Returns the element id for the element addressed by the parameters.
Definition: pzgengrid.cpp:800
virtual ~TPZGenGrid()
Default destructor.
Definition: pzgengrid.cpp:41
virtual bool GenerateNodes(TPZGeoMesh *grid)
Creates the geometric nodes, it depends on fElementType, layer and fRotAngle.
Definition: pzgengrid.cpp:434
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
void ResetConnectivities()
Reset all connectivities.
Definition: pzgmesh.cpp:1576
int Id() const
Returns the identity of the current node.
Definition: pzgnode.h:68
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void GetCoordinates(TPZVec< REAL > &co)
Fill the coordinates of the node.
Definition: pzgnode.cpp:83
void SetNodeId(int id)
Definition: pzgnode.h:73
Definition: pzeltype.h:55
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Definition: pzreal.h:514
void ElementConnectivity(int64_t iel, TPZVec< int64_t > &nodes)
compute the nodes of the ith Element
Definition: pzgengrid.cpp:625
virtual short Read(TPZGeoMesh *mesh, int matid=1)
Add nodes and elements to the object mesh.
Definition: pzgengrid.cpp:64
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138