2 creation d'une geometrie 3d : un cube [0,1]^3
3 maillé uniformement en hexahedres reguliers;
4 avec en plus une partie des faces (une partie
5 des faces de la frontiere) du maillage.
6 ATTENTION : 3 noeuds dans chaque direction
12 int main (int argc, char **argv)
16 char maa[MED_TAILLE_NOM+1] = "CUBE_EN_HEXA8_QUAD4_WRONG";
51 char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z ";
52 char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm ";
53 /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
55 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};
56 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};
62 4, 13, 14, 5, 1, 10, 11, 2,
63 5, 14, 15, 6, 2, 11, 12, 3,
64 7, 16, 17, 8, 4, 13, 14, 5,
65 8, 17, 18, 9, 5, 14, 15, 6,
66 13, 22, 23, 14, 10, 19, 20, 11,
67 14, 23, 24, 15, 11, 20, 21, 12,
68 16, 25, 26, 17, 13, 22, 23, 14,
69 17, 26, 27, 18, 14, 23, 24, 15
71 char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 ";
72 med_int numhexa8[8] = {1,2,3,4,5,6,7,8};
73 med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2};
76 Les Faces qui dans ce cas (2D) sont des arretes
78 a face is wrongly oriented, it is just to test the applidation
95 char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 ";
96 med_int numquad4[8] = {1,2,3,4,5,6,7,8};
97 med_int nufaquad4[8] = {-3,-3,-3,-3,-4, -4, -4 , -4};
99 char nomfam[MED_TAILLE_NOM+1];
101 char attdes[MED_TAILLE_DESC+1];
106 char gro[MED_TAILLE_LNOM+1];
113 Some fields : 2 on nodes : one int and one double , one on cells : double
116 char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
117 char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
118 char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
119 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};
121 char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
122 char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
123 char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
124 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.};
125 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.};
127 char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
128 char champ3_comp[MED_TAILLE_PNOM*3+1]="comp1 comp2 comp3 " ;
129 char champ3_unit[MED_TAILLE_PNOM*3+1]="M/S m/s m/s " ;
130 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.};
132 /***************************************************************************/
133 fid = MEDouvrir("cube_hexa8_quad4_wrong.med",MED_REMP);
140 /***************************************************************************/
142 ret = MEDmaaCr(fid,maa,mdim);
145 ret = MEDunvCr(fid,maa);
148 /***************************************************************************/
150 ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
151 nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
152 nufano,nnoe,MED_ECRI);
155 /* ecriture des mailles MED_HEXA8 :
158 - numeros (optionnel)
159 - numeros des familles */
161 ret = MEDelementsEcr(fid,maa,mdim,hexa8,MED_FULL_INTERLACE,
162 nomhexa8,MED_FAUX,numhexa8,MED_VRAI,nufahexa8,nhexa8,
163 MED_MAILLE,MED_HEXA8,MED_NOD,MED_ECRI);
166 /* ecriture des mailles MED_QUAD4 :
169 - numeros (optionnel)
170 - numeros des familles */
172 ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
173 nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
174 MED_FACE,MED_QUAD4,MED_NOD,MED_ECRI);
177 /***************************************************************************/
178 /* ecriture des familles */
180 - toujours creer une famille de numero 0 ne comportant aucun attribut
181 ni groupe (famille de reference pour les noeuds ou les elements
182 qui ne sont rattaches a aucun groupe ni attribut)
183 - les numeros de familles de noeuds sont > 0
184 - les numeros de familles des elements sont < 0
185 - rien d'imposer sur les noms de familles
191 strcpy(nomfam,"FAMILLE_0");
193 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
199 - 2 familles d'elements (-1,-2) et
200 - 3 familles de noeuds (1,2,3)
201 - 1 famille(s) d'elements de dimension (d-1)
208 for (i=0;i<nfame;i++)
212 strcpy(nomfam,"FAMILLE_ELEMENT_");
214 sprintf(nomfam,"%s%d",nomfam,-numfam);
218 strcpy(attdes,"description attribut");
219 strcpy(gro,"groupe1");
222 /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
224 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
226 printf("MEDfamCr : %d\n",ret);
234 for (i=0;i<nfamn;i++)
238 strcpy(nomfam,"FAMILLE_NOEUD_");
240 sprintf(nomfam,"%s%d",nomfam,numfam);
244 strcpy(attdes,"description attribut");
245 strcpy(gro,"groupe2");
247 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
249 printf("MEDfamCr : %d\n",ret);
257 for (i=0;i<nfamf;i++)
261 strcpy(nomfam,"FAMILLE_FACE_");
263 sprintf(nomfam,"%s%d",nomfam,-numfam);
267 strcpy(attdes,"description attribut");
268 strcpy(gro,"groupe3");
270 /*printf("nomfam : %s - numfam : %d - attide : %d - attval : %d - ngro : %d \n",nomfam,numfam,attide,attval,ngro);*/
271 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
273 printf("MEDfamCr : %d\n",ret);
278 /***************************************************************************/
284 ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
285 printf("MEDchampCr : %d \n",ret);
287 ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
288 MED_FULL_INTERLACE, nnoe,
289 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
290 0, MED_NOPDT," ", 0., MED_NONOR);
292 printf("MEDchampEcr : %d \n",ret);
298 ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
299 printf("MEDchampCr : %d \n",ret);
301 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
302 MED_FULL_INTERLACE, nnoe,
303 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
304 0, 1,"S ", 1.1 , MED_NONOR);
305 printf("MEDchampEcr1 : %d \n",ret);
306 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
307 MED_FULL_INTERLACE, nnoe,
308 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
309 0, 2,"S ", 1.2 , MED_NONOR);
310 printf("MEDchampEcr2 : %d \n",ret);
314 /* on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !*/
317 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
318 MED_FULL_INTERLACE, nnoe,
319 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
320 0, MED_NOPDT," ", 0. , MED_NONOR);
321 printf("MEDchampEcr : %d \n",ret);
326 ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,3);
327 printf("MEDchampCr : %d \n",ret);
329 ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
330 MED_FULL_INTERLACE, nhexa8,
331 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
332 MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR);
333 printf("MEDchampEcr : %d \n",ret);
337 /***************************************************************************/
339 ret = MEDfermer(fid);