Version: 6.5.0
Polyhedra and polygons

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 .

polygon_connectivity_small.png
Example for polygon connectivity

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.

polyhedron_connectivity_small.png
Example for polyhedron connectivity. Node numbers are written with a normal font, while face numbers are written in italic font.

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 :

// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDMEM_Field.hxx"
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,// Polyhedron 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, // Polyhedron 2
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, // Polygon 1
7, 8, 9, 3, 2 // Polygon 2
};
const int REFpolygonIndex[3] =
{
1, 7, 12
};
MESHING *myMeshing=new MESHING;
myMeshing->setName("meshing");
int NumberOfNodes = 19;
int SpaceDimension = 3;
const int NumberOfTypes = 2;
medGeometryElement Types[NumberOfTypes] =
{
MED_TETRA4, MED_POLYHEDRA
};
const int NumberOfElements[NumberOfTypes] =
{
1,2
};
myMeshing->setNumberOfTypes(NumberOfTypes, MED_CELL);
myMeshing->setCoordinates(SpaceDimension, NumberOfNodes, Coordinates,
"CARTESIAN", MED_FULL_INTERLACE);
myMeshing->setTypes(Types, MED_CELL);
myMeshing->setNumberOfElements(NumberOfElements, MED_CELL);
string Names[3] =
{
"X","Y","Z"
};
myMeshing->setCoordinatesNames(Names);
string Units[3] =
{
"cm","cm","cm"
};
myMeshing->setCoordinatesUnits(Units);
const int sizeTetra = 4*1 ;
int ConnectivityTetra[sizeTetra]=
{
17, 9, 18, 19
};
myMeshing->setConnectivity(MED_CELL, MED_TETRA4, ConnectivityTetra);
myMeshing->setConnectivity(MED_CELL, MED_POLYHEDRA, REFnodalConnOfFaces, REFpolyIndex);
MESHING *myPolygonMeshing=new MESHING;
myPolygonMeshing->setName("PolygonMeshing");
NumberOfNodes = 9;
SpaceDimension = 3;
medGeometryElement PolygonTypes[NumberOfTypes] =
{
MED_TRIA3,MED_POLYGON
};
const int PolygonNumberOfElements[NumberOfTypes] =
{
2,2
};
myPolygonMeshing->setNumberOfTypes(NumberOfTypes, MED_CELL);
myPolygonMeshing->setCoordinates(SpaceDimension, NumberOfNodes, PolygonCoordinates,
"CARTESIAN", MED_FULL_INTERLACE);
myPolygonMeshing->setTypes(PolygonTypes, MED_CELL);
myPolygonMeshing->setNumberOfElements(PolygonNumberOfElements, MED_CELL);
myPolygonMeshing->setCoordinatesNames(Names);
myPolygonMeshing->setCoordinatesUnits(Units);
const int sizeTri = 3*2 ;
int ConnectivityTri[sizeTri]=
{
1, 7, 2, 3, 9, 4
};
myPolygonMeshing->setConnectivity(MED_CELL, MED_TRIA3, ConnectivityTri);
myPolygonMeshing->setConnectivity(MED_CELL, MED_POLYGON, REFpolygonFaces, REFpolygonIndex);
FIELD<double> *areas = myPolygonMeshing->getArea(myPolygonMeshing->getSupportOnAll( MED_CELL ));
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 SUPPORT *sup = myMeshing->getSupportOnAll(MED_CELL);
FIELD<double> *vols = myMeshing->getVolume(sup,false);
const double *vals = vols->getValue();
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") ) // performing 'make check'?
remove("totoPoly_V22.med");
return 0;
}
Copyright © 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS