1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MEDMEM_Meshing.hxx"
24 #include "MEDMEM_Group.hxx"
27 #define access _access
34 {0, 0.21504, 0.21504, 0, 0.43008,
35 0.43008, 0.21504, 0, 0.43008, 0,
36 0.21504, 0.21504, 0, 0.43008,
37 0.43008, 0.21504, 0, 0.43008, 0,
38 0.21504, 0.21504, 0, 0.43008,
39 0.43008, 0.21504, 0, 0.43008, 0,
40 0.21504, 0.21504, 0, 0.43008,
41 0.43008, 0.21504, 0, 0.43008,
43 0, 0, 0.21504, 0.21504, 0, 0.21504,
44 0.43008, 0.43008, 0.43008, 0, 0,
45 0.21504, 0.21504, 0, 0.21504,
46 0.43008, 0.43008, 0.43008, 0, 0,
47 0.21504, 0.21504, 0, 0.21504,
48 0.43008, 0.43008, 0.43008, 0, 0,
49 0.21504, 0.21504, 0, 0.21504,
50 0.43008, 0.43008, 0.43008,
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.15677, 0.15677,
53 0.15677, 0.15677, 0.15677,
54 0.15677, 0.15677, 0.15677,
55 0.15677, 0.1934, 0.1934,
56 0.1934, 0.1934, 0.1934,
57 0.1934, 0.1934, 0.1934,
58 0.1934, 0.3485, 0.3485,
59 0.3485, 0.3485, 0.3485,
60 0.3485, 0.3485, 0.3485,
63 int connNodalCellClassical[48]=
64 { 1, 2, 3, 4, 10, 11, 12, 13,
65 4, 3, 7, 8, 13, 12, 16, 17,
66 10, 11, 12, 13, 19, 20, 21, 22,
67 13, 12, 16, 17, 22, 21, 25, 26,
68 19, 20, 21, 22, 28, 29, 30, 31,
69 22, 21, 25, 26, 31, 30, 34, 35 };
71 int polyHedraInd[7]={1, 30, 59, 88, 117, 146, 175};
73 int polyHedraConn[174]={
74 2, 3, 6, 5, -1, 11, 14, 15, 12, -1, 2, 5, 14, 11, -1, 5, 6, 15, 14, -1, 6, 3, 12, 15, -1, 3, 2, 11, 12,
75 3, 7, 9, 6, -1, 12, 15, 18, 16, -1, 3, 6, 15, 12, -1, 6, 9, 18, 15, -1, 9, 7, 16, 18, -1, 7, 3, 12, 16,
76 11, 12, 15, 14, -1, 20, 23, 24, 21, -1, 11, 14, 23, 20, -1, 14, 15, 24, 23, -1, 15, 12, 21, 24, -1, 12, 11, 20, 21,
77 12, 16, 18, 15, -1, 21, 24, 27, 25, -1, 12, 15, 24, 21, -1, 15, 18, 27, 24, -1, 18, 16, 25, 27, -1, 16, 12, 21, 25,
78 20, 21, 24, 23, -1, 29, 32, 33, 30, -1, 20, 23, 32, 29, -1, 23, 24, 33, 32, -1, 24, 21, 30, 33, -1, 21, 20, 29, 30,
79 21, 25, 27, 24, -1, 30, 33, 36, 34, -1, 21, 24, 33, 30, -1, 24, 27, 36, 33, -1, 27, 25, 34, 36, -1, 25, 21, 30, 34 };
81 int connNodalFaceClassical[116]=
112 int cpolygonsIndex[24]=
113 { 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69,
114 73, 77, 81, 85, 89, 93};
116 int cpolygonsValue[92]=
141 int bottom[4]={1,7,30,35};
142 MED_EN::medGeometryElement bottomTypes[2]={MED_EN::MED_QUAD4, MED_EN::MED_POLYGON };
143 int bottomIndex[3]={1,3,5};
144 int bottomNbOfElts[2]={2,2};
145 int top[4]={21,26,46,50};
146 MED_EN::medGeometryElement topTypes[2]={MED_EN::MED_QUAD4, MED_EN::MED_POLYGON };
147 int topIndex[3]={1,3,5};
148 int topNbOfElts[2]={2,2};
149 int side[24]={ 3, 6, 10, 11, 13, 16, 19, 20, 22, 25, 28, 29, 32, 33, 37, 38, 40, 41, 44, 45, 47, 48, 51, 52};
150 MED_EN::medGeometryElement sideTypes[2]={MED_EN::MED_QUAD4, MED_EN::MED_POLYGON };
151 int sideIndex[3]={1,13,25};
152 int sideNbOfElts[2]={12,12};
154 using namespace MEDMEM;
156 static void addMedFacesGroup( MESHING& meshing, int nFaces, const int *groupValue,
157 string groupName, const MED_EN::medGeometryElement *mytypes, const int *index, const int *myNumberOfElements, int nbOfGeomTypes)
159 GROUP *faces=new GROUP;
160 faces->setName(groupName) ;
161 faces->setMesh(&meshing) ;
162 faces->setEntity(MED_EN::MED_FACE) ;
163 faces->setNumberOfGeometricType(nbOfGeomTypes) ;
164 faces->setGeometricType(mytypes);
165 faces->setNumberOfElements(myNumberOfElements) ;
166 faces->setNumber(index, groupValue) ;
167 meshing.addGroup(*faces) ;
168 faces->removeReference();
173 MESHING* meshing = new MESHING;
174 meshing->setName( "TESTMESH" );
176 meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",
177 MED_EN::MED_NO_INTERLACE);
178 string coordname[3] = { "x", "y", "z" };
179 meshing->setCoordinatesNames(coordname);
180 string coordunit[3] = { "m", "m", "m" };
181 meshing->setCoordinatesUnits(coordunit);
182 //Cell connectivity info for classical elts
183 const MED_EN::medGeometryElement classicalTypesCell[2]={MED_EN::MED_HEXA8,MED_EN::MED_POLYHEDRA};
184 const int nbOfCellElts[2]={6,6};
185 meshing->setNumberOfTypes(2,MED_EN::MED_CELL);
186 meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL);
187 meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL);
188 //Face connectivity info for classical elts
189 const MED_EN::medGeometryElement classicalTypesFace[2]={MED_EN::MED_QUAD4,MED_EN::MED_POLYGON};
190 const int nbOfFaceElts[2]={29,23};
191 meshing->setNumberOfTypes(2,MED_EN::MED_FACE);
192 meshing->setTypes(classicalTypesFace,MED_EN::MED_FACE);
193 meshing->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE);
195 meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,connNodalCellClassical);
196 meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA,polyHedraConn,polyHedraInd);
198 meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_QUAD4,connNodalFaceClassical);
199 meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_POLYGON, cpolygonsValue,cpolygonsIndex);
200 //Adding some groups on faces
201 addMedFacesGroup( *meshing, 4, bottom, "BottomFaces",bottomTypes,bottomIndex,bottomNbOfElts,2) ;
202 addMedFacesGroup( *meshing, 4, top, "TopFaces",topTypes,topIndex,topNbOfElts,2) ;
203 addMedFacesGroup( *meshing, 24, side, "SideFaces",sideTypes,sideIndex,sideNbOfElts,2) ;
205 string medfile = "/tmp";
206 if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 )
207 medfile=getenv("TMP");
208 else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 )
209 medfile=getenv("TMPDIR");
210 medfile += "/totoFlica_V22.med";
212 int id=meshing->addDriver(MED_DRIVER,medfile.c_str());
214 meshing->removeReference();
216 if ( getenv("srcdir") )
217 remove(medfile.c_str());