ParMooN
 All Classes Functions Variables Friends Pages
aerofoil_expt.h
1 // ==========================================================================
2 // instationary problem
3 // ==========================================================================
4 
5 //===========================================================================
6 // example file
7 // =========================================================================
8 // exact solution in unit cube
9 void ExampleFile()
10 {
11  OutPut("Example: Aerofoil_expt.h" << endl);
12 }
13 
14 void GridBoundCondition(double x, double y, double z, BoundCond &cond)
15 {
16  cond = DIRICHLET;
17 }
18 // exact solution
19 void Exact(double x, double y, double z, double *values)
20 {
21  values[0] = 0;
22  values[1] = 0;
23  values[2] = 0;
24  values[3] = 0;
25  values[4] = 0;
26 }
27 
28 // initial conditon
29 void InitialCondition(double x, double y, double z, double *values)
30 {
31  values[0] = TDatabase::ParamDB->P0;
32 }
33 
34 // type of boundary condition
35 void BoundCondition(double x, double y, double z, BoundCond &cond)
36 {
37  cond = DIRICHLET;
38  //cond = NEUMANN;
39 }
40 
41 // value of boundary condition
42 void BoundValue(double x, double y, double z, double &value)
43 {
44  value = 0;
45 }
46 
47 void BilinearCoeffs(int n_points, double *X, double *Y, double *Z, double **parameters, double **coeffs)
48 {
49  static double eps=1/TDatabase::ParamDB->RE_NR;
50  int i;
51  double *coeff, *param;
52 
53  for(i=0;i<n_points;i++)
54  {
55  coeff = coeffs[i];
56  param = parameters[i];
57 
58  coeff[0] = eps;
59  coeff[1] = 0;
60  coeff[2] = 0;
61  coeff[3] = 0;
62  coeff[4] = 0;
63  coeff[5] = 0;;
64  }
65 }
66 
67 void ReadAdditionalNodes(char *NODE, tetgenio &InAddPts)
68 {
69  int i, N_Vertices, index, N_Atribude, BDMarker;
70  char line[100];
71  std::ifstream dat(NODE);
72 
73  if (!dat)
74  {
75  cerr << "cannot open '" << NODE << "' for input" << endl;
76  exit(-1);
77  }
78 
79  dat.getline (line, 99); // first line is command line
80  dat >> N_Vertices >> N_Atribude >> BDMarker;
81  dat.getline (line, 99);
82 
83  InAddPts.numberofpoints = N_Vertices;
84  InAddPts.pointlist = new double[3*N_Vertices];
85 
86  //read from file
87  for(i=0;i<N_Vertices; i++)
88  {
89  dat.getline (line, 99);
90  dat >> index >> InAddPts.pointlist[3*i] >> InAddPts.pointlist[3*i+1] >> InAddPts.pointlist[3*i+2];
91  cout<< i << " vert X: " <<InAddPts.pointlist[3*i] << " vert Y: " <<InAddPts.pointlist[3*i+1] <<" vert Z: " <<InAddPts.pointlist[3*i+2] <<endl;
92 
93  }
94 
95  dat.close();
96 
97 // cout << "N_Vertices " <<N_Vertices <<endl;
98 //
99 // exit(0);
100 
101 } // ReadAdditionalNModes
102 
103 
104 
105 void ReadMeditMeshWithCells(char *SMESH, tetgenio &In)
106 {
107  int i, j, k, dimension, N_FVert, N_Faces, N_Vertices, N_CVert, N_Cells;
108  int BDComp_Min=10000000;
109  int *plist;
110 
111  double x;
112  cout << "test " <<endl;
113 
114  char line[100];
115  tetgenio::facet *F;
116  tetgenio::polygon *P;
117 
118  std::ifstream dat(SMESH);
119 
120  if (!dat)
121  {
122  cerr << "cannot open '" << SMESH << "' for input" << endl;
123  exit(-1);
124  }
125 
126  // check the dimension
127  while (!dat.eof())
128  {
129  dat >> line;
130 
131  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
132  {
133  dat.getline (line, 99);
134  dat >> dimension;
135  break;
136  }
137  // read until end of line
138  dat.getline (line, 99);
139  }
140 
141  if(dimension!=3)
142  {
143  cerr << "dimension: " << dimension << endl;
144  exit(-1);
145  }
146 
147  // find the N_Vertices
148  while (!dat.eof())
149  {
150  dat >> line;
151 
152  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
153  {
154  dat.getline (line, 99);
155  dat >> N_Vertices;
156  break;
157  }
158  // read until end of line
159  dat.getline (line, 99);
160  }
161 
162  In.numberofpoints = N_Vertices;
163  In.pointlist = new double[3*N_Vertices];
164 
165  //read from file
166  for(i=0;i<N_Vertices; i++)
167  {
168  dat.getline (line, 99);
169  dat >> x >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
170 
171  In.pointlist[3*i] = x - 3.606596999999999830777142; //center point
172 
173 // if(i==1063 || i==1061 || i==1062 || i==162 || i==1175 || i==517 || i==1064 || i==518 ) // i==1063 as center
174 // if(i==1062 || i==916 || i==341 || i==914 || i==162 || i==1063 || i==1061) // i==1062 as center
175 // cout<< i << " vert X: " <<In.pointlist[3*i] << " vert Y: " <<In.pointlist[3*i+1] <<" vert Z: " <<In.pointlist[3*i+2] <<endl;
176  }
177 
178  // find the N_Triangles
179  // find the N_Vertices
180  while (!dat.eof())
181  {
182  dat >> line;
183 
184  if ( (!strcmp(line, "Triangles")) || (!strcmp(line, "triangles")) || (!strcmp(line, "TRIANGLES")) )
185  {
186  N_FVert = 3;
187  dat.getline (line, 99);
188  dat >> N_Faces;
189  break;
190  }
191  else if ( (!strcmp(line, "Quadrilaterals")) || (!strcmp(line, "quadrilaterals")) || (!strcmp(line, "QUADRILATERALS")) )
192  {
193  N_FVert = 4;
194  dat.getline (line, 99);
195  dat >> N_Faces;
196  break;
197  }
198 
199  // read until end of line
200  dat.getline (line, 99);
201  }
202 
203  In.numberoffacets = N_Faces;
204  In.facetlist = new tetgenio::facet[In.numberoffacets];
205  In.facetmarkerlist = new int[In.numberoffacets];
206 
207  for(i=0;i<N_Faces; i++)
208  {
209  dat.getline (line, 99);
210 
211  F = &In.facetlist[i];
212  tetgenio::init(F);
213  F->numberofpolygons = 1;
214  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
215  F->numberofholes = 0;
216  F->holelist = NULL;
217 
218  P = &F->polygonlist[0];
219  tetgenio::init(P);
220  P->numberofvertices = N_FVert;
221  P->vertexlist = new int[P->numberofvertices];
222 
223  for(j=0;j<N_FVert;j++)
224  {
225  dat >> k;
226  P->vertexlist[j] = k-1; // c numbering
227  }
228 
229  dat >> In.facetmarkerlist[i];
230 
231  if(BDComp_Min > In.facetmarkerlist[i])
232  BDComp_Min=In.facetmarkerlist[i];
233 
234  // cout << i<< " P->vertexlist[j]: " << In.facetmarkerlist[i] << endl;
235  } // for(i=0;i<N_Faces; i++)
236 
237  BDComp_Min--;
238 
239  for(i=0;i<N_Faces; i++)
240  In.facetmarkerlist[i] -= BDComp_Min;
241 
242 
244  while (!dat.eof())
245  {
246  dat >> line;
247 
248  if ( (!strcmp(line, "Tetrahedron")) || (!strcmp(line, "tetrahedron")) || (!strcmp(line, "TETRAHEDRON")) )
249  {
250  N_CVert = 4;
251  dat.getline (line, 99);
252  dat >> N_Cells;
253  break;
254  }
255  // read until end of line
256  dat.getline (line, 99);
257  }
258 
259  In.numberoftetrahedra = N_Cells;
260  In.numberofcorners = N_CVert;
261  In.numberoftetrahedronattributes = 1;
262  In.tetrahedronlist = new int[N_Cells * 4];
263  In.tetrahedronattributelist = new REAL[N_Cells];
264  In.tetrahedronvolumelist = new REAL[N_Cells];
265 
266  for(i=0; i<N_Cells; i++)
267  {
268  dat.getline (line, 99);
269  plist = &(In.tetrahedronlist[i * 4]);
270 
271  for(j=0;j<N_CVert;j++)
272  {
273  dat >> k;
274  plist[j] = k -1;
275  }// for(j=0;j<N_CV
276 
277 
278  dat >> In.tetrahedronattributelist[i];
279 // In.tetrahedronvolumelist [i] = 100.;
280  } // for(i=0; i<N_
281 
282 
283 
284 // cout << i<< " N_Cells : " << N_Cells << endl;
285 // exit(0);
286 
287  dat.close();
288 // exit(0);
289 } // ReadMeditMeshWithCells
290 
291 
292 void ReadMeditMesh(char *SMESH, tetgenio &In)
293 {
294  int i, j, k, dimension, N_FVert, N_Faces, N_Vertices;
295  int BDComp_Min=10000000;
296  double x, y, z;
297 
298  char line[100];
299  tetgenio::facet *F;
300  tetgenio::polygon *P;
301 
302  std::ifstream dat(SMESH);
303 
304  if (!dat)
305  {
306  cerr << "cannot open '" << SMESH << "' for input" << endl;
307  exit(-1);
308  }
309 
310  // check the dimension
311  while (!dat.eof())
312  {
313  dat >> line;
314 
315  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
316  {
317  dat.getline (line, 99);
318  dat >> dimension;
319  break;
320  }
321  // read until end of line
322  dat.getline (line, 99);
323  }
324 
325  if(dimension!=3)
326  {
327  cerr << "dimension: " << dimension << endl;
328  exit(-1);
329  }
330 
331  // find the N_Vertices
332  while (!dat.eof())
333  {
334  dat >> line;
335 
336  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
337  {
338  dat.getline (line, 99);
339  dat >> N_Vertices;
340  break;
341  }
342  // read until end of line
343  dat.getline (line, 99);
344  }
345 
346  In.numberofpoints = N_Vertices;
347  In.pointlist = new double[3*N_Vertices];
348  In.pointmtrlist = new double[N_Vertices];
349  In.numberofpointmtrs = 1;
350 
351 //===========================================================================
352 // hole list
353 // =========================================================================
354 // In.numberofholes =1;
355 // In.holelist = new double[3];
356 // In.holelist[0] =2.;
357 // In.holelist[1] =2.;
358 // In.holelist[2] =2.;
359 // =========================================================================
360 
361 
362  //read from file
363  for(i=0;i<N_Vertices; i++)
364  {
365  dat.getline (line, 99);
366  dat >> In.pointlist[3*i] >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
367 // dat >> x >> y >> z ;
368 // In.pointlist[3*i] = -x/100.;
369 // In.pointlist[3*i+1] =y/100.;
370 // In.pointlist[3*i+2] = z/100.;
371 
372  In.pointmtrlist[i] = 10.;
373  //cout<< i << " vert X: " <<In.pointlist[3*i] << " vert Y: " <<In.pointlist[3*i+1] <<endl;
374  }
375 
376 // In.pointmtrlist[0] = 0.75;
377 
378  // find the N_Triangles
379  // find the N_Vertices
380  while (!dat.eof())
381  {
382  dat >> line;
383 
384  if ( (!strcmp(line, "Triangles")) || (!strcmp(line, "triangles")) || (!strcmp(line, "TRIANGLES")) )
385  {
386  N_FVert = 3;
387  dat.getline (line, 99);
388  dat >> N_Faces;
389  break;
390  }
391  else if ( (!strcmp(line, "Quadrilaterals")) || (!strcmp(line, "quadrilaterals")) || (!strcmp(line, "QUADRILATERALS")) )
392  {
393  N_FVert = 4;
394  dat.getline (line, 99);
395  dat >> N_Faces;
396  break;
397  }
398 
399  // read until end of line
400  dat.getline (line, 99);
401  }
402 
403  In.numberoffacets = N_Faces;
404  In.facetlist = new tetgenio::facet[In.numberoffacets];
405  In.facetmarkerlist = new int[In.numberoffacets];
406 
407  for(i=0;i<N_Faces; i++)
408  {
409  dat.getline (line, 99);
410 
411  F = &In.facetlist[i];
412  tetgenio::init(F);
413  F->numberofpolygons = 1;
414  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
415  F->numberofholes = 0;
416  F->holelist = NULL;
417  P = &F->polygonlist[0];
418  tetgenio::init(P);
419  P->numberofvertices = N_FVert;
420  P->vertexlist = new int[P->numberofvertices];
421 
422  for(j=0;j<N_FVert;j++)
423  {
424  dat >> k;
425  P->vertexlist[j] = k-1; // c numbering
426  }
427 
428  dat >> In.facetmarkerlist[i];
429 
430  if(BDComp_Min > In.facetmarkerlist[i])
431  BDComp_Min=In.facetmarkerlist[i];
432 
433  // cout << i<< " P->vertexlist[j]: " << In.facetmarkerlist[i] << endl;
434  } // for(i=0;i<N_Faces; i++)
435 
436  BDComp_Min--;
437 
438 
439 
440 
441 
442 
443 
444 
445 
446 
447  for(i=0;i<N_Faces; i++)
448  In.facetmarkerlist[i] -= BDComp_Min;
449 
450 // cout << i<< " P->vertexlist[j]: " << BDComp_Min << endl;
451 
452 
453  dat.close();
454 // exit(0);
455 } // ReadMeditMesh
456 
457 
458 
459 void ReadMeditMesh_Adapt(char *SMESH, tetgenio &In)
460 {
461  int i, j, k, m, dimension, N_FVert, N_Faces, N_Vertices;
462  int BDComp_Min=10000000, N_AddVert, count, VertList[4], Fcount;
463 
464  double X_, Y_, Z_;
465  char line[100];
466  tetgenio::facet *F;
467  tetgenio::polygon *P;
468 
469  std::ifstream dat(SMESH);
470 
471  if (!dat)
472  {
473  cerr << "cannot open '" << SMESH << "' for input" << endl;
474  exit(-1);
475  }
476 
477  // check the dimension
478  while (!dat.eof())
479  {
480  dat >> line;
481 
482  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
483  {
484  dat.getline (line, 99);
485  dat >> dimension;
486  break;
487  }
488  // read until end of line
489  dat.getline (line, 99);
490  }
491 
492  if(dimension!=3)
493  {
494  cerr << "dimension: " << dimension << endl;
495  exit(-1);
496  }
497 
498  // find the N_Vertices
499  while (!dat.eof())
500  {
501  dat >> line;
502 
503  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
504  {
505  dat.getline (line, 99);
506  dat >> N_Vertices;
507  break;
508  }
509  // read until end of line
510  dat.getline (line, 99);
511  }
512 
513  N_AddVert = 6;
514  In.numberofpoints = N_Vertices + N_AddVert;
515  In.pointlist = new double[3*In.numberofpoints];
516 // In.pointmtrlist = new double[In.numberofpoints];
517 // In.numberofpointmtrs = 1;
518 
519  //read from file
520  for(i=0;i<N_Vertices; i++)
521  {
522  dat.getline (line, 99);
523  dat >> In.pointlist[3*i] >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
524 // In.pointmtrlist[i] = 10.;
525  //cout<< i << " vert X: " <<In.pointlist[3*i] << " vert Y: " <<In.pointlist[3*i+1] <<endl;
526  }
527 
528  // N_AddVert vertices will be added later
529 
530 
531  // find the N_Triangles
532  // find the N_Vertices
533  while (!dat.eof())
534  {
535  dat >> line;
536 
537  if ( (!strcmp(line, "Triangles")) || (!strcmp(line, "triangles")) || (!strcmp(line, "TRIANGLES")) )
538  {
539  N_FVert = 3;
540  dat.getline (line, 99);
541  dat >> N_Faces;
542  break;
543  }
544  else if ( (!strcmp(line, "Quadrilaterals")) || (!strcmp(line, "quadrilaterals")) || (!strcmp(line, "QUADRILATERALS")) )
545  {
546  N_FVert = 4;
547  dat.getline (line, 99);
548  dat >> N_Faces;
549  break;
550  }
551 
552  // read until end of line
553  dat.getline (line, 99);
554  }
555 
556  cout << "N_Faces " << N_Faces << endl;
557  In.numberoffacets = N_Faces + 2;
558  In.facetlist = new tetgenio::facet[In.numberoffacets];
559  In.facetmarkerlist = new int[In.numberoffacets];
560 
561  count = 0;
562  Fcount = 0;
563  for(i=0;i<N_Faces; i++)
564  {
565  dat.getline (line, 99);
566 
567  F = &In.facetlist[i];
568  tetgenio::init(F);
569  F->numberofpolygons = 1;
570  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
571  F->numberofholes = 0;
572  F->holelist = NULL;
573  P = &F->polygonlist[0];
574  tetgenio::init(P);
575 
576 
577  if( (i==1479 || i==1517 || i==1518 || i==1695 || i==1702 || i==1740 ) && N_AddVert>0) //
578  {
579  X_=0.;
580  Y_=0.;
581  Z_=0.;
582 
583  //first generate new vertex in the face
584  for(j=0;j<N_FVert;j++)
585  {
586  dat >> k;
587  m = k-1; // c numbering
588  VertList[j] = m; // store the orig order for later use
589  X_ += In.pointlist[3*m];
590  Y_ += In.pointlist[3*m + 1];
591  Z_ += In.pointlist[3*m + 2];
592 
593 // cout<< m << " vert X: " <<In.pointlist[3*m] << " vert Y: " <<In.pointlist[3*m + 1] << " vert Z: " <<In.pointlist[3*m + 2]<<endl;
594  }
595  dat >> In.facetmarkerlist[i];
596 
597  X_ /=(double)N_FVert;
598  Y_ /=(double)N_FVert;
599  Z_ /=(double)N_FVert;
600 
601 
602  // add the additional vertex in thethe polygon
603  m = N_Vertices + count;
604  In.pointlist[3*m] = X_;
605  In.pointlist[3*m+1] = Y_;
606  In.pointlist[3*m+2] = Z_;
607  count++;
608 // cout<< m << " vert X: " <<X_ << " vert Y: " <<Y_ << " vert Z: " <<Z_ <<endl;
609 
610  //now input the ith face info
611  P->numberofvertices = N_FVert;
612  P->vertexlist = new int[P->numberofvertices];
613 
614  if(i==1479 || i==1517)
615  {
616  P->vertexlist[0] = VertList[0];
617  P->vertexlist[1] = m;
618  P->vertexlist[2] = VertList[2];
619  }
620  else if( i==1740 )
621  {
622  P->vertexlist[0] = VertList[2];
623  P->vertexlist[1] = m;
624  P->vertexlist[2] = VertList[1];
625  }
626  else
627  {
628  P->vertexlist[0] = VertList[0];
629  P->vertexlist[1] = VertList[1];
630  P->vertexlist[2] = m;
631  }
632 
633  cout<< m << " vert 1: " << P->vertexlist[0] << " vert 2: " <<P->vertexlist[1] << " vert 3: " <<P->vertexlist[2]<<endl;
634  cout<<endl;
635 
636 /* // add additional two faces
637  F = &In.facetlist[N_Faces+Fcount];
638  tetgenio::init(F);
639  F->numberofpolygons = 1;
640  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
641  F->numberofholes = 0;
642  F->holelist = NULL;
643  P = &F->polygonlist[0];
644  tetgenio::init(P);
645  P->numberofvertices = N_FVert;
646  P->vertexlist = new int[P->numberofvertices];
647  P->vertexlist[0] = VertList[1];
648  P->vertexlist[1] = VertList[2];
649  P->vertexlist[2] = m;
650  In.facetmarkerlist[N_Faces+Fcount] = In.facetmarkerlist[i];
651  Fcount++;
652 
653  F = &In.facetlist[N_Faces+Fcount];
654  tetgenio::init(F);
655  F->numberofpolygons = 1;
656  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
657  F->numberofholes = 0;
658  F->holelist = NULL;
659  P = &F->polygonlist[0];
660  tetgenio::init(P);
661  P->numberofvertices = N_FVert;
662  P->vertexlist = new int[P->numberofvertices];
663  P->vertexlist[0] = VertList[2];
664  P->vertexlist[1] = VertList[0];
665  P->vertexlist[2] = m;
666  In.facetmarkerlist[N_Faces+Fcount] = In.facetmarkerlist[i];
667  Fcount++; */
668  }
669  else
670  {
671  P->numberofvertices = N_FVert;
672  P->vertexlist = new int[P->numberofvertices];
673 
674  for(j=0;j<N_FVert;j++)
675  {
676  dat >> k;
677  P->vertexlist[j] = k-1; // c numbering
678  }
679 
680  dat >> In.facetmarkerlist[i];
681 
682  }
683 
684 
685 
686  if(BDComp_Min > In.facetmarkerlist[i])
687  BDComp_Min=In.facetmarkerlist[i];
688 
689  // cout << i<< " P->vertexlist[j]: " << In.facetmarkerlist[i] << endl;
690  } // for(i=0;i<N_Faces; i++)
691 
692 
693  // now add other 2 faces
694 
695  // add additional two faces
696  F = &In.facetlist[N_Faces+Fcount];
697  tetgenio::init(F);
698  F->numberofpolygons = 1;
699  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
700  F->numberofholes = 0;
701  F->holelist = NULL;
702  P = &F->polygonlist[0];
703  tetgenio::init(P);
704  P->numberofvertices = 8;
705  P->vertexlist = new int[P->numberofvertices];
706  P->vertexlist[0] = 729;
707  P->vertexlist[1] = N_Vertices;
708  P->vertexlist[2] = 728;
709  P->vertexlist[3] = N_Vertices + 1;
710  P->vertexlist[4] = 409;
711  P->vertexlist[5] = N_Vertices + 2;
712  P->vertexlist[6] = 727;
713  P->vertexlist[7] = N_Vertices + 4;
714 
715  In.facetmarkerlist[N_Faces+Fcount] = In.facetmarkerlist[i-1];
716  Fcount++;
717 
718  F = &In.facetlist[N_Faces+Fcount];
719  tetgenio::init(F);
720  F->numberofpolygons = 1;
721  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
722  F->numberofholes = 0;
723  F->holelist = NULL;
724  P = &F->polygonlist[0];
725  tetgenio::init(P);
726  P->numberofvertices = 8;
727  P->vertexlist = new int[P->numberofvertices];
728  P->vertexlist[0] = 727;
729  P->vertexlist[1] = N_Vertices + 4;
730  P->vertexlist[2] = 410;
731  P->vertexlist[3] = N_Vertices + 3;
732  P->vertexlist[4] = 724;
733  P->vertexlist[5] = N_Vertices + 5;
734  P->vertexlist[6] = 723;
735  P->vertexlist[7] = N_Vertices + 2;
736 
737 
738 
739  cout<< m << " vert: " << P->vertexlist[0] << " vert: " <<P->vertexlist[1] << " vert: " <<P->vertexlist[2]<< " vert: " << P->vertexlist[3] << " vert: " << P->vertexlist[4]<<endl;
740  cout<<endl;
741 
742  In.facetmarkerlist[N_Faces+Fcount] = In.facetmarkerlist[i-1];
743  Fcount++;
744 
745 
746  F = &In.facetlist[N_Faces+Fcount];
747  tetgenio::init(F);
748  F->numberofpolygons = 1;
749  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
750  F->numberofholes = 0;
751  F->holelist = NULL;
752  P = &F->polygonlist[0];
753  tetgenio::init(P);
754  P->numberofvertices = 4;
755  P->vertexlist = new int[P->numberofvertices];
756  P->vertexlist[0] = N_Vertices + 3;
757  P->vertexlist[1] = N_Vertices + 5;
758  P->vertexlist[2] = N_Vertices + 2;
759  P->vertexlist[3] = 727;
760 // P->vertexlist[5] = N_Vertices + 4;
761 
762  cout<< m << " vert: " << P->vertexlist[0] << " vert: " <<P->vertexlist[1] << " vert: " <<P->vertexlist[2]<< " vert: " << P->vertexlist[3] << " vert: " << P->vertexlist[4]<<endl;
763  cout<<endl;
764 
765  In.facetmarkerlist[N_Faces+Fcount] = In.facetmarkerlist[i-1];
766  Fcount++;
767 
768  BDComp_Min--;
769 
770  for(i=0;i<N_Faces + Fcount; i++)
771  In.facetmarkerlist[i] -= BDComp_Min;
772 
773 // cout << i<< " P->vertexlist[j]: " << BDComp_Min << endl;
774 
775 
776  dat.close();
777 // exit(0);
778 } // ReadMeditMesh_Adapt
779 
780 void DeleteDomain(TDomain *&Domain)
781 {
782  int i, j, k, N_Cells, N_RootCells;
783  int CurrVertex, N_Faces, N_Vertices, ID;
784 
785  TBaseCell **CellTree, **SurfCellTree, *cell;
786  TGridCell **DelCell;
787  TVertex **VertexDel;
788  TCollection *coll;
789 
790 
791  Domain->GetTreeInfo(CellTree,N_RootCells);
792  coll = Domain->GetCollection(It_Finest, 0);
793  N_Cells = coll->GetN_Cells();
794 
795 
796  // cout<<"N_RootCells: "<<N_RootCells<<endl;
797  // remove all existing vertices and joints
798  VertexDel = new TVertex*[8*N_RootCells];
799  CurrVertex = 0;
800 
801  for(i=0;i<N_Cells;i++)
802  {
803  cell = coll->GetCell(i);
804  N_Faces = cell->GetN_Faces();
805  N_Vertices = cell->GetN_Vertices();
806  for(j=0;j<N_Faces;j++)
807  {
808  if(CurrVertex==0)
809  {
810  VertexDel[CurrVertex++] = cell->GetVertex(j);
811  }
812  else
813  {
814  ID = 0;
815  for(k=0;k<CurrVertex;k++)
816  if(VertexDel[k]==cell->GetVertex(j))
817  {
818  ID = 1; break;
819  }
820  if(ID!=1)
821  {
822  VertexDel[CurrVertex++] = cell->GetVertex(j);
823  }
824  } // else if(CurrVertex==0)
825 
826  ID = 0;
827  for(k=0;k<CurrVertex;k++)
828  if(VertexDel[k]==cell->GetVertex((j+1)%N_Vertices))
829  {
830  ID = 1; break;
831  }
832  if(ID!=1)
833  {
834  VertexDel[CurrVertex++] = cell->GetVertex((j+1)%N_Vertices);
835  }
836 
837  ID = 0;
838  for(k=0;k<CurrVertex;k++)
839  if(VertexDel[k]==cell->GetVertex((j+2)%N_Vertices))
840  {
841  ID = 1; break;
842  }
843  if(ID!=1)
844  {
845  VertexDel[CurrVertex++] = cell->GetVertex((j+2)%N_Vertices);
846  }
847  if(N_Faces==6) // If old cell is hexahedrol
848  {
849  ID = 0;
850  for(k=0;k<CurrVertex;k++)
851  if(VertexDel[k]==cell->GetVertex((j+4)%N_Vertices))
852  {
853  ID = 1; break;
854  }
855  if(ID!=1)
856  {
857  VertexDel[CurrVertex++] = cell->GetVertex((j+4)%N_Vertices);
858  }
859  }
860  } // for j
861  } // for i
862 
863  for(i=0;i<CurrVertex;i++)
864  delete VertexDel[i];
865  delete [] VertexDel;
866  OutPut(CurrVertex<<" vertices were deleted"<<endl);
867 
868  // remove all existing cells and joints
869 
870  for(i=0;i<N_RootCells;i++)
871  delete (TGridCell*)CellTree[i];
872  delete [] CellTree;
873  OutPut(N_RootCells<<" cells were deleted"<<endl);
874 
875 
876 /*
877  cout << "DeleteDomain" <<endl;
878  exit(0);
879  */
880 }
881 
882 
883 void TetrameshCreate(TDomain *&Domain)
884 {
885  int i, j, k, l, dimension, N_Vertices;
886  int N_FVert, N_Faces, *Facemarkerlist, *Facelist, N_RootCells;
887  int v1, v2, v3, v4, CellMarker, RefLevel=0, *Tetrahedrals, *PointNeighb, maxEpV, *Tetrahedrals_loc;
888  int a, b, c, Neib[2], Neighb_tmp, CurrNeib, len1, len2, len3, CurrComp, N_Points ;
889  int N_Cells, MaxLen, jj;
890  const int *EdgeVertex, *TmpFV, *TmpLen;
891 
892  double X, Y, Z, DispX, DispY, DispZ;
893  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
894  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
895  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
896 
897  char *MESH, line[100];
898  MESH = TDatabase::ParamDB->SMESHFILE;
899 
900  TVertex **NewVertices;
901  TBaseCell **CellTree, *cell;
902  TJoint *Joint;
903  TBoundComp3D *bdcomp;
904  TShapeDesc *ShapeDesc;
905  TCollection *coll;
906 
907 #ifdef _MPI
908  int rank, size;
909  MPI_Comm Comm = TDatabase::ParamDB->Comm;
910 
911  MPI_Comm_rank(Comm, &rank);
912  MPI_Comm_size(Comm, &size);
913 
914 #endif
915 
917  DeleteDomain(Domain);
918 
919 
920  // cout << " SMESHFILE is " << SMESH << endl;
922  std::ifstream dat(MESH);
923 
924  if (!dat)
925  {
926  cerr << "cannot open '" << MESH << "' for input" << endl;
927  exit(-1);
928  }
929 
930 
931  // check the dimension
932  while (!dat.eof())
933  {
934  dat >> line;
935 
936  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
937  {
938  dat.getline (line, 99);
939  dat >> dimension;
940  break;
941  }
942  // read until end of line
943  dat.getline (line, 99);
944  }
945 
946  if(dimension!=3)
947  {
948  cerr << "dimension: " << dimension << endl;
949  exit(-1);
950  }
951 
952  // find the N_Vertices
953  while (!dat.eof())
954  {
955  dat >> line;
956 
957  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
958  {
959  dat.getline (line, 99);
960  dat >> N_Vertices;
961  break;
962  }
963  // read until end of line
964  dat.getline (line, 99);
965  }
966 
967  // generate new vertices
968  NewVertices = new TVertex*[N_Vertices];
969 
970  //read from file
971  for(i=0;i<N_Vertices; i++)
972  {
973  dat.getline (line, 99);
974  dat >> X >> Y >> Z;
975 
976  if(TDatabase::ParamDB->P13==0)
977  { //Lside
978  //center point is 3.606596999999999830777142 93.27791100000000312775228 78.19347199999999986630428
979  DispX = 3.606596999999999830777142;
980  DispY = 0.;
981  DispZ = 0.;
982  }
983  else if(TDatabase::ParamDB->P13==1)
984  {
985  //Backside
986  //center point is 60388: 83.11056343315070193966676 12.29866318748098663604651 97.409675520607805765394
987  DispX = 0.;
988  DispY = 12.29866318748098663604651;
989  DispZ = 0.;
990  }
991  else if(TDatabase::ParamDB->P13==2)// default
992  {
993  //Front side
994  //center point is 986: 91.21127599999999802093953 214.3263880000000028758222 85.10373400000000287946023
995  DispX = 0.;
996  DispY = 214.3263880000000028758222;
997  DispZ = 0.;
998  }
999  else // default
1000  {
1001  //right side
1002  //center point is 727: 177.8944370000000105846993 95.85110799999999642295734 81.84575200000000450017978
1003  DispX = 177.8944370000000105846993;
1004  DispY = 0.;
1005  DispZ = 0.;
1006  }
1007 
1008 
1009 
1010  NewVertices[i] = new TVertex( (X - DispX), (Y - DispY), (Z- DispZ));
1011 
1012 // if(i==1062 || i==916 || i==341 || i==914 || i==162 || i==1063 || i==1061) // i==1062 as center LSide
1013 // if(i==60388 || i==65824 || i==60386 || i==230 || i==60394 || i==60391 || i==590) // i==60388 as center BackSide
1014 // cout<< i << " vert X: " <<X << " vert Y: " <<Y <<" vert Z: " <<Z <<endl;
1015 
1016 // if(i==986 || i==524 || i==993 || i==985 || i==546 || i==987 || i==988) // i==71212 as center Front
1017 // cout<< i << " vert X: " <<X << " vert Y: " <<Y <<" vert Z: " <<Z <<endl;
1018 
1019 // if(i==727 || i==410 || i==729 || i==728 || i==409 || i==723 || i==724) // i==727 as right side
1020 // cout<< i << " vert X: " <<X << " vert Y: " <<Y <<" vert Z: " <<Z <<endl;
1021 
1022 
1023  // set bounding box
1024  if (X > Xmax) Xmax = X;
1025  if (X < Xmin) Xmin = X;
1026  if (Y > Ymax) Ymax = Y;
1027  if (Y < Ymin) Ymin = Y;
1028  if (Z > Zmax) Zmax = Z;
1029  if (Z < Zmin) Zmin = Z;
1030 
1031  //cout<< i << " vert X: " <<X << " vert Y: " <<Y <<" vert Z: " <<Z <<endl;
1032  } // for(i=0;i<N_Vertices; i++)
1033 
1034  // set bounding box
1035  StartX = Xmin;
1036  StartY = Ymin;
1037  StartZ = Zmin;
1038  BoundX = Xmax - Xmin;
1039  BoundY = Ymax - Ymin;
1040  BoundZ = Zmax - Zmin;
1041 
1042 
1043  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1044 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
1045 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
1046 // 0.032813 3.78927 -0.883686 // brain cells range
1047 // 181.509 216.944 174.768 // brain cells range
1048 // cout<<" N_Vertices "<<N_Vertices <<endl;
1049 // exit(0);
1050 
1051 
1052  // find the N_Triangles
1053  while (!dat.eof())
1054  {
1055  dat >> line;
1056 
1057  if ( (!strcmp(line, "Triangles")) || (!strcmp(line, "triangles")) || (!strcmp(line, "TRIANGLES")) )
1058  {
1059  N_FVert = 3;
1060  dat.getline (line, 99);
1061  dat >> N_Faces;
1062  break;
1063  }
1064  else if ( (!strcmp(line, "Quadrilaterals")) || (!strcmp(line, "quadrilaterals")) || (!strcmp(line, "QUADRILATERALS")) )
1065  {
1066  N_FVert = 4;
1067  dat.getline (line, 99);
1068  dat >> N_Faces;
1069  break;
1070  }
1071 
1072  // read until end of line
1073  dat.getline (line, 99);
1074  }
1075 
1076 
1077  if(N_FVert!=3)
1078  {
1079  cerr << "Only Tria surfaces implemented N_FVert: " << N_FVert << endl;
1080  exit(-1);
1081  }
1082 
1083  Facelist = new int[N_FVert*N_Faces];
1084  Facemarkerlist = new int[N_Faces];
1085 
1086  for(i=0;i<N_Faces; i++)
1087  {
1088  dat.getline (line, 99);
1089 
1090  for(j=0;j<N_FVert;j++)
1091  {
1092  dat >> k;
1093  Facelist[i*N_FVert + j] = k-1; // c numbering
1094  }
1095 
1096  dat >> Facemarkerlist[i];
1097 
1098  } // for(i=0;i<N_Faces; i++)
1099 
1100 
1101 // for(i=0;i<N_Faces; i++)
1102 // {
1103 // if(Facelist[3*i]==0 ||Facelist[3*i+1]==0 ||Facelist[3*i+2]==0 )
1104 // cout<< i << " vert X: " <<Facelist[3*i] << " vert Y: " <<Facelist[3*i+1] <<" vert Z: " <<Facelist[3*i+2] <<endl;
1105 //
1106 //
1107 // }
1108  // find the N_RootCells
1109  while (!dat.eof())
1110  {
1111  dat >> line;
1112 
1113  if ( (!strcmp(line, "Tetrahedron")) || (!strcmp(line, "tetrahedron")) || (!strcmp(line, "TETRAHEDRON")) )
1114  {
1115  dat.getline (line, 99);
1116  dat >> N_RootCells;
1117  break;
1118  }
1119  // read until end of line
1120  dat.getline (line, 99);
1121  }
1122 
1123  // generate new cells
1124  CellTree = new TBaseCell*[N_RootCells];
1125  Tetrahedrals = new int[4*N_RootCells];
1126 
1127  for (i=0;i<N_RootCells;i++)
1128  {
1129  dat.getline (line, 99);
1130  dat >> v1 >> v2 >> v3 >> v4 >> CellMarker;
1131  Tetrahedrals[4*i ] = v1 -1;
1132  Tetrahedrals[4*i + 1] = v2 -1;
1133  Tetrahedrals[4*i + 2] = v3 -1;
1134  Tetrahedrals[4*i + 3] = v4 -1;
1135 
1136 
1137  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron], RefLevel);
1138  CellTree[i]->SetRegionID(CellMarker);
1139  CellTree[i]->SetAsLayerCell(1);
1140 
1141  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
1142  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
1143  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
1144  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
1145 
1146  CellTree[i]->SetClipBoard(i);
1147  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
1148  }
1149 
1150  dat.close();
1151 
1152 
1153  Domain->SetTreeInfo(CellTree, N_RootCells);
1154 
1155  // initialize iterators
1156  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
1157  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
1158  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
1159  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
1160  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
1161 
1162  // search neighbours
1163  PointNeighb = new int[N_Vertices];
1164 #ifdef _MPI
1165  if(rank==0)
1166 #endif
1167  cout<<"Numberofpoints "<<N_Vertices<<endl;
1168  memset(PointNeighb, 0, N_Vertices*SizeOfInt);
1169 
1170  for (i=0;i<4*N_RootCells;i++)
1171  PointNeighb[Tetrahedrals[i]]++;
1172 
1173  maxEpV = 0;
1174  for (i=0;i<N_Vertices;i++)
1175  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1176  delete [] PointNeighb;
1177 
1178 #ifdef _MPI
1179  if(rank==0)
1180 #endif
1181  cout<<"maxEpV "<< maxEpV<<endl;
1182 
1183  PointNeighb = new int[++maxEpV * N_Vertices];
1184 
1185  memset(PointNeighb, 0, maxEpV*N_Vertices*SizeOfInt);
1186 
1187  // every vertex contains "maxEpV" columns
1188  // for every vertex at first colomn contains the number of cells containing this vertex
1189  // at further columns we set the index of corresponding cells containing this vertex
1190  // cout<<"maxEpV*N_Vertices "<<maxEpV*N_Vertices<<endl;
1191  for(i=0;i<4*N_RootCells;i++)
1192  {
1193  j = Tetrahedrals[i]*maxEpV;
1194  PointNeighb[j]++;
1195  //cout<<"j + PointNeighb[j] " << j <<endl;
1196  PointNeighb[j + PointNeighb[j]] = i / 4;
1197  }
1198 
1199 
1200  // first generate surface faces
1201 #ifdef _MPI
1202  if(rank==0)
1203 #endif
1204  cout<<"Surface faces "<<N_Faces<<endl;
1205 
1206  for (i=0;i<N_Faces;i++)
1207  {
1208  a = Facelist[3*i];
1209  b = Facelist[3*i+1];
1210  c = Facelist[3*i+2];
1211 
1212 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
1213 
1214  Neib[0] = -1;
1215  Neib[1] = -1;
1216  CurrNeib = 0;
1217 
1218  len1 = PointNeighb[a*maxEpV];
1219  len2 = PointNeighb[b*maxEpV];
1220  len3 = PointNeighb[c*maxEpV];
1221 
1222  // find the index of the cells containing current face with point indices a,b,c
1223  for (j=1;j<=len1;j++)
1224  {
1225  Neighb_tmp = PointNeighb[a*maxEpV + j];
1226  for (k=1;k<=len2;k++)
1227  {
1228  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1229  {
1230  for (l=1;l<=len3;l++)
1231  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1232  {
1233  Neib[CurrNeib++] = Neighb_tmp;
1234  break;
1235  }
1236  }
1237  }
1238  if (CurrNeib == 2) break;
1239  }
1240 
1241  if(CurrNeib>1)
1242  continue;
1243 
1244 // if(CurrNeib>1)
1245 // {
1246 // // cout<<"Face " << i << "No. CurrNeib " << CurrNeib << " Neib 1" << Neib[0] << " Neib 2" << Neib[1] <<endl;
1247 // // exit(0);
1248 // }
1249 
1250  CurrComp = Facemarkerlist[i] - 1;
1251 
1252  if (CurrNeib == 1) // boundary face, scalp and skull layer
1253  {
1254 
1255  if(CurrComp!=0)
1256  cout<<"Not a scalp and skull layer: "<<CurrComp<<endl;
1257 
1258  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
1259 
1260 
1261  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
1262  NewVertices[a]->GetY(), T[1], S[1]) ||
1263  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
1264  NewVertices[b]->GetY(), T[2], S[2]) ||
1265  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
1266  NewVertices[c]->GetY(), T[3], S[3]) )
1267  {
1268  cerr<<"Error: could not set parameter values"<<endl;
1269  OutPut(NewVertices[a]<<endl);
1270  OutPut(NewVertices[b]<<endl);
1271  OutPut(NewVertices[c]<<endl);
1272  exit(0);
1273  }
1274 
1275 // if (CurrNeib == 2)
1276 // {
1277 // if(bdcomp->IsFreeBoundary())
1278 // Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
1279 // CellTree[Neib[0]], CellTree[Neib[1]] );
1280 // else
1281 // Joint = new TInterfaceJoint3D(bdcomp, T, S,
1282 // CellTree[Neib[0]], CellTree[Neib[1]] );
1283 // }
1284 // else
1285 // {
1286 // if(bdcomp->IsFreeBoundary())
1287 // Joint = new TIsoBoundFace(bdcomp, T, S);
1288 // else
1289  Joint = new TBoundFace(bdcomp, T, S);
1290 // }
1291  }
1292  else
1293  {
1294  // cout<<"Inner face"<<endl;
1295  if (CurrNeib != 2)
1296  cerr << "Error !!!!!!!! not enough or more neighbours!" << endl;
1297 
1298  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1299 
1300  }
1301 
1302  // First element containing the current face
1303  // find the local index for the point 'a' on the cell
1304  for (j=0;j<4;j++)
1305  if (Tetrahedrals[4*Neib[0]+j] == a) break;
1306 
1307  // find the local index for the point 'b' on the cell
1308  for (k=0;k<4;k++)
1309  if (Tetrahedrals[4*Neib[0]+k] == b) break;
1310 
1311  // find the local index for the point 'c' on the cell
1312  for (l=0;l<4;l++)
1313  if (Tetrahedrals[4*Neib[0]+l] == c) break;
1314 
1315  l = l*100 + k*10 + j;
1316 
1317  //cout<<""<< l <<endl;
1318 
1319  switch (l) // j will contain the local index for the current face
1320  {
1321  case 210: case 21: case 102:
1322  case 120: case 12: case 201:
1323  j = 0;
1324  break;
1325  case 310: case 31: case 103:
1326  case 130: case 13: case 301:
1327  j = 1;
1328  break;
1329  case 321: case 132: case 213:
1330  case 231: case 123: case 312:
1331  j = 2;
1332  break;
1333  case 230: case 23: case 302:
1334  case 320: case 32: case 203:
1335  j = 3;
1336  break;
1337 
1338  default:
1339  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1340  exit(0);
1341  } // switch (l)
1342 
1343  CellTree[Neib[0]]->SetJoint(j, Joint);
1344 
1345  if (Neib[1] != -1) // second element containing the current face
1346  {
1347  // find the local index for the point 'a' on the cell
1348  for (j=0;j<4;j++)
1349  if (Tetrahedrals[4*Neib[1]+j] == a) break;
1350 
1351  // find the local index for the point 'b' on the cell
1352  for (k=0;k<4;k++)
1353  if (Tetrahedrals[4*Neib[1]+k] == b) break;
1354 
1355  // find the local index for the point 'c' on the cell
1356  for (l=0;l<4;l++)
1357  if (Tetrahedrals[4*Neib[1]+l] == c) break;
1358 
1359  l = l*100 + k*10 + j;
1360 
1361 // cout<<""<< l <<endl;
1362 
1363  switch (l) // j will contain the local index for the current face
1364  {
1365  case 210: case 21: case 102:
1366  case 120: case 12: case 201:
1367  j = 0;
1368  break;
1369  case 310: case 31: case 103:
1370  case 130: case 13: case 301:
1371  j = 1;
1372  break;
1373  case 321: case 132: case 213:
1374  case 231: case 123: case 312:
1375  j = 2;
1376  break;
1377  case 230: case 23: case 302:
1378  case 320: case 32: case 203:
1379  j = 3;
1380  break;
1381 
1382  default:
1383  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1384  exit(0);
1385  }
1386  CellTree[Neib[1]]->SetJoint(j, Joint);
1387  } // if (Neib[1] != -1)
1388 
1389  if (Joint->GetType() == InterfaceJoint3D ||
1390  Joint->GetType() == IsoInterfaceJoint3D)
1391  {
1392  ((TInterfaceJoint3D*)Joint)->SetMapType();
1393  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
1394  }
1395  else
1396  if (Joint->GetType() == JointEqN)
1397  Joint->SetMapType();
1398 
1399  } // for (i=0;i<N_Faces;i++)
1400 
1401 
1403  coll=Domain->GetCollection(It_Finest, 0);
1404  N_Cells = coll->GetN_Cells();
1405 
1406  for(i=0;i<N_Cells;i++)
1407  {
1408  cell = coll->GetCell(i);
1409  ShapeDesc= cell->GetShapeDesc();
1410  ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
1411  N_Faces = cell->GetN_Faces();
1412  Tetrahedrals_loc = Tetrahedrals+4*i;
1413 
1414 
1415  for(jj=0;jj<N_Faces;jj++)
1416  if(cell->GetJoint(jj) == NULL)
1417  {
1418  N_Points = TmpLen[jj];
1419 
1420  if(N_Points!=3)
1421  {
1422  cerr << "Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
1423  exit(-1);
1424  }
1425 
1426  //printf(" TetrameshGen Null joint \n" );
1427  a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
1428  b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
1429  c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
1430 
1431  //cout<<" "<< a<<" "<< b<<" "<< c<<endl;
1432 
1433  Neib[0] = -1;
1434  Neib[1] = -1;
1435  CurrNeib = 0;
1436 
1437  len1 = PointNeighb[a*maxEpV];
1438  len2 = PointNeighb[b*maxEpV];
1439  len3 = PointNeighb[c*maxEpV];
1440 
1441  // find the index of the cells containing current face with point indices a,b,c
1442  for (j=1;j<=len1;j++)
1443  {
1444  Neighb_tmp = PointNeighb[a*maxEpV + j];
1445  for (k=1;k<=len2;k++)
1446  {
1447  if(Neighb_tmp == PointNeighb[b*maxEpV + k])
1448  {
1449  for(l=1;l<=len3;l++)
1450  if(Neighb_tmp == PointNeighb[c*maxEpV + l])
1451  {
1452  Neib[CurrNeib++] = Neighb_tmp;
1453  break;
1454  }
1455  }
1456  }
1457  if (CurrNeib == 2) break;
1458  } // for (j=1;j<=len1;j++)
1459 
1460  if(CurrNeib!=2)
1461  {
1462  cerr<<"Face " << i << "No. CurrNeib " << CurrNeib << " Neib 1" << Neib[0] << " Neib 2" << Neib[1] <<endl;
1463  exit(0);
1464  }
1465 
1466  // inner face
1467  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1468 
1469  // First element containing the current face
1470  // find the local index for the point 'a' on the cell
1471  for (j=0;j<4;j++)
1472  if (Tetrahedrals[4*Neib[0]+j] == a) break;
1473 
1474  // find the local index for the point 'b' on the cell
1475  for (k=0;k<4;k++)
1476  if (Tetrahedrals[4*Neib[0]+k] == b) break;
1477 
1478  // find the local index for the point 'c' on the cell
1479  for (l=0;l<4;l++)
1480  if (Tetrahedrals[4*Neib[0]+l] == c) break;
1481 
1482  l = l*100 + k*10 + j;
1483 
1484  //cout<<" l "<< l <<endl;
1485 
1486  switch (l) // j will contain the local index for the current face
1487  {
1488  case 210: case 21: case 102:
1489  case 120: case 12: case 201:
1490  j = 0;
1491  break;
1492  case 310: case 31: case 103:
1493  case 130: case 13: case 301:
1494  j = 1;
1495  break;
1496  case 321: case 132: case 213:
1497  case 231: case 123: case 312:
1498  j = 2;
1499  break;
1500  case 230: case 23: case 302:
1501  case 320: case 32: case 203:
1502  j = 3;
1503  break;
1504 
1505  default:
1506  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1507  exit(0);
1508  } // switch (l)
1509 
1510  CellTree[Neib[0]]->SetJoint(j, Joint);
1511 
1512  // second cell containing the current face
1513  // find the local index for the point 'a' on the cell
1514  for (j=0;j<4;j++)
1515  if (Tetrahedrals[4*Neib[1]+j] == a) break;
1516 
1517  // find the local index for the point 'b' on the cell
1518  for (k=0;k<4;k++)
1519  if (Tetrahedrals[4*Neib[1]+k] == b) break;
1520 
1521  // find the local index for the point 'c' on the cell
1522  for (l=0;l<4;l++)
1523  if (Tetrahedrals[4*Neib[1]+l] == c) break;
1524 
1525  l = l*100 + k*10 + j;
1526 
1527  //cout<<" l "<< l <<endl;
1528 
1529  switch (l) // j will contain the local index for the current face
1530  {
1531  case 210: case 21: case 102:
1532  case 120: case 12: case 201:
1533  j = 0;
1534  break;
1535  case 310: case 31: case 103:
1536  case 130: case 13: case 301:
1537  j = 1;
1538  break;
1539  case 321: case 132: case 213:
1540  case 231: case 123: case 312:
1541  j = 2;
1542  break;
1543  case 230: case 23: case 302:
1544  case 320: case 32: case 203:
1545  j = 3;
1546  break;
1547 
1548  default:
1549  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1550  exit(0);
1551  }
1552  CellTree[Neib[1]]->SetJoint(j, Joint);
1553 
1554  if (Joint->GetType() == InterfaceJoint3D ||
1555  Joint->GetType() == IsoInterfaceJoint3D)
1556  {
1557  ((TInterfaceJoint3D*)Joint)->SetMapType();
1558  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
1559  }
1560  else
1561  if (Joint->GetType() == JointEqN)
1562  Joint->SetMapType();
1563 
1564  } // if(cell->GetJoint(j)
1565  } // for(i=0;i<N_Cells;i++)
1566 
1567 delete [] PointNeighb;
1568 
1569 // #ifdef _MPI
1570 // if(rank==1)
1571 // printf(" TetrameshGen complete \n" );
1572 // MPI_Finalize();
1573 // #endif
1574 // exit(0);
1575 //
1576 
1577 }
1578 
1579 
1580 void TetrameshGen(TDomain *&Domain)
1581 {
1582  //======================================================================
1583  // Tetgen for grid generation begin
1584  //======================================================================
1585  int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
1586  int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
1587  int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
1588  int *Tetrahedrals, *PointNeighb, dimension;
1589  int *Facelist, *Facemarkerlist;
1590 
1591  double X, Y, Z, DispX, DispY, DispZ;
1592  double *Coordinates, N_x, N_y, N_z;
1593  double *Vertices;
1594  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
1595  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
1596  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
1597 
1598  tetgenio In, Out, Out_New;
1599 
1600  TBaseCell **CellTree, **SurfCellTree;
1601  TGridCell **DelCell;
1602  TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1603  TBoundPart *BoundPart;
1604  TBdPlane **UpdateFaceParams;
1605  TJoint *Joint;
1606  TBoundComp3D *bdcomp;
1607  TCollection *coll, *SurfColl;
1608  TBaseCell *cell;
1609  TBdSphere *UpdateParam;
1610 
1611  char *SMESH, line[100];
1612  SMESH = TDatabase::ParamDB->SMESHFILE;
1613 
1614 #ifdef _MPI
1615  int rank, size;
1616  MPI_Comm Comm = TDatabase::ParamDB->Comm;
1617 
1618  MPI_Comm_rank(Comm, &rank);
1619  MPI_Comm_size(Comm, &size);
1620 
1621 #endif
1622 
1623 
1624 
1626 #ifdef _MPI
1627  if(rank==0)
1628 #endif
1629  {
1630 
1631 // In.initialize();
1632 // Out.initialize();
1633 
1634  std::ostringstream opts;
1635  opts << " ";
1636 
1637  opts.seekp(std::ios::beg);
1638  opts<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
1639 // opts<<'r'; // -r Reconstructs a previously generated mesh
1640  opts<<"q"<<1.75; // quality mesh generation(q) with a specified quality bound
1641 // opts<<"a"<<0.1; // maximum volume constraint
1642 // opts<<'i'; // Inserts a list of additional points into mesh.
1643  opts<<'z'; // numbers all output items starting from zero
1644 // opts<<'d'; // Detect intersections of PLC facets.
1645  opts<<'f'; // Outputs all faces (including non-boundary)
1646  opts<<'e'; // Outputs a list of edges of the triangulation
1647 // opts<<'I'; // Suppresses mesh iteration numbers.
1648  opts<<'C'; // Checks the consistency of the final mesh.
1649 // opts<<'Q'; // Quiet: No terminal output except errors.
1650 // opts<<'g'; // Outputs mesh to .mesh file for viewing by Medit
1651 // opts<<'Y'; // Suppresses boundary facets/segments splitting
1652 // opts<<'m'; //
1653 
1654 
1655 // opts<<'V'; //verbose mode
1656  opts<<ends;
1657 
1658 
1659 // cout << " SMESHFILE is " << SMESH << endl;
1661 // ReadMeditMesh(SMESH, In);
1662  ReadMeditMesh_Adapt(SMESH, In);
1663 // // // // ReadMeditMesh_Adapt2(SMESH, In);
1664 // for(i=0;i<In.numberofpoints;i++)
1665 // OutPut(i<<" (x, y, z) = "<<
1666 // In.pointlist[3*i]<<' '<<In.pointlist[3*i+1]<<' '<<In.pointlist[3*i+2]<<endl);
1667 
1668  // Calling tetrahedralize function of 3dtetgen mesh generator
1669  tetrahedralize((char*)opts.str().c_str(), &In, &Out);
1670 
1671 
1672 // std::ostringstream opts_New;
1673 // opts_New << " ";
1674 //
1675 // opts_New.seekp(std::ios::beg);
1676 // // opts_New<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
1677 // opts_New<<'r'; // -r Reconstructs a previously generated mesh
1678 // // opts_New<<"q"<<1.49; // quality mesh generation(q) with a specified quality bound
1679 // // opts_New<<"a"<<0.1; // maximum volume constraint
1680 // // opts_New<<'i'; // Inserts a list of additional points into mesh.
1681 // opts_New<<'z'; // numbers all output items starting from zero
1682 // // opts_New<<'d'; // Detect intersections of PLC facets.
1683 // opts_New<<'f'; // Outputs all faces (including non-boundary)
1684 // opts_New<<'e'; // Outputs a list of edges of the triangulation
1685 // // opts_New<<'I'; // Suppresses mesh iteration numbers.
1686 // opts_New<<'C'; // Checks the consistency of the final mesh.
1687 // // opts_New<<'Q'; // Quiet: No terminal output except errors.
1688 // // opts_New<<'g'; // Outputs mesh to .mesh file for viewing by Medit
1689 // // opts_New<<'Y'; // Suppresses boundary facets/segments splitting
1690 // opts_New<<'m'; //
1691 //
1692 //
1693 // opts_New<<'V'; //verbose mode
1694 // opts_New<<ends;
1695 //
1696 // N_G = Out.numberofpoints;
1697 // Out.pointmtrlist = new double[N_G];
1698 // Out.numberofpointmtrs = 1;
1699 //
1700 // for (i=0;i<N_G;i++)
1701 // Out.pointmtrlist[i] = 10.;
1702 //
1703 // Out.pointmtrlist[Out.tetrahedronlist[0]] = 0.025;
1704 // Out.pointmtrlist[Out.tetrahedronlist[1]] = 0.025;
1705 //
1706 // tetrahedralize((char*)opts_New.str().c_str(), &Out, &Out_New);
1707 //
1708 // for (i=0;i<N_G;i++)
1709 // cout << "Out_New.pointmtrlist " << Out_New.pointmtrlist[i]<< endl;
1710 //
1711  } // if(rank==0)
1712 
1713 // MPI_Finalize();
1714 // exit(0);
1715 //
1716 
1717  // output: coordinates of all vertices
1718 // for(i=0;i<Out.numberofpoints;i++)
1719 // OutPut(" (x, y, z) = "<< Out.pointlist[3*i]<<' '<<Out.pointlist[3*i+1]<<' '<<Out.pointlist[3*i+2]<<endl);
1720 
1721  Domain->GetTreeInfo(CellTree,N_RootCells);
1722  coll = Domain->GetCollection(It_Finest, 0);
1723  N_Cells = coll->GetN_Cells();
1724 
1725 // cout<<"N_RootCells: "<<N_RootCells<<endl;
1726  // remove all existing vertices and joints
1727  VertexDel = new TVertex*[8*N_RootCells];
1728  CurrVertex = 0;
1729 
1730  for(i=0;i<N_Cells;i++)
1731  {
1732  cell = coll->GetCell(i);
1733  N_Faces = cell->GetN_Faces();
1734  N_Vertices = cell->GetN_Vertices();
1735  for(j=0;j<N_Faces;j++)
1736  {
1737  if(CurrVertex==0)
1738  {
1739  VertexDel[CurrVertex++] = cell->GetVertex(j);
1740  }
1741  else
1742  {
1743  ID = 0;
1744  for(k=0;k<CurrVertex;k++)
1745  if(VertexDel[k]==cell->GetVertex(j))
1746  {
1747  ID = 1; break;
1748  }
1749  if(ID!=1)
1750  {
1751  VertexDel[CurrVertex++] = cell->GetVertex(j);
1752  }
1753  } // else if(CurrVertex==0)
1754 
1755  ID = 0;
1756  for(k=0;k<CurrVertex;k++)
1757  if(VertexDel[k]==cell->GetVertex((j+1)%N_Vertices))
1758  {
1759  ID = 1; break;
1760  }
1761  if(ID!=1)
1762  {
1763  VertexDel[CurrVertex++] = cell->GetVertex((j+1)%N_Vertices);
1764  }
1765 
1766  ID = 0;
1767  for(k=0;k<CurrVertex;k++)
1768  if(VertexDel[k]==cell->GetVertex((j+2)%N_Vertices))
1769  {
1770  ID = 1; break;
1771  }
1772  if(ID!=1)
1773  {
1774  VertexDel[CurrVertex++] = cell->GetVertex((j+2)%N_Vertices);
1775  }
1776  if(N_Faces==6) // If old cell is hexahedrol
1777  {
1778  ID = 0;
1779  for(k=0;k<CurrVertex;k++)
1780  if(VertexDel[k]==cell->GetVertex((j+4)%N_Vertices))
1781  {
1782  ID = 1; break;
1783  }
1784  if(ID!=1)
1785  {
1786  VertexDel[CurrVertex++] = cell->GetVertex((j+4)%N_Vertices);
1787  }
1788  }
1789  } // for j
1790  } // for i
1791 
1792  for(i=0;i<CurrVertex;i++)
1793  delete VertexDel[i];
1794  delete [] VertexDel;
1795  OutPut(CurrVertex<<" vertices were deleted"<<endl);
1796 
1797  // remove all existing cells and joints
1798 
1799  for(i=0;i<N_RootCells;i++)
1800  delete (TGridCell*)CellTree[i];
1801  delete [] CellTree;
1802  OutPut(N_RootCells<<" cells were deleted"<<endl);
1803 
1804 
1805 #ifdef _MPI
1806  if(rank==0)
1807 #endif
1808  {
1809  N_RootCells = Out.numberoftetrahedra;
1810  N_G = Out.numberofpoints;
1811 
1812  // allocate auxillary fields
1813  Coordinates = Out.pointlist;
1814  Tetrahedrals = Out.tetrahedronlist;
1815  }
1816 
1817 
1818 
1819 #ifdef _MPI
1820  MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1821  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1822 
1823 
1824  if(rank!=0)
1825  {
1826  Coordinates = new double [3*N_G];
1827  Tetrahedrals = new int[4*N_RootCells];
1828  }
1829 
1830  MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1831  MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1832 #endif
1833 
1834  // generate new vertices
1835  NewVertices = new TVertex*[N_G];
1836 
1837  for (i=0;i<N_G;i++)
1838  {
1839  X = Coordinates[3*i];
1840  Y = Coordinates[3*i+1];
1841  Z = Coordinates[3*i+2];
1842 
1843  if(TDatabase::ParamDB->P13==0)
1844  { //Lside
1845  //center point is 3.606596999999999830777142 93.27791100000000312775228 78.19347199999999986630428
1846  DispX = 3.606596999999999830777142;
1847  DispY = 0.;
1848  DispZ = 0.;
1849  }
1850  else if(TDatabase::ParamDB->P13==1)
1851  {
1852  //Backside
1853  //center point is 60388: 83.11056343315070193966676 12.29866318748098663604651 97.409675520607805765394
1854  DispX = 0.;
1855  DispY = 12.29866318748098663604651;
1856  DispZ = 0.;
1857  }
1858  else if(TDatabase::ParamDB->P13==2)// default
1859  {
1860  //Front side
1861  //center point is 986: 91.21127599999999802093953 214.3263880000000028758222 85.10373400000000287946023
1862  DispX = 0.;
1863  DispY = 214.3263880000000028758222;
1864  DispZ = 0.;
1865  }
1866  else // default
1867  {
1868  //right side
1869  //center point is 727: 177.8944370000000105846993 95.85110799999999642295734 81.84575200000000450017978
1870  DispX = 177.8944370000000105846993;
1871  DispY = 0.;
1872  DispZ = 0.;
1873  }
1874 
1875  NewVertices[i] = new TVertex( (X - DispX), (Y - DispY), (Z- DispZ));
1876 
1877  // set bounding box
1878  if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
1879  if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
1880  if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
1881  if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
1882  if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
1883  if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
1884  }
1885 
1886  // set bounding box
1887  StartX = Xmin;
1888  StartY = Ymin;
1889  StartZ = Zmin;
1890  BoundX = Xmax - Xmin;
1891  BoundY = Ymax - Ymin;
1892  BoundZ = Zmax - Zmin;
1893 
1894 
1895  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1896 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
1897 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
1898 
1899  CellTree = new TBaseCell*[N_RootCells];
1900  // output of each tetraheron vertex indices (four vertices for each)
1901 // for (i=0;i<N_RootCells;i++)
1902 // cout<< Tetrahedrals[4*i]<<" "<<Tetrahedrals[4*i + 1]<<" "
1903 // <<Tetrahedrals[4*i + 2]<<" "<<Tetrahedrals[4*i + 3]<<endl;
1904 
1905 
1906  for (i=0;i<N_RootCells;i++)
1907  {
1908  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron],
1909  RefLevel);
1910 
1911  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
1912  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
1913  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
1914  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
1915 
1916  CellTree[i]->SetClipBoard(i);
1917  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
1918 
1919  //default all cells will be treated as skull
1920  CellTree[i]->SetRegionID(1);
1921  CellTree[i]->SetAsLayerCell(1);
1922  }
1923 
1924  Domain->SetTreeInfo(CellTree, N_RootCells);
1925 
1926 
1927  // initialize iterators
1928  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
1929  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
1930  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
1931  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
1932  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
1933 
1934 
1935  // search neighbours
1936  PointNeighb = new int[N_G];
1937 #ifdef _MPI
1938  if(rank==0)
1939 #endif
1940  cout<<"numberofpoints "<<N_G<<endl;
1941  memset(PointNeighb, 0, N_G *SizeOfInt);
1942 
1943  for (i=0;i<4*N_RootCells;i++)
1944  PointNeighb[Tetrahedrals[i]]++;
1945 
1946  for (i=0;i<N_G;i++)
1947  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1948  delete [] PointNeighb;
1949 
1950 #ifdef _MPI
1951  if(rank==0)
1952 #endif
1953  cout<<"maxEpV "<< maxEpV<<endl;
1954 
1955  PointNeighb = new int[++maxEpV * N_G];
1956 
1957  memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1958 
1959  // every vertex contains "maxEpV" columns
1960  // for every vertex at first colomn contains the number of cells containing this vertex
1961  // at further columns we set the index of corresponding cells containing this vertex
1962  // cout<<"maxEpV*N_G "<<maxEpV*N_G<<endl;
1963 
1964  for(i=0;i<4*N_RootCells;i++)
1965  {
1966  j = Tetrahedrals[i]*maxEpV;
1967  PointNeighb[j]++;
1968  //cout<<"j + PointNeighb[j] " << j <<endl;
1969  PointNeighb[j + PointNeighb[j]] = i / 4;
1970  }
1971  // output of PointNeighb columns for each point
1972 // for (i=0;i<N_G;i++)
1973 // {
1974 // for (j=0;j<maxEpV;j++)
1975 // cout<<" "<< PointNeighb[i*maxEpV+j];
1976 // cout<<endl;
1977 // }
1978 
1979 
1980 
1981  // generate new faces
1982 
1983 #ifdef _MPI
1984  if(rank==0)
1985 #endif
1986  {
1987  N_G = Out.numberoftrifaces;
1988  Facelist = Out.trifacelist;
1989  Facemarkerlist = Out.trifacemarkerlist;
1990  }
1991 
1992 #ifdef _MPI
1993  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1994 
1995  if(rank!=0)
1996  {
1997  Facelist = new int [3*N_G];
1998  Facemarkerlist = new int[N_G];
1999  }
2000 
2001 
2002  MPI_Bcast(Facelist, 3*N_G, MPI_INT, 0, Comm);
2003  MPI_Bcast(Facemarkerlist, N_G, MPI_INT, 0, Comm);
2004 
2005  if(rank==0)
2006 #endif
2007  cout<<"numberoftrifaces "<<N_G<<endl;
2008 
2009  for (i=0;i<N_G;i++)
2010  {
2011  a = Facelist[3*i];
2012  b = Facelist[3*i+1];
2013  c = Facelist[3*i+2];
2014 
2015 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
2016 
2017  Neib[0] = -1;
2018  Neib[1] = -1;
2019  CurrNeib = 0;
2020 
2021  len1 = PointNeighb[a*maxEpV];
2022  len2 = PointNeighb[b*maxEpV];
2023  len3 = PointNeighb[c*maxEpV];
2024 
2025  // find the index of the cells containing current face with point indices a,b,c
2026  for (j=1;j<=len1;j++)
2027  {
2028  Neighb_tmp = PointNeighb[a*maxEpV + j];
2029  for (k=1;k<=len2;k++)
2030  {
2031  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
2032  {
2033  for (l=1;l<=len3;l++)
2034  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
2035  {
2036  Neib[CurrNeib++] = Neighb_tmp;
2037  break;
2038  }
2039  }
2040  }
2041  if (CurrNeib == 2) break;
2042  }
2043  // cout<<"CurrNeib " << CurrNeib <<endl;
2044 // cout<<"Facemarkerlist[i] : "<<Facemarkerlist[i]<<endl;
2045  if (Facemarkerlist[i]) // 0 for inner edges and Boundcomp+1 for Boundedge respect
2046  {
2047 
2048  CurrComp = Facemarkerlist[i] - 1;
2049 // cout<<"Boundary face CurrComp: "<<CurrComp<<endl;
2050 // exit(0);
2051  CurrComp = 0; // not yet implemented fully
2052 
2053 
2054 
2055  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
2056 
2057 
2058  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
2059  NewVertices[a]->GetY(), T[1], S[1]) ||
2060  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
2061  NewVertices[b]->GetY(), T[2], S[2]) ||
2062  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
2063  NewVertices[c]->GetY(), T[3], S[3]) )
2064  {
2065  cerr<<"Error: could not set parameter values"<<endl;
2066  OutPut(NewVertices[a]<<endl);
2067  OutPut(NewVertices[b]<<endl);
2068  OutPut(NewVertices[c]<<endl);
2069  exit(0);
2070  }
2071 
2072  if (CurrNeib == 2)
2073  {
2074  if(bdcomp->IsFreeBoundary())
2075  Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
2076  CellTree[Neib[0]], CellTree[Neib[1]] );
2077  else
2078  Joint = new TInterfaceJoint3D(bdcomp, T, S,
2079  CellTree[Neib[0]], CellTree[Neib[1]] );
2080  }
2081  else
2082  {
2083  if(bdcomp->IsFreeBoundary())
2084  Joint = new TIsoBoundFace(bdcomp, T, S);
2085  else
2086  Joint = new TBoundFace(bdcomp, T, S);
2087  }
2088  }
2089  else
2090  {
2091 // // cout<<"Inner face"<<endl;
2092  if (CurrNeib != 2)
2093  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
2094 
2095  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
2096 
2097  }
2098 
2099  // First element containing the current face
2100  // find the local index for the point 'a' on the cell
2101  for (j=0;j<4;j++)
2102  if (Tetrahedrals[4*Neib[0]+j] == a) break;
2103 
2104  // find the local index for the point 'b' on the cell
2105  for (k=0;k<4;k++)
2106  if (Tetrahedrals[4*Neib[0]+k] == b) break;
2107 
2108  // find the local index for the point 'c' on the cell
2109  for (l=0;l<4;l++)
2110  if (Tetrahedrals[4*Neib[0]+l] == c) break;
2111 
2112  l = l*100 + k*10 + j;
2113 
2114 // cout<<""<< l <<endl;
2115 
2116  switch (l) // j will contain the local index for the current face
2117  {
2118  case 210: case 21: case 102:
2119  case 120: case 12: case 201:
2120  j = 0;
2121  break;
2122  case 310: case 31: case 103:
2123  case 130: case 13: case 301:
2124  j = 1;
2125  break;
2126  case 321: case 132: case 213:
2127  case 231: case 123: case 312:
2128  j = 2;
2129  break;
2130  case 230: case 23: case 302:
2131  case 320: case 32: case 203:
2132  j = 3;
2133  break;
2134 
2135  default:
2136  Error("Unable to set the face !!!!!!!!!!!!" << endl);
2137  exit(0);
2138  }
2139  CellTree[Neib[0]]->SetJoint(j, Joint);
2140 
2141  if (Neib[1] != -1) // second element containing the current face
2142  {
2143  // find the local index for the point 'a' on the cell
2144  for (j=0;j<4;j++)
2145  if (Tetrahedrals[4*Neib[1]+j] == a) break;
2146 
2147  // find the local index for the point 'b' on the cell
2148  for (k=0;k<4;k++)
2149  if (Tetrahedrals[4*Neib[1]+k] == b) break;
2150 
2151  // find the local index for the point 'c' on the cell
2152  for (l=0;l<4;l++)
2153  if (Tetrahedrals[4*Neib[1]+l] == c) break;
2154 
2155  l = l*100 + k*10 + j;
2156 
2157 // cout<<""<< l <<endl;
2158 
2159  switch (l) // j will contain the local index for the current face
2160  {
2161  case 210: case 21: case 102:
2162  case 120: case 12: case 201:
2163  j = 0;
2164  break;
2165  case 310: case 31: case 103:
2166  case 130: case 13: case 301:
2167  j = 1;
2168  break;
2169  case 321: case 132: case 213:
2170  case 231: case 123: case 312:
2171  j = 2;
2172  break;
2173  case 230: case 23: case 302:
2174  case 320: case 32: case 203:
2175  j = 3;
2176  break;
2177 
2178  default:
2179  Error("Unable to set the face !!!!!!!!!!!!" << endl);
2180  exit(0);
2181  }
2182  CellTree[Neib[1]]->SetJoint(j, Joint);
2183  }
2184 
2185  if (Joint->GetType() == InterfaceJoint3D ||
2186  Joint->GetType() == IsoInterfaceJoint3D)
2187  {
2188  ((TInterfaceJoint3D*)Joint)->SetMapType();
2189  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
2190  }
2191  else
2192  if (Joint->GetType() == JointEqN)
2193  Joint->SetMapType();
2194 
2195  }
2196 
2197 #ifdef _MPI
2198  if(rank==0)
2199 #endif
2200  {
2201 // In.deinitialize();
2202 // Out.deinitialize();
2203  }
2204 
2205 
2206 
2207 
2208 #ifdef _MPI
2209  if(rank!=0)
2210  {
2211  delete [] Tetrahedrals ;
2212  delete [] Coordinates;
2213  delete [] Facelist;
2214  delete [] Facemarkerlist;
2215  }
2216 #endif
2217 
2218  delete [] PointNeighb;
2219 
2220 // #ifdef _MPI
2221 // if(rank==3)
2222 // printf(" TetrameshGen %d \n", N_G );
2223 // MPI_Finalize();
2224 // #endif
2225 // exit(0);
2226 //
2227 
2228 }
2229 
2230 
2232 void TetraGen(TDomain *&Domain)
2233 {
2234  //======================================================================
2235  // Tetgen for grid generation begin
2236  //======================================================================
2237  int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
2238  int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
2239  int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
2240  int *Tetrahedrals, *PointNeighb, dimension;
2241  int jj, N_Points, MaxLen, *Tetrahedrals_loc;
2242  const int *EdgeVertex, *TmpFV, *TmpLen;
2243 
2244  double *Coordinates, N_x, N_y, N_z;
2245  double *Vertices;
2246  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
2247  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
2248  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
2249 
2250  tetgenio In, Out;
2251 
2252  TBaseCell **CellTree, **SurfCellTree;
2253  TGridCell **DelCell;
2254  TVertex **VertexDel, **NewVertices, **NewSurfVertices;
2255  TBoundPart *BoundPart;
2256  TBdPlane **UpdateFaceParams;
2257  TJoint *Joint;
2258  TBoundComp3D *bdcomp;
2259  TCollection *coll, *SurfColl;
2260  TBaseCell *cell;
2261  TBdSphere *UpdateParam;
2262  TShapeDesc *ShapeDesc;
2263 
2264  char *SMESH, line[100];
2265  SMESH = TDatabase::ParamDB->SMESHFILE;
2266 
2267 #ifdef _MPI
2268  int rank, size;
2269  MPI_Comm Comm = TDatabase::ParamDB->Comm;
2270 
2271  MPI_Comm_rank(Comm, &rank);
2272  MPI_Comm_size(Comm, &size);
2273 
2274 #endif
2275 
2277 #ifdef _MPI
2278  if(rank==0)
2279 #endif
2280  {
2281 
2282 // In.initialize();
2283 // Out.initialize();
2284 
2285  std::ostringstream opts;
2286  opts << " ";
2287 
2288  opts.seekp(std::ios::beg);
2289  opts<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
2290 // opts<<'r'; // -r Reconstructs a previously generated mesh
2291  opts<<"q"<<1.20; // quality mesh generation(q) with a specified quality bound
2292 // opts<<"a"<<0.1; // maximum volume constraint
2293 // opts<<'i'; // Inserts a list of additional points into mesh.
2294  opts<<'z'; // numbers all output items starting from zero
2295 // opts<<'d'; // Detect intersections of PLC facets.
2296  opts<<'f'; // Outputs all faces (including non-boundary)
2297  opts<<'e'; // Outputs a list of edges of the triangulation
2298 // opts<<'I'; // Suppresses mesh iteration numbers.
2299  opts<<'C'; // Checks the consistency of the final mesh.
2300 // opts<<'Q'; // Quiet: No terminal output except errors.
2301 // opts<<'g'; // Outputs mesh to .mesh file for viewing by Medit
2302  opts<<'Y'; // Suppresses boundary facets/segments splitting
2303  opts<<'V'; //verbose mode
2304  opts<<ends;
2305  cout<< "test DeleteDomain " <<endl;
2306 
2307 // cout << " SMESHFILE is " << SMESH << endl;
2309  ReadMeditMesh(SMESH, In);
2310 
2311  cout<< "test DeleteDomain 2" <<endl;
2312 // for(i=0;i<In.numberofpoints;i++)
2313 // OutPut(i<<" (x, y, z) = "<<
2314 // In.pointlist[3*i]<<' '<<In.pointlist[3*i+1]<<' '<<In.pointlist[3*i+2]<<endl);
2315 
2316  // Calling tetrahedralize function of 3dtetgen mesh generator
2317  tetrahedralize((char*)opts.str().c_str(), &In, &Out);
2318 
2319  // output: coordinates of all vertices
2320 // for(i=0;i<Out.numberofpoints;i++)
2321 // OutPut(" (x, y, z) = "<< Out.pointlist[3*i]<<' '<<Out.pointlist[3*i+1]<<' '<<Out.pointlist[3*i+2]<<endl);
2322 
2323  } // if(rank==0)
2324 
2326  DeleteDomain(Domain);
2327 // cout<< "test DeleteDomain " <<endl;
2328 // exit(0);
2329 
2330 #ifdef _MPI
2331  if(rank==0)
2332 #endif
2333  {
2334  N_RootCells = Out.numberoftetrahedra;
2335  N_G = Out.numberofpoints;
2336 
2337  // allocate auxillary fields
2338  Coordinates = Out.pointlist;
2339  Tetrahedrals = Out.tetrahedronlist;
2340  }
2341 
2342 #ifdef _MPI
2343  MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
2344  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
2345 
2346 
2347  if(rank!=0)
2348  {
2349  Coordinates = new double [3*N_G];
2350  Tetrahedrals = new int[4*N_RootCells];
2351  }
2352 
2353  MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
2354  MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
2355 #endif
2356 
2357  // generate new vertices
2358  NewVertices = new TVertex*[N_G];
2359 
2360  for (i=0;i<N_G;i++)
2361  {
2362  NewVertices[i] = new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
2363 
2364  // set bounding box
2365  if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
2366  if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
2367  if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
2368  if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
2369  if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
2370  if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
2371  }
2372 
2373  // set bounding box
2374  StartX = Xmin;
2375  StartY = Ymin;
2376  StartZ = Zmin;
2377  BoundX = Xmax - Xmin;
2378  BoundY = Ymax - Ymin;
2379  BoundZ = Zmax - Zmin;
2380 
2381 
2382  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
2383 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
2384 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
2385 
2386  CellTree = new TBaseCell*[N_RootCells];
2387  // output of each tetraheron vertex indices (four vertices for each)
2388 // for (i=0;i<N_RootCells;i++)
2389 // cout<< Tetrahedrals[4*i]<<" "<<Tetrahedrals[4*i + 1]<<" "
2390 // <<Tetrahedrals[4*i + 2]<<" "<<Tetrahedrals[4*i + 3]<<endl;
2391 
2392 
2393  for (i=0;i<N_RootCells;i++)
2394  {
2395  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron],
2396  RefLevel);
2397 
2398  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
2399  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
2400  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
2401  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
2402 
2403  CellTree[i]->SetClipBoard(i);
2404  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
2405  }
2406 
2407  Domain->SetTreeInfo(CellTree, N_RootCells);
2408 
2409 
2410  // initialize iterators
2411  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
2412  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
2413  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
2414  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
2415  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
2416 
2417 
2418  // search neighbours
2419  PointNeighb = new int[N_G];
2420 #ifdef _MPI
2421  if(rank==0)
2422 #endif
2423  cout<<"numberofpoints "<<N_G<<endl;
2424  memset(PointNeighb, 0, N_G *SizeOfInt);
2425 
2426  for (i=0;i<4*N_RootCells;i++)
2427  PointNeighb[Tetrahedrals[i]]++;
2428 
2429  for (i=0;i<N_G;i++)
2430  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
2431  delete [] PointNeighb;
2432 
2433 #ifdef _MPI
2434  if(rank==0)
2435 #endif
2436  cout<<"maxEpV "<< maxEpV<<endl;
2437 
2438  PointNeighb = new int[++maxEpV * N_G];
2439 
2440  memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
2441 
2442  // every vertex contains "maxEpV" columns
2443  // for every vertex at first colomn contains the number of cells containing this vertex
2444  // at further columns we set the index of corresponding cells containing this vertex
2445  // cout<<"maxEpV*N_G "<<maxEpV*N_G<<endl;
2446 
2447  for(i=0;i<4*N_RootCells;i++)
2448  {
2449  j = Tetrahedrals[i]*maxEpV;
2450  PointNeighb[j]++;
2451  //cout<<"j + PointNeighb[j] " << j <<endl;
2452  PointNeighb[j + PointNeighb[j]] = i / 4;
2453  }
2454 
2455 
2456  // generate new faces
2457  coll=Domain->GetCollection(It_Finest, 0);
2458  N_Cells = coll->GetN_Cells();
2459  N_G = 0;
2460  for (i=0;i<N_Cells;i++)
2461  {
2462  cell = coll->GetCell(i);
2463  ShapeDesc= cell->GetShapeDesc();
2464  ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
2465  N_Faces = cell->GetN_Faces();
2466  Tetrahedrals_loc = Tetrahedrals+4*i;
2467 
2468  for(jj=0;jj<N_Faces;jj++)
2469  if(cell->GetJoint(jj) == NULL)
2470  {
2471  N_G++;
2472  N_Points = TmpLen[jj];
2473 
2474  if(N_Points!=3)
2475  {
2476  cerr << "Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
2477  exit(-1);
2478  }
2479 
2480 
2481  //printf(" TetrameshGen Null joint \n" );
2482  a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
2483  b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
2484  c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
2485 
2486 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
2487 
2488  Neib[0] = -1;
2489  Neib[1] = -1;
2490  CurrNeib = 0;
2491 
2492  len1 = PointNeighb[a*maxEpV];
2493  len2 = PointNeighb[b*maxEpV];
2494  len3 = PointNeighb[c*maxEpV];
2495 
2496  // find the index of the cells containing current face with point indices a,b,c
2497  for (j=1;j<=len1;j++)
2498  {
2499  Neighb_tmp = PointNeighb[a*maxEpV + j];
2500  for (k=1;k<=len2;k++)
2501  {
2502  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
2503  {
2504  for (l=1;l<=len3;l++)
2505  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
2506  {
2507  Neib[CurrNeib++] = Neighb_tmp;
2508  break;
2509  }
2510  }
2511  }
2512  if (CurrNeib == 2) break;
2513  }// for (j=1;j<=len1;j++)
2514 
2515  // cout<<"CurrNeib " << CurrNeib <<endl;
2516  // cout<<"Facemarkerlist[i] : "<<Facemarkerlist[i]<<endl;
2517  if (CurrNeib == 1) // 0 for inner edges and Boundcomp+1 for Boundedge respect
2518  {
2519  CurrComp = 0; // not yet implemented fully
2520 
2521 
2522 
2523  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
2524 
2525 
2526  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
2527  NewVertices[a]->GetY(), T[1], S[1]) ||
2528  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
2529  NewVertices[b]->GetY(), T[2], S[2]) ||
2530  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
2531  NewVertices[c]->GetY(), T[3], S[3]) )
2532  {
2533  cerr<<"Error: could not set parameter values"<<endl;
2534  OutPut(NewVertices[a]<<endl);
2535  OutPut(NewVertices[b]<<endl);
2536  OutPut(NewVertices[c]<<endl);
2537  exit(0);
2538  }
2539 
2540  if (CurrNeib == 2)
2541  {
2542  if(bdcomp->IsFreeBoundary())
2543  Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
2544  CellTree[Neib[0]], CellTree[Neib[1]] );
2545  else
2546  Joint = new TInterfaceJoint3D(bdcomp, T, S,
2547  CellTree[Neib[0]], CellTree[Neib[1]] );
2548  }
2549  else
2550  {
2551  if(bdcomp->IsFreeBoundary())
2552  Joint = new TIsoBoundFace(bdcomp, T, S);
2553  else
2554  Joint = new TBoundFace(bdcomp, T, S);
2555  }
2556  }
2557  else
2558  {
2559  // cout<<"Inner face"<<endl;
2560  if (CurrNeib != 2)
2561  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
2562 
2563  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
2564  }
2565 
2566  // First element containing the current face
2567  // find the local index for the point 'a' on the cell
2568  for (j=0;j<4;j++)
2569  if (Tetrahedrals[4*Neib[0]+j] == a) break;
2570 
2571  // find the local index for the point 'b' on the cell
2572  for (k=0;k<4;k++)
2573  if (Tetrahedrals[4*Neib[0]+k] == b) break;
2574 
2575  // find the local index for the point 'c' on the cell
2576  for (l=0;l<4;l++)
2577  if (Tetrahedrals[4*Neib[0]+l] == c) break;
2578 
2579  l = l*100 + k*10 + j;
2580 
2581 // cout<<""<< l <<endl;
2582 
2583  switch (l) // j will contain the local index for the current face
2584  {
2585  case 210: case 21: case 102:
2586  case 120: case 12: case 201:
2587  j = 0;
2588  break;
2589  case 310: case 31: case 103:
2590  case 130: case 13: case 301:
2591  j = 1;
2592  break;
2593  case 321: case 132: case 213:
2594  case 231: case 123: case 312:
2595  j = 2;
2596  break;
2597  case 230: case 23: case 302:
2598  case 320: case 32: case 203:
2599  j = 3;
2600  break;
2601 
2602  default:
2603  Error("Unable to set the face !!!!!!!!!!!!" << endl);
2604  exit(0);
2605  }
2606  CellTree[Neib[0]]->SetJoint(j, Joint);
2607 
2608  if (Neib[1] != -1) // second element containing the current face
2609  {
2610  // find the local index for the point 'a' on the cell
2611  for (j=0;j<4;j++)
2612  if (Tetrahedrals[4*Neib[1]+j] == a) break;
2613 
2614  // find the local index for the point 'b' on the cell
2615  for (k=0;k<4;k++)
2616  if (Tetrahedrals[4*Neib[1]+k] == b) break;
2617 
2618  // find the local index for the point 'c' on the cell
2619  for (l=0;l<4;l++)
2620  if (Tetrahedrals[4*Neib[1]+l] == c) break;
2621 
2622  l = l*100 + k*10 + j;
2623 
2624 // cout<<""<< l <<endl;
2625 
2626  switch (l) // j will contain the local index for the current face
2627  {
2628  case 210: case 21: case 102:
2629  case 120: case 12: case 201:
2630  j = 0;
2631  break;
2632  case 310: case 31: case 103:
2633  case 130: case 13: case 301:
2634  j = 1;
2635  break;
2636  case 321: case 132: case 213:
2637  case 231: case 123: case 312:
2638  j = 2;
2639  break;
2640  case 230: case 23: case 302:
2641  case 320: case 32: case 203:
2642  j = 3;
2643  break;
2644 
2645  default:
2646  Error("Unable to set the face !!!!!!!!!!!!" << endl);
2647  exit(0);
2648  }
2649  CellTree[Neib[1]]->SetJoint(j, Joint);
2650  } // if (Neib[1] != -1)
2651 
2652  if (Joint->GetType() == InterfaceJoint3D ||
2653  Joint->GetType() == IsoInterfaceJoint3D)
2654  {
2655  ((TInterfaceJoint3D*)Joint)->SetMapType();
2656  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
2657  }
2658  else
2659  if (Joint->GetType() == JointEqN)
2660  Joint->SetMapType();
2661  } // if(cell->GetJoint(jj) == NULL)
2662  } // for (i=0;i<N_Cells;i++)
2663 
2664 
2665 #ifdef _MPI
2666  if(rank==0)
2667 #endif
2668  cout<<"numberoftrifaces after "<<N_G<<endl;
2669 
2670 #ifdef _MPI
2671  if(rank==0)
2672 #endif
2673  {
2674 // In.deinitialize();
2675 // Out.deinitialize();
2676  }
2677 
2678 
2679 
2680 
2681 #ifdef _MPI
2682  if(rank!=0)
2683  {
2684  delete [] Tetrahedrals ;
2685  delete [] Coordinates;
2686 // delete [] Facelist;
2687 // delete [] Facemarkerlist;
2688  }
2689 #endif
2690 
2691  delete [] PointNeighb;
2692 
2693 // #ifdef _MPI
2694 // if(rank==3)
2695 // printf(" TetrameshGen %d \n", N_G );
2696 // MPI_Finalize();
2697 // #endif
2698 // exit(0);
2699 //
2700 
2701 }
2702 
2703 
2705 void TetraGenWithInputCells(TDomain *&Domain)
2706 {
2707  //======================================================================
2708  // Tetgen for grid generation begin
2709  //======================================================================
2710  int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
2711  int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
2712  int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
2713  int *Tetrahedrals, *PointNeighb, dimension;
2714  int jj, N_Points, MaxLen, *Tetrahedrals_loc;
2715  const int *EdgeVertex, *TmpFV, *TmpLen;
2716  double *TetRegionlist;
2717 
2718  double *Coordinates, N_x, N_y, N_z;
2719  double *Vertices;
2720  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
2721  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
2722  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
2723 
2724  tetgenio In, Out, InAddPts;
2725 
2726  TBaseCell **CellTree, **SurfCellTree;
2727  TGridCell **DelCell;
2728  TVertex **VertexDel, **NewVertices, **NewSurfVertices;
2729  TBoundPart *BoundPart;
2730  TBdPlane **UpdateFaceParams;
2731  TJoint *Joint;
2732  TBoundComp3D *bdcomp;
2733  TCollection *coll, *SurfColl;
2734  TBaseCell *cell;
2735  TBdSphere *UpdateParam;
2736  TShapeDesc *ShapeDesc;
2737 
2738  char *SMESH, *NODE, line[100];
2739  SMESH = TDatabase::ParamDB->SMESHFILE;
2740  NODE = TDatabase::ParamDB->GRAPEBASENAME;
2741 
2742 #ifdef _MPI
2743  int rank, size;
2744  MPI_Comm Comm = TDatabase::ParamDB->Comm;
2745 
2746  MPI_Comm_rank(Comm, &rank);
2747  MPI_Comm_size(Comm, &size);
2748 
2749 #endif
2750 
2752 #ifdef _MPI
2753  if(rank==0)
2754 #endif
2755  {
2756 
2757 // In.initialize();
2758 // Out.initialize();
2759 
2760  std::ostringstream opts;
2761  opts << " ";
2762 
2763  opts.seekp(std::ios::beg);
2764 // opts<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
2765  opts<<'r'; // -r Reconstructs a previously generated mesh
2766 // opts<<'q'<<1.2; // quality mesh generation(q) with a specified quality bound
2767 // opts<<'a'<<100; // maximum volume constraint
2768 // opts<<'a'; // maximum volume constraint
2769 // opts<<'i'; // Inserts a list of additional points into mesh.
2770  opts<<'z'; // numbers all output items starting from zero
2771 // opts<<'d'; // Detect intersections of PLC facets.
2772  opts<<'f'; // Outputs all faces (including non-boundary)
2773  opts<<'e'; // Outputs a list of edges of the triangulation
2774 // opts<<'I'; // Suppresses mesh iteration numbers.
2775  opts<<'C'; // Checks the consistency of the final mesh.
2776 // opts<<'Q'; // Quiet: No terminal output except errors.
2777 // opts<<'g'; // Outputs mesh to .mesh file for viewing by Medit
2778  opts<<'Y'; // Suppresses boundary facets/segments splitting
2779 // opts<<'A'; // output region attribute list
2780 // opts<<'V'; //verbose mode
2781 // opts<<'V';
2782 // opts<<'V';
2783 // opts<<'V';
2784 // opts<<'V';
2785  opts<<ends;
2786 
2787  In.initialize();
2788  Out.initialize();
2789 // InAddPts.initialize();
2790 // cout << " SMESHFILE is " << SMESH << endl;
2792  ReadMeditMeshWithCells(SMESH, In);
2793 
2794 // ReadAdditionalNModes(NODE, InAddPts);
2795 // In.load_medit(SMESH, 1);
2796 
2797 
2798 // InAddPts.load_node(NODE);
2799 // cout<< " InAddPts.numberofpoints " << InAddPts.numberofpoints <<endl;
2800 // exit(0);
2801 // for(i=0;i<In.numberofpoints;i++)
2802 // OutPut(i<<" (x, y, z) = "<<
2803 // In.pointlist[3*i]<<' '<<In.pointlist[3*i+1]<<' '<<In.pointlist[3*i+2]<<endl);
2804 // exit(0);
2805  // Calling tetrahedralize function of 3dtetgen mesh generator
2806 
2807 
2808  tetrahedralize((char*)opts.str().c_str(), &In, &Out);
2809  cout<<"11111111111111"<<endl;
2810  exit(0);
2811  cout<<"2222222222222"<<endl;
2812 // tetrahedralize((char*)opts.str().c_str(), &In, &Out, &InAddPts);
2813 // exit(0);
2814  // output: coordinates of all vertices
2815 // for(i=0;i<Out.numberofpoints;i++)
2816 // OutPut(" (x, y, z) = "<< Out.pointlist[3*i]<<' '<<Out.pointlist[3*i+1]<<' '<<Out.pointlist[3*i+2]<<endl);
2817 
2818  } // if(rank==0)
2819 
2821  DeleteDomain(Domain);
2822 
2823 
2824 #ifdef _MPI
2825  if(rank==0)
2826 #endif
2827  {
2828  N_RootCells = Out.numberoftetrahedra;
2829  N_G = Out.numberofpoints;
2830 
2831  // allocate auxillary fields
2832  Coordinates = Out.pointlist;
2833  Tetrahedrals = Out.tetrahedronlist;
2834 
2835  TetRegionlist = Out.tetrahedronattributelist;
2836  }
2837 
2838 #ifdef _MPI
2839  MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
2840  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
2841 
2842 
2843  if(rank!=0)
2844  {
2845  Coordinates = new double [3*N_G];
2846  Tetrahedrals = new int[4*N_RootCells];
2847  TetRegionlist = new double [N_RootCells];
2848  }
2849 
2850  MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
2851  MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
2852  MPI_Bcast(TetRegionlist, N_RootCells, MPI_DOUBLE, 0, Comm);
2853 #endif
2854 
2855  // generate new vertices
2856  NewVertices = new TVertex*[N_G];
2857 
2858  for (i=0;i<N_G;i++)
2859  {
2860  NewVertices[i] = new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
2861 
2862  // set bounding box
2863  if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
2864  if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
2865  if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
2866  if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
2867  if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
2868  if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
2869  }
2870 
2871  // set bounding box
2872  StartX = Xmin;
2873  StartY = Ymin;
2874  StartZ = Zmin;
2875  BoundX = Xmax - Xmin;
2876  BoundY = Ymax - Ymin;
2877  BoundZ = Zmax - Zmin;
2878 
2879 
2880  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
2881 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
2882 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
2883 
2884  CellTree = new TBaseCell*[N_RootCells];
2885  // output of each tetraheron vertex indices (four vertices for each)
2886 // for (i=0;i<N_RootCells;i++)
2887 // cout<< Tetrahedrals[4*i]<<" "<<Tetrahedrals[4*i + 1]<<" "
2888 // <<Tetrahedrals[4*i + 2]<<" "<<Tetrahedrals[4*i + 3]<<endl;
2889 
2890 
2891  for (i=0;i<N_RootCells;i++)
2892  {
2893  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron],
2894  RefLevel);
2895 
2896  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
2897  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
2898  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
2899  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
2900 
2901  CellTree[i]->SetClipBoard(i);
2902  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
2903 
2904 // cout << i<< " TetRegionlist : " << TetRegionlist[i] << endl;
2905  CellTree[i]->SetRegionID((int)TetRegionlist[i]);
2906  }
2907 // exit(0);
2908  Domain->SetTreeInfo(CellTree, N_RootCells);
2909 
2910 
2911  // initialize iterators
2912  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
2913  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
2914  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
2915  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
2916  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
2917 
2918 
2919  // search neighbours
2920  PointNeighb = new int[N_G];
2921 #ifdef _MPI
2922  if(rank==0)
2923 #endif
2924  cout<<"numberofpoints "<<N_G<<endl;
2925  memset(PointNeighb, 0, N_G *SizeOfInt);
2926 
2927  for (i=0;i<4*N_RootCells;i++)
2928  PointNeighb[Tetrahedrals[i]]++;
2929 
2930  for (i=0;i<N_G;i++)
2931  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
2932  delete [] PointNeighb;
2933 
2934 #ifdef _MPI
2935  if(rank==0)
2936 #endif
2937  cout<<"maxEpV "<< maxEpV<<endl;
2938 
2939  PointNeighb = new int[++maxEpV * N_G];
2940 
2941  memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
2942 
2943  // every vertex contains "maxEpV" columns
2944  // for every vertex at first colomn contains the number of cells containing this vertex
2945  // at further columns we set the index of corresponding cells containing this vertex
2946  // cout<<"maxEpV*N_G "<<maxEpV*N_G<<endl;
2947 
2948  for(i=0;i<4*N_RootCells;i++)
2949  {
2950  j = Tetrahedrals[i]*maxEpV;
2951  PointNeighb[j]++;
2952  //cout<<"j + PointNeighb[j] " << j <<endl;
2953  PointNeighb[j + PointNeighb[j]] = i / 4;
2954  }
2955 
2956 
2957  // generate new faces
2958  coll=Domain->GetCollection(It_Finest, 0);
2959  N_Cells = coll->GetN_Cells();
2960  N_G = 0;
2961  for (i=0;i<N_Cells;i++)
2962  {
2963  cell = coll->GetCell(i);
2964  ShapeDesc= cell->GetShapeDesc();
2965  ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
2966  N_Faces = cell->GetN_Faces();
2967  Tetrahedrals_loc = Tetrahedrals+4*i;
2968 
2969  for(jj=0;jj<N_Faces;jj++)
2970  if(cell->GetJoint(jj) == NULL)
2971  {
2972  N_G++;
2973  N_Points = TmpLen[jj];
2974 
2975  if(N_Points!=3)
2976  {
2977  cerr << "Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
2978  exit(-1);
2979  }
2980 
2981 
2982  //printf(" TetrameshGen Null joint \n" );
2983  a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
2984  b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
2985  c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
2986 
2987 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
2988 
2989  Neib[0] = -1;
2990  Neib[1] = -1;
2991  CurrNeib = 0;
2992 
2993  len1 = PointNeighb[a*maxEpV];
2994  len2 = PointNeighb[b*maxEpV];
2995  len3 = PointNeighb[c*maxEpV];
2996 
2997  // find the index of the cells containing current face with point indices a,b,c
2998  for (j=1;j<=len1;j++)
2999  {
3000  Neighb_tmp = PointNeighb[a*maxEpV + j];
3001  for (k=1;k<=len2;k++)
3002  {
3003  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
3004  {
3005  for (l=1;l<=len3;l++)
3006  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
3007  {
3008  Neib[CurrNeib++] = Neighb_tmp;
3009  break;
3010  }
3011  }
3012  }
3013  if (CurrNeib == 2) break;
3014  }// for (j=1;j<=len1;j++)
3015 
3016  // cout<<"CurrNeib " << CurrNeib <<endl;
3017  // cout<<"Facemarkerlist[i] : "<<Facemarkerlist[i]<<endl;
3018  if (CurrNeib == 1) // 0 for inner edges and Boundcomp+1 for Boundedge respect
3019  {
3020  CurrComp = 0; // not yet implemented fully
3021 
3022 
3023 
3024  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
3025 
3026 
3027  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
3028  NewVertices[a]->GetY(), T[1], S[1]) ||
3029  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
3030  NewVertices[b]->GetY(), T[2], S[2]) ||
3031  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
3032  NewVertices[c]->GetY(), T[3], S[3]) )
3033  {
3034  cerr<<"Error: could not set parameter values"<<endl;
3035  OutPut(NewVertices[a]<<endl);
3036  OutPut(NewVertices[b]<<endl);
3037  OutPut(NewVertices[c]<<endl);
3038  exit(0);
3039  }
3040 
3041  if (CurrNeib == 2)
3042  {
3043  if(bdcomp->IsFreeBoundary())
3044  Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
3045  CellTree[Neib[0]], CellTree[Neib[1]] );
3046  else
3047  Joint = new TInterfaceJoint3D(bdcomp, T, S,
3048  CellTree[Neib[0]], CellTree[Neib[1]] );
3049  }
3050  else
3051  {
3052  if(bdcomp->IsFreeBoundary())
3053  Joint = new TIsoBoundFace(bdcomp, T, S);
3054  else
3055  Joint = new TBoundFace(bdcomp, T, S);
3056  }
3057  }
3058  else
3059  {
3060  // cout<<"Inner face"<<endl;
3061  if (CurrNeib != 2)
3062  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
3063 
3064  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
3065  }
3066 
3067  // First element containing the current face
3068  // find the local index for the point 'a' on the cell
3069  for (j=0;j<4;j++)
3070  if (Tetrahedrals[4*Neib[0]+j] == a) break;
3071 
3072  // find the local index for the point 'b' on the cell
3073  for (k=0;k<4;k++)
3074  if (Tetrahedrals[4*Neib[0]+k] == b) break;
3075 
3076  // find the local index for the point 'c' on the cell
3077  for (l=0;l<4;l++)
3078  if (Tetrahedrals[4*Neib[0]+l] == c) break;
3079 
3080  l = l*100 + k*10 + j;
3081 
3082 // cout<<""<< l <<endl;
3083 
3084  switch (l) // j will contain the local index for the current face
3085  {
3086  case 210: case 21: case 102:
3087  case 120: case 12: case 201:
3088  j = 0;
3089  break;
3090  case 310: case 31: case 103:
3091  case 130: case 13: case 301:
3092  j = 1;
3093  break;
3094  case 321: case 132: case 213:
3095  case 231: case 123: case 312:
3096  j = 2;
3097  break;
3098  case 230: case 23: case 302:
3099  case 320: case 32: case 203:
3100  j = 3;
3101  break;
3102 
3103  default:
3104  Error("Unable to set the face !!!!!!!!!!!!" << endl);
3105  exit(0);
3106  }
3107  CellTree[Neib[0]]->SetJoint(j, Joint);
3108 
3109  if (Neib[1] != -1) // second element containing the current face
3110  {
3111  // find the local index for the point 'a' on the cell
3112  for (j=0;j<4;j++)
3113  if (Tetrahedrals[4*Neib[1]+j] == a) break;
3114 
3115  // find the local index for the point 'b' on the cell
3116  for (k=0;k<4;k++)
3117  if (Tetrahedrals[4*Neib[1]+k] == b) break;
3118 
3119  // find the local index for the point 'c' on the cell
3120  for (l=0;l<4;l++)
3121  if (Tetrahedrals[4*Neib[1]+l] == c) break;
3122 
3123  l = l*100 + k*10 + j;
3124 
3125 // cout<<""<< l <<endl;
3126 
3127  switch (l) // j will contain the local index for the current face
3128  {
3129  case 210: case 21: case 102:
3130  case 120: case 12: case 201:
3131  j = 0;
3132  break;
3133  case 310: case 31: case 103:
3134  case 130: case 13: case 301:
3135  j = 1;
3136  break;
3137  case 321: case 132: case 213:
3138  case 231: case 123: case 312:
3139  j = 2;
3140  break;
3141  case 230: case 23: case 302:
3142  case 320: case 32: case 203:
3143  j = 3;
3144  break;
3145 
3146  default:
3147  Error("Unable to set the face !!!!!!!!!!!!" << endl);
3148  exit(0);
3149  }
3150  CellTree[Neib[1]]->SetJoint(j, Joint);
3151  } // if (Neib[1] != -1)
3152 
3153  if (Joint->GetType() == InterfaceJoint3D ||
3154  Joint->GetType() == IsoInterfaceJoint3D)
3155  {
3156  ((TInterfaceJoint3D*)Joint)->SetMapType();
3157  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
3158  }
3159  else
3160  if (Joint->GetType() == JointEqN)
3161  Joint->SetMapType();
3162  } // if(cell->GetJoint(jj) == NULL)
3163  } // for (i=0;i<N_Cells;i++)
3164 
3165 
3166 #ifdef _MPI
3167  if(rank==0)
3168 #endif
3169  cout<<"numberoftrifaces after "<<N_G<<endl;
3170 
3171 #ifdef _MPI
3172  if(rank==0)
3173 #endif
3174  {
3175 // In.deinitialize();
3176 // Out.deinitialize();
3177  }
3178 
3179 
3180 
3181 
3182 #ifdef _MPI
3183  if(rank!=0)
3184  {
3185  delete [] Tetrahedrals ;
3186  delete [] Coordinates;
3187  delete [] TetRegionlist;
3188 // delete [] Facemarkerlist;
3189  }
3190 #endif
3191 
3192  delete [] PointNeighb;
3193 
3194 // #ifdef _MPI
3195 // if(rank==3)
3196 // printf(" TetrameshGen %d \n", N_G );
3197 // MPI_Finalize();
3198 // #endif
3199 // exit(0);
3200 //
3201 
3202 }
3203 
3204 
3205 
3206 
void SetMapType()
Definition: Joint.C:107
Definition: BdPlane.h:18
void GetTreeInfo(TBaseCell **&celltree, int &N_rootcells)
get tree of cells
Definition: Domain.h:176
virtual int GetTSofXYZ(double X, double Y, double Z, double &T, double &S)=0
JointType GetType()
Definition: Joint.h:75
TBaseCell * GetCell(int i) const
return Cell with index i in Cells-array
Definition: Collection.h:50
int GetN_Faces()
return the number of faces of the cell
Definition: BaseCell.h:190
TBoundComp2D * GetBdComp(int i)
Definition: BoundPart.h:49
int SetJoint(int J_i, TJoint *J)
set the pointer to face J_i to J
Definition: BaseCell.h:168
double P0
Definition: Database.h:533
int GetFaceVertex(const int *&TmpFV, const int *&TmpLen, int &MaxLen)
Definition: ShapeDesc.h:124
contains the boundary description, the virtual cell tree and macro grid
Definition: Domain.h:36
void SetClipBoard(int value)
set value in ClipBoard
Definition: BaseCell.h:263
double RE_NR
Definition: Database.h:313
int SetParam(TDomain *domain)
Definition: Iterator.C:17
static TIterator ** IteratorDB
Definition: Database.h:1131
Definition: IsoBoundFace.h:18
TShapeDesc * GetShapeDesc() const
return shape descriptor of refinement descriptor
Definition: BaseCell.h:134
store cells in an array, used by cell iterators
Definition: Collection.h:18
virtual TVertex * GetVertex(int Vert_i)=0
return the pointer to vertex with number i
represent a unit of the macro grid
Definition: MacroCell.h:15
Definition: JointEqN.h:20
int GetN_Cells() const
return number of cells
Definition: Collection.h:46
Definition: ShapeDesc.h:29
TJoint * GetJoint(int J_i)
return the pointer to face with number i
Definition: BaseCell.h:175
MPI_Comm Comm
Definition: Database.h:978
Definition: Joint.h:48
TBoundPart * GetBdPart(int i)
get i-th boundary part
Definition: Domain.h:172
Definition: BoundComp3D.h:17
double GetY() const
Definition: Vertex.h:99
int GetN_Vertices()
return the number of vertices of the cell
Definition: BaseCell.h:179
Definition: BoundPart.h:21
void SetTreeInfo(TBaseCell **celltree, int N_rootcells)
set tree of cells
Definition: Domain.h:183
bool IsFreeBoundary() const
Definition: BoundComp.h:57
TCollection * GetCollection(Iterators it, int level)
produce a collection with all cells returned by iterator it
Definition: Domain.C:1982
Definition: IsoInterfaceJoint3D.h:19
information for finite element data structure
Definition: BaseCell.h:25
Definition: Vertex.h:19
static TRefDesc ** RefDescDB
Definition: Database.h:1125
void SetRegionID(int val)
set region number to this cell
Definition: BaseCell.h:347
Definition: BoundFace.h:18
double GetX() const
Definition: Vertex.h:96
virtual int SetVertex(int Vert_i, TVertex *Vert)=0
set the pointer of vertex Vert_i to Vert
represent geometric information of the cell
Definition: GridCell.h:15
void SetAsLayerCell(int val)
set as LayerCell cell
Definition: BaseCell.h:355
Definition: BdSphere.h:18
static TParamDB * ParamDB
Definition: Database.h:1134
Definition: InterfaceJoint3D.h:18