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
22 #include "MEDMEM_Meshing.hxx"
23 #include "MEDMEM_Group.hxx"
26 using namespace MEDMEM;
27 using namespace MED_EN;
29 static void addMedFacesGroup (MESHING& meshing, int nFaces, int *groupValue, string groupName)
31 GROUP *faces=new GROUP;
32 int myNumberOfElements[1];
33 medGeometryElement mytypes[1];
35 faces->setName(groupName);
36 faces->setMesh(&meshing);
37 faces->setEntity(MED_EN::MED_FACE);
38 faces->setNumberOfGeometricType(1);
39 mytypes[0] = MED_EN::MED_POLYGON;
40 faces->setGeometricType(mytypes);
41 myNumberOfElements[0] = nFaces;
42 faces->setNumberOfElements(myNumberOfElements);
45 faces->setNumber(index, groupValue);
46 meshing.addGroup(*faces);
47 faces->removeReference();
52 MESHING *pmesh = new MESHING;
53 pmesh->setName( "C2MESH" );
54 pmesh->setNumberOfTypes(0, MED_EN::MED_CELL);
55 const int nb_hexagone = 7;
56 const int nbmailles_axiales = 2;
57 const int nb_polyH = nb_hexagone*(nbmailles_axiales-1);
58 const int nb_polyG = nb_hexagone*nbmailles_axiales;
59 const int nNodes = 6 * nb_hexagone * nbmailles_axiales;
62 44.401823743922364, 0 , 0, 55.698259110886582, 6.5220000000000002, 0,
63 55.698259110886582, 19.566000000000003, 0, 44.401823743922364, 26.088000000000001, 0,
64 33.105388376958146, 19.566000000000003, 0, 33.105388376958146, 6.5220000000000002, 0,
65 66.9946944778508 , 0 , 0, 78.291129844815018, 6.5220000000000002, 0,
66 78.291129844815018, 19.566000000000003, 0, 66.9946944778508 , 26.088000000000001, 0,
67 55.698259110886582, 19.566000000000003, 0, 55.698259110886582, 6.5220000000000002, 0,
68 33.105388376958146, 19.565999999999999, 0, 44.401823743922364, 26.088000000000001, 0,
69 44.401823743922364, 39.131999999999998, 0, 33.105388376958146, 45.653999999999996, 0,
70 21.808953009993928, 39.131999999999998, 0, 21.808953009993928, 26.088000000000001, 0,
71 55.698259110886582, 19.565999999999999, 0, 66.9946944778508 , 26.088000000000001, 0,
72 66.9946944778508 , 39.131999999999998, 0, 55.698259110886582, 45.653999999999996, 0,
73 44.401823743922364, 39.131999999999998, 0, 44.401823743922364, 26.088000000000001, 0,
74 78.291129844815018, 19.565999999999999, 0, 89.587565211779236, 26.088000000000001, 0,
75 89.587565211779236, 39.131999999999998, 0, 78.291129844815018, 45.653999999999996, 0,
76 66.9946944778508 , 39.131999999999998, 0, 66.9946944778508 , 26.088000000000001, 0,
77 44.401823743922364, 39.132000000000005, 0, 55.698259110886582, 45.654000000000003, 0,
78 55.698259110886582, 58.698 , 0, 44.401823743922364, 65.219999999999999, 0,
79 33.105388376958146, 58.698 , 0, 33.105388376958146, 45.654000000000003, 0,
80 66.9946944778508 , 39.132000000000005, 0, 78.291129844815018, 45.654000000000003, 0,
81 78.291129844815018, 58.698 , 0, 66.9946944778508 , 65.219999999999999, 0,
82 55.698259110886582, 58.698 , 0, 55.698259110886582, 45.654000000000003, 0,
83 44.401823743922364, 0 , 1, 55.698259110886582, 6.5220000000000002, 1,
84 55.698259110886582, 19.566000000000003, 1, 44.401823743922364, 26.088000000000001, 1,
85 33.105388376958146, 19.566000000000003, 1, 33.105388376958146, 6.5220000000000002, 1,
86 66.9946944778508 , 0 , 1, 78.291129844815018, 6.5220000000000002, 1,
87 78.291129844815018, 19.566000000000003, 1, 66.9946944778508 , 26.088000000000001, 1,
88 55.698259110886582, 19.566000000000003, 1, 55.698259110886582, 6.5220000000000002, 1,
89 33.105388376958146, 19.565999999999999, 1, 44.401823743922364, 26.088000000000001, 1,
90 44.401823743922364, 39.131999999999998, 1, 33.105388376958146, 45.653999999999996, 1,
91 21.808953009993928, 39.131999999999998, 1, 21.808953009993928, 26.088000000000001, 1,
92 55.698259110886582, 19.565999999999999, 1, 66.9946944778508 , 26.088000000000001, 1,
93 66.9946944778508 , 39.131999999999998, 1, 55.698259110886582, 45.653999999999996, 1,
94 44.401823743922364, 39.131999999999998, 1, 44.401823743922364, 26.088000000000001, 1,
95 78.291129844815018, 19.565999999999999, 1, 89.587565211779236, 26.088000000000001, 1,
96 89.587565211779236, 39.131999999999998, 1, 78.291129844815018, 45.653999999999996, 1,
97 66.9946944778508 , 39.131999999999998, 1, 66.9946944778508 , 26.088000000000001, 1,
98 44.401823743922364, 39.132000000000005, 1, 55.698259110886582, 45.654000000000003, 1,
99 55.698259110886582, 58.698 , 1, 44.401823743922364, 65.219999999999999, 1,
100 33.105388376958146, 58.698 , 1, 33.105388376958146, 45.654000000000003, 1,
101 66.9946944778508 , 39.132000000000005, 1, 78.291129844815018, 45.654000000000003, 1,
102 78.291129844815018, 58.698 , 1, 66.9946944778508 , 65.219999999999999, 1,
103 55.698259110886582, 58.698 , 1, 55.698259110886582, 45.654000000000003, 1};
105 pmesh->setCoordinates(3, nNodes, coord, "CARTESIAN", MED_EN::MED_FULL_INTERLACE);
107 string coordname[3] = { "x", "y", "z" };
108 pmesh->setCoordinatesNames(coordname);
110 // Set coordinates units
111 string coordunit[3] = { "cm", "cm", "cm" };
112 pmesh->setCoordinatesUnits(coordunit);
114 const medGeometryElement types[] = { MED_EN::MED_POLYGON, MED_EN::MED_POLYHEDRA };
116 pmesh->setNumberOfTypes(1, MED_EN::MED_CELL);
117 pmesh->setTypes( & types[1], MED_EN::MED_CELL );
118 pmesh->setNumberOfElements( & nb_polyH, MED_CELL );
120 pmesh->setNumberOfTypes(1, MED_EN::MED_FACE);
121 pmesh->setTypes( & types[0], MED_EN::MED_FACE );
122 pmesh->setNumberOfElements( & nb_polyG, MED_FACE );
124 int polyHInd[nb_polyH+1] = {1, 44, 87, 130, 173, 216, 259, 302 };
125 int polyHConn[301] = {
126 1,2,3,4,5,6, -1, 43,44,45,46,47,48,-1, 1,2,44,43, -1, 2,3,45,44, -1,
127 3,4,46,45, -1, 4,5,47,46, -1, 5,6,48,47, -1, 6,1,43,48, // #1
128 7,8,9,10,3,2, -1, 49,50,51,52,45,44,-1, 7,8,50,49, -1, 8,9,51,50, -1,
129 9,10,52,51, -1, 10,3,45,52, -1, 3,2,44,45, -1, 2,7,49,44, // #2
130 5,4,15,16,17,18, -1, 47,46,57,58,59,60,-1, 5,4,46,47, -1, 4,15,57,46, -1,
131 15,16,58,57, -1, 16,17,59,58, -1, 17,18,60,59,-1, 18,5,47,60, // #3
132 3,10,21,22,15,4, -1, 45,52,63,64,57,46,-1, 3,10,52,45, -1, 10,21,63,52,-1,
133 21,22,64,63, -1, 22,15,57,64, -1, 15,4,46,57, -1, 4,3,45,46, // #4
134 9,26,27,28,21,10, -1, 51,68,69,70,63,52,-1, 9,26,68,51, -1, 26,27,69,68,-1,
135 27,28,70,69, -1, 28,21,63,70, -1, 21,10,52,63,-1, 10,9,51,52, // #5
136 15,22,33,34,35,16,-1, 57,64,75,76,77,58,-1, 15,22,64,57,-1, 22,33,75,64,-1,
137 33,34,76,75, -1, 34,35,77,76, -1, 35,16,58,77,-1, 16,15,57,58, // #6
138 21,28,39,40,33,22,-1, 63,70,81,82,75,64,-1, 21,28,70,63,-1, 28,39,81,70,-1,
139 39,40,82,81, -1, 40,33,75,82, -1, 33,22,64,75,-1, 22,21,63,64}; // #7
141 pmesh->setConnectivity(MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA, polyHConn, polyHInd);
143 int cpolygonsindex[nb_polyG+1] = {1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85};
145 1 , 2 , 3 , 4 , 5 , 6 ,
146 7 , 8 , 9 , 10, 3 , 2 ,
147 5 , 4 , 15, 16, 17, 18,
148 3 , 10, 21, 22, 15, 4 ,
149 9 , 26, 27, 28, 21, 10,
150 15, 22, 33, 34, 35, 16,
151 21, 28, 39, 40, 33, 22,
152 43, 44, 45, 46, 47, 48,
153 49, 50, 51, 52, 45, 44,
154 47, 46, 57, 58, 59, 60,
155 45, 52, 63, 64, 57, 46,
156 51, 68, 69, 70, 63, 52,
157 57, 64, 75, 76, 77, 58,
158 63, 70, 81, 82, 75, 64};
160 pmesh->setConnectivity(MED_EN::MED_FACE, MED_EN::MED_POLYGON,connec, cpolygonsindex);
162 int bottom[] = {1, 2, 3, 4, 5, 6, 7};
163 addMedFacesGroup(*pmesh, nb_hexagone, bottom, "BottomFaces");
165 int id = pmesh->addDriver(MED_DRIVER, "cronoshexa.med", pmesh->getName());
167 pmesh->removeReference();
169 if ( getenv("srcdir") )
170 /* we are in 'make check' */
171 remove( "cronoshexa.med" );