5 #include <InterfaceJoint3D.h>
6 #include <IsoInterfaceJoint3D.h>
7 #include <IsoBoundFace.h>
15 OutPut(
"Example: CircularChannel.h" << endl) ;
23 void ExactU1(
double x,
double y,
double z,
double *values)
32 void ExactU2(
double x,
double y,
double z,
double *values)
41 void ExactU3(
double x,
double y,
double z,
double *values)
44 values[0] = 1-(x*x+y*y);
51 void ExactP(
double x,
double y,
double z,
double *values)
55 values[0] = 4*eps*(10-z);
63 void BoundCondition(
int CompID,
double x,
double y,
double z, BoundCond &cond)
77 void U2BoundValue(
int CompID,
double x,
double y,
double z,
double &value)
83 void U1BoundValue(
int CompID,
double x,
double y,
double z,
double &value)
89 void U3BoundValue(
int CompID,
double x,
double y,
double z,
double &value)
106 void LinCoeffs(
int n_points,
double *X,
double *Y,
double *Z,
107 double **parameters,
double **coeffs)
111 double *coeff, x, y, z;
113 for(i=0;i<n_points;i++)
124 void ReadMeditMesh(
char *SMESH, tetgenio &In)
126 int i, j, k, dimension, N_FVert, N_Faces, N_Vertices;
127 int BDComp_Min=10000000;
131 tetgenio::polygon *P;
133 std::ifstream dat(SMESH);
137 cerr <<
"cannot open '" << SMESH <<
"' for input" << endl;
146 if ( (!strcmp(line,
"Dimension")) || (!strcmp(line,
"dimension")) || (!strcmp(line,
"DIMENSION")))
148 dat.getline (line, 99);
153 dat.getline (line, 99);
158 cerr <<
"dimension: " << dimension << endl;
167 if ( (!strcmp(line,
"Vertices")) || (!strcmp(line,
"vertices")) || (!strcmp(line,
"VERTICES")) )
169 dat.getline (line, 99);
174 dat.getline (line, 99);
177 In.numberofpoints = N_Vertices;
178 In.pointlist =
new double[3*N_Vertices];
179 In.pointmtrlist =
new double[N_Vertices];
180 In.numberofpointmtrs = 1;
183 for(i=0;i<N_Vertices; i++)
185 dat.getline (line, 99);
186 dat >> In.pointlist[3*i] >> In.pointlist[3*i+1] >> In.pointlist[3*i+2];
187 In.pointmtrlist[i] = 10.;
199 if ( (!strcmp(line,
"Triangles")) || (!strcmp(line,
"triangles")) || (!strcmp(line,
"TRIANGLES")) )
202 dat.getline (line, 99);
206 else if ( (!strcmp(line,
"Quadrilaterals")) || (!strcmp(line,
"quadrilaterals")) || (!strcmp(line,
"QUADRILATERALS")) )
209 dat.getline (line, 99);
215 dat.getline (line, 99);
218 In.numberoffacets = N_Faces;
219 In.facetlist =
new tetgenio::facet[In.numberoffacets];
220 In.facetmarkerlist =
new int[In.numberoffacets];
222 for(i=0;i<N_Faces; i++)
224 dat.getline (line, 99);
226 F = &In.facetlist[i];
228 F->numberofpolygons = 1;
229 F->polygonlist =
new tetgenio::polygon[F->numberofpolygons];
230 F->numberofholes = 0;
232 P = &F->polygonlist[0];
234 P->numberofvertices = N_FVert;
235 P->vertexlist =
new int[P->numberofvertices];
237 for(j=0;j<N_FVert;j++)
240 P->vertexlist[j] = k-1;
243 dat >> In.facetmarkerlist[i];
245 if(BDComp_Min > In.facetmarkerlist[i])
246 BDComp_Min=In.facetmarkerlist[i];
253 for(i=0;i<N_Faces; i++)
254 In.facetmarkerlist[i] -= BDComp_Min;
264 void TetrameshGen(
TDomain *&Domain)
269 int i, j, k, l, N_Coord, *N_FVerts, N_Faces, *Facets;
270 int N, N_RootCells, N_Cells, CurrVertex, N_Vertices, ID, N_G, RefLevel=0;
271 int CurrNeib, len1, len2, len3, maxEpV = 0, a, b, c, Neib[2], Neighb_tmp, CurrComp;
272 int *Tetrahedrals, *PointNeighb, dimension;
273 int *Facelist, *Facemarkerlist;
275 double X, Y, Z, DispX, DispY, DispZ;
276 double *Coordinates, N_x, N_y, N_z;
278 double Xmin = 1e10, Xmax = -1e10, Ymin = 1e10, Ymax = -1e10;
279 double Zmin = 1e10, Zmax = -1e10, T[4]={0,0,0,0}, S[4]={0,0,0,0};
280 double StartX, StartY, StartZ, BoundX, BoundY, BoundZ;
282 tetgenio In, Out, Out_New;
286 TVertex **VertexDel, **NewVertices, **NewSurfVertices;
295 char *SMESH, line[100];
302 MPI_Comm_rank(Comm, &rank);
303 MPI_Comm_size(Comm, &size);
318 std::ostringstream opts;
321 opts.seekp(std::ios::beg);
344 ReadMeditMesh(SMESH, In);
350 tetrahedralize((
char*)opts.str().c_str(), &In, &Out);
359 for(i=0;i<Out.numberofpoints;i++)
360 OutPut(
" (x, y, z) = "<< Out.pointlist[3*i]<<
' '<<Out.pointlist[3*i+1]<<
' '<<Out.pointlist[3*i+2]<<endl);
369 VertexDel =
new TVertex*[8*N_RootCells];
372 for(i=0;i<N_Cells;i++)
377 for(j=0;j<N_Faces;j++)
381 VertexDel[CurrVertex++] = cell->
GetVertex(j);
386 for(k=0;k<CurrVertex;k++)
393 VertexDel[CurrVertex++] = cell->
GetVertex(j);
398 for(k=0;k<CurrVertex;k++)
399 if(VertexDel[k]==cell->
GetVertex((j+1)%N_Vertices))
405 VertexDel[CurrVertex++] = cell->
GetVertex((j+1)%N_Vertices);
409 for(k=0;k<CurrVertex;k++)
410 if(VertexDel[k]==cell->
GetVertex((j+2)%N_Vertices))
416 VertexDel[CurrVertex++] = cell->
GetVertex((j+2)%N_Vertices);
421 for(k=0;k<CurrVertex;k++)
422 if(VertexDel[k]==cell->
GetVertex((j+4)%N_Vertices))
428 VertexDel[CurrVertex++] = cell->
GetVertex((j+4)%N_Vertices);
434 for(i=0;i<CurrVertex;i++)
437 OutPut(CurrVertex<<
" vertices were deleted"<<endl);
441 for(i=0;i<N_RootCells;i++)
444 OutPut(N_RootCells<<
" cells were deleted"<<endl);
451 N_RootCells = Out.numberoftetrahedra;
452 N_G = Out.numberofpoints;
455 Coordinates = Out.pointlist;
456 Tetrahedrals = Out.tetrahedronlist;
462 MPI_Bcast(&N_RootCells, 1, MPI_INT, 0, Comm);
463 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
468 Coordinates =
new double [3*N_G];
469 Tetrahedrals =
new int[4*N_RootCells];
472 MPI_Bcast(Coordinates, 3*N_G, MPI_DOUBLE, 0, Comm);
473 MPI_Bcast(Tetrahedrals, 4*N_RootCells, MPI_INT, 0, Comm);
477 NewVertices =
new TVertex*[N_G];
481 NewVertices[i] =
new TVertex( Coordinates[3*i], Coordinates[3*i+1], Coordinates[3*i+2]);
484 if (Coordinates[3*i] > Xmax) Xmax = Coordinates[3*i];
485 if (Coordinates[3*i] < Xmin) Xmin = Coordinates[3*i];
486 if (Coordinates[3*i+1] > Ymax) Ymax = Coordinates[3*i+1];
487 if (Coordinates[3*i+1] < Ymin) Ymin = Coordinates[3*i+1];
488 if (Coordinates[3*i+2] > Zmax) Zmax = Coordinates[3*i+2];
489 if (Coordinates[3*i+2] < Zmin) Zmin = Coordinates[3*i+2];
496 BoundX = Xmax - Xmin;
497 BoundY = Ymax - Ymin;
498 BoundZ = Zmax - Zmin;
501 Domain->SetBoundBox(StartX, StartY, StartZ, BoundX, BoundY, BoundZ);
512 for (i=0;i<N_RootCells;i++)
517 CellTree[i]->
SetVertex(0, NewVertices[Tetrahedrals[4*i ]]);
518 CellTree[i]->
SetVertex(1, NewVertices[Tetrahedrals[4*i + 1]]);
519 CellTree[i]->
SetVertex(2, NewVertices[Tetrahedrals[4*i + 2]]);
520 CellTree[i]->
SetVertex(3, NewVertices[Tetrahedrals[4*i + 3]]);
523 ((
TMacroCell *) CellTree[i])->SetSubGridID(0);
542 PointNeighb =
new int[N_G];
546 cout<<
"numberofpoints "<<N_G<<endl;
547 memset(PointNeighb, 0, N_G *SizeOfInt);
549 for (i=0;i<4*N_RootCells;i++)
550 PointNeighb[Tetrahedrals[i]]++;
553 if (PointNeighb[i] > maxEpV) maxEpV = PointNeighb[i];
554 delete [] PointNeighb;
559 cout<<
"maxEpV "<< maxEpV<<endl;
561 PointNeighb =
new int[++maxEpV * N_G];
563 memset(PointNeighb, 0, maxEpV*N_G*SizeOfInt);
570 for(i=0;i<4*N_RootCells;i++)
572 j = Tetrahedrals[i]*maxEpV;
575 PointNeighb[j + PointNeighb[j]] = i / 4;
593 N_G = Out.numberoftrifaces;
594 Facelist = Out.trifacelist;
595 Facemarkerlist = Out.trifacemarkerlist;
599 MPI_Bcast(&N_G, 1, MPI_INT, 0, Comm);
603 Facelist =
new int [3*N_G];
604 Facemarkerlist =
new int[N_G];
608 MPI_Bcast(Facelist, 3*N_G, MPI_INT, 0, Comm);
609 MPI_Bcast(Facemarkerlist, N_G, MPI_INT, 0, Comm);
613 cout<<
"numberoftrifaces "<<N_G<<endl;
627 len1 = PointNeighb[a*maxEpV];
628 len2 = PointNeighb[b*maxEpV];
629 len3 = PointNeighb[c*maxEpV];
632 for (j=1;j<=len1;j++)
634 Neighb_tmp = PointNeighb[a*maxEpV + j];
635 for (k=1;k<=len2;k++)
637 if (Neighb_tmp == PointNeighb[b*maxEpV + k])
639 for (l=1;l<=len3;l++)
640 if (Neighb_tmp == PointNeighb[c*maxEpV + l])
642 Neib[CurrNeib++] = Neighb_tmp;
647 if (CurrNeib == 2)
break;
651 if (Facemarkerlist[i])
654 CurrComp = Facemarkerlist[i] - 1;
665 NewVertices[a]->
GetY(), T[1], S[1]) ||
667 NewVertices[b]->
GetY(), T[2], S[2]) ||
669 NewVertices[c]->
GetY(), T[3], S[3]) )
671 cerr<<
"Error: could not set parameter values"<<endl;
672 OutPut(NewVertices[a]<<endl);
673 OutPut(NewVertices[b]<<endl);
674 OutPut(NewVertices[c]<<endl);
682 CellTree[Neib[0]], CellTree[Neib[1]] );
685 CellTree[Neib[0]], CellTree[Neib[1]] );
699 cerr <<
"Error !!!!!!!! not enough neighbours!" << endl;
701 Joint =
new TJointEqN(CellTree[Neib[0]], CellTree[Neib[1]]);
708 if (Tetrahedrals[4*Neib[0]+j] == a)
break;
712 if (Tetrahedrals[4*Neib[0]+k] == b)
break;
716 if (Tetrahedrals[4*Neib[0]+l] == c)
break;
718 l = l*100 + k*10 + j;
724 case 210:
case 21:
case 102:
725 case 120:
case 12:
case 201:
728 case 310:
case 31:
case 103:
729 case 130:
case 13:
case 301:
732 case 321:
case 132:
case 213:
733 case 231:
case 123:
case 312:
736 case 230:
case 23:
case 302:
737 case 320:
case 32:
case 203:
742 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
745 CellTree[Neib[0]]->
SetJoint(j, Joint);
751 if (Tetrahedrals[4*Neib[1]+j] == a)
break;
755 if (Tetrahedrals[4*Neib[1]+k] == b)
break;
759 if (Tetrahedrals[4*Neib[1]+l] == c)
break;
761 l = l*100 + k*10 + j;
767 case 210:
case 21:
case 102:
768 case 120:
case 12:
case 201:
771 case 310:
case 31:
case 103:
772 case 130:
case 13:
case 301:
775 case 321:
case 132:
case 213:
776 case 231:
case 123:
case 312:
779 case 230:
case 23:
case 302:
780 case 320:
case 32:
case 203:
785 Error(
"Unable to set the face !!!!!!!!!!!!" << endl);
788 CellTree[Neib[1]]->
SetJoint(j, Joint);
791 if (Joint->
GetType() == InterfaceJoint3D ||
792 Joint->
GetType() == IsoInterfaceJoint3D)
798 if (Joint->
GetType() == JointEqN)
817 delete [] Tetrahedrals ;
818 delete [] Coordinates;
820 delete [] Facemarkerlist;
824 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
contains the boundary description, the virtual cell tree and macro grid
Definition: Domain.h:36
void SetClipBoard(int value)
set value in ClipBoard
Definition: BaseCell.h:263
double RE_NR
Definition: Database.h:313
int SetParam(TDomain *domain)
Definition: Iterator.C:17
static TIterator ** IteratorDB
Definition: Database.h:1131
Definition: IsoBoundFace.h:18
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
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