ParMooN
 All Classes Functions Variables Friends Pages
import3Dmesh1.h
1 // ==========================================================================
2 // instationary problem
3 // ==========================================================================
4 //===========================================================================
5 // example file
6 // =========================================================================
7 // exact solution in unit cube
8 void ExampleFile()
9 {
10 #define __ROBINBC__
11  OutPut("Example: import3Dmesh.h" << endl);
12 }
13 
14 void GridBoundCondition(double x, double y, double z, BoundCond &cond)
15 {
16  cond = DIRICHLET;
17 }
18 
19 void SolidBoundCondition(double x, double y, double z, BoundCond &cond)
20 {
21  cond = DIRICHLET;
22 }
23 
24 void FluidBoundCondition(double x, double y, double z, BoundCond &cond)
25 {
26  cond = DIRICHLET;
27 }
28 // exact solution
29 void Exact(double x, double y, double z, double *values)
30 {
31  values[0] = 0;
32  values[1] = 0;
33  values[2] = 0;
34  values[3] = 0;
35  values[4] = 0;
36 }
37 
38 // initial conditon
39 void InitialCondition(double x, double y, double z, double *values)
40 {
41  values[0] = TDatabase::ParamDB->P0;
42  values[0] = x;
43 }
44 
45 // kind of boundary condition
46 void BoundCondition(double x, double y, double z, BoundCond &cond)
47 {
48 
49 
50  if(TDatabase::ParamDB->P13==0)
51  { //Lside
52  if(x<225 && y>76 )
53  { cond = DIRICHLET; }
54  else
55  { cond = NEUMANN; }
56  }
57  else
58  {
59  if(x< 240 && y<-72. && z>191)
60  { cond = DIRICHLET; }
61  else
62  { cond = NEUMANN; }
63  }
64 }
65 
66 // value of boundary condition
67 void BoundValue(double x, double y, double z, double &value)
68 {
69  value = 0;
70 }
71 
72 void BilinearCoeffs(int n_points, double *X, double *Y, double *Z, double **parameters, double **coeffs)
73 {
74  double eps=0;
75  int i, Region_ID;
76  double *coeff;
77  double x, y, z, hK;
78 
79 
80  double rhsfact, alpha, char_L, beam_r, DimlessBeam_r;
81  double xp=0., yp=0., zp=0., SourceCoord, Sourceradius;
82 
83  if(TDatabase::ParamDB->P13==0)
84  { // center point is (291.977 -1.8733333333333333 159.89 ), old, wrong
85  // 2.922130000000000e+02 -1.8733333333333333e+00 1.583800000000000e+02 1
86  xp=2.922130000000000e+02;
87  zp=1.583800000000000e+02;
88  }
89  else
90  { // side 300.565 69.66666666666666 157.038
91  xp= 300.565;
92  zp=157.038;
93  }
94 
95 
96  beam_r = TDatabase::ParamDB->P11;
97  char_L = TDatabase::ParamDB->P12;
98 
99  hK = coeffs[0][2];
100  Region_ID = coeffs[0][1];
101  DimlessBeam_r = beam_r/char_L;
102 
103 
104  // cout << "Region_ID = " << Region_ID << endl;
105 
106  if(Region_ID==0) //0-Fat/adipost
107  {
108  eps = TDatabase::ParamDB->P1/(1100.*4483*char_L*char_L); ;
109  alpha = TDatabase::ParamDB->P7;
110  rhsfact = (alpha*TDatabase::ParamDB->P4)/(1100.0*4483*(22./7.)*beam_r*beam_r);
111  }
112  else
113  {
114  eps = TDatabase::ParamDB->P2/(1040.0*3500.*char_L*char_L);
115  alpha = TDatabase::ParamDB->P8;
116  rhsfact = alpha*TDatabase::ParamDB->P4/(1040.0*3500.*(22./7.)*beam_r*beam_r);
117  }
118 
119 // //2-CSF
120 // eps = TDatabase::ParamDB->P2/(997.0*3710*char_L*char_L);
121 // alpha = TDatabase::ParamDB->P8;
122 // rhsfact = alpha*TDatabase::ParamDB->P4/(997.0*3710*(22./7.)*beam_r*beam_r);
123 //
124  for(i=0;i<n_points;i++)
125  {
126  coeff = coeffs[i];
127 
128  x = X[i];
129  y = Y[i];
130  z = Z[i];
131 
132  // diffusion
133  coeff[0] = eps;
134  // convection in x direction
135  coeff[1] = 0;
136  // convection in y direction
137  coeff[2] = 0;
138  // convection in z direction
139  coeff[3] = 0;
140  // reaction
141  coeff[4] = 0;
142  // rhs
143 
144  if(TDatabase::ParamDB->P13==0)
145  { //Lside
146  Sourceradius = sqrt( (x-xp)*(x-xp) + (z-zp)*(z-zp));
147 
148  if(y<0.) y=0.;
149  SourceCoord = -y;
150  }
151  else
152  { // side
153  Sourceradius = sqrt( (x-xp)*(x-xp) + (z-zp)*(z-zp));
154 
155  if(y>0.) y=0.;
156  SourceCoord = y;
157  }
158 
159 
160  if(Sourceradius<=DimlessBeam_r)
161  {
162  coeff[5] = rhsfact*exp(alpha*SourceCoord*char_L);// f
163 
164 // cout << "Sourceradius : " << Sourceradius << endl;
165  if(TDatabase::ParamDB->P14< hK) TDatabase::ParamDB->P14=hK;
166  }
167  else
168  {coeff[5] = 0; }// f
169 
170  coeff[6] = 0;
171 
172  }
173 }
174 
175 void ReadAdditionalNModes(char *NODE, tetgenio &InAddPts)
176 {
177  int i, N_Vertices, index, N_Atribude, BDMarker;
178  char line[100];
179  std::ifstream dat(NODE);
180 
181  if (!dat)
182  {
183  cerr << "cannot open '" << NODE << "' for input" << endl;
184  exit(-1);
185  }
186 
187  dat.getline (line, 99); // first line is command line
188  dat >> N_Vertices >> N_Atribude >> BDMarker;
189  dat.getline (line, 99);
190 
191  InAddPts.numberofpoints = N_Vertices;
192  InAddPts.pointlist = new double[3*N_Vertices];
193 
194  //read from file
195  for(i=0;i<N_Vertices; i++)
196  {
197  dat.getline (line, 99);
198  dat >> index >> InAddPts.pointlist[3*i] >> InAddPts.pointlist[3*i+1] >> InAddPts.pointlist[3*i+2];
199  cout<< i << " vert X: " <<InAddPts.pointlist[3*i] << " vert Y: " <<InAddPts.pointlist[3*i+1] <<" vert Z: " <<InAddPts.pointlist[3*i+2] <<endl;
200 
201  }
202 
203  dat.close();
204 
205 // cout << "N_Vertices " <<N_Vertices <<endl;
206 //
207 // exit(0);
208 
209 } // ReadAdditionalNModes
210 
211 void ReadMeditMeshWithCells(char *SMESH, tetgenio &In)
212 {
213  int i, j, k, dimension, N_FVert, N_Faces, N_Vertices, N_CVert, N_Cells;
214  int BDComp_Min=10000000;
215  int *plist;
216 
217  double x;
218 
219  char line[100];
220  tetgenio::facet *F;
221  tetgenio::polygon *P;
222 
223  std::ifstream dat(SMESH);
224 
225  if (!dat)
226  {
227  cerr << "cannot open '" << SMESH << "' for input" << endl;
228  exit(-1);
229  }
230 
231  // check the dimension
232  while (!dat.eof())
233  {
234  dat >> line;
235 
236  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
237  {
238  dat.getline (line, 99);
239  dat >> dimension;
240  break;
241  }
242  // read until end of line
243  dat.getline (line, 99);
244  }
245 
246  if(dimension!=3)
247  {
248  cerr << "dimension: " << dimension << endl;
249  exit(-1);
250  }
251 
252  // find the N_Vertices
253  while (!dat.eof())
254  {
255  dat >> line;
256 
257  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
258  {
259  dat.getline (line, 99);
260  dat >> N_Vertices;
261  break;
262  }
263  // read until end of line
264  dat.getline (line, 99);
265  }
266 
267  In.numberofpoints = N_Vertices;
268  In.pointlist = new double[3*N_Vertices];
269 
270  //read from file
271  for(i=0;i<N_Vertices; i++)
272  {
273  dat.getline (line, 99);
274  dat >> x >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
275 
276  In.pointlist[3*i] = x - 3.606596999999999830777142; //center point
277 
278 // if(i==1063 || i==1061 || i==1062 || i==162 || i==1175 || i==517 || i==1064 || i==518 ) // i==1063 as center
279  if(i==1062 || i==916 || i==341 || i==914 || i==162 || i==1063 || i==1061) // i==1062 as center
280  cout<< i << " vert X: " <<In.pointlist[3*i] << " vert Y: " <<In.pointlist[3*i+1] <<" vert Z: " <<In.pointlist[3*i+2] <<endl;
281  }
282 
283  // find the N_Triangles
284  // find the N_Vertices
285  while (!dat.eof())
286  {
287  dat >> line;
288 
289  if ( (!strcmp(line, "Triangles")) || (!strcmp(line, "triangles")) || (!strcmp(line, "TRIANGLES")) )
290  {
291  N_FVert = 3;
292  dat.getline (line, 99);
293  dat >> N_Faces;
294  break;
295  }
296  else if ( (!strcmp(line, "Quadrilaterals")) || (!strcmp(line, "quadrilaterals")) || (!strcmp(line, "QUADRILATERALS")) )
297  {
298  N_FVert = 4;
299  dat.getline (line, 99);
300  dat >> N_Faces;
301  break;
302  }
303 
304  // read until end of line
305  dat.getline (line, 99);
306  }
307 
308  In.numberoffacets = N_Faces;
309  In.facetlist = new tetgenio::facet[In.numberoffacets];
310  In.facetmarkerlist = new int[In.numberoffacets];
311 
312  for(i=0;i<N_Faces; i++)
313  {
314  dat.getline (line, 99);
315 
316  F = &In.facetlist[i];
317  tetgenio::init(F);
318  F->numberofpolygons = 1;
319  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
320  F->numberofholes = 0;
321  F->holelist = NULL;
322  P = &F->polygonlist[0];
323  tetgenio::init(P);
324  P->numberofvertices = N_FVert;
325  P->vertexlist = new int[P->numberofvertices];
326 
327  for(j=0;j<N_FVert;j++)
328  {
329  dat >> k;
330  P->vertexlist[j] = k-1; // c numbering
331  }
332 
333  dat >> In.facetmarkerlist[i];
334 
335  if(BDComp_Min > In.facetmarkerlist[i])
336  BDComp_Min=In.facetmarkerlist[i];
337 
338  // cout << i<< " P->vertexlist[j]: " << In.facetmarkerlist[i] << endl;
339  } // for(i=0;i<N_Faces; i++)
340 
341  BDComp_Min--;
342 
343  for(i=0;i<N_Faces; i++)
344  In.facetmarkerlist[i] -= BDComp_Min;
345 
346 
348  while (!dat.eof())
349  {
350  dat >> line;
351 
352  if ( (!strcmp(line, "Tetrahedron")) || (!strcmp(line, "tetrahedron")) || (!strcmp(line, "TETRAHEDRON")) )
353  {
354  N_CVert = 4;
355  dat.getline (line, 99);
356  dat >> N_Cells;
357  break;
358  }
359  // read until end of line
360  dat.getline (line, 99);
361  }
362 
363  In.numberoftetrahedra = N_Cells;
364  In.numberofcorners = N_CVert;
365  In.numberoftetrahedronattributes = 1;
366  In.tetrahedronlist = new int[N_Cells * 4];
367  In.tetrahedronattributelist = new REAL[N_Cells];
368  In.tetrahedronvolumelist = new REAL[N_Cells];
369 
370  for(i=0; i<N_Cells; i++)
371  {
372  dat.getline (line, 99);
373  plist = &(In.tetrahedronlist[i * 4]);
374 
375  for(j=0;j<N_CVert;j++)
376  {
377  dat >> k;
378  plist[j] = k -1;
379  }// for(j=0;j<N_CV
380 
381 
382  dat >> In.tetrahedronattributelist[i];
383 // In.tetrahedronvolumelist [i] = 100.;
384  } // for(i=0; i<N_
385 
386 
387 
388 // cout << i<< " N_Cells : " << N_Cells << endl;
389 // exit(0);
390 
391  dat.close();
392 // exit(0);
393 } // ReadMeditMeshWithCells
394 
395 void ReadMeditMesh(char *SMESH, tetgenio &In)
396 {
397  int i, j, k, dimension, N_FVert, N_Faces, N_Vertices;
398  int BDComp_Min=10000000;
399 
400  char line[100];
401  tetgenio::facet *F;
402  tetgenio::polygon *P;
403 
404  std::ifstream dat(SMESH);
405 
406  if (!dat)
407  {
408  cerr << "cannot open '" << SMESH << "' for input" << endl;
409  exit(-1);
410  }
411 
412  // check the dimension
413  while (!dat.eof())
414  {
415  dat >> line;
416 
417  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
418  {
419  dat.getline (line, 99);
420  dat >> dimension;
421  break;
422  }
423  // read until end of line
424  dat.getline (line, 99);
425  }
426 
427  if(dimension!=3)
428  {
429  cerr << "dimension: " << dimension << endl;
430  exit(-1);
431  }
432 
433  // find the N_Vertices
434  while (!dat.eof())
435  {
436  dat >> line;
437 
438  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
439  {
440  dat.getline (line, 99);
441  dat >> N_Vertices;
442  break;
443  }
444  // read until end of line
445  dat.getline (line, 99);
446  }
447 
448  In.numberofpoints = N_Vertices;
449  In.pointlist = new double[3*N_Vertices];
450 
451  //read from file
452  for(i=0;i<N_Vertices; i++)
453  {
454  dat.getline (line, 99);
455  dat >> In.pointlist[3*i] >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
456  //cout<< i << " vert X: " <<In.pointlist[3*i] << " vert Y: " <<In.pointlist[3*i+1] <<endl;
457  }
458 
459  // find the N_Triangles
460  // find the N_Vertices
461  while (!dat.eof())
462  {
463  dat >> line;
464 
465  if ( (!strcmp(line, "Triangles")) || (!strcmp(line, "triangles")) || (!strcmp(line, "TRIANGLES")) )
466  {
467  N_FVert = 3;
468  dat.getline (line, 99);
469  dat >> N_Faces;
470  break;
471  }
472  else if ( (!strcmp(line, "Quadrilaterals")) || (!strcmp(line, "quadrilaterals")) || (!strcmp(line, "QUADRILATERALS")) )
473  {
474  N_FVert = 4;
475  dat.getline (line, 99);
476  dat >> N_Faces;
477  break;
478  }
479 
480  // read until end of line
481  dat.getline (line, 99);
482  }
483 
484  In.numberoffacets = N_Faces;
485  In.facetlist = new tetgenio::facet[In.numberoffacets];
486  In.facetmarkerlist = new int[In.numberoffacets];
487 
488  for(i=0;i<N_Faces; i++)
489  {
490  dat.getline (line, 99);
491 
492  F = &In.facetlist[i];
493  tetgenio::init(F);
494  F->numberofpolygons = 1;
495  F->polygonlist = new tetgenio::polygon[F->numberofpolygons];
496  F->numberofholes = 0;
497  F->holelist = NULL;
498  P = &F->polygonlist[0];
499  tetgenio::init(P);
500  P->numberofvertices = N_FVert;
501  P->vertexlist = new int[P->numberofvertices];
502 
503  for(j=0;j<N_FVert;j++)
504  {
505  dat >> k;
506  P->vertexlist[j] = k-1; // c numbering
507  }
508 
509  dat >> In.facetmarkerlist[i];
510 
511  if(BDComp_Min > In.facetmarkerlist[i])
512  BDComp_Min=In.facetmarkerlist[i];
513 
514  // cout << i<< " P->vertexlist[j]: " << In.facetmarkerlist[i] << endl;
515  } // for(i=0;i<N_Faces; i++)
516 
517  BDComp_Min--;
518 
519  for(i=0;i<N_Faces; i++)
520  In.facetmarkerlist[i] -= BDComp_Min;
521 
522 // cout << i<< " P->vertexlist[j]: " << BDComp_Min << endl;
523 
524 
525  dat.close();
526 // exit(0);
527 } // ReadMeditMesh
528 
529 void DeleteDomain(TDomain *&Domain)
530 {
531  int i, j, k, N_Cells, N_RootCells;
532  int CurrVertex, N_Faces, N_Vertices, ID;
533  TBaseCell **CellTree, **SurfCellTree, *cell;
534  TGridCell **DelCell;
535  TVertex **VertexDel;
536  TCollection *coll;
537 
538  Domain->GetTreeInfo(CellTree,N_RootCells);
539  coll = Domain->GetCollection(It_Finest, 0);
540  N_Cells = coll->GetN_Cells();
541 
542  VertexDel = new TVertex*[8*N_RootCells];
543  CurrVertex = 0;
544 
545  for(i=0;i<N_Cells;i++)
546  {
547  cell = coll->GetCell(i);
548  N_Faces = cell->GetN_Faces();
549  N_Vertices = cell->GetN_Vertices();
550  for(j=0;j<N_Faces;j++)
551  {
552  if(CurrVertex==0)
553  {
554  VertexDel[CurrVertex++] = cell->GetVertex(j);
555  }
556  else
557  {
558  ID = 0;
559  for(k=0;k<CurrVertex;k++)
560  if(VertexDel[k]==cell->GetVertex(j))
561  {
562  ID = 1; break;
563  }
564  if(ID!=1)
565  {
566  VertexDel[CurrVertex++] = cell->GetVertex(j);
567  }
568  } // else if(CurrVertex==0)
569 
570  ID = 0;
571  for(k=0;k<CurrVertex;k++)
572  if(VertexDel[k]==cell->GetVertex((j+1)%N_Vertices))
573  {
574  ID = 1; break;
575  }
576  if(ID!=1)
577  {
578  VertexDel[CurrVertex++] = cell->GetVertex((j+1)%N_Vertices);
579  }
580 
581  ID = 0;
582  for(k=0;k<CurrVertex;k++)
583  if(VertexDel[k]==cell->GetVertex((j+2)%N_Vertices))
584  {
585  ID = 1; break;
586  }
587  if(ID!=1)
588  {
589  VertexDel[CurrVertex++] = cell->GetVertex((j+2)%N_Vertices);
590  }
591  if(N_Faces==6) // If old cell is hexahedrol
592  {
593  ID = 0;
594  for(k=0;k<CurrVertex;k++)
595  if(VertexDel[k]==cell->GetVertex((j+4)%N_Vertices))
596  {
597  ID = 1; break;
598  }
599  if(ID!=1)
600  {
601  VertexDel[CurrVertex++] = cell->GetVertex((j+4)%N_Vertices);
602  }
603  }
604  } // for j
605  } // for i
606 
607  for(i=0;i<CurrVertex;i++)
608  delete VertexDel[i];
609  delete [] VertexDel;
610  OutPut(CurrVertex<<" vertices were deleted"<<endl);
611 
612  // remove all existing cells and joints
613  for(i=0;i<N_RootCells;i++)
614  delete (TGridCell*)CellTree[i];
615  delete [] CellTree;
616  OutPut(N_RootCells<<" cells were deleted"<<endl);
617 }
618 
619 TDomain* TetrameshCreate()
620 {
621  int i, j, k, l, dimension, N_Vertices;
622  int N_Faces, N_RootCells;
623  int v1, v2, v3, v4, CellMarker, RefLevel=0, *Tetrahedrals, *PointNeighb, maxEpV, *Tetrahedrals_loc;
624  int a, b, c, Neib[2], Neighb_tmp, CurrNeib, len1, len2, len3, CurrComp=0, N_Points ;
625  int N_Cells, MaxLen, jj, CompID=0;
626  const int *EdgeVertex, *TmpFV, *TmpLen;
627  double X, Y, Z, DispX, DispY, DispZ;
628  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
629  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
630  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
631  char *MESH, line[100];
632  MESH = TDatabase::ParamDB->SMESHFILE;
633  TDomain *Domain= new TDomain;
634  TVertex **NewVertices;
635  TBaseCell **CellTree, *cell;
636  TJoint *Joint;
637  TBoundComp3D *bdcomp;
638  TShapeDesc *ShapeDesc;
639  TCollection *coll;
640  TBoundPart *someboundpart;
641  std::ifstream dat(MESH);
642 
643  if (!dat)
644  {
645  cerr << "cannot open '" << MESH << "' for input" << endl;
646  exit(-1);
647  }
648 
649  while (!dat.eof())
650  {
651  dat >> line;
652 
653  if ( (!strcmp(line, "Dimension")) || (!strcmp(line, "dimension")) || (!strcmp(line, "DIMENSION")))
654  {
655  dat.getline (line, 99);
656  dat >> dimension;
657  break;
658  }
659 
660  dat.getline (line, 99);
661  }
662 
663  if(dimension!=3)
664  {
665  cerr << "dimension: " << dimension << endl;
666  exit(-1);
667  }
668 
669  while (!dat.eof())
670  {
671  dat >> line;
672  if ( (!strcmp(line, "Vertices")) || (!strcmp(line, "vertices")) || (!strcmp(line, "VERTICES")) )
673  {
674  dat.getline (line, 99);
675  dat >> N_Vertices;
676  break;
677  }
678  // read until end of line
679  dat.getline (line, 99);
680  }
681  // generate new vertices
682  cout <<"N_Vertices "<<N_Vertices<<endl;
683  NewVertices = new TVertex*[N_Vertices];
684 
685  for(i=0;i<N_Vertices; i++)
686  {
687  dat.getline (line, 99);
688  dat >> X >> Y >> Z;
689  NewVertices[i] = new TVertex(X, Y, Z);
690 
691  if (X > Xmax) Xmax = X;
692  if (X < Xmin) Xmin = X;
693  if (Y > Ymax) Ymax = Y;
694  if (Y < Ymin) Ymin = Y;
695  if (Z > Zmax) Zmax = Z;
696  if (Z < Zmin) Zmin = Z;
697  }
698  // set bounding box
699  StartX = Xmin;
700  StartY = Ymin;
701  StartZ = Zmin;
702  BoundX = Xmax - Xmin;
703  BoundY = Ymax - Ymin;
704  BoundZ = Zmax - Zmin;
705 
706  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
707 
708  while (!dat.eof())
709  {
710  dat >> line;
711 
712  if ( (!strcmp(line, "Tetrahedra")) || (!strcmp(line, "tetrahedra")) || (!strcmp(line, "TETRAHEDRA")) )
713  {
714  dat.getline (line, 99);
715  dat >> N_RootCells;
716  break;
717  }
718  // read until end of line
719  dat.getline (line, 99);
720  }
721 
722  // generate new cells
723  cout << "number of root cells "<<N_RootCells <<endl;
724  CellTree = new TBaseCell*[N_RootCells];
725  Tetrahedrals = new int[4*N_RootCells];
726 
727  for (i=0;i<N_RootCells;i++)
728  {
729  dat.getline (line, 99);
730  dat >> v1 >> v2 >> v3 >> v4 >> CellMarker;
731  Tetrahedrals[4*i ] = v1-1;
732  Tetrahedrals[4*i + 1] = v2-1;
733  Tetrahedrals[4*i + 2] = v3-1;
734  Tetrahedrals[4*i + 3] = v4-1;
735 
736  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron], RefLevel);
737  CellTree[i]->SetRegionID(CellMarker);
738  CellTree[i]->SetAsLayerCell(1);
739  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
740  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
741  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
742  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
743  CellTree[i]->SetClipBoard(i);
744 
745  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
746  }
747  dat.close();
748 
749  Domain->SetTreeInfo(CellTree, N_RootCells);
750  // initialize iterators
751  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
752  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
753  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
754  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
755  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
756 
757  // search neighbours
758  PointNeighb = new int[N_Vertices];
759  memset(PointNeighb, 0, N_Vertices*SizeOfInt);
760 
761  for (i=0;i<4*N_RootCells;i++)
762  PointNeighb[Tetrahedrals[i]]++;
763 
764  maxEpV = 0;
765  for (i=0;i<N_Vertices;i++)
766  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
767  delete [] PointNeighb;
768  cout<<"maximum edges per vertex "<< maxEpV<<endl;
769  PointNeighb = new int[++maxEpV * N_Vertices];
770  memset(PointNeighb, 0, maxEpV*N_Vertices*SizeOfInt);
771 
772  // every vertex contains "maxEpV" columns
773  // for every vertex at first colomn contains the number of cells containing this vertex
774  // at further columns we set the index of corresponding cells containing this vertex
775  // cout<<"maxEpV*N_Vertices "<<maxEpV*N_Vertices<<endl;
776  for(i=0;i<4*N_RootCells;i++)
777  {
778  j = Tetrahedrals[i]*maxEpV;
779  PointNeighb[j]++;
780  PointNeighb[j + PointNeighb[j]] = i / 4;
781  } //=====================================================
783  coll=Domain->GetCollection(It_Finest, 0);
784  N_Cells = coll->GetN_Cells();
785 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
786 // for(i=0;i<N_Cells;i++)
787 // {
788 // cell = coll->GetCell(i);
789 // ShapeDesc= cell->GetShapeDesc();
790 // ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
791 // N_Faces = cell->GetN_Faces();
792 // cout<<"N_Faces "<<N_Faces<<endl;
793 // for(j=0;j<N_Faces;j++)
794 // cout<<"TmpLen["<<j<<"] is "<<TmpLen[j]<<endl;
795 // }
796 // exit(0);
797  for(i=0;i<N_Cells;i++)
798  {
799  cell = coll->GetCell(i);
800  ShapeDesc= cell->GetShapeDesc();
801  ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
805  N_Faces = cell->GetN_Faces();
806  Tetrahedrals_loc = Tetrahedrals+4*i;
807 // cout <<"chek 9 "<< i<<endl;
808  for(jj=0;jj<N_Faces;jj++)
809  if(cell->GetJoint(jj) == NULL)
810  {
811  N_Points = TmpLen[jj];
812  if(N_Points!=3)
813  {
814  cerr << "Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
815  exit(-1);
816  }
817  a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
818  b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
819  c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
820 // cout<<"a "<<a<<endl;
821 // cout<<"b "<<b<<endl;
822 // cout<<"c "<<c<<endl;
823 // cout<<"TmpFV1 "<<TmpFV[jj*MaxLen]<<endl;
824 // cout<<"TmpFV2 "<<TmpFV[jj*MaxLen+1]<<endl;
825 // cout<<"TmpFV3 "<<TmpFV[jj*MaxLen+2]<<endl;
826 // cout<<"TmpFV1 "<<TmpFV[jj*MaxLen]<<endl;
827 // cout<<"TmpFV2 "<<TmpFV[(jj+1)*MaxLen+1]<<endl;
828 // cout<<"TmpFV3 "<<TmpFV[(jj+1)*MaxLen+2]<<endl;
829 // cout<<"TmpFV1 "<<TmpFV[(jj+1)*MaxLen]<<endl;
830 // cout<<"TmpFV2 "<<TmpFV[(jj+2)*MaxLen+1]<<endl;
831 // cout<<"TmpFV3 "<<TmpFV[(jj+2)*MaxLen+2]<<endl;
832 // cout<<"TmpFV1 "<<TmpFV[(jj+2)*MaxLen]<<endl;
833 // cout<<"TmpFV2 "<<TmpFV[(jj+3)*MaxLen+1]<<endl;
834 // cout<<"TmpFV3 "<<TmpFV[(jj+3)*MaxLen+2]<<endl;
835 // exit(0);
836 // a = TmpFV[jj*MaxLen];
837 // b = TmpFV[jj*MaxLen + 1];
838 // c = TmpFV[jj*MaxLen + 2];
839  Neib[0] = -1;
840  Neib[1] = -1;
841  CurrNeib = 0;
842  len1 = PointNeighb[a*maxEpV];
843  len2 = PointNeighb[b*maxEpV];
844  len3 = PointNeighb[c*maxEpV];
845 // cout <<"chek 10 "<< i<<endl;
846  // find the index of the cells containing current face with node(vertex) indices a,b,c
847  for (j=1;j<=len1;j++)
848  {
849  Neighb_tmp = PointNeighb[a*maxEpV + j];
850  for (k=1;k<=len2;k++)
851  {
852  if(Neighb_tmp == PointNeighb[b*maxEpV + k])
853  {
854  for(l=1;l<=len3;l++)
855  if(Neighb_tmp == PointNeighb[c*maxEpV + l])
856  {
857  Neib[CurrNeib++] = Neighb_tmp;
858  break;
859  }
860  }
861  }
862  if (CurrNeib == 2) break;
863  } // for (j=1;j<=len1;j++)
864 // cout <<"chek 11 "<< i<<endl;
865  if(CurrNeib==1)
866  {
867 // cout <<"chek 11.10 "<<endl;
868  someboundpart = Domain->GetBdPart(0);
869 // if(someboundpart==NULL)
870 // cout <<"chek 11.12 NULL"<<endl;
871 // fflush(stdout);
872 // cout <<"CurrComp "<<CurrComp<<endl;
873 // scanf("%d",&CurrComp);
874  bdcomp = new TBdPlane(CompID++);
875 // bdcomp = someboundpart->GetBdComp(CurrComp);
876 // cout <<"chek 11.15 "<<endl;
877 // cout <<"chek 11.20 "<<endl;
878 // fflush(stdout);
879 // scanf("%d",&CurrComp);
880 // exit(0);
881 // double vertx, verty, vertz, t1, s1;
882 // vertx = NewVertices[a]->GetX();
883 // verty = NewVertices[a]->GetY();
884 // vertz = NewVertices[a]->GetZ();
885 // cout <<"chek 11.11 "<<NewVertices[a]->GetX()<<" "<<NewVertices[a]->GetY()<<" "<<NewVertices[a]->GetZ()<<endl;
886 // cout <<"chek 11.11 "<<endl;
887 // bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(), NewVertices[a]->GetZ(), T[1], S[1]);
888 // bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(), NewVertices[a]->GetZ(), T[1], S[1]);
889 // cout <<T[1]<<" "<<S[1]<<endl;
890 // cout<<"b is "<<b<<endl;
891 // cout <<NewVertices[239]->GetX()<<" "<<NewVertices[239]->GetY()<<endl;
892 // bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(), NewVertices[b]->GetZ(), T[2], S[2]);
893 // bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(), NewVertices[c]->GetZ(), T[3], S[3]);
894 // bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
895 // exit(0);
896 // cout<<"chek 11.12"<<endl;
897 // cout <<"chek 11.25 "<< i<<endl;
898 // cout <<"chek 11.35 "<<NewVertices[a]->GetX()<<" "<<NewVertices[a]->GetY()<<" "<<NewVertices[a]->GetZ()<<endl;
899 // cout <<"bdcomp "<<bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(), NewVertices[a]->GetZ(), T[1], S[1])<<endl;
900 // exit(0);
901  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(), NewVertices[a]->GetZ(), T[1], S[1])
902  ||
903  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(), NewVertices[b]->GetZ(), T[2], S[2])
904  ||
905  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(), NewVertices[c]->GetZ(), T[3], S[3]) )
906  {
907  cout <<"chek 11.5 "<< i<<endl;
908  cerr<<"Error: could not set parameter values"<<endl;
909  OutPut(NewVertices[a]<<endl);
910  OutPut(NewVertices[b]<<endl);
911  OutPut(NewVertices[c]<<endl);
912  exit(0);
913  }
914  Joint = new TBoundFace(bdcomp, T, S);
915 // cout <<"chek 11.75 "<< i<<endl;
916  }
917  else
918  {
919  if (CurrNeib != 2)
920  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
921  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
922  }
923 // cout <<"chek 12 "<< i<<endl;
924  // First element containing the current face
925  // find the local index for the point 'a' on the cell
926  for (j=0;j<4;j++)
927  if (Tetrahedrals[4*Neib[0]+j] == a) break;
928  // find the local index for the point 'b' on the cell
929  for (k=0;k<4;k++)
930  if (Tetrahedrals[4*Neib[0]+k] == b) break;
931  // find the local index for the point 'c' on the cell
932  for (l=0;l<4;l++)
933  if (Tetrahedrals[4*Neib[0]+l] == c) break;
934  l = l*100 + k*10 + j;
935 
936  switch (l) // j will contain the local index for the current face
937  {
938  case 210: case 21: case 102:
939  case 120: case 12: case 201:
940  j = 0;
941  break;
942  case 310: case 31: case 103:
943  case 130: case 13: case 301:
944  j = 1;
945  break;
946  case 321: case 132: case 213:
947  case 231: case 123: case 312:
948  j = 2;
949  break;
950  case 230: case 23: case 302:
951  case 320: case 32: case 203:
952  j = 3;
953  break;
954 
955  default:
956  Error("Unable to set the face !!!!!!!!!!!!" << endl);
957  exit(0);
958  } // switch (l)
959  cout <<"chek 13 "<< i<<endl;
960  CellTree[Neib[0]]->SetJoint(j, Joint);
961 
962  // second cell containing the current face
963  if (Neib[1] != -1) // second element containing the current face
964  {
965  cout <<"chek 13.5 "<< i<<endl;
966  // find the local index for the point 'a' on the cell
967  for (j=0;j<4;j++)
968  if (Tetrahedrals[4*Neib[1]+j] == a) break;
969 
970  // find the local index for the point 'b' on the cell
971  for (k=0;k<4;k++)
972  if (Tetrahedrals[4*Neib[1]+k] == b) break;
973 
974  // find the local index for the point 'c' on the cell
975  for (l=0;l<4;l++)
976  if (Tetrahedrals[4*Neib[1]+l] == c) break;
977 
978  l = l*100 + k*10 + j;
979  switch (l) // j will contain the local index for the current face
980  {
981  case 210: case 21: case 102:
982  case 120: case 12: case 201:
983  j = 0;
984  break;
985  case 310: case 31: case 103:
986  case 130: case 13: case 301:
987  j = 1;
988  break;
989  case 321: case 132: case 213:
990  case 231: case 123: case 312:
991  j = 2;
992  break;
993  case 230: case 23: case 302:
994  case 320: case 32: case 203:
995  j = 3;
996  break;
997 
998  default:
999  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1000  exit(0);
1001  }
1002  CellTree[Neib[1]]->SetJoint(j, Joint);
1003  } // if (Neib[1] != -1)
1004 
1005  if (Joint->GetType() == InterfaceJoint3D || Joint->GetType() == IsoInterfaceJoint3D)
1006  {
1007  ((TInterfaceJoint3D*)Joint)->SetMapType();
1008  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
1009  }
1010  else
1011  if (Joint->GetType() == JointEqN)
1012  Joint->SetMapType();
1013  } // if(cell->GetJoint(j)
1014  } // for(i=0;i<N_Cells;i++)
1015 delete [] PointNeighb;
1016  cout<< "tetrameshcreatesuccessful " <<"\n";
1017  return Domain;
1018 }
1019 
1020 void TetrameshGen(TDomain *&Domain)
1021 {
1022  //======================================================================
1023  // Tetgen for grid generation begin
1024  //======================================================================
1025  int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
1026  int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
1027  int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
1028  int *Tetrahedrals, *PointNeighb, dimension;
1029  int *Facelist, *Facemarkerlist;
1030 
1031  double *Coordinates, N_x, N_y, N_z;
1032  double *Vertices;
1033  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
1034  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
1035  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
1036 
1037  tetgenio In, Out;
1038 
1039  TBaseCell **CellTree, **SurfCellTree;
1040  TGridCell **DelCell;
1041  TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1042  TBoundPart *BoundPart;
1043  TBdPlane **UpdateFaceParams;
1044  TJoint *Joint;
1045  TBoundComp3D *bdcomp;
1046  TCollection *coll, *SurfColl;
1047  TBaseCell *cell;
1048  TBdSphere *UpdateParam;
1049 
1050  char *SMESH, line[100];
1051  SMESH = TDatabase::ParamDB->SMESHFILE;
1052 
1053 #ifdef _MPI
1054  int rank, size;
1055  MPI_Comm Comm = TDatabase::ParamDB->Comm;
1056 
1057  MPI_Comm_rank(Comm, &rank);
1058  MPI_Comm_size(Comm, &size);
1059 
1060 #endif
1061 
1063 #ifdef _MPI
1064  if(rank==0)
1065 #endif
1066  {
1067 
1068 // In.initialize();
1069 // Out.initialize();
1070 
1071  std::ostringstream opts;
1072  opts << " ";
1073 
1074  opts.seekp(std::ios::beg);
1075  opts<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
1076 // opts<<'r'; // -r Reconstructs a previously generated mesh
1077 // opts<<"q"<<1.49; // quality mesh generation(q) with a specified quality bound
1078 // opts<<"a"<<0.1; // maximum volume constraint
1079 // opts<<'i'; // Inserts a list of additional points into mesh.
1080  opts<<'z'; // numbers all output items starting from zero
1081 // opts<<'d'; // Detect intersections of PLC facets.
1082  opts<<'f'; // Outputs all faces (including non-boundary)
1083  opts<<'e'; // Outputs a list of edges of the triangulation
1084 // opts<<'I'; // Suppresses mesh iteration numbers.
1085  opts<<'C'; // Checks the consistency of the final mesh.
1086 // opts<<'Q'; // Quiet: No terminal output except errors.
1087 // opts<<'g'; // Outputs mesh to .mesh file for viewing by Medit
1088  opts<<'Y'; // Suppresses boundary facets/segments splitting
1089 // opts<<'V'; //verbose mode
1090  opts<<ends;
1091 
1092 // cout << " SMESHFILE is " << SMESH << endl;
1094  ReadMeditMesh(SMESH, In);
1095 
1096 // for(i=0;i<In.numberofpoints;i++)
1097 // OutPut(i<<" (x, y, z) = "<<
1098 // In.pointlist[3*i]<<' '<<In.pointlist[3*i+1]<<' '<<In.pointlist[3*i+2]<<endl);
1099 
1100  // Calling tetrahedralize function of 3dtetgen mesh generator
1101  tetrahedralize((char*)opts.str().c_str(), &In, &Out);
1102 
1103  } // if(rank==0)
1104 
1105 
1106  // output: coordinates of all vertices
1107 // for(i=0;i<Out.numberofpoints;i++)
1108 // OutPut(" (x, y, z) = "<< Out.pointlist[3*i]<<' '<<Out.pointlist[3*i+1]<<' '<<Out.pointlist[3*i+2]<<endl);
1109 
1110  Domain->GetTreeInfo(CellTree,N_RootCells);
1111  coll = Domain->GetCollection(It_Finest, 0);
1112  N_Cells = coll->GetN_Cells();
1113 
1114 // cout<<"N_RootCells: "<<N_RootCells<<endl;
1115  // remove all existing vertices and joints
1116  VertexDel = new TVertex*[8*N_RootCells];
1117  CurrVertex = 0;
1118 
1119  for(i=0;i<N_Cells;i++)
1120  {
1121  cell = coll->GetCell(i);
1122  N_Faces = cell->GetN_Faces();
1123  N_Vertices = cell->GetN_Vertices();
1124  for(j=0;j<N_Faces;j++)
1125  {
1126  if(CurrVertex==0)
1127  {
1128  VertexDel[CurrVertex++] = cell->GetVertex(j);
1129  }
1130  else
1131  {
1132  ID = 0;
1133  for(k=0;k<CurrVertex;k++)
1134  if(VertexDel[k]==cell->GetVertex(j))
1135  {
1136  ID = 1; break;
1137  }
1138  if(ID!=1)
1139  {
1140  VertexDel[CurrVertex++] = cell->GetVertex(j);
1141  }
1142  } // else if(CurrVertex==0)
1143 
1144  ID = 0;
1145  for(k=0;k<CurrVertex;k++)
1146  if(VertexDel[k]==cell->GetVertex((j+1)%N_Vertices))
1147  {
1148  ID = 1; break;
1149  }
1150  if(ID!=1)
1151  {
1152  VertexDel[CurrVertex++] = cell->GetVertex((j+1)%N_Vertices);
1153  }
1154 
1155  ID = 0;
1156  for(k=0;k<CurrVertex;k++)
1157  if(VertexDel[k]==cell->GetVertex((j+2)%N_Vertices))
1158  {
1159  ID = 1; break;
1160  }
1161  if(ID!=1)
1162  {
1163  VertexDel[CurrVertex++] = cell->GetVertex((j+2)%N_Vertices);
1164  }
1165  if(N_Faces==6) // If old cell is hexahedrol
1166  {
1167  ID = 0;
1168  for(k=0;k<CurrVertex;k++)
1169  if(VertexDel[k]==cell->GetVertex((j+4)%N_Vertices))
1170  {
1171  ID = 1; break;
1172  }
1173  if(ID!=1)
1174  {
1175  VertexDel[CurrVertex++] = cell->GetVertex((j+4)%N_Vertices);
1176  }
1177  }
1178  } // for j
1179  } // for i
1180 
1181  for(i=0;i<CurrVertex;i++)
1182  delete VertexDel[i];
1183  delete [] VertexDel;
1184  OutPut(CurrVertex<<" vertices were deleted"<<endl);
1185 
1186  // remove all existing cells and joints
1187 
1188  for(i=0;i<N_RootCells;i++)
1189  delete (TGridCell*)CellTree[i];
1190  delete [] CellTree;
1191  OutPut(N_RootCells<<" cells were deleted"<<endl);
1192 
1193 
1194 #ifdef _MPI
1195  if(rank==0)
1196 #endif
1197  {
1198  N_RootCells = Out.numberoftetrahedra;
1199  N_G = Out.numberofpoints;
1200 
1201  // allocate auxillary fields
1202  Coordinates = Out.pointlist;
1203  Tetrahedrals = Out.tetrahedronlist;
1204  }
1205 
1206 
1207 
1208 #ifdef _MPI
1209  MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1210  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1211 
1212 
1213  if(rank!=0)
1214  {
1215  Coordinates = new double [3*N_G];
1216  Tetrahedrals = new int[4*N_RootCells];
1217  }
1218 
1219  MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1220  MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1221 #endif
1222 
1223  // generate new vertices
1224  NewVertices = new TVertex*[N_G];
1225 
1226  for (i=0;i<N_G;i++)
1227  {
1228  NewVertices[i] = new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
1229 
1230  // set bounding box
1231  if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
1232  if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
1233  if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
1234  if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
1235  if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
1236  if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
1237  }
1238  // set bounding box
1239  StartX = Xmin;
1240  StartY = Ymin;
1241  StartZ = Zmin;
1242  BoundX = Xmax - Xmin;
1243  BoundY = Ymax - Ymin;
1244  BoundZ = Zmax - Zmin;
1245 
1246  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1247 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
1248 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
1249 
1250  CellTree = new TBaseCell*[N_RootCells];
1251  // output of each tetraheron vertex indices (four vertices for each)
1252 // for (i=0;i<N_RootCells;i++)
1253 // cout<< Tetrahedrals[4*i]<<" "<<Tetrahedrals[4*i + 1]<<" "
1254 // <<Tetrahedrals[4*i + 2]<<" "<<Tetrahedrals[4*i + 3]<<endl;
1255 
1256 
1257  for (i=0;i<N_RootCells;i++)
1258  {
1259  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron],RefLevel);
1260 
1261  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
1262  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
1263  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
1264  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
1265 
1266  CellTree[i]->SetClipBoard(i);
1267  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
1268  }
1269 
1270  Domain->SetTreeInfo(CellTree, N_RootCells);
1271 
1272  // initialize iterators
1273  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
1274  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
1275  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
1276  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
1277  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
1278 
1279 
1280  // search neighbours
1281  PointNeighb = new int[N_G];
1282 #ifdef _MPI
1283  if(rank==0)
1284 #endif
1285  cout<<"numberofpoints "<<N_G<<endl;
1286  memset(PointNeighb, 0, N_G *SizeOfInt);
1287 
1288  for (i=0;i<4*N_RootCells;i++)
1289  PointNeighb[Tetrahedrals[i]]++;
1290 
1291  for (i=0;i<N_G;i++)
1292  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1293  delete [] PointNeighb;
1294 
1295 #ifdef _MPI
1296  if(rank==0)
1297 #endif
1298  cout<<"maxEpV "<< maxEpV<<endl;
1299 
1300  PointNeighb = new int[++maxEpV * N_G];
1301 
1302  memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1303 
1304  // every vertex contains "maxEpV" columns
1305  // for every vertex at first colomn contains the number of cells containing this vertex
1306  // at further columns we set the index of corresponding cells containing this vertex
1307  // cout<<"maxEpV*N_G "<<maxEpV*N_G<<endl;
1308 
1309  for(i=0;i<4*N_RootCells;i++)
1310  {
1311  j = Tetrahedrals[i]*maxEpV;
1312  PointNeighb[j]++;
1313  //cout<<"j + PointNeighb[j] " << j <<endl;
1314  PointNeighb[j + PointNeighb[j]] = i / 4;
1315  }
1316  // output of PointNeighb columns for each point
1317 // for (i=0;i<N_G;i++)
1318 // {
1319 // for (j=0;j<maxEpV;j++)
1320 // cout<<" "<< PointNeighb[i*maxEpV+j];
1321 // cout<<endl;
1322 // }
1323 
1324  // generate new faces
1325 
1326 #ifdef _MPI
1327  if(rank==0)
1328 #endif
1329  {
1330  N_G = Out.numberoftrifaces;
1331  Facelist = Out.trifacelist;
1332  Facemarkerlist = Out.trifacemarkerlist;
1333  }
1334 
1335 #ifdef _MPI
1336  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1337 
1338  if(rank!=0)
1339  {
1340  Facelist = new int [3*N_G];
1341  Facemarkerlist = new int[N_G];
1342  }
1343 
1344 
1345  MPI_Bcast(Facelist, 3*N_G, MPI_INT, 0, Comm);
1346  MPI_Bcast(Facemarkerlist, N_G, MPI_INT, 0, Comm);
1347 
1348  if(rank==0)
1349 #endif
1350  cout<<"numberoftrifaces "<<N_G<<endl;
1351 
1352  for (i=0;i<N_G;i++)
1353  {
1354  a = Facelist[3*i];
1355  b = Facelist[3*i+1];
1356  c = Facelist[3*i+2];
1357 
1358 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
1359 
1360  Neib[0] = -1;
1361  Neib[1] = -1;
1362  CurrNeib = 0;
1363 
1364  len1 = PointNeighb[a*maxEpV];
1365  len2 = PointNeighb[b*maxEpV];
1366  len3 = PointNeighb[c*maxEpV];
1367 
1368  // find the index of the cells containing current face with point indices a,b,c
1369  for (j=1;j<=len1;j++)
1370  {
1371  Neighb_tmp = PointNeighb[a*maxEpV + j];
1372  for (k=1;k<=len2;k++)
1373  {
1374  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1375  {
1376  for (l=1;l<=len3;l++)
1377  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1378  {
1379  Neib[CurrNeib++] = Neighb_tmp;
1380  break;
1381  }
1382  }
1383  }
1384  if (CurrNeib == 2) break;
1385  }
1386  // cout<<"CurrNeib " << CurrNeib <<endl;
1387 // cout<<"Facemarkerlist[i] : "<<Facemarkerlist[i]<<endl;
1388  if (Facemarkerlist[i]) // 0 for inner edges and Boundcomp+1 for Boundedge respect
1389  {
1390 
1391  CurrComp = Facemarkerlist[i] - 1;
1392 // cout<<"Boundary face CurrComp: "<<CurrComp<<endl;
1393 // exit(0);
1394  CurrComp = 0; // not yet implemented fully
1395 
1396 
1397 
1398  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
1399 
1400 
1401  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
1402  NewVertices[a]->GetY(), T[1], S[1]) ||
1403  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
1404  NewVertices[b]->GetY(), T[2], S[2]) ||
1405  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
1406  NewVertices[c]->GetY(), T[3], S[3]) )
1407  {
1408  cerr<<"Error: could not set parameter values"<<endl;
1409  OutPut(NewVertices[a]<<endl);
1410  OutPut(NewVertices[b]<<endl);
1411  OutPut(NewVertices[c]<<endl);
1412  exit(0);
1413  }
1414 
1415  if (CurrNeib == 2)
1416  {
1417  if(bdcomp->IsFreeBoundary())
1418  Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
1419  CellTree[Neib[0]], CellTree[Neib[1]] );
1420  else
1421  Joint = new TInterfaceJoint3D(bdcomp, T, S,
1422  CellTree[Neib[0]], CellTree[Neib[1]] );
1423  }
1424  else
1425  {
1426  if(bdcomp->IsFreeBoundary())
1427  Joint = new TIsoBoundFace(bdcomp, T, S);
1428  else
1429  Joint = new TBoundFace(bdcomp, T, S);
1430  }
1431  }
1432  else
1433  {
1434 // // cout<<"Inner face"<<endl;
1435  if (CurrNeib != 2)
1436  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
1437 
1438  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1439 
1440  }
1441 
1442  // First element containing the current face
1443  // find the local index for the point 'a' on the cell
1444  for (j=0;j<4;j++)
1445  if (Tetrahedrals[4*Neib[0]+j] == a) break;
1446 
1447  // find the local index for the point 'b' on the cell
1448  for (k=0;k<4;k++)
1449  if (Tetrahedrals[4*Neib[0]+k] == b) break;
1450 
1451  // find the local index for the point 'c' on the cell
1452  for (l=0;l<4;l++)
1453  if (Tetrahedrals[4*Neib[0]+l] == c) break;
1454 
1455  l = l*100 + k*10 + j;
1456 
1457 // cout<<""<< l <<endl;
1458 
1459  switch (l) // j will contain the local index for the current face
1460  {
1461  case 210: case 21: case 102:
1462  case 120: case 12: case 201:
1463  j = 0;
1464  break;
1465  case 310: case 31: case 103:
1466  case 130: case 13: case 301:
1467  j = 1;
1468  break;
1469  case 321: case 132: case 213:
1470  case 231: case 123: case 312:
1471  j = 2;
1472  break;
1473  case 230: case 23: case 302:
1474  case 320: case 32: case 203:
1475  j = 3;
1476  break;
1477 
1478  default:
1479  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1480  exit(0);
1481  }
1482  CellTree[Neib[0]]->SetJoint(j, Joint);
1483 
1484  if (Neib[1] != -1) // second element containing the current face
1485  {
1486  // find the local index for the point 'a' on the cell
1487  for (j=0;j<4;j++)
1488  if (Tetrahedrals[4*Neib[1]+j] == a) break;
1489 
1490  // find the local index for the point 'b' on the cell
1491  for (k=0;k<4;k++)
1492  if (Tetrahedrals[4*Neib[1]+k] == b) break;
1493 
1494  // find the local index for the point 'c' on the cell
1495  for (l=0;l<4;l++)
1496  if (Tetrahedrals[4*Neib[1]+l] == c) break;
1497 
1498  l = l*100 + k*10 + j;
1499 
1500 // cout<<""<< l <<endl;
1501 
1502  switch (l) // j will contain the local index for the current face
1503  {
1504  case 210: case 21: case 102:
1505  case 120: case 12: case 201:
1506  j = 0;
1507  break;
1508  case 310: case 31: case 103:
1509  case 130: case 13: case 301:
1510  j = 1;
1511  break;
1512  case 321: case 132: case 213:
1513  case 231: case 123: case 312:
1514  j = 2;
1515  break;
1516  case 230: case 23: case 302:
1517  case 320: case 32: case 203:
1518  j = 3;
1519  break;
1520 
1521  default:
1522  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1523  exit(0);
1524  }
1525  CellTree[Neib[1]]->SetJoint(j, Joint);
1526  }
1527 
1528  if (Joint->GetType() == InterfaceJoint3D ||
1529  Joint->GetType() == IsoInterfaceJoint3D)
1530  {
1531  ((TInterfaceJoint3D*)Joint)->SetMapType();
1532  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
1533  }
1534  else
1535  if (Joint->GetType() == JointEqN)
1536  Joint->SetMapType();
1537 
1538  }
1539 
1540 #ifdef _MPI
1541  if(rank==0)
1542 #endif
1543  {
1544 // In.deinitialize();
1545 // Out.deinitialize();
1546  }
1547 
1548 
1549 
1550 
1551 #ifdef _MPI
1552  if(rank!=0)
1553  {
1554  delete [] Tetrahedrals ;
1555  delete [] Coordinates;
1556  delete [] Facelist;
1557  delete [] Facemarkerlist;
1558  }
1559 #endif
1560 
1561  delete [] PointNeighb;
1562 
1563 // #ifdef _MPI
1564 // if(rank==3)
1565 // printf(" TetrameshGen %d \n", N_G );
1566 // MPI_Finalize();
1567 // #endif
1568 // exit(0);
1569 //
1570 
1571 }
1572 
1574 void TetraGen(TDomain *&Domain)
1575 {
1576  //======================================================================
1577  // Tetgen for grid generation begin
1578  //======================================================================
1579  int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
1580  int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
1581  int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
1582  int *Tetrahedrals, *PointNeighb, dimension;
1583  int jj, N_Points, MaxLen, *Tetrahedrals_loc;
1584  const int *EdgeVertex, *TmpFV, *TmpLen;
1585 
1586  double *Coordinates, N_x, N_y, N_z;
1587  double *Vertices;
1588  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
1589  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
1590  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
1591 
1592  tetgenio In, Out;
1593 
1594  TBaseCell **CellTree, **SurfCellTree;
1595  TGridCell **DelCell;
1596  TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1597  TBoundPart *BoundPart;
1598  TBdPlane **UpdateFaceParams;
1599  TJoint *Joint;
1600  TBoundComp3D *bdcomp;
1601  TCollection *coll, *SurfColl;
1602  TBaseCell *cell;
1603  TBdSphere *UpdateParam;
1604  TShapeDesc *ShapeDesc;
1605 
1606  char *SMESH, line[100];
1607  SMESH = TDatabase::ParamDB->SMESHFILE;
1608 
1609 #ifdef _MPI
1610  int rank, size;
1611  MPI_Comm Comm = TDatabase::ParamDB->Comm;
1612  MPI_Comm_rank(Comm, &rank);
1613  MPI_Comm_size(Comm, &size);
1614 #endif
1615 
1617 #ifdef _MPI
1618  if(rank==0)
1619 #endif
1620  {
1621 // In.initialize();
1622 // Out.initialize();
1623  std::ostringstream opts;
1624  opts << " ";
1625 
1626  opts.seekp(std::ios::beg);
1627  opts<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
1628 // opts<<'r'; // -r Reconstructs a previously generated mesh
1629  opts<<"q"<<1.20; // quality mesh generation(q) with a specified quality bound
1630 // opts<<"a"<<0.1; // maximum volume constraint
1631 // opts<<'i'; // Inserts a list of additional points into mesh.
1632  opts<<'z'; // numbers all output items starting from zero
1633 // opts<<'d'; // Detect intersections of PLC facets.
1634  opts<<'f'; // Outputs all faces (including non-boundary)
1635  opts<<'e'; // Outputs a list of edges of the triangulation
1636 // opts<<'I'; // Suppresses mesh iteration numbers.
1637  opts<<'C'; // Checks the consistency of the final mesh.
1638 // opts<<'Q'; // Quiet: No terminal output except errors.
1639 // opts<<'g'; // Outputs mesh to .mesh file for viewing by Medit
1640  opts<<'Y'; // Suppresses boundary facets/segments splitting
1641 // opts<<'V'; //verbose mode
1642  opts<<ends;
1643 
1644 // cout << " SMESHFILE is " << SMESH << endl;
1646  ReadMeditMesh(SMESH, In);
1647 
1648 // for(i=0;i<In.numberofpoints;i++)
1649 // OutPut(i<<" (x, y, z) = "<<
1650 // In.pointlist[3*i]<<' '<<In.pointlist[3*i+1]<<' '<<In.pointlist[3*i+2]<<endl);
1651 
1652  // Calling tetrahedralize function of 3dtetgen mesh generator
1653  tetrahedralize((char*)opts.str().c_str(), &In, &Out);
1654 
1655  // output: coordinates of all vertices
1656 // for(i=0;i<Out.numberofpoints;i++)
1657 // OutPut(" (x, y, z) = "<< Out.pointlist[3*i]<<' '<<Out.pointlist[3*i+1]<<' '<<Out.pointlist[3*i+2]<<endl);
1658 
1659  } // if(rank==0)
1660 
1662  DeleteDomain(Domain);
1663 
1664 #ifdef _MPI
1665  if(rank==0)
1666 #endif
1667  {
1668  N_RootCells = Out.numberoftetrahedra;
1669  N_G = Out.numberofpoints;
1670  // allocate auxillary fields
1671  Coordinates = Out.pointlist;
1672  Tetrahedrals = Out.tetrahedronlist;
1673  }
1674 
1675 #ifdef _MPI
1676  MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1677  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1678  if(rank!=0)
1679  {
1680  Coordinates = new double [3*N_G];
1681  Tetrahedrals = new int[4*N_RootCells];
1682  }
1683  MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1684  MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1685 #endif
1686 
1687  // generate new vertices
1688  NewVertices = new TVertex*[N_G];
1689 
1690  for (i=0;i<N_G;i++)
1691  {
1692  NewVertices[i] = new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
1693  // set bounding box
1694  if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
1695  if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
1696  if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
1697  if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
1698  if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
1699  if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
1700  }
1701 
1702  // set bounding box
1703  StartX = Xmin;
1704  StartY = Ymin;
1705  StartZ = Zmin;
1706  BoundX = Xmax - Xmin;
1707  BoundY = Ymax - Ymin;
1708  BoundZ = Zmax - Zmin;
1709 
1710  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1711 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
1712 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
1713  CellTree = new TBaseCell*[N_RootCells];
1714  // output of each tetraheron vertex indices (four vertices for each)
1715 // for (i=0;i<N_RootCells;i++)
1716 // cout<< Tetrahedrals[4*i]<<" "<<Tetrahedrals[4*i + 1]<<" "
1717 // <<Tetrahedrals[4*i + 2]<<" "<<Tetrahedrals[4*i + 3]<<endl;
1718 
1719 
1720  for (i=0;i<N_RootCells;i++)
1721  {
1722  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron], RefLevel);
1723 
1724  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
1725  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
1726  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
1727  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
1728  CellTree[i]->SetClipBoard(i);
1729  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
1730  }
1731 
1732  Domain->SetTreeInfo(CellTree, N_RootCells);
1733  // initialize iterators
1734  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
1735  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
1736  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
1737  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
1738  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
1739  // search neighbours
1740  PointNeighb = new int[N_G];
1741 #ifdef _MPI
1742  if(rank==0)
1743 #endif
1744  cout<<"numberofpoints "<<N_G<<endl;
1745  memset(PointNeighb, 0, N_G *SizeOfInt);
1746 
1747  for (i=0;i<4*N_RootCells;i++)
1748  PointNeighb[Tetrahedrals[i]]++;
1749 
1750  for (i=0;i<N_G;i++)
1751  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1752  delete [] PointNeighb;
1753 
1754 #ifdef _MPI
1755  if(rank==0)
1756 #endif
1757  cout<<"maxEpV "<< maxEpV<<endl;
1758  PointNeighb = new int[++maxEpV * N_G];
1759  memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1760  // every vertex contains "maxEpV" columns
1761  // for every vertex at first colomn contains the number of cells containing this vertex
1762  // at further columns we set the index of corresponding cells containing this vertex
1763  // cout<<"maxEpV*N_G "<<maxEpV*N_G<<endl;
1764 
1765  for(i=0;i<4*N_RootCells;i++)
1766  {
1767  j = Tetrahedrals[i]*maxEpV;
1768  PointNeighb[j]++;
1769  //cout<<"j + PointNeighb[j] " << j <<endl;
1770  PointNeighb[j + PointNeighb[j]] = i / 4;
1771  }
1772  // generate new faces
1773  coll=Domain->GetCollection(It_Finest, 0);
1774  N_Cells = coll->GetN_Cells();
1775  N_G = 0;
1776  for (i=0;i<N_Cells;i++)
1777  {
1778  cell = coll->GetCell(i);
1779  ShapeDesc= cell->GetShapeDesc();
1780  ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
1781  N_Faces = cell->GetN_Faces();
1782  Tetrahedrals_loc = Tetrahedrals+4*i;
1783 
1784  for(jj=0;jj<N_Faces;jj++)
1785  if(cell->GetJoint(jj) == NULL)
1786  {
1787  N_G++;
1788  N_Points = TmpLen[jj];
1789 
1790  if(N_Points!=3)
1791  {
1792  cerr << "Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
1793  exit(-1);
1794  }
1795 
1796  //printf(" TetrameshGen Null joint \n" );
1797  a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
1798  b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
1799  c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
1800 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
1801  Neib[0] = -1;
1802  Neib[1] = -1;
1803  CurrNeib = 0;
1804 
1805  len1 = PointNeighb[a*maxEpV];
1806  len2 = PointNeighb[b*maxEpV];
1807  len3 = PointNeighb[c*maxEpV];
1808 
1809  // find the index of the cells containing current face with point indices a,b,c
1810  for (j=1;j<=len1;j++)
1811  {
1812  Neighb_tmp = PointNeighb[a*maxEpV + j];
1813  for (k=1;k<=len2;k++)
1814  {
1815  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1816  {
1817  for (l=1;l<=len3;l++)
1818  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1819  {
1820  Neib[CurrNeib++] = Neighb_tmp;
1821  break;
1822  }
1823  }
1824  }
1825  if (CurrNeib == 2) break;
1826  }// for (j=1;j<=len1;j++)
1827  // cout<<"CurrNeib " << CurrNeib <<endl;
1828  // cout<<"Facemarkerlist[i] : "<<Facemarkerlist[i]<<endl;
1829  if (CurrNeib == 1) // 0 for inner edges and Boundcomp+1 for Boundedge respect
1830  {
1831  CurrComp = 0; // not yet implemented fully
1832 
1833  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
1834 
1835  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
1836  NewVertices[a]->GetY(), T[1], S[1]) ||
1837  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
1838  NewVertices[b]->GetY(), T[2], S[2]) ||
1839  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
1840  NewVertices[c]->GetY(), T[3], S[3]) )
1841  {
1842  cerr<<"Error: could not set parameter values"<<endl;
1843  OutPut(NewVertices[a]<<endl);
1844  OutPut(NewVertices[b]<<endl);
1845  OutPut(NewVertices[c]<<endl);
1846  exit(0);
1847  }
1848 
1849  if (CurrNeib == 2)
1850  {
1851  if(bdcomp->IsFreeBoundary())
1852  Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
1853  CellTree[Neib[0]], CellTree[Neib[1]] );
1854  else
1855  Joint = new TInterfaceJoint3D(bdcomp, T, S,
1856  CellTree[Neib[0]], CellTree[Neib[1]] );
1857  }
1858  else
1859  {
1860  if(bdcomp->IsFreeBoundary())
1861  Joint = new TIsoBoundFace(bdcomp, T, S);
1862  else
1863  Joint = new TBoundFace(bdcomp, T, S);
1864  }
1865  }
1866  else
1867  {
1868  // cout<<"Inner face"<<endl;
1869  if (CurrNeib != 2)
1870  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
1871 
1872  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1873  }
1874 
1875  // First element containing the current face
1876  // find the local index for the point 'a' on the cell
1877  for (j=0;j<4;j++)
1878  if (Tetrahedrals[4*Neib[0]+j] == a) break;
1879 
1880  // find the local index for the point 'b' on the cell
1881  for (k=0;k<4;k++)
1882  if (Tetrahedrals[4*Neib[0]+k] == b) break;
1883 
1884  // find the local index for the point 'c' on the cell
1885  for (l=0;l<4;l++)
1886  if (Tetrahedrals[4*Neib[0]+l] == c) break;
1887 
1888  l = l*100 + k*10 + j;
1889 
1890 // cout<<""<< l <<endl;
1891 
1892  switch (l) // j will contain the local index for the current face
1893  {
1894  case 210: case 21: case 102:
1895  case 120: case 12: case 201:
1896  j = 0;
1897  break;
1898  case 310: case 31: case 103:
1899  case 130: case 13: case 301:
1900  j = 1;
1901  break;
1902  case 321: case 132: case 213:
1903  case 231: case 123: case 312:
1904  j = 2;
1905  break;
1906  case 230: case 23: case 302:
1907  case 320: case 32: case 203:
1908  j = 3;
1909  break;
1910 
1911  default:
1912  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1913  exit(0);
1914  }
1915  CellTree[Neib[0]]->SetJoint(j, Joint);
1916 
1917  if (Neib[1] != -1) // second element containing the current face
1918  {
1919  // find the local index for the point 'a' on the cell
1920  for (j=0;j<4;j++)
1921  if (Tetrahedrals[4*Neib[1]+j] == a) break;
1922 
1923  // find the local index for the point 'b' on the cell
1924  for (k=0;k<4;k++)
1925  if (Tetrahedrals[4*Neib[1]+k] == b) break;
1926 
1927  // find the local index for the point 'c' on the cell
1928  for (l=0;l<4;l++)
1929  if (Tetrahedrals[4*Neib[1]+l] == c) break;
1930 
1931  l = l*100 + k*10 + j;
1932 // cout<<""<< l <<endl;
1933  switch (l) // j will contain the local index for the current face
1934  {
1935  case 210: case 21: case 102:
1936  case 120: case 12: case 201:
1937  j = 0;
1938  break;
1939  case 310: case 31: case 103:
1940  case 130: case 13: case 301:
1941  j = 1;
1942  break;
1943  case 321: case 132: case 213:
1944  case 231: case 123: case 312:
1945  j = 2;
1946  break;
1947  case 230: case 23: case 302:
1948  case 320: case 32: case 203:
1949  j = 3;
1950  break;
1951 
1952  default:
1953  Error("Unable to set the face !!!!!!!!!!!!" << endl);
1954  exit(0);
1955  }
1956  CellTree[Neib[1]]->SetJoint(j, Joint);
1957  } // if (Neib[1] != -1)
1958 
1959  if (Joint->GetType() == InterfaceJoint3D ||
1960  Joint->GetType() == IsoInterfaceJoint3D)
1961  {
1962  ((TInterfaceJoint3D*)Joint)->SetMapType();
1963  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
1964  }
1965  else
1966  if (Joint->GetType() == JointEqN)
1967  Joint->SetMapType();
1968  } // if(cell->GetJoint(jj) == NULL)
1969  } // for (i=0;i<N_Cells;i++)
1970 
1971 #ifdef _MPI
1972  if(rank==0)
1973 #endif
1974  cout<<"numberoftrifaces after "<<N_G<<endl;
1975 
1976 #ifdef _MPI
1977  if(rank==0)
1978 #endif
1979  {
1980 // In.deinitialize();
1981 // Out.deinitialize();
1982  }
1983 #ifdef _MPI
1984  if(rank!=0)
1985  {
1986  delete [] Tetrahedrals ;
1987  delete [] Coordinates;
1988 // delete [] Facelist;
1989 // delete [] Facemarkerlist;
1990  }
1991 #endif
1992  delete [] PointNeighb;
1993 // #ifdef _MPI
1994 // if(rank==3)
1995 // printf(" TetrameshGen %d \n", N_G );
1996 // MPI_Finalize();
1997 // #endif
1998 // exit(0);
1999 //
2000 }
2001 
2003 void TetraGenWithInputCells(TDomain *&Domain)
2004 {
2005  //======================================================================
2006  // Tetgen for grid generation begin
2007  //======================================================================
2008  int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
2009  int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
2010  int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
2011  int *Tetrahedrals, *PointNeighb, dimension;
2012  int jj, N_Points, MaxLen, *Tetrahedrals_loc;
2013  const int *EdgeVertex, *TmpFV, *TmpLen;
2014  double *TetRegionlist;
2015 
2016  double *Coordinates, N_x, N_y, N_z;
2017  double *Vertices;
2018  double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
2019  double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
2020  double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
2021 
2022  tetgenio In, Out, InAddPts;
2023 
2024  TBaseCell **CellTree, **SurfCellTree;
2025  TGridCell **DelCell;
2026  TVertex **VertexDel, **NewVertices, **NewSurfVertices;
2027  TBoundPart *BoundPart;
2028  TBdPlane **UpdateFaceParams;
2029  TJoint *Joint;
2030  TBoundComp3D *bdcomp;
2031  TCollection *coll, *SurfColl;
2032  TBaseCell *cell;
2033  TBdSphere *UpdateParam;
2034  TShapeDesc *ShapeDesc;
2035 
2036  char *SMESH, *NODE, line[100];
2037  SMESH = TDatabase::ParamDB->SMESHFILE;
2038  NODE = TDatabase::ParamDB->GRAPEBASENAME;
2039 
2040 #ifdef _MPI
2041  int rank, size;
2042  MPI_Comm Comm = TDatabase::ParamDB->Comm;
2043  MPI_Comm_rank(Comm, &rank);
2044  MPI_Comm_size(Comm, &size);
2045 #endif
2046 
2048 #ifdef _MPI
2049  if(rank==0)
2050 #endif
2051  {
2052 // In.initialize();
2053 // Out.initialize();
2054  std::ostringstream opts;
2055  opts << " ";
2056 
2057  opts.seekp(std::ios::beg);
2058 // opts<<'p'; // Tetrahedralize the PLC. Switches are chosen to read a PLC (p)
2059  opts<<'r'; // -r Reconstructs a previously generated mesh
2060 // opts<<'q'<<1.2; // quality mesh generation(q) with a specified quality bound
2061 // opts<<'a'<<100; // maximum volume constraint
2062 // opts<<'a'; // maximum volume constraint
2063 // opts<<'i'; // Inserts a list of additional points into mesh.
2064  opts<<'z'; // numbers all output items starting from zero
2065 // opts<<'d'; // Detect intersections of PLC facets.
2066  opts<<'f'; // Outputs all faces (including non-boundary)
2067  opts<<'e'; // Outputs a list of edges of the triangulation
2068 // opts<<'I'; // Suppresses mesh iteration numbers.
2069  opts<<'C'; // Checks the consistency of the final mesh.
2070 // opts<<'Q'; // Quiet: No terminal output except errors.
2071 // opts<<'g'; // Outputs mesh to .mesh file for viewing by Medit
2072  opts<<'Y'; // Suppresses boundary facets/segments splitting
2073 // opts<<'A'; // output region attribute list
2074 // opts<<'V'; //verbose mode
2075 // opts<<'V';
2076 // opts<<'V';
2077 // opts<<'V';
2078 // opts<<'V';
2079  opts<<ends;
2080 
2081  In.initialize();
2082  Out.initialize();
2083 // InAddPts.initialize();
2084 // cout << " SMESHFILE is " << SMESH << endl;
2086  ReadMeditMeshWithCells(SMESH, In);
2087 // ReadAdditionalNModes(NODE, InAddPts);
2088 // In.load_medit(SMESH, 1);
2089 
2090 // InAddPts.load_node(NODE);
2091 // cout<< " InAddPts.numberofpoints " << InAddPts.numberofpoints <<endl;
2092 // exit(0);
2093 // for(i=0;i<In.numberofpoints;i++)
2094 // OutPut(i<<" (x, y, z) = "<<
2095 // In.pointlist[3*i]<<' '<<In.pointlist[3*i+1]<<' '<<In.pointlist[3*i+2]<<endl);
2096 // exit(0);
2097  // Calling tetrahedralize function of 3dtetgen mesh generator
2098  tetrahedralize((char*)opts.str().c_str(), &In, &Out);
2099 // tetrahedralize((char*)opts.str().c_str(), &In, &Out, &InAddPts);
2100 // exit(0);
2101  // output: coordinates of all vertices
2102 // for(i=0;i<Out.numberofpoints;i++)
2103 // OutPut(" (x, y, z) = "<< Out.pointlist[3*i]<<' '<<Out.pointlist[3*i+1]<<' '<<Out.pointlist[3*i+2]<<endl);
2104 
2105  } // if(rank==0)
2106 
2108  DeleteDomain(Domain);
2109 
2110 #ifdef _MPI
2111  if(rank==0)
2112 #endif
2113  {
2114  N_RootCells = Out.numberoftetrahedra;
2115  N_G = Out.numberofpoints;
2116  // allocate auxillary fields
2117  Coordinates = Out.pointlist;
2118  Tetrahedrals = Out.tetrahedronlist;
2119  TetRegionlist = Out.tetrahedronattributelist;
2120  }
2121 
2122 #ifdef _MPI
2123  MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
2124  MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
2125 
2126  if(rank!=0)
2127  {
2128  Coordinates = new double [3*N_G];
2129  Tetrahedrals = new int[4*N_RootCells];
2130  TetRegionlist = new double [N_RootCells];
2131  }
2132 
2133  MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
2134  MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
2135  MPI_Bcast(TetRegionlist, N_RootCells, MPI_DOUBLE, 0, Comm);
2136 #endif
2137 
2138  // generate new vertices
2139  NewVertices = new TVertex*[N_G];
2140 
2141  for (i=0;i<N_G;i++)
2142  {
2143  NewVertices[i] = new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
2144 
2145  // set bounding box
2146  if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
2147  if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
2148  if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
2149  if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
2150  if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
2151  if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
2152  }
2153 
2154  // set bounding box
2155  StartX = Xmin;
2156  StartY = Ymin;
2157  StartZ = Zmin;
2158  BoundX = Xmax - Xmin;
2159  BoundY = Ymax - Ymin;
2160  BoundZ = Zmax - Zmin;
2161  Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
2162 // cout<<Xmin <<" "<<Ymin <<" "<<Zmin<<endl;
2163 // cout<<Xmax <<" "<<Ymax <<" "<<Zmax<<endl;
2164  CellTree = new TBaseCell*[N_RootCells];
2165  // output of each tetraheron vertex indices (four vertices for each)
2166 // for (i=0;i<N_RootCells;i++)
2167 // cout<< Tetrahedrals[4*i]<<" "<<Tetrahedrals[4*i + 1]<<" "
2168 // <<Tetrahedrals[4*i + 2]<<" "<<Tetrahedrals[4*i + 3]<<endl;
2169 
2170 
2171  for (i=0;i<N_RootCells;i++)
2172  {
2173  CellTree[i] = new TMacroCell(TDatabase::RefDescDB[Tetrahedron], RefLevel);
2174  CellTree[i]->SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
2175  CellTree[i]->SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
2176  CellTree[i]->SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
2177  CellTree[i]->SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
2178  CellTree[i]->SetClipBoard(i);
2179  ((TMacroCell *) CellTree[i])->SetSubGridID(0);
2180 // cout << i<< " TetRegionlist : " << TetRegionlist[i] << endl;
2181  CellTree[i]->SetRegionID((int)TetRegionlist[i]);
2182  }
2183 // exit(0);
2184  Domain->SetTreeInfo(CellTree, N_RootCells);
2185  // initialize iterators
2186  TDatabase::IteratorDB[It_EQ]->SetParam(Domain);
2187  TDatabase::IteratorDB[It_LE]->SetParam(Domain);
2188  TDatabase::IteratorDB[It_Finest]->SetParam(Domain);
2189  TDatabase::IteratorDB[It_Between]->SetParam(Domain);
2190  TDatabase::IteratorDB[It_OCAF]->SetParam(Domain);
2191 
2192  // search neighbours
2193  PointNeighb = new int[N_G];
2194 #ifdef _MPI
2195  if(rank==0)
2196 #endif
2197  cout<<"numberofpoints "<<N_G<<endl;
2198  memset(PointNeighb, 0, N_G *SizeOfInt);
2199 
2200  for (i=0;i<4*N_RootCells;i++)
2201  PointNeighb[Tetrahedrals[i]]++;
2202 
2203  for (i=0;i<N_G;i++)
2204  if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
2205  delete [] PointNeighb;
2206 
2207 #ifdef _MPI
2208  if(rank==0)
2209 #endif
2210  cout<<"maxEpV "<< maxEpV<<endl;
2211 
2212  PointNeighb = new int[++maxEpV * N_G];
2213 
2214  memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
2215  // every vertex contains "maxEpV" columns
2216  // for every vertex at first colomn contains the number of cells containing this vertex
2217  // at further columns we set the index of corresponding cells containing this vertex
2218  // cout<<"maxEpV*N_G "<<maxEpV*N_G<<endl;
2219 
2220  for(i=0;i<4*N_RootCells;i++)
2221  {
2222  j = Tetrahedrals[i]*maxEpV;
2223  PointNeighb[j]++;
2224  //cout<<"j + PointNeighb[j] " << j <<endl;
2225  PointNeighb[j + PointNeighb[j]] = i / 4;
2226  }
2227 
2228  // generate new faces
2229  coll=Domain->GetCollection(It_Finest, 0);
2230  N_Cells = coll->GetN_Cells();
2231  N_G = 0;
2232  for (i=0;i<N_Cells;i++)
2233  {
2234  cell = coll->GetCell(i);
2235  ShapeDesc= cell->GetShapeDesc();
2236  ShapeDesc->GetFaceVertex(TmpFV, TmpLen, MaxLen);
2237  N_Faces = cell->GetN_Faces();
2238  Tetrahedrals_loc = Tetrahedrals+4*i;
2239 
2240  for(jj=0;jj<N_Faces;jj++)
2241  if(cell->GetJoint(jj) == NULL)
2242  {
2243  N_G++;
2244  N_Points = TmpLen[jj];
2245 
2246  if(N_Points!=3)
2247  {
2248  cerr << "Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
2249  exit(-1);
2250  }
2251 
2252  //printf(" TetrameshGen Null joint \n" );
2253  a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
2254  b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
2255  c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
2256 
2257 // cout<<" "<< a<<" "<< b<<" "<< c<<endl;
2258 
2259  Neib[0] = -1;
2260  Neib[1] = -1;
2261  CurrNeib = 0;
2262 
2263  len1 = PointNeighb[a*maxEpV];
2264  len2 = PointNeighb[b*maxEpV];
2265  len3 = PointNeighb[c*maxEpV];
2266 
2267  // find the index of the cells containing current face with point indices a,b,c
2268  for (j=1;j<=len1;j++)
2269  {
2270  Neighb_tmp = PointNeighb[a*maxEpV + j];
2271  for (k=1;k<=len2;k++)
2272  {
2273  if (Neighb_tmp == PointNeighb[b*maxEpV + k])
2274  {
2275  for (l=1;l<=len3;l++)
2276  if (Neighb_tmp == PointNeighb[c*maxEpV + l])
2277  {
2278  Neib[CurrNeib++] = Neighb_tmp;
2279  break;
2280  }
2281  }
2282  }
2283  if (CurrNeib == 2) break;
2284  }// for (j=1;j<=len1;j++)
2285  // cout<<"CurrNeib " << CurrNeib <<endl;
2286  // cout<<"Facemarkerlist[i] : "<<Facemarkerlist[i]<<endl;
2287  if (CurrNeib == 1) // 0 for inner edges and Boundcomp+1 for Boundedge respect
2288  {
2289  CurrComp = 0; // not yet implemented fully
2290 
2291  bdcomp = Domain->GetBdPart(0)->GetBdComp(CurrComp);
2292 
2293  if(bdcomp->GetTSofXYZ(NewVertices[a]->GetX(), NewVertices[a]->GetY(),
2294  NewVertices[a]->GetY(), T[1], S[1]) ||
2295  bdcomp->GetTSofXYZ(NewVertices[b]->GetX(), NewVertices[b]->GetY(),
2296  NewVertices[b]->GetY(), T[2], S[2]) ||
2297  bdcomp->GetTSofXYZ(NewVertices[c]->GetX(), NewVertices[c]->GetY(),
2298  NewVertices[c]->GetY(), T[3], S[3]) )
2299  {
2300  cerr<<"Error: could not set parameter values"<<endl;
2301  OutPut(NewVertices[a]<<endl);
2302  OutPut(NewVertices[b]<<endl);
2303  OutPut(NewVertices[c]<<endl);
2304  exit(0);
2305  }
2306 
2307  if (CurrNeib == 2)
2308  {
2309  if(bdcomp->IsFreeBoundary())
2310  Joint = new TIsoInterfaceJoint3D(bdcomp, T, S,
2311  CellTree[Neib[0]], CellTree[Neib[1]] );
2312  else
2313  Joint = new TInterfaceJoint3D(bdcomp, T, S,
2314  CellTree[Neib[0]], CellTree[Neib[1]] );
2315  }
2316  else
2317  {
2318  if(bdcomp->IsFreeBoundary())
2319  Joint = new TIsoBoundFace(bdcomp, T, S);
2320  else
2321  Joint = new TBoundFace(bdcomp, T, S);
2322  }
2323  }
2324  else
2325  {
2326  // cout<<"Inner face"<<endl;
2327  if (CurrNeib != 2)
2328  cerr << "Error !!!!!!!! not enough neighbours!" << endl;
2329 
2330  Joint = new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
2331  }
2332 
2333  // First element containing the current face
2334  // find the local index for the point 'a' on the cell
2335  for (j=0;j<4;j++)
2336  if (Tetrahedrals[4*Neib[0]+j] == a) break;
2337 
2338  // find the local index for the point 'b' on the cell
2339  for (k=0;k<4;k++)
2340  if (Tetrahedrals[4*Neib[0]+k] == b) break;
2341 
2342  // find the local index for the point 'c' on the cell
2343  for (l=0;l<4;l++)
2344  if (Tetrahedrals[4*Neib[0]+l] == c) break;
2345 
2346  l = l*100 + k*10 + j;
2347 // cout<<""<< l <<endl;
2348 
2349  switch (l) // j will contain the local index for the current face
2350  {
2351  case 210: case 21: case 102:
2352  case 120: case 12: case 201:
2353  j = 0;
2354  break;
2355  case 310: case 31: case 103:
2356  case 130: case 13: case 301:
2357  j = 1;
2358  break;
2359  case 321: case 132: case 213:
2360  case 231: case 123: case 312:
2361  j = 2;
2362  break;
2363  case 230: case 23: case 302:
2364  case 320: case 32: case 203:
2365  j = 3;
2366  break;
2367 
2368  default:
2369  Error("Unable to set the face !!!!!!!!!!!!" << endl);
2370  exit(0);
2371  }
2372  CellTree[Neib[0]]->SetJoint(j, Joint);
2373 
2374  if (Neib[1] != -1) // second element containing the current face
2375  {
2376  // find the local index for the point 'a' on the cell
2377  for (j=0;j<4;j++)
2378  if (Tetrahedrals[4*Neib[1]+j] == a) break;
2379 
2380  // find the local index for the point 'b' on the cell
2381  for (k=0;k<4;k++)
2382  if (Tetrahedrals[4*Neib[1]+k] == b) break;
2383 
2384  // find the local index for the point 'c' on the cell
2385  for (l=0;l<4;l++)
2386  if (Tetrahedrals[4*Neib[1]+l] == c) break;
2387 
2388  l = l*100 + k*10 + j;
2389 
2390 // cout<<""<< l <<endl;
2391 
2392  switch (l) // j will contain the local index for the current face
2393  {
2394  case 210: case 21: case 102:
2395  case 120: case 12: case 201:
2396  j = 0;
2397  break;
2398  case 310: case 31: case 103:
2399  case 130: case 13: case 301:
2400  j = 1;
2401  break;
2402  case 321: case 132: case 213:
2403  case 231: case 123: case 312:
2404  j = 2;
2405  break;
2406  case 230: case 23: case 302:
2407  case 320: case 32: case 203:
2408  j = 3;
2409  break;
2410 
2411  default:
2412  Error("Unable to set the face !!!!!!!!!!!!" << endl);
2413  exit(0);
2414  }
2415  CellTree[Neib[1]]->SetJoint(j, Joint);
2416  } // if (Neib[1] != -1)
2417 
2418  if (Joint->GetType() == InterfaceJoint3D ||
2419  Joint->GetType() == IsoInterfaceJoint3D)
2420  {
2421  ((TInterfaceJoint3D*)Joint)->SetMapType();
2422  ((TInterfaceJoint3D*)(Joint))->CheckOrientation();
2423  }
2424  else
2425  if (Joint->GetType() == JointEqN)
2426  Joint->SetMapType();
2427  } // if(cell->GetJoint(jj) == NULL)
2428  } // for (i=0;i<N_Cells;i++)
2429 
2430 #ifdef _MPI
2431  if(rank==0)
2432 #endif
2433  cout<<"numberoftrifaces after "<<N_G<<endl;
2434 
2435 #ifdef _MPI
2436  if(rank==0)
2437 #endif
2438  {
2439 // In.deinitialize();
2440 // Out.deinitialize();
2441  }
2442 
2443 #ifdef _MPI
2444  if(rank!=0)
2445  {
2446  delete [] Tetrahedrals ;
2447  delete [] Coordinates;
2448  delete [] TetRegionlist;
2449 // delete [] Facemarkerlist;
2450  }
2451 #endif
2452 
2453  delete [] PointNeighb;
2454 
2455 // #ifdef _MPI
2456 // if(rank==3)
2457 // printf(" TetrameshGen %d \n", N_G );
2458 // MPI_Finalize();
2459 // #endif
2460 // exit(0);
2461 //
2462 }
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
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 GetZ() const
Definition: Vertex.h:103
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