General information
The methods described in section MESH do not take into account information about polygonal
and polyhedral
cells contained in a MESH object. Indeed, in the MEDMEM library, the connectivity data for these elements are stored the same way as connectivity of standard elements. Therefore, the methods that give access to this data are same as those of section MESH.
The polygon and the polyhedra case differ in nature, because in 3D, the list of nodes is not sufficient to described the shape of an element. A descending cell>face>nodes connectivity has to be established to fully describe the elements.
Polygon connectivity
Let us consider the case illustrated in figure fig_polygon_connectivity .
Example for polygon connectivity
- The connectivity table writes : {2, 6, 7, 3, 3, 7, 8, 4, 1, 2, 3, 4, 5 }
- The connectivity index table writes : {1, 5, 9, 14 }
Polyhedron connectivity
For polyhedra, in the nodal connectivity case, list of nodes does not suffice to describe a general polyhedron; information of connectivity of each face is needed. A general polyhedron is therefore described by a list of nodes of all faces with -1 as separator between faces.
Let us consider an example with the two tetrahedra represented on figure fig_polyhedron_connectivity , the left one being stored as a MED_TETRA4
element, the right one being stored as a MED_POLYHEDRA
element.
Example for polyhedron connectivity. Node numbers are written with a normal font, while face numbers are written in italic font.
- The connectivity table writes : {1, 2, 3, 4, 2, 5, 3, -1, 2, 4, 5, -1, 4, 3, 5, -1, 2, 3, 4}
- The index connectivity table writes : {1, 5, 20 }
If there are two MED_POLYHEDRA
elements that share a common face, the list of nodes is repeated twice in the polyhedron connectivity array but with reversed order.
Example
The following example illustrates the creation method for a mesh that contains polygons and/or polyhedra :
using namespace std;
using namespace MEDMEM;
using namespace MED_EN;
int main (int argc, char ** argv)
{
double Coordinates[57] =
{
2.0, 3.0, 2.0,
3.0, 2.0, 2.0,
4.0, 1.0, 2.0,
2.0, 0.0, 2.0,
0.0, 1.0, 2.0,
1.0, 2.0, 2.0,
2.0, 3.0, 1.0,
3.0, 2.0, 0.0,
4.0, 1.0, 0.0,
2.0, 0.0, 0.0,
0.0, 1.0, 0.0,
1.0, 2.0, 0.0,
5.0, 3.0, 2.0,
7.0, 2.0, 2.0,
6.0, 0.0, 2.0,
6.0, 3.0, 0.0,
7.0, 2.0, 0.0,
6.0, 0.0, -1.0,
5.0, 1.0, -3.0
};
const int REFnodalConnOfFaces[91] =
{
1, 2, 3, 4, 5, 6, -1,
1, 7, 8, 2, -1,
2, 8, 9, 3, -1,
4, 3, 9, 10, -1,
5, 4, 10, 11, -1,
6, 5, 11, 12, -1,
1, 6, 12, 7, -1,
7, 12, 8, -1,
10, 9, 8, 12, 11,
13, 14, 15, 3, 2, -1,
13, 2, 8, 16, -1,
14, 13, 16, 17, -1,
15, 14, 17, -1,
15, 17, 18, -1,
15, 18, 9, -1,
3, 15, 9, -1,
2, 3, 9, 8, -1,
8, 9, 17, 16, -1,
9, 18, 17
};
const int REFpolyIndex[3] =
{
1, 47, 92
};
double PolygonCoordinates[27] =
{
2.0, 3.0, 12.0,
3.0, 2.0, 12.0,
4.0, 1.0, 12.0,
2.0, 0.0, 12.0,
0.0, 1.0, 12.0,
1.0, 2.0, 12.0,
5.0, 3.0, 12.0,
7.0, 2.0, 12.0,
6.0, 0.0, 12.0
};
const int REFpolygonFaces[11] =
{
1, 2, 3, 4, 5, 6,
7, 8, 9, 3, 2
};
const int REFpolygonIndex[3] =
{
1, 7, 12
};
int NumberOfNodes = 19;
int SpaceDimension = 3;
const int NumberOfTypes = 2;
medGeometryElement Types[NumberOfTypes] =
{
MED_TETRA4, MED_POLYHEDRA
};
const int NumberOfElements[NumberOfTypes] =
{
1,2
};
"CARTESIAN", MED_FULL_INTERLACE);
string Names[3] =
{
"X","Y","Z"
};
string Units[3] =
{
"cm","cm","cm"
};
const int sizeTetra = 4*1 ;
int ConnectivityTetra[sizeTetra]=
{
17, 9, 18, 19
};
myMeshing->
setConnectivity(MED_CELL, MED_POLYHEDRA, REFnodalConnOfFaces, REFpolyIndex);
myPolygonMeshing->
setName(
"PolygonMeshing");
NumberOfNodes = 9;
SpaceDimension = 3;
medGeometryElement PolygonTypes[NumberOfTypes] =
{
MED_TRIA3,MED_POLYGON
};
const int PolygonNumberOfElements[NumberOfTypes] =
{
2,2
};
myPolygonMeshing->
setCoordinates(SpaceDimension, NumberOfNodes, PolygonCoordinates,
"CARTESIAN", MED_FULL_INTERLACE);
myPolygonMeshing->
setTypes(PolygonTypes, MED_CELL);
const int sizeTri = 3*2 ;
int ConnectivityTri[sizeTri]=
{
1, 7, 2, 3, 9, 4
};
myPolygonMeshing->
setConnectivity(MED_CELL, MED_POLYGON, REFpolygonFaces, REFpolygonIndex);
myPolygonMeshing->removeReference();
const double *vals2 = areas->
getValue();
const double REFAreaOfPolyg[4] =
{
1.5, 2, 6, 6.5
};
int nbPts=0;
int i;
for(i=0;i<4;i++)
if(fabs(REFAreaOfPolyg[i]-vals2[i])<1e-12)
nbPts++;
areas->removeReference();
const double REFVolOfPolyHedron[3] =
{
2.333333333333333, -11.66666666666666, -13.83224131414673
};
for(i=0;i<3;i++)
if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12)
nbPts++;
vols->removeReference();
if(nbPts==7)
{
cout << "ALL TESTS OK !!!" << endl;
}
else
{
cout << "TEST FAILS !!!" << endl;
return -1;
}
cout << "Writing test " << endl;
myMeshing->
write(MED_DRIVER,
"totoPoly_V22.med");
myMeshing->removeReference();
if ( getenv("srcdir") )
remove("totoPoly_V22.med");
return 0;
}