1 // Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
2 // PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 creation d'une geometrie 2d :
21 maillé en 4 quadrangles reguliers
22 1 triangle et 1 polygone.
29 int main (int argc, char **argv)
33 char maa[MED_TAILLE_NOM+1] = "poly2D";
34 char maadesc[MED_TAILLE_DESC+1] = "Example de maillage non structure 2D avec 1 polygone";
53 char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
54 char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
55 /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
57 med_int numnoe[11] = {1,2,3,4,5,6,7,8,9,10,11};
58 med_int nufano[11] = {0,0,0,0,0,0,0,0,0,0,0};
69 char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";
70 med_int numquad4[4] = {1,2,3,4};
71 med_int nufaquad4[4] = {-1,-1,0,0};
77 char nomtria3[MED_TAILLE_PNOM+1] = "tria1 ";
78 med_int numtria3[1] = {1};
79 med_int nufatria3[1] = {-2};
82 med_int nindexpoly = 2;
83 med_int indexpoly [2] = {
89 char nompoly[MED_TAILLE_PNOM+1] = "poly ";
90 med_int numpoly[1] = {1};
91 med_int nufapoly[1] = {-3};
93 char nomfam[MED_TAILLE_NOM+1];
95 char attdes[MED_TAILLE_DESC+1];
100 char gro[MED_TAILLE_LNOM+1];
106 Some fields : 2 on nodes : one int and one double , one on cells : double
108 char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
109 char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
110 char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
111 med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5};
113 char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
114 char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
115 char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
116 med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
117 med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
119 char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
120 char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
121 char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
122 med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
124 /***************************************************************************/
125 fid = MEDouvrir("poly2D.med",MED_LECTURE_ECRITURE);
130 printf("MEDouvrir : %d\n",ret);
132 /***************************************************************************/
134 ret = MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,maadesc);
135 printf("MEDmaaCr : %d\n",ret);
137 ret = MEDunvCr(fid,maa);
138 printf("MEDunvCr : %d\n",ret);
140 /***************************************************************************/
142 ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
143 nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
145 printf("MEDnoeudsEcr : %d\n",ret);
147 /* ecriture des mailles MED_QUAD4 :
150 - numeros (optionnel)
151 - numeros des familles */
153 ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
154 nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
155 MED_MAILLE,MED_QUAD4,MED_NOD);
156 printf("MEDelementsEcr for quad : %d \n",ret);
158 /* ecriture des mailles MED_TRIA3 :
161 - numeros (optionnel)
162 - numeros des familles */
164 ret = MEDelementsEcr(fid,maa,mdim,tria3,MED_FULL_INTERLACE,
165 nomtria3,MED_FAUX,numtria3,MED_VRAI,nufatria3,ntria3,
166 MED_MAILLE,MED_TRIA3,MED_NOD);
167 printf("MEDelementsEcr for tria : %d \n",ret);
169 /* ecriture des mailles MED_POLYGONE:
172 - numeros (optionnel)
173 - numeros des familles
174 Dans ce cas il n existe pas de routine globale (Warning !!)
178 ret = MEDpolygoneConnEcr(fid,maa,indexpoly,nindexpoly,poly,
180 printf("MEDpolygoneConnEcr: %d \n",ret);
183 MEDnomEcr(fid,maa,nompoly,npoly,MED_MAILLE,MED_POLYGONE);
184 printf("MEDnomEcr for poly : %d \n",ret);
187 MEDnumEcr(fid,maa,numpoly,npoly,MED_MAILLE,MED_POLYGONE);
188 printf("MEDnumEcr for poly : %d \n",ret);
191 MEDfamEcr(fid,maa,nufapoly,npoly,MED_MAILLE,MED_POLYGONE);
192 printf("MEDfamEcr for poly : %d \n",ret);
195 /***************************************************************************/
196 /* ecriture des familles */
198 - toujours creer une famille de numero 0 ne comportant aucun attribut
199 ni groupe (famille de reference pour les noeuds ou les elements
200 qui ne sont rattaches a aucun groupe ni attribut)
201 - les numeros de familles de noeuds sont > 0
202 - les numeros de familles des elements sont < 0
203 - rien d'imposer sur les noms de familles
209 strcpy(nomfam,"FAMILLE_0");
211 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
214 printf("MEDfamCr : %d \n",ret);
217 - 2 familles d'elements de dimension (d)
218 en fait de face (-10)
223 strcpy(nomfam,"FAMILLE_CELL_");
224 sprintf(nomfam,"%s%d",nomfam,-numfam);
228 strcpy(attdes,"description attribut");
229 strcpy(gro,"groupe0");
232 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
234 printf("MEDfamCr : %d\n",ret);
237 strcpy(nomfam,"FAMILLE_CELL_");
238 sprintf(nomfam,"%s%d",nomfam,-numfam);
242 strcpy(attdes,"description attribut");
243 strcpy(gro,"groupe0");
246 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
248 printf("MEDfamCr : %d\n",ret);
251 strcpy(nomfam,"FAMILLE_CELL_");
252 sprintf(nomfam,"%s%d",nomfam,-numfam);
256 strcpy(attdes,"description attribut");
257 strcpy(gro,"groupe0");
260 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
262 printf("MEDfamCr : %d\n",ret);
265 /***************************************************************************/
271 ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
272 printf("MEDchampCr : %d \n",ret);
274 ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
275 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
276 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
277 MED_NOPDT," ", 0., MED_NONOR);
279 printf("MEDchampEcr : %d \n",ret);
285 ret = MEDchampCr(fid,champ2,MED_FLOAT64,champ2_comp,champ2_unit,1);
286 printf("MEDchampCr : %d \n",ret);
288 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
289 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
290 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
291 1,"S ", 1.1 , MED_NONOR);
292 printf("MEDchampEcr1 : %d \n",ret);
293 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
294 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
295 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
296 2,"S ", 1.2 , MED_NONOR);
297 printf("MEDchampEcr2 : %d \n",ret);
301 // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
304 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
305 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
306 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
307 MED_NOPDT," ", 0. , MED_NONOR);
308 printf("MEDchampEcr : %d \n",ret);
313 ret = MEDchampCr(fid,champ3,MED_FLOAT64,champ3_comp,champ3_unit,2);
314 printf("MEDchampCr : %d \n",ret);
316 ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
317 MED_NO_INTERLACE, nquad4, MED_NOGAUSS, MED_ALL,
318 MED_NOPFL, MED_NO_PFLMOD, MED_MAILLE, MED_QUAD4,
319 MED_NOPDT," ", 0., MED_NONOR);
320 printf("MEDchampEcr : %d \n",ret);
324 /***************************************************************************/
326 ret = MEDfermer(fid);
327 printf("MEDfermer : %d\n",ret);