11 OutPut(
"Example: import3Dmesh.h" << endl);
14 void GridBoundCondition(
double x,
double y,
double z, BoundCond &cond)
19 void SolidBoundCondition(
double x,
double y,
double z, BoundCond &cond)
24 void FluidBoundCondition(
double x,
double y,
double z, BoundCond &cond)
29 void Exact(
double x,
double y,
double z,
double *values)
39 void InitialCondition(
double x,
double y,
double z,
double *values)
46 void BoundCondition(
double x,
double y,
double z, BoundCond &cond)
59 if(x< 240 && y<-72. && z>191)
67 void BoundValue(
double x,
double y,
double z,
double &value)
72 void BilinearCoeffs(
int n_points,
double *X,
double *Y,
double *Z,
double **parameters,
double **coeffs)
80 double rhsfact, alpha, char_L, beam_r, DimlessBeam_r;
81 double xp=0., yp=0., zp=0., SourceCoord, Sourceradius;
86 xp=2.922130000000000e+02;
87 zp=1.583800000000000e+02;
100 Region_ID = coeffs[0][1];
101 DimlessBeam_r = beam_r/char_L;
124 for(i=0;i<n_points;i++)
146 Sourceradius = sqrt( (x-xp)*(x-xp) + (z-zp)*(z-zp));
153 Sourceradius = sqrt( (x-xp)*(x-xp) + (z-zp)*(z-zp));
160 if(Sourceradius<=DimlessBeam_r)
162 coeff[5] = rhsfact*exp(alpha*SourceCoord*char_L);
175 void ReadAdditionalNModes(
char *NODE, tetgenio &InAddPts)
177 int i, N_Vertices, index, N_Atribude, BDMarker;
179 std::ifstream dat(NODE);
183 cerr <<
"cannot open '" << NODE <<
"' for input" << endl;
187 dat.getline (line, 99);
188 dat >> N_Vertices >> N_Atribude >> BDMarker;
189 dat.getline (line, 99);
191 InAddPts.numberofpoints = N_Vertices;
192 InAddPts.pointlist =
new double[3*N_Vertices];
195 for(i=0;i<N_Vertices; i++)
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;
211 void ReadMeditMeshWithCells(
char *SMESH, tetgenio &In)
213 int i, j, k, dimension, N_FVert, N_Faces, N_Vertices, N_CVert, N_Cells;
214 int BDComp_Min=10000000;
221 tetgenio::polygon *P;
223 std::ifstream dat(SMESH);
227 cerr <<
"cannot open '" << SMESH <<
"' for input" << endl;
236 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
238 dat.getline (line, 99);
243 dat.getline (line, 99);
248 cerr <<
"dimension: " << dimension << endl;
257 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
259 dat.getline (line, 99);
264 dat.getline (line, 99);
267 In.numberofpoints = N_Vertices;
268 In.pointlist =
new double[3*N_Vertices];
271 for(i=0;i<N_Vertices; i++)
273 dat.getline (line, 99);
274 dat >> x >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
276 In.pointlist[3*i] = x - 3.606596999999999830777142;
279 if(i==1062 || i==916 || i==341 || i==914 || i==162 || i==1063 || i==1061)
280 cout<< i <<
" vert X: " <<In.pointlist[3*i] <<
" vert Y: " <<In.pointlist[3*i+1] <<
" vert Z: " <<In.pointlist[3*i+2] <<endl;
289 if ( (!strcmp(line,
"Triangles")) || (!strcmp(line,
"triangles")) || (!strcmp(line,
"TRIANGLES")) )
292 dat.getline (line, 99);
296 else if ( (!strcmp(line,
"Quadrilaterals")) || (!strcmp(line,
"quadrilaterals")) || (!strcmp(line,
"QUADRILATERALS")) )
299 dat.getline (line, 99);
305 dat.getline (line, 99);
308 In.numberoffacets = N_Faces;
309 In.facetlist =
new tetgenio::facet[In.numberoffacets];
310 In.facetmarkerlist =
new int[In.numberoffacets];
312 for(i=0;i<N_Faces; i++)
314 dat.getline (line, 99);
316 F = &In.facetlist[i];
318 F->numberofpolygons = 1;
319 F->polygonlist =
new tetgenio::polygon[F->numberofpolygons];
320 F->numberofholes = 0;
322 P = &F->polygonlist[0];
324 P->numberofvertices = N_FVert;
325 P->vertexlist =
new int[P->numberofvertices];
327 for(j=0;j<N_FVert;j++)
330 P->vertexlist[j] = k-1;
333 dat >> In.facetmarkerlist[i];
335 if(BDComp_Min > In.facetmarkerlist[i])
336 BDComp_Min=In.facetmarkerlist[i];
343 for(i=0;i<N_Faces; i++)
344 In.facetmarkerlist[i] -= BDComp_Min;
352 if ( (!strcmp(line,
"Tetrahedron")) || (!strcmp(line,
"tetrahedron")) || (!strcmp(line,
"TETRAHEDRON")) )
355 dat.getline (line, 99);
360 dat.getline (line, 99);
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];
370 for(i=0; i<N_Cells; i++)
372 dat.getline (line, 99);
373 plist = &(In.tetrahedronlist[i * 4]);
375 for(j=0;j<N_CVert;j++)
382 dat >> In.tetrahedronattributelist[i];
395 void ReadMeditMesh(
char *SMESH, tetgenio &In)
397 int i, j, k, dimension, N_FVert, N_Faces, N_Vertices;
398 int BDComp_Min=10000000;
402 tetgenio::polygon *P;
404 std::ifstream dat(SMESH);
408 cerr <<
"cannot open '" << SMESH <<
"' for input" << endl;
417 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
419 dat.getline (line, 99);
424 dat.getline (line, 99);
429 cerr <<
"dimension: " << dimension << endl;
438 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
440 dat.getline (line, 99);
445 dat.getline (line, 99);
448 In.numberofpoints = N_Vertices;
449 In.pointlist =
new double[3*N_Vertices];
452 for(i=0;i<N_Vertices; i++)
454 dat.getline (line, 99);
455 dat >> In.pointlist[3*i] >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
465 if ( (!strcmp(line,
"Triangles")) || (!strcmp(line,
"triangles")) || (!strcmp(line,
"TRIANGLES")) )
468 dat.getline (line, 99);
472 else if ( (!strcmp(line,
"Quadrilaterals")) || (!strcmp(line,
"quadrilaterals")) || (!strcmp(line,
"QUADRILATERALS")) )
475 dat.getline (line, 99);
481 dat.getline (line, 99);
484 In.numberoffacets = N_Faces;
485 In.facetlist =
new tetgenio::facet[In.numberoffacets];
486 In.facetmarkerlist =
new int[In.numberoffacets];
488 for(i=0;i<N_Faces; i++)
490 dat.getline (line, 99);
492 F = &In.facetlist[i];
494 F->numberofpolygons = 1;
495 F->polygonlist =
new tetgenio::polygon[F->numberofpolygons];
496 F->numberofholes = 0;
498 P = &F->polygonlist[0];
500 P->numberofvertices = N_FVert;
501 P->vertexlist =
new int[P->numberofvertices];
503 for(j=0;j<N_FVert;j++)
506 P->vertexlist[j] = k-1;
509 dat >> In.facetmarkerlist[i];
511 if(BDComp_Min > In.facetmarkerlist[i])
512 BDComp_Min=In.facetmarkerlist[i];
519 for(i=0;i<N_Faces; i++)
520 In.facetmarkerlist[i] -= BDComp_Min;
529 void DeleteDomain(
TDomain *&Domain)
531 int i, j, k, N_Cells, N_RootCells;
532 int CurrVertex, N_Faces, N_Vertices, ID;
533 TBaseCell **CellTree, **SurfCellTree, *cell;
542 VertexDel =
new TVertex*[8*N_RootCells];
545 for(i=0;i<N_Cells;i++)
550 for(j=0;j<N_Faces;j++)
554 VertexDel[CurrVertex++] = cell->
GetVertex(j);
559 for(k=0;k<CurrVertex;k++)
566 VertexDel[CurrVertex++] = cell->
GetVertex(j);
571 for(k=0;k<CurrVertex;k++)
572 if(VertexDel[k]==cell->
GetVertex((j+1)%N_Vertices))
578 VertexDel[CurrVertex++] = cell->
GetVertex((j+1)%N_Vertices);
582 for(k=0;k<CurrVertex;k++)
583 if(VertexDel[k]==cell->
GetVertex((j+2)%N_Vertices))
589 VertexDel[CurrVertex++] = cell->
GetVertex((j+2)%N_Vertices);
594 for(k=0;k<CurrVertex;k++)
595 if(VertexDel[k]==cell->
GetVertex((j+4)%N_Vertices))
601 VertexDel[CurrVertex++] = cell->
GetVertex((j+4)%N_Vertices);
607 for(i=0;i<CurrVertex;i++)
610 OutPut(CurrVertex<<
" vertices were deleted"<<endl);
613 for(i=0;i<N_RootCells;i++)
616 OutPut(N_RootCells<<
" cells were deleted"<<endl);
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];
641 std::ifstream dat(MESH);
645 cerr <<
"cannot open '" << MESH <<
"' for input" << endl;
653 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
655 dat.getline (line, 99);
660 dat.getline (line, 99);
665 cerr <<
"dimension: " << dimension << endl;
672 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
674 dat.getline (line, 99);
679 dat.getline (line, 99);
682 cout <<
"N_Vertices "<<N_Vertices<<endl;
683 NewVertices =
new TVertex*[N_Vertices];
685 for(i=0;i<N_Vertices; i++)
687 dat.getline (line, 99);
689 NewVertices[i] =
new TVertex(X, Y, Z);
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;
702 BoundX = Xmax - Xmin;
703 BoundY = Ymax - Ymin;
704 BoundZ = Zmax - Zmin;
706 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
712 if ( (!strcmp(line,
"Tetrahedra")) || (!strcmp(line,
"tetrahedra")) || (!strcmp(line,
"TETRAHEDRA")) )
714 dat.getline (line, 99);
719 dat.getline (line, 99);
723 cout <<
"number of root cells "<<N_RootCells <<endl;
725 Tetrahedrals =
new int[4*N_RootCells];
727 for (i=0;i<N_RootCells;i++)
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;
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]]);
745 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
758 PointNeighb =
new int[N_Vertices];
759 memset(PointNeighb, 0, N_Vertices*SizeOfInt);
761 for (i=0;i<4*N_RootCells;i++)
762 PointNeighb[Tetrahedrals[i]]++;
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);
776 for(i=0;i<4*N_RootCells;i++)
778 j = Tetrahedrals[i]*maxEpV;
780 PointNeighb[j + PointNeighb[j]] = i / 4;
797 for(i=0;i<N_Cells;i++)
806 Tetrahedrals_loc = Tetrahedrals+4*i;
808 for(jj=0;jj<N_Faces;jj++)
811 N_Points = TmpLen[jj];
814 cerr <<
"Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
817 a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
818 b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
819 c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
842 len1 = PointNeighb[a*maxEpV];
843 len2 = PointNeighb[b*maxEpV];
844 len3 = PointNeighb[c*maxEpV];
847 for (j=1;j<=len1;j++)
849 Neighb_tmp = PointNeighb[a*maxEpV + j];
850 for (k=1;k<=len2;k++)
852 if(Neighb_tmp == PointNeighb[b*maxEpV + k])
855 if(Neighb_tmp == PointNeighb[c*maxEpV + l])
857 Neib[CurrNeib++] = Neighb_tmp;
862 if (CurrNeib == 2)
break;
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);
920 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
921 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
927 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
930 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
933 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
934 l = l*100 + k*10 + j;
938 case 210:
case 21:
case 102:
939 case 120:
case 12:
case 201:
942 case 310:
case 31:
case 103:
943 case 130:
case 13:
case 301:
946 case 321:
case 132:
case 213:
947 case 231:
case 123:
case 312:
950 case 230:
case 23:
case 302:
951 case 320:
case 32:
case 203:
956 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
959 cout <<
"chek 13 "<< i<<endl;
960 CellTree[Neib[0]]->
SetJoint(j, Joint);
965 cout <<
"chek 13.5 "<< i<<endl;
968 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
972 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
976 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
978 l = l*100 + k*10 + j;
981 case 210:
case 21:
case 102:
982 case 120:
case 12:
case 201:
985 case 310:
case 31:
case 103:
986 case 130:
case 13:
case 301:
989 case 321:
case 132:
case 213:
990 case 231:
case 123:
case 312:
993 case 230:
case 23:
case 302:
994 case 320:
case 32:
case 203:
999 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1002 CellTree[Neib[1]]->
SetJoint(j, Joint);
1005 if (Joint->
GetType() == InterfaceJoint3D || Joint->
GetType() == IsoInterfaceJoint3D)
1011 if (Joint->
GetType() == JointEqN)
1015 delete [] PointNeighb;
1016 cout<<
"tetrameshcreatesuccessful " <<
"\n";
1020 void TetrameshGen(
TDomain *&Domain)
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;
1031 double *Coordinates, N_x, N_y, N_z;
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;
1041 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1050 char *SMESH, line[100];
1057 MPI_Comm_rank(Comm, &rank);
1058 MPI_Comm_size(Comm, &size);
1071 std::ostringstream opts;
1074 opts.seekp(std::ios::beg);
1094 ReadMeditMesh(SMESH, In);
1101 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
1116 VertexDel =
new TVertex*[8*N_RootCells];
1119 for(i=0;i<N_Cells;i++)
1124 for(j=0;j<N_Faces;j++)
1128 VertexDel[CurrVertex++] = cell->
GetVertex(j);
1133 for(k=0;k<CurrVertex;k++)
1140 VertexDel[CurrVertex++] = cell->
GetVertex(j);
1145 for(k=0;k<CurrVertex;k++)
1146 if(VertexDel[k]==cell->
GetVertex((j+1)%N_Vertices))
1152 VertexDel[CurrVertex++] = cell->
GetVertex((j+1)%N_Vertices);
1156 for(k=0;k<CurrVertex;k++)
1157 if(VertexDel[k]==cell->
GetVertex((j+2)%N_Vertices))
1163 VertexDel[CurrVertex++] = cell->
GetVertex((j+2)%N_Vertices);
1168 for(k=0;k<CurrVertex;k++)
1169 if(VertexDel[k]==cell->
GetVertex((j+4)%N_Vertices))
1175 VertexDel[CurrVertex++] = cell->
GetVertex((j+4)%N_Vertices);
1181 for(i=0;i<CurrVertex;i++)
1182 delete VertexDel[i];
1183 delete [] VertexDel;
1184 OutPut(CurrVertex<<
" vertices were deleted"<<endl);
1188 for(i=0;i<N_RootCells;i++)
1191 OutPut(N_RootCells<<
" cells were deleted"<<endl);
1198 N_RootCells = Out.numberoftetrahedra;
1199 N_G = Out.numberofpoints;
1202 Coordinates = Out.pointlist;
1203 Tetrahedrals = Out.tetrahedronlist;
1209 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1210 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1215 Coordinates =
new double [3*N_G];
1216 Tetrahedrals =
new int[4*N_RootCells];
1219 MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1220 MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1224 NewVertices =
new TVertex*[N_G];
1228 NewVertices[i] =
new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
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];
1242 BoundX = Xmax - Xmin;
1243 BoundY = Ymax - Ymin;
1244 BoundZ = Zmax - Zmin;
1246 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1257 for (i=0;i<N_RootCells;i++)
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]]);
1267 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
1281 PointNeighb =
new int[N_G];
1285 cout<<
"numberofpoints "<<N_G<<endl;
1286 memset(PointNeighb, 0, N_G *SizeOfInt);
1288 for (i=0;i<4*N_RootCells;i++)
1289 PointNeighb[Tetrahedrals[i]]++;
1292 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1293 delete [] PointNeighb;
1298 cout<<
"maxEpV "<< maxEpV<<endl;
1300 PointNeighb =
new int[++maxEpV * N_G];
1302 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1309 for(i=0;i<4*N_RootCells;i++)
1311 j = Tetrahedrals[i]*maxEpV;
1314 PointNeighb[j + PointNeighb[j]] = i / 4;
1330 N_G = Out.numberoftrifaces;
1331 Facelist = Out.trifacelist;
1332 Facemarkerlist = Out.trifacemarkerlist;
1336 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1340 Facelist =
new int [3*N_G];
1341 Facemarkerlist =
new int[N_G];
1345 MPI_Bcast(Facelist, 3*N_G, MPI_INT, 0, Comm);
1346 MPI_Bcast(Facemarkerlist, N_G, MPI_INT, 0, Comm);
1350 cout<<
"numberoftrifaces "<<N_G<<endl;
1355 b = Facelist[3*i+1];
1356 c = Facelist[3*i+2];
1364 len1 = PointNeighb[a*maxEpV];
1365 len2 = PointNeighb[b*maxEpV];
1366 len3 = PointNeighb[c*maxEpV];
1369 for (j=1;j<=len1;j++)
1371 Neighb_tmp = PointNeighb[a*maxEpV + j];
1372 for (k=1;k<=len2;k++)
1374 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1376 for (l=1;l<=len3;l++)
1377 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1379 Neib[CurrNeib++] = Neighb_tmp;
1384 if (CurrNeib == 2)
break;
1388 if (Facemarkerlist[i])
1391 CurrComp = Facemarkerlist[i] - 1;
1402 NewVertices[a]->
GetY(), T[1], S[1]) ||
1404 NewVertices[b]->
GetY(), T[2], S[2]) ||
1406 NewVertices[c]->
GetY(), T[3], S[3]) )
1408 cerr<<
"Error: could not set parameter values"<<endl;
1409 OutPut(NewVertices[a]<<endl);
1410 OutPut(NewVertices[b]<<endl);
1411 OutPut(NewVertices[c]<<endl);
1419 CellTree[Neib[0]], CellTree[Neib[1]] );
1422 CellTree[Neib[0]], CellTree[Neib[1]] );
1436 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
1438 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1445 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
1449 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
1453 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
1455 l = l*100 + k*10 + j;
1461 case 210:
case 21:
case 102:
1462 case 120:
case 12:
case 201:
1465 case 310:
case 31:
case 103:
1466 case 130:
case 13:
case 301:
1469 case 321:
case 132:
case 213:
1470 case 231:
case 123:
case 312:
1473 case 230:
case 23:
case 302:
1474 case 320:
case 32:
case 203:
1479 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1482 CellTree[Neib[0]]->
SetJoint(j, Joint);
1488 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
1492 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
1496 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
1498 l = l*100 + k*10 + j;
1504 case 210:
case 21:
case 102:
1505 case 120:
case 12:
case 201:
1508 case 310:
case 31:
case 103:
1509 case 130:
case 13:
case 301:
1512 case 321:
case 132:
case 213:
1513 case 231:
case 123:
case 312:
1516 case 230:
case 23:
case 302:
1517 case 320:
case 32:
case 203:
1522 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1525 CellTree[Neib[1]]->
SetJoint(j, Joint);
1528 if (Joint->
GetType() == InterfaceJoint3D ||
1529 Joint->
GetType() == IsoInterfaceJoint3D)
1535 if (Joint->
GetType() == JointEqN)
1554 delete [] Tetrahedrals ;
1555 delete [] Coordinates;
1557 delete [] Facemarkerlist;
1561 delete [] PointNeighb;
1574 void TetraGen(
TDomain *&Domain)
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;
1586 double *Coordinates, N_x, N_y, N_z;
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;
1596 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1606 char *SMESH, line[100];
1612 MPI_Comm_rank(Comm, &rank);
1613 MPI_Comm_size(Comm, &size);
1623 std::ostringstream opts;
1626 opts.seekp(std::ios::beg);
1646 ReadMeditMesh(SMESH, In);
1653 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
1662 DeleteDomain(Domain);
1668 N_RootCells = Out.numberoftetrahedra;
1669 N_G = Out.numberofpoints;
1671 Coordinates = Out.pointlist;
1672 Tetrahedrals = Out.tetrahedronlist;
1676 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1677 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1680 Coordinates =
new double [3*N_G];
1681 Tetrahedrals =
new int[4*N_RootCells];
1683 MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1684 MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1688 NewVertices =
new TVertex*[N_G];
1692 NewVertices[i] =
new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
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];
1706 BoundX = Xmax - Xmin;
1707 BoundY = Ymax - Ymin;
1708 BoundZ = Zmax - Zmin;
1710 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1720 for (i=0;i<N_RootCells;i++)
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]]);
1729 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
1740 PointNeighb =
new int[N_G];
1744 cout<<
"numberofpoints "<<N_G<<endl;
1745 memset(PointNeighb, 0, N_G *SizeOfInt);
1747 for (i=0;i<4*N_RootCells;i++)
1748 PointNeighb[Tetrahedrals[i]]++;
1751 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1752 delete [] PointNeighb;
1757 cout<<
"maxEpV "<< maxEpV<<endl;
1758 PointNeighb =
new int[++maxEpV * N_G];
1759 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1765 for(i=0;i<4*N_RootCells;i++)
1767 j = Tetrahedrals[i]*maxEpV;
1770 PointNeighb[j + PointNeighb[j]] = i / 4;
1776 for (i=0;i<N_Cells;i++)
1782 Tetrahedrals_loc = Tetrahedrals+4*i;
1784 for(jj=0;jj<N_Faces;jj++)
1788 N_Points = TmpLen[jj];
1792 cerr <<
"Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
1797 a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
1798 b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
1799 c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
1805 len1 = PointNeighb[a*maxEpV];
1806 len2 = PointNeighb[b*maxEpV];
1807 len3 = PointNeighb[c*maxEpV];
1810 for (j=1;j<=len1;j++)
1812 Neighb_tmp = PointNeighb[a*maxEpV + j];
1813 for (k=1;k<=len2;k++)
1815 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1817 for (l=1;l<=len3;l++)
1818 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1820 Neib[CurrNeib++] = Neighb_tmp;
1825 if (CurrNeib == 2)
break;
1836 NewVertices[a]->
GetY(), T[1], S[1]) ||
1838 NewVertices[b]->
GetY(), T[2], S[2]) ||
1840 NewVertices[c]->
GetY(), T[3], S[3]) )
1842 cerr<<
"Error: could not set parameter values"<<endl;
1843 OutPut(NewVertices[a]<<endl);
1844 OutPut(NewVertices[b]<<endl);
1845 OutPut(NewVertices[c]<<endl);
1853 CellTree[Neib[0]], CellTree[Neib[1]] );
1856 CellTree[Neib[0]], CellTree[Neib[1]] );
1870 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
1872 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1878 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
1882 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
1886 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
1888 l = l*100 + k*10 + j;
1894 case 210:
case 21:
case 102:
1895 case 120:
case 12:
case 201:
1898 case 310:
case 31:
case 103:
1899 case 130:
case 13:
case 301:
1902 case 321:
case 132:
case 213:
1903 case 231:
case 123:
case 312:
1906 case 230:
case 23:
case 302:
1907 case 320:
case 32:
case 203:
1912 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1915 CellTree[Neib[0]]->
SetJoint(j, Joint);
1921 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
1925 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
1929 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
1931 l = l*100 + k*10 + j;
1935 case 210:
case 21:
case 102:
1936 case 120:
case 12:
case 201:
1939 case 310:
case 31:
case 103:
1940 case 130:
case 13:
case 301:
1943 case 321:
case 132:
case 213:
1944 case 231:
case 123:
case 312:
1947 case 230:
case 23:
case 302:
1948 case 320:
case 32:
case 203:
1953 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1956 CellTree[Neib[1]]->
SetJoint(j, Joint);
1959 if (Joint->
GetType() == InterfaceJoint3D ||
1960 Joint->
GetType() == IsoInterfaceJoint3D)
1966 if (Joint->
GetType() == JointEqN)
1974 cout<<
"numberoftrifaces after "<<N_G<<endl;
1986 delete [] Tetrahedrals ;
1987 delete [] Coordinates;
1992 delete [] PointNeighb;
2003 void TetraGenWithInputCells(
TDomain *&Domain)
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;
2016 double *Coordinates, N_x, N_y, N_z;
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;
2022 tetgenio In, Out, InAddPts;
2026 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
2036 char *SMESH, *NODE, line[100];
2043 MPI_Comm_rank(Comm, &rank);
2044 MPI_Comm_size(Comm, &size);
2054 std::ostringstream opts;
2057 opts.seekp(std::ios::beg);
2086 ReadMeditMeshWithCells(SMESH, In);
2098 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
2108 DeleteDomain(Domain);
2114 N_RootCells = Out.numberoftetrahedra;
2115 N_G = Out.numberofpoints;
2117 Coordinates = Out.pointlist;
2118 Tetrahedrals = Out.tetrahedronlist;
2119 TetRegionlist = Out.tetrahedronattributelist;
2123 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
2124 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
2128 Coordinates =
new double [3*N_G];
2129 Tetrahedrals =
new int[4*N_RootCells];
2130 TetRegionlist =
new double [N_RootCells];
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);
2139 NewVertices =
new TVertex*[N_G];
2143 NewVertices[i] =
new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
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];
2158 BoundX = Xmax - Xmin;
2159 BoundY = Ymax - Ymin;
2160 BoundZ = Zmax - Zmin;
2161 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
2171 for (i=0;i<N_RootCells;i++)
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]]);
2179 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
2193 PointNeighb =
new int[N_G];
2197 cout<<
"numberofpoints "<<N_G<<endl;
2198 memset(PointNeighb, 0, N_G *SizeOfInt);
2200 for (i=0;i<4*N_RootCells;i++)
2201 PointNeighb[Tetrahedrals[i]]++;
2204 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
2205 delete [] PointNeighb;
2210 cout<<
"maxEpV "<< maxEpV<<endl;
2212 PointNeighb =
new int[++maxEpV * N_G];
2214 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
2220 for(i=0;i<4*N_RootCells;i++)
2222 j = Tetrahedrals[i]*maxEpV;
2225 PointNeighb[j + PointNeighb[j]] = i / 4;
2232 for (i=0;i<N_Cells;i++)
2238 Tetrahedrals_loc = Tetrahedrals+4*i;
2240 for(jj=0;jj<N_Faces;jj++)
2244 N_Points = TmpLen[jj];
2248 cerr <<
"Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
2253 a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
2254 b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
2255 c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
2263 len1 = PointNeighb[a*maxEpV];
2264 len2 = PointNeighb[b*maxEpV];
2265 len3 = PointNeighb[c*maxEpV];
2268 for (j=1;j<=len1;j++)
2270 Neighb_tmp = PointNeighb[a*maxEpV + j];
2271 for (k=1;k<=len2;k++)
2273 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
2275 for (l=1;l<=len3;l++)
2276 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
2278 Neib[CurrNeib++] = Neighb_tmp;
2283 if (CurrNeib == 2)
break;
2294 NewVertices[a]->
GetY(), T[1], S[1]) ||
2296 NewVertices[b]->
GetY(), T[2], S[2]) ||
2298 NewVertices[c]->
GetY(), T[3], S[3]) )
2300 cerr<<
"Error: could not set parameter values"<<endl;
2301 OutPut(NewVertices[a]<<endl);
2302 OutPut(NewVertices[b]<<endl);
2303 OutPut(NewVertices[c]<<endl);
2311 CellTree[Neib[0]], CellTree[Neib[1]] );
2314 CellTree[Neib[0]], CellTree[Neib[1]] );
2328 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
2330 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
2336 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
2340 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
2344 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
2346 l = l*100 + k*10 + j;
2351 case 210:
case 21:
case 102:
2352 case 120:
case 12:
case 201:
2355 case 310:
case 31:
case 103:
2356 case 130:
case 13:
case 301:
2359 case 321:
case 132:
case 213:
2360 case 231:
case 123:
case 312:
2363 case 230:
case 23:
case 302:
2364 case 320:
case 32:
case 203:
2369 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
2372 CellTree[Neib[0]]->
SetJoint(j, Joint);
2378 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
2382 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
2386 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
2388 l = l*100 + k*10 + j;
2394 case 210:
case 21:
case 102:
2395 case 120:
case 12:
case 201:
2398 case 310:
case 31:
case 103:
2399 case 130:
case 13:
case 301:
2402 case 321:
case 132:
case 213:
2403 case 231:
case 123:
case 312:
2406 case 230:
case 23:
case 302:
2407 case 320:
case 32:
case 203:
2412 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
2415 CellTree[Neib[1]]->
SetJoint(j, Joint);
2418 if (Joint->
GetType() == InterfaceJoint3D ||
2419 Joint->
GetType() == IsoInterfaceJoint3D)
2425 if (Joint->
GetType() == JointEqN)
2433 cout<<
"numberoftrifaces after "<<N_G<<endl;
2446 delete [] Tetrahedrals ;
2447 delete [] Coordinates;
2448 delete [] TetRegionlist;
2453 delete [] PointNeighb;
void SetMapType()
Definition: Joint.C:107
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
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
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