1 /*----------------------------------------------------------------------------
2 MED MEDMEM : MED files in memory
4 Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 File : create_mesh_c3h8q4_wrong.c
27 ----------------------------------------------------------------------------*/
30 creation d'une geometrie 3d : un cube [0,1]^3
31 maillé uniformement en hexahedres reguliers;
32 avec en plus une partie des faces (une partie
33 des faces de la frontiere) du maillage.
34 ATTENTION : 3 noeuds dans chaque direction
40 int main (int argc, char **argv)
44 char maa[MED_TAILLE_NOM+1] = "CUBE_EN_HEXA8_QUAD4_WRONG";
79 char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
80 char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
81 /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
83 med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27};
84 med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2};
90 4, 13, 14, 5, 1, 10, 11, 2,
91 5, 14, 15, 6, 2, 11, 12, 3,
92 7, 16, 17, 8, 4, 13, 14, 5,
93 8, 17, 18, 9, 5, 14, 15, 6,
94 13, 22, 23, 14, 10, 19, 20, 11,
95 14, 23, 24, 15, 11, 20, 21, 12,
96 16, 25, 26, 17, 13, 22, 23, 14,
97 17, 26, 27, 18, 14, 23, 24, 15
99 char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 ";
100 med_int numhexa8[8] = {1,2,3,4,5,6,7,8};
101 med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2};
104 Les Faces qui dans ce cas (2D) sont des arretes
106 a face is wrongly oriented, it is just to test the applidation
111 med_int quad4[32] = {
123 char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 ";
124 med_int numquad4[8] = {1,2,3,4,5,6,7,8};
125 med_int nufaquad4[8] = {-3,-3,-3,-3,-4, -4, -4 , -4};
127 char nomfam[MED_TAILLE_NOM+1];
129 char attdes[MED_TAILLE_DESC+1];
134 char gro[MED_TAILLE_LNOM+1];
141 Some fields : 2 on nodes : one int and one double , one on cells : double
144 char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
145 char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
146 char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
147 med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5};
149 char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
150 char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
151 char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
152 med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.};
153 med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.};
155 char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
156 char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
157 char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S m/s m/s " ;
158 med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.};
160 /***************************************************************************/
161 fid = MEDouvrir("cube_hexa8_quad4_wrong.med",MED_REMP);
168 /***************************************************************************/
170 ret = MEDmaaCr(fid,maa,mdim);
173 ret = MEDunvCr(fid,maa);
176 /***************************************************************************/
178 ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
179 nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
180 nufano,nnoe,MED_ECRI);
183 /* ecriture des mailles MED_HEXA8 :
186 - numeros (optionnel)
187 - numeros des familles */
189 ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
190 nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
191 MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
194 /* ecriture des mailles MED_QUAD4 :
197 - numeros (optionnel)
198 - numeros des familles */
200 ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
201 nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
202 MED_FACE,MED_QUAD4,MED_NOD,MED_ECRI);
205 /***************************************************************************/
206 /* ecriture des familles */
208 - toujours creer une famille de numero 0 ne comportant aucun attribut
209 ni groupe (famille de reference pour les noeuds ou les elements
210 qui ne sont rattaches a aucun groupe ni attribut)
211 - les numeros de familles de noeuds sont > 0
212 - les numeros de familles des elements sont < 0
213 - rien d'imposer sur les noms de familles
219 strcpy(nomfam,"FAMILLE_0");
221 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
227 - 2 familles d'elements (-1,-2) et
228 - 3 familles de noeuds (1,2,3)
229 - 1 famille(s) d'elements de dimension (d-1)
236 for (i=0;i<nfame;i++)
240 strcpy(nomfam,"FAMILLE_ELEMENT_");
242 sprintf(nomfam,"%s%d",nomfam,-numfam);
246 strcpy(attdes,"description attribut");
247 strcpy(gro,"groupe1");
250 /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
252 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
254 printf("MEDfamCr : %d\n",ret);
262 for (i=0;i<nfamn;i++)
266 strcpy(nomfam,"FAMILLE_NOEUD_");
268 sprintf(nomfam,"%s%d",nomfam,numfam);
272 strcpy(attdes,"description attribut");
273 strcpy(gro,"groupe2");
275 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
277 printf("MEDfamCr : %d\n",ret);
285 for (i=0;i<nfamf;i++)
289 strcpy(nomfam,"FAMILLE_FACE_");
291 sprintf(nomfam,"%s%d",nomfam,-numfam);
295 strcpy(attdes,"description attribut");
296 strcpy(gro,"groupe3");
298 /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
299 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
301 printf("MEDfamCr : %d\n",ret);
306 /***************************************************************************/
312 ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
313 printf("MEDchampCr : %d \n",ret);
315 ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
316 MED_FULL_INTERLACE, nnoe,
317 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
318 0, MED_NOPDT," ", 0., MED_NONOR);
320 printf("MEDchampEcr : %d \n",ret);
326 ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
327 printf("MEDchampCr : %d \n",ret);
329 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
330 MED_FULL_INTERLACE, nnoe,
331 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
332 0, 1,"S ", 1.1 , MED_NONOR);
333 printf("MEDchampEcr1 : %d \n",ret);
334 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
335 MED_FULL_INTERLACE, nnoe,
336 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
337 0, 2,"S ", 1.2 , MED_NONOR);
338 printf("MEDchampEcr2 : %d \n",ret);
342 // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
345 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
346 MED_FULL_INTERLACE, nnoe,
347 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
348 0, MED_NOPDT," ", 0. , MED_NONOR);
349 printf("MEDchampEcr : %d \n",ret);
354 ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,3);
355 printf("MEDchampCr : %d \n",ret);
357 ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
358 MED_FULL_INTERLACE, nhexa8,
359 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
360 MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
361 printf("MEDchampEcr : %d \n",ret);
365 /***************************************************************************/
367 ret = MEDfermer(fid);