12 OutPut(
"Example: TeraHertzBrain.h" << endl);
15 void GridBoundCondition(
double x,
double y,
double z, BoundCond &cond)
20 void Exact(
double x,
double y,
double z,
double *values)
30 void InitialCondition(
double x,
double y,
double z,
double *values)
37 void BoundCondition(
double x,
double y,
double z, BoundCond &cond)
50 if(x< 240 && y<-72. && z>191)
62 void BoundValue(
double x,
double y,
double z,
double &value)
67 void BilinearCoeffs(
int n_points,
double *X,
double *Y,
double *Z,
double **parameters,
double **coeffs)
75 double rhsfact, alpha, char_L, beam_r, DimlessBeam_r;
76 double xp=0., yp=0., zp=0., SourceCoord, Sourceradius;
81 xp=2.922130000000000e+02;
82 zp=1.583800000000000e+02;
95 Region_ID = coeffs[0][1];
96 DimlessBeam_r = beam_r/char_L;
119 for(i=0;i<n_points;i++)
141 Sourceradius = sqrt( (x-xp)*(x-xp) + (z-zp)*(z-zp));
148 Sourceradius = sqrt( (x-xp)*(x-xp) + (z-zp)*(z-zp));
155 if(Sourceradius<=DimlessBeam_r)
157 coeff[5] = rhsfact*exp(alpha*SourceCoord*char_L);
170 void ReadAdditionalNModes(
char *NODE, tetgenio &InAddPts)
172 int i, N_Vertices, index, N_Atribude, BDMarker;
174 std::ifstream dat(NODE);
178 cerr <<
"cannot open '" << NODE <<
"' for input" << endl;
182 dat.getline (line, 99);
183 dat >> N_Vertices >> N_Atribude >> BDMarker;
184 dat.getline (line, 99);
186 InAddPts.numberofpoints = N_Vertices;
187 InAddPts.pointlist =
new double[3*N_Vertices];
190 for(i=0;i<N_Vertices; i++)
192 dat.getline (line, 99);
193 dat >> index >> InAddPts.pointlist[3*i] >> InAddPts.pointlist[3*i+1] >> InAddPts.pointlist[3*i+2];
194 cout<< i <<
" vert X: " <<InAddPts.pointlist[3*i] <<
" vert Y: " <<InAddPts.pointlist[3*i+1] <<
" vert Z: " <<InAddPts.pointlist[3*i+2] <<endl;
208 void ReadMeditMeshWithCells(
char *SMESH, tetgenio &In)
210 int i, j, k, dimension, N_FVert, N_Faces, N_Vertices, N_CVert, N_Cells;
211 int BDComp_Min=10000000;
218 tetgenio::polygon *P;
220 std::ifstream dat(SMESH);
224 cerr <<
"cannot open '" << SMESH <<
"' for input" << endl;
233 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
235 dat.getline (line, 99);
240 dat.getline (line, 99);
245 cerr <<
"dimension: " << dimension << endl;
254 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
256 dat.getline (line, 99);
261 dat.getline (line, 99);
264 In.numberofpoints = N_Vertices;
265 In.pointlist =
new double[3*N_Vertices];
268 for(i=0;i<N_Vertices; i++)
270 dat.getline (line, 99);
271 dat >> x >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
273 In.pointlist[3*i] = x - 3.606596999999999830777142;
276 if(i==1062 || i==916 || i==341 || i==914 || i==162 || i==1063 || i==1061)
277 cout<< i <<
" vert X: " <<In.pointlist[3*i] <<
" vert Y: " <<In.pointlist[3*i+1] <<
" vert Z: " <<In.pointlist[3*i+2] <<endl;
286 if ( (!strcmp(line,
"Triangles")) || (!strcmp(line,
"triangles")) || (!strcmp(line,
"TRIANGLES")) )
289 dat.getline (line, 99);
293 else if ( (!strcmp(line,
"Quadrilaterals")) || (!strcmp(line,
"quadrilaterals")) || (!strcmp(line,
"QUADRILATERALS")) )
296 dat.getline (line, 99);
302 dat.getline (line, 99);
305 In.numberoffacets = N_Faces;
306 In.facetlist =
new tetgenio::facet[In.numberoffacets];
307 In.facetmarkerlist =
new int[In.numberoffacets];
309 for(i=0;i<N_Faces; i++)
311 dat.getline (line, 99);
313 F = &In.facetlist[i];
315 F->numberofpolygons = 1;
316 F->polygonlist =
new tetgenio::polygon[F->numberofpolygons];
317 F->numberofholes = 0;
319 P = &F->polygonlist[0];
321 P->numberofvertices = N_FVert;
322 P->vertexlist =
new int[P->numberofvertices];
324 for(j=0;j<N_FVert;j++)
327 P->vertexlist[j] = k-1;
330 dat >> In.facetmarkerlist[i];
332 if(BDComp_Min > In.facetmarkerlist[i])
333 BDComp_Min=In.facetmarkerlist[i];
340 for(i=0;i<N_Faces; i++)
341 In.facetmarkerlist[i] -= BDComp_Min;
349 if ( (!strcmp(line,
"Tetrahedron")) || (!strcmp(line,
"tetrahedron")) || (!strcmp(line,
"TETRAHEDRON")) )
352 dat.getline (line, 99);
357 dat.getline (line, 99);
360 In.numberoftetrahedra = N_Cells;
361 In.numberofcorners = N_CVert;
362 In.numberoftetrahedronattributes = 1;
363 In.tetrahedronlist =
new int[N_Cells * 4];
364 In.tetrahedronattributelist =
new REAL[N_Cells];
365 In.tetrahedronvolumelist =
new REAL[N_Cells];
367 for(i=0; i<N_Cells; i++)
369 dat.getline (line, 99);
370 plist = &(In.tetrahedronlist[i * 4]);
372 for(j=0;j<N_CVert;j++)
379 dat >> In.tetrahedronattributelist[i];
393 void ReadMeditMesh(
char *SMESH, tetgenio &In)
395 int i, j, k, dimension, N_FVert, N_Faces, N_Vertices;
396 int BDComp_Min=10000000;
400 tetgenio::polygon *P;
402 std::ifstream dat(SMESH);
406 cerr <<
"cannot open '" << SMESH <<
"' for input" << endl;
415 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
417 dat.getline (line, 99);
422 dat.getline (line, 99);
427 cerr <<
"dimension: " << dimension << endl;
436 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
438 dat.getline (line, 99);
443 dat.getline (line, 99);
446 In.numberofpoints = N_Vertices;
447 In.pointlist =
new double[3*N_Vertices];
450 for(i=0;i<N_Vertices; i++)
452 dat.getline (line, 99);
453 dat >> In.pointlist[3*i] >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
463 if ( (!strcmp(line,
"Triangles")) || (!strcmp(line,
"triangles")) || (!strcmp(line,
"TRIANGLES")) )
466 dat.getline (line, 99);
470 else if ( (!strcmp(line,
"Quadrilaterals")) || (!strcmp(line,
"quadrilaterals")) || (!strcmp(line,
"QUADRILATERALS")) )
473 dat.getline (line, 99);
479 dat.getline (line, 99);
482 In.numberoffacets = N_Faces;
483 In.facetlist =
new tetgenio::facet[In.numberoffacets];
484 In.facetmarkerlist =
new int[In.numberoffacets];
486 for(i=0;i<N_Faces; i++)
488 dat.getline (line, 99);
490 F = &In.facetlist[i];
492 F->numberofpolygons = 1;
493 F->polygonlist =
new tetgenio::polygon[F->numberofpolygons];
494 F->numberofholes = 0;
496 P = &F->polygonlist[0];
498 P->numberofvertices = N_FVert;
499 P->vertexlist =
new int[P->numberofvertices];
501 for(j=0;j<N_FVert;j++)
504 P->vertexlist[j] = k-1;
507 dat >> In.facetmarkerlist[i];
509 if(BDComp_Min > In.facetmarkerlist[i])
510 BDComp_Min=In.facetmarkerlist[i];
517 for(i=0;i<N_Faces; i++)
518 In.facetmarkerlist[i] -= BDComp_Min;
528 void DeleteDomain(
TDomain *&Domain)
530 int i, j, k, N_Cells, N_RootCells;
531 int CurrVertex, N_Faces, N_Vertices, ID;
533 TBaseCell **CellTree, **SurfCellTree, *cell;
546 VertexDel =
new TVertex*[8*N_RootCells];
549 for(i=0;i<N_Cells;i++)
554 for(j=0;j<N_Faces;j++)
558 VertexDel[CurrVertex++] = cell->
GetVertex(j);
563 for(k=0;k<CurrVertex;k++)
570 VertexDel[CurrVertex++] = cell->
GetVertex(j);
575 for(k=0;k<CurrVertex;k++)
576 if(VertexDel[k]==cell->
GetVertex((j+1)%N_Vertices))
582 VertexDel[CurrVertex++] = cell->
GetVertex((j+1)%N_Vertices);
586 for(k=0;k<CurrVertex;k++)
587 if(VertexDel[k]==cell->
GetVertex((j+2)%N_Vertices))
593 VertexDel[CurrVertex++] = cell->
GetVertex((j+2)%N_Vertices);
598 for(k=0;k<CurrVertex;k++)
599 if(VertexDel[k]==cell->
GetVertex((j+4)%N_Vertices))
605 VertexDel[CurrVertex++] = cell->
GetVertex((j+4)%N_Vertices);
611 for(i=0;i<CurrVertex;i++)
614 OutPut(CurrVertex<<
" vertices were deleted"<<endl);
618 for(i=0;i<N_RootCells;i++)
621 OutPut(N_RootCells<<
" cells were deleted"<<endl);
631 void TetrameshCreate(
TDomain *&Domain)
633 int i, j, k, l, dimension, N_Vertices;
634 int N_FVert, N_Faces, *Facemarkerlist, *Facelist, N_RootCells;
635 int v1, v2, v3, v4, CellMarker, RefLevel=0, *Tetrahedrals, *PointNeighb, maxEpV, *Tetrahedrals_loc;
636 int a, b, c, Neib[2], Neighb_tmp, CurrNeib, len1, len2, len3, CurrComp, N_Points ;
637 int N_Cells, MaxLen, jj, N_SourcePts;
638 const int *EdgeVertex, *TmpFV, *TmpLen;
639 double X, Y, Z, DispX, DispY, DispZ;
640 double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
641 double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
642 double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
643 char *MESH, line[100];
655 MPI_Comm_rank(Comm, &rank);
656 MPI_Comm_size(Comm, &size);
660 DeleteDomain(Domain);
662 std::ifstream dat(MESH);
666 cerr <<
"cannot open '" << MESH <<
"' for input" << endl;
675 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
677 dat.getline (line, 99);
682 dat.getline (line, 99);
687 cerr <<
"dimension: " << dimension << endl;
695 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
697 dat.getline (line, 99);
702 dat.getline (line, 99);
706 NewVertices =
new TVertex*[N_Vertices];
709 for(i=0;i<N_Vertices; i++)
711 dat.getline (line, 99);
713 NewVertices[i] =
new TVertex( (X - DispX), (Y - DispY), (Z- DispZ));
715 if (X > Xmax) Xmax = X;
716 if (X < Xmin) Xmin = X;
717 if (Y > Ymax) Ymax = Y;
718 if (Y < Ymin) Ymin = Y;
719 if (Z > Zmax) Zmax = Z;
720 if (Z < Zmin) Zmin = Z;
726 BoundX = Xmax - Xmin;
727 BoundY = Ymax - Ymin;
728 BoundZ = Zmax - Zmin;
730 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
736 if ( (!strcmp(line,
"Tetrahedra")) || (!strcmp(line,
"tetrahedra")) || (!strcmp(line,
"TETRAHEDRA")) )
738 dat.getline (line, 99);
743 dat.getline (line, 99);
746 cout <<
"number of root cells "<<N_RootCells <<endl;
747 if (CellTree == NULL)
748 cout <<
"no celltree"<<endl;
750 Tetrahedrals =
new int[4*N_RootCells];
752 for (i=0;i<N_RootCells;i++)
754 dat.getline (line, 99);
755 dat >> v1 >> v2 >> v3 >> v4 >> CellMarker;
756 Tetrahedrals[4*i ] = v1 -1;
757 Tetrahedrals[4*i + 1] = v2 -1;
758 Tetrahedrals[4*i + 2] = v3 -1;
759 Tetrahedrals[4*i + 3] = v4 -1;
773 CellTree[i]->
SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
774 CellTree[i]->
SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
775 CellTree[i]->
SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
776 CellTree[i]->
SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
779 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
792 PointNeighb =
new int[N_Vertices];
796 cout<<
"Numberofpoints "<<N_Vertices<<endl;
797 memset(PointNeighb, 0, N_Vertices*SizeOfInt);
799 for (i=0;i<4*N_RootCells;i++)
800 PointNeighb[Tetrahedrals[i]]++;
803 for (i=0;i<N_Vertices;i++)
804 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
805 delete [] PointNeighb;
810 cout<<
"maxEpV "<< maxEpV<<endl;
811 PointNeighb =
new int[++maxEpV * N_Vertices];
812 memset(PointNeighb, 0, maxEpV*N_Vertices*SizeOfInt);
817 for(i=0;i<4*N_RootCells;i++)
819 j = Tetrahedrals[i]*maxEpV;
821 PointNeighb[j + PointNeighb[j]] = i / 4;
827 for(i=0;i<N_Cells;i++)
833 Tetrahedrals_loc = Tetrahedrals+4*i;
835 for(jj=0;jj<N_Faces;jj++)
838 N_Points = TmpLen[jj];
841 cerr <<
"Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
846 a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
847 b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
848 c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
852 len1 = PointNeighb[a*maxEpV];
853 len2 = PointNeighb[b*maxEpV];
854 len3 = PointNeighb[c*maxEpV];
856 for (j=1;j<=len1;j++)
858 Neighb_tmp = PointNeighb[a*maxEpV + j];
859 for (k=1;k<=len2;k++)
861 if(Neighb_tmp == PointNeighb[b*maxEpV + k])
864 if(Neighb_tmp == PointNeighb[c*maxEpV + l])
866 Neib[CurrNeib++] = Neighb_tmp;
871 if (CurrNeib == 2)
break;
878 NewVertices[a]->
GetY(), T[1], S[1]) ||
880 NewVertices[b]->
GetY(), T[2], S[2]) ||
882 NewVertices[c]->
GetY(), T[3], S[3]) )
884 cerr<<
"Error: could not set parameter values"<<endl;
885 OutPut(NewVertices[a]<<endl);
886 OutPut(NewVertices[b]<<endl);
887 OutPut(NewVertices[c]<<endl);
895 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
896 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
901 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
904 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
907 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
908 l = l*100 + k*10 + j;
912 case 210:
case 21:
case 102:
913 case 120:
case 12:
case 201:
916 case 310:
case 31:
case 103:
917 case 130:
case 13:
case 301:
920 case 321:
case 132:
case 213:
921 case 231:
case 123:
case 312:
924 case 230:
case 23:
case 302:
925 case 320:
case 32:
case 203:
930 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
933 CellTree[Neib[0]]->
SetJoint(j, Joint);
940 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
944 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
948 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
950 l = l*100 + k*10 + j;
953 case 210:
case 21:
case 102:
954 case 120:
case 12:
case 201:
957 case 310:
case 31:
case 103:
958 case 130:
case 13:
case 301:
961 case 321:
case 132:
case 213:
962 case 231:
case 123:
case 312:
965 case 230:
case 23:
case 302:
966 case 320:
case 32:
case 203:
971 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
974 CellTree[Neib[1]]->
SetJoint(j, Joint);
977 if (Joint->
GetType() == InterfaceJoint3D ||
978 Joint->
GetType() == IsoInterfaceJoint3D)
984 if (Joint->
GetType() == JointEqN)
989 delete [] PointNeighb;
990 cout<<
"Yestetrameshcreate " <<
"\n";
993 void TetrameshGen(
TDomain *&Domain)
998 int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
999 int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
1000 int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
1001 int *Tetrahedrals, *PointNeighb, dimension;
1002 int *Facelist, *Facemarkerlist;
1004 double *Coordinates, N_x, N_y, N_z;
1006 double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
1007 double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
1008 double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
1014 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1023 char *SMESH, line[100];
1030 MPI_Comm_rank(Comm, &rank);
1031 MPI_Comm_size(Comm, &size);
1046 std::ostringstream opts;
1049 opts.seekp(std::ios::beg);
1070 ReadMeditMesh(SMESH, In);
1078 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
1093 VertexDel =
new TVertex*[8*N_RootCells];
1096 for(i=0;i<N_Cells;i++)
1101 for(j=0;j<N_Faces;j++)
1105 VertexDel[CurrVertex++] = cell->
GetVertex(j);
1110 for(k=0;k<CurrVertex;k++)
1117 VertexDel[CurrVertex++] = cell->
GetVertex(j);
1122 for(k=0;k<CurrVertex;k++)
1123 if(VertexDel[k]==cell->
GetVertex((j+1)%N_Vertices))
1129 VertexDel[CurrVertex++] = cell->
GetVertex((j+1)%N_Vertices);
1133 for(k=0;k<CurrVertex;k++)
1134 if(VertexDel[k]==cell->
GetVertex((j+2)%N_Vertices))
1140 VertexDel[CurrVertex++] = cell->
GetVertex((j+2)%N_Vertices);
1145 for(k=0;k<CurrVertex;k++)
1146 if(VertexDel[k]==cell->
GetVertex((j+4)%N_Vertices))
1152 VertexDel[CurrVertex++] = cell->
GetVertex((j+4)%N_Vertices);
1158 for(i=0;i<CurrVertex;i++)
1159 delete VertexDel[i];
1160 delete [] VertexDel;
1161 OutPut(CurrVertex<<
" vertices were deleted"<<endl);
1165 for(i=0;i<N_RootCells;i++)
1168 OutPut(N_RootCells<<
" cells were deleted"<<endl);
1175 N_RootCells = Out.numberoftetrahedra;
1176 N_G = Out.numberofpoints;
1179 Coordinates = Out.pointlist;
1180 Tetrahedrals = Out.tetrahedronlist;
1186 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1187 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1192 Coordinates =
new double [3*N_G];
1193 Tetrahedrals =
new int[4*N_RootCells];
1196 MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1197 MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1201 NewVertices =
new TVertex*[N_G];
1205 NewVertices[i] =
new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
1208 if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
1209 if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
1210 if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
1211 if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
1212 if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
1213 if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
1220 BoundX = Xmax - Xmin;
1221 BoundY = Ymax - Ymin;
1222 BoundZ = Zmax - Zmin;
1225 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1236 for (i=0;i<N_RootCells;i++)
1241 CellTree[i]->
SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
1242 CellTree[i]->
SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
1243 CellTree[i]->
SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
1244 CellTree[i]->
SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
1247 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
1262 PointNeighb =
new int[N_G];
1266 cout<<
"numberofpoints "<<N_G<<endl;
1267 memset(PointNeighb, 0, N_G *SizeOfInt);
1269 for (i=0;i<4*N_RootCells;i++)
1270 PointNeighb[Tetrahedrals[i]]++;
1273 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1274 delete [] PointNeighb;
1279 cout<<
"maxEpV "<< maxEpV<<endl;
1281 PointNeighb =
new int[++maxEpV * N_G];
1283 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1290 for(i=0;i<4*N_RootCells;i++)
1292 j = Tetrahedrals[i]*maxEpV;
1295 PointNeighb[j + PointNeighb[j]] = i / 4;
1313 N_G = Out.numberoftrifaces;
1314 Facelist = Out.trifacelist;
1315 Facemarkerlist = Out.trifacemarkerlist;
1319 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1323 Facelist =
new int [3*N_G];
1324 Facemarkerlist =
new int[N_G];
1328 MPI_Bcast(Facelist, 3*N_G, MPI_INT, 0, Comm);
1329 MPI_Bcast(Facemarkerlist, N_G, MPI_INT, 0, Comm);
1333 cout<<
"numberoftrifaces "<<N_G<<endl;
1338 b = Facelist[3*i+1];
1339 c = Facelist[3*i+2];
1347 len1 = PointNeighb[a*maxEpV];
1348 len2 = PointNeighb[b*maxEpV];
1349 len3 = PointNeighb[c*maxEpV];
1352 for (j=1;j<=len1;j++)
1354 Neighb_tmp = PointNeighb[a*maxEpV + j];
1355 for (k=1;k<=len2;k++)
1357 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1359 for (l=1;l<=len3;l++)
1360 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1362 Neib[CurrNeib++] = Neighb_tmp;
1367 if (CurrNeib == 2)
break;
1371 if (Facemarkerlist[i])
1374 CurrComp = Facemarkerlist[i] - 1;
1385 NewVertices[a]->
GetY(), T[1], S[1]) ||
1387 NewVertices[b]->
GetY(), T[2], S[2]) ||
1389 NewVertices[c]->
GetY(), T[3], S[3]) )
1391 cerr<<
"Error: could not set parameter values"<<endl;
1392 OutPut(NewVertices[a]<<endl);
1393 OutPut(NewVertices[b]<<endl);
1394 OutPut(NewVertices[c]<<endl);
1402 CellTree[Neib[0]], CellTree[Neib[1]] );
1405 CellTree[Neib[0]], CellTree[Neib[1]] );
1419 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
1421 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1428 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
1432 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
1436 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
1438 l = l*100 + k*10 + j;
1444 case 210:
case 21:
case 102:
1445 case 120:
case 12:
case 201:
1448 case 310:
case 31:
case 103:
1449 case 130:
case 13:
case 301:
1452 case 321:
case 132:
case 213:
1453 case 231:
case 123:
case 312:
1456 case 230:
case 23:
case 302:
1457 case 320:
case 32:
case 203:
1462 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1465 CellTree[Neib[0]]->
SetJoint(j, Joint);
1471 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
1475 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
1479 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
1481 l = l*100 + k*10 + j;
1487 case 210:
case 21:
case 102:
1488 case 120:
case 12:
case 201:
1491 case 310:
case 31:
case 103:
1492 case 130:
case 13:
case 301:
1495 case 321:
case 132:
case 213:
1496 case 231:
case 123:
case 312:
1499 case 230:
case 23:
case 302:
1500 case 320:
case 32:
case 203:
1505 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1508 CellTree[Neib[1]]->
SetJoint(j, Joint);
1511 if (Joint->
GetType() == InterfaceJoint3D ||
1512 Joint->
GetType() == IsoInterfaceJoint3D)
1518 if (Joint->
GetType() == JointEqN)
1537 delete [] Tetrahedrals ;
1538 delete [] Coordinates;
1540 delete [] Facemarkerlist;
1544 delete [] PointNeighb;
1558 void TetraGen(
TDomain *&Domain)
1563 int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
1564 int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
1565 int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
1566 int *Tetrahedrals, *PointNeighb, dimension;
1567 int jj, N_Points, MaxLen, *Tetrahedrals_loc;
1568 const int *EdgeVertex, *TmpFV, *TmpLen;
1570 double *Coordinates, N_x, N_y, N_z;
1572 double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
1573 double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
1574 double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
1580 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
1590 char *SMESH, line[100];
1597 MPI_Comm_rank(Comm, &rank);
1598 MPI_Comm_size(Comm, &size);
1611 std::ostringstream opts;
1614 opts.seekp(std::ios::beg);
1635 ReadMeditMesh(SMESH, In);
1643 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
1652 DeleteDomain(Domain);
1659 N_RootCells = Out.numberoftetrahedra;
1660 N_G = Out.numberofpoints;
1663 Coordinates = Out.pointlist;
1664 Tetrahedrals = Out.tetrahedronlist;
1668 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
1669 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
1674 Coordinates =
new double [3*N_G];
1675 Tetrahedrals =
new int[4*N_RootCells];
1678 MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
1679 MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
1683 NewVertices =
new TVertex*[N_G];
1687 NewVertices[i] =
new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
1690 if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
1691 if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
1692 if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
1693 if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
1694 if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
1695 if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
1702 BoundX = Xmax - Xmin;
1703 BoundY = Ymax - Ymin;
1704 BoundZ = Zmax - Zmin;
1707 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
1718 for (i=0;i<N_RootCells;i++)
1723 CellTree[i]->
SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
1724 CellTree[i]->
SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
1725 CellTree[i]->
SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
1726 CellTree[i]->
SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
1729 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
1744 PointNeighb =
new int[N_G];
1748 cout<<
"numberofpoints "<<N_G<<endl;
1749 memset(PointNeighb, 0, N_G *SizeOfInt);
1751 for (i=0;i<4*N_RootCells;i++)
1752 PointNeighb[Tetrahedrals[i]]++;
1755 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
1756 delete [] PointNeighb;
1761 cout<<
"maxEpV "<< maxEpV<<endl;
1763 PointNeighb =
new int[++maxEpV * N_G];
1765 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
1772 for(i=0;i<4*N_RootCells;i++)
1774 j = Tetrahedrals[i]*maxEpV;
1777 PointNeighb[j + PointNeighb[j]] = i / 4;
1785 for (i=0;i<N_Cells;i++)
1791 Tetrahedrals_loc = Tetrahedrals+4*i;
1793 for(jj=0;jj<N_Faces;jj++)
1797 N_Points = TmpLen[jj];
1801 cerr <<
"Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
1807 a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
1808 b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
1809 c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
1817 len1 = PointNeighb[a*maxEpV];
1818 len2 = PointNeighb[b*maxEpV];
1819 len3 = PointNeighb[c*maxEpV];
1822 for (j=1;j<=len1;j++)
1824 Neighb_tmp = PointNeighb[a*maxEpV + j];
1825 for (k=1;k<=len2;k++)
1827 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
1829 for (l=1;l<=len3;l++)
1830 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
1832 Neib[CurrNeib++] = Neighb_tmp;
1837 if (CurrNeib == 2)
break;
1852 NewVertices[a]->
GetY(), T[1], S[1]) ||
1854 NewVertices[b]->
GetY(), T[2], S[2]) ||
1856 NewVertices[c]->
GetY(), T[3], S[3]) )
1858 cerr<<
"Error: could not set parameter values"<<endl;
1859 OutPut(NewVertices[a]<<endl);
1860 OutPut(NewVertices[b]<<endl);
1861 OutPut(NewVertices[c]<<endl);
1869 CellTree[Neib[0]], CellTree[Neib[1]] );
1872 CellTree[Neib[0]], CellTree[Neib[1]] );
1886 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
1888 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
1894 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
1898 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
1902 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
1904 l = l*100 + k*10 + j;
1910 case 210:
case 21:
case 102:
1911 case 120:
case 12:
case 201:
1914 case 310:
case 31:
case 103:
1915 case 130:
case 13:
case 301:
1918 case 321:
case 132:
case 213:
1919 case 231:
case 123:
case 312:
1922 case 230:
case 23:
case 302:
1923 case 320:
case 32:
case 203:
1928 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1931 CellTree[Neib[0]]->
SetJoint(j, Joint);
1937 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
1941 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
1945 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
1947 l = l*100 + k*10 + j;
1953 case 210:
case 21:
case 102:
1954 case 120:
case 12:
case 201:
1957 case 310:
case 31:
case 103:
1958 case 130:
case 13:
case 301:
1961 case 321:
case 132:
case 213:
1962 case 231:
case 123:
case 312:
1965 case 230:
case 23:
case 302:
1966 case 320:
case 32:
case 203:
1971 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
1974 CellTree[Neib[1]]->
SetJoint(j, Joint);
1977 if (Joint->
GetType() == InterfaceJoint3D ||
1978 Joint->
GetType() == IsoInterfaceJoint3D)
1984 if (Joint->
GetType() == JointEqN)
1993 cout<<
"numberoftrifaces after "<<N_G<<endl;
2009 delete [] Tetrahedrals ;
2010 delete [] Coordinates;
2016 delete [] PointNeighb;
2030 void TetraGenWithInputCells(
TDomain *&Domain)
2035 int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
2036 int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
2037 int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
2038 int *Tetrahedrals, *PointNeighb, dimension;
2039 int jj, N_Points, MaxLen, *Tetrahedrals_loc;
2040 const int *EdgeVertex, *TmpFV, *TmpLen;
2041 double *TetRegionlist;
2043 double *Coordinates, N_x, N_y, N_z;
2045 double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
2046 double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
2047 double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
2049 tetgenio In, Out, InAddPts;
2053 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
2063 char *SMESH, *NODE, line[100];
2071 MPI_Comm_rank(Comm, &rank);
2072 MPI_Comm_size(Comm, &size);
2085 std::ostringstream opts;
2088 opts.seekp(std::ios::beg);
2117 ReadMeditMeshWithCells(SMESH, In);
2132 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
2142 DeleteDomain(Domain);
2149 N_RootCells = Out.numberoftetrahedra;
2150 N_G = Out.numberofpoints;
2153 Coordinates = Out.pointlist;
2154 Tetrahedrals = Out.tetrahedronlist;
2156 TetRegionlist = Out.tetrahedronattributelist;
2160 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
2161 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
2166 Coordinates =
new double [3*N_G];
2167 Tetrahedrals =
new int[4*N_RootCells];
2168 TetRegionlist =
new double [N_RootCells];
2171 MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
2172 MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
2173 MPI_Bcast(TetRegionlist, N_RootCells, MPI_DOUBLE, 0, Comm);
2177 NewVertices =
new TVertex*[N_G];
2181 NewVertices[i] =
new TVertex(Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
2184 if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
2185 if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
2186 if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
2187 if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
2188 if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
2189 if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
2196 BoundX = Xmax - Xmin;
2197 BoundY = Ymax - Ymin;
2198 BoundZ = Zmax - Zmin;
2201 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
2212 for (i=0;i<N_RootCells;i++)
2217 CellTree[i]->
SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
2218 CellTree[i]->
SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
2219 CellTree[i]->
SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
2220 CellTree[i]->
SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
2223 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
2241 PointNeighb =
new int[N_G];
2245 cout<<
"numberofpoints "<<N_G<<endl;
2246 memset(PointNeighb, 0, N_G *SizeOfInt);
2248 for (i=0;i<4*N_RootCells;i++)
2249 PointNeighb[Tetrahedrals[i]]++;
2252 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
2253 delete [] PointNeighb;
2258 cout<<
"maxEpV "<< maxEpV<<endl;
2260 PointNeighb =
new int[++maxEpV * N_G];
2262 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
2269 for(i=0;i<4*N_RootCells;i++)
2271 j = Tetrahedrals[i]*maxEpV;
2274 PointNeighb[j + PointNeighb[j]] = i / 4;
2282 for (i=0;i<N_Cells;i++)
2288 Tetrahedrals_loc = Tetrahedrals+4*i;
2290 for(jj=0;jj<N_Faces;jj++)
2294 N_Points = TmpLen[jj];
2298 cerr <<
"Only Tria faces are allowed!!! N_FVert: " << N_Points << endl;
2304 a = Tetrahedrals_loc[TmpFV[jj*MaxLen]];
2305 b = Tetrahedrals_loc[TmpFV[jj*MaxLen + 1]];
2306 c = Tetrahedrals_loc[TmpFV[jj*MaxLen + 2]];
2314 len1 = PointNeighb[a*maxEpV];
2315 len2 = PointNeighb[b*maxEpV];
2316 len3 = PointNeighb[c*maxEpV];
2319 for (j=1;j<=len1;j++)
2321 Neighb_tmp = PointNeighb[a*maxEpV + j];
2322 for (k=1;k<=len2;k++)
2324 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
2326 for (l=1;l<=len3;l++)
2327 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
2329 Neib[CurrNeib++] = Neighb_tmp;
2334 if (CurrNeib == 2)
break;
2349 NewVertices[a]->
GetY(), T[1], S[1]) ||
2351 NewVertices[b]->
GetY(), T[2], S[2]) ||
2353 NewVertices[c]->
GetY(), T[3], S[3]) )
2355 cerr<<
"Error: could not set parameter values"<<endl;
2356 OutPut(NewVertices[a]<<endl);
2357 OutPut(NewVertices[b]<<endl);
2358 OutPut(NewVertices[c]<<endl);
2366 CellTree[Neib[0]], CellTree[Neib[1]] );
2369 CellTree[Neib[0]], CellTree[Neib[1]] );
2383 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
2385 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
2391 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
2395 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
2399 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
2401 l = l*100 + k*10 + j;
2407 case 210:
case 21:
case 102:
2408 case 120:
case 12:
case 201:
2411 case 310:
case 31:
case 103:
2412 case 130:
case 13:
case 301:
2415 case 321:
case 132:
case 213:
2416 case 231:
case 123:
case 312:
2419 case 230:
case 23:
case 302:
2420 case 320:
case 32:
case 203:
2425 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
2428 CellTree[Neib[0]]->
SetJoint(j, Joint);
2434 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
2438 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
2442 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
2444 l = l*100 + k*10 + j;
2450 case 210:
case 21:
case 102:
2451 case 120:
case 12:
case 201:
2454 case 310:
case 31:
case 103:
2455 case 130:
case 13:
case 301:
2458 case 321:
case 132:
case 213:
2459 case 231:
case 123:
case 312:
2462 case 230:
case 23:
case 302:
2463 case 320:
case 32:
case 203:
2468 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
2471 CellTree[Neib[1]]->
SetJoint(j, Joint);
2474 if (Joint->
GetType() == InterfaceJoint3D ||
2475 Joint->
GetType() == IsoInterfaceJoint3D)
2481 if (Joint->
GetType() == JointEqN)
2490 cout<<
"numberoftrifaces after "<<N_G<<endl;
2506 delete [] Tetrahedrals ;
2507 delete [] Coordinates;
2508 delete [] TetRegionlist;
2513 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 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