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 : un cube [0,1]^2
21 maillé uniformement en quadrangle reguliers;
22 avec en plus une partie des aretes (une partie
23 des arretes de la frontiere) du maillage.
24 ATTENTION : 3 noeuds dans chaque direction
30 int main (int argc, char **argv)
34 char maa[MED_TAILLE_NOM+1] = "carre_en_quad4_seg2_wrong";
35 char maadesc[MED_TAILLE_DESC+1] = "Example de maillage non structure 2D";
52 char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
53 char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
54 /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
56 med_int numnoe[9] = {1,2,3,4,5,6,7,8,9};
57 med_int nufano[9] = {0,0,0,0,0,0,0,0,0};
68 char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";
69 med_int numquad4[4] = {1,2,3,4};
70 med_int nufaquad4[4] = {-10,-10,0,0};
73 Les Faces qui dans ce cas (2D) sont des arretes
75 a face is wrongly oriented, it is just to test the applidation
89 char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 ";
90 med_int numseg2[6] = {1,2,3,4,5,6};
91 med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2};
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("carre_en_quad4_seg2_wrong.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 : %d \n",ret);
158 /* ecriture des mailles MED_SEG2 :
161 - numeros (optionnel)
162 - numeros des familles */
164 ret = MEDelementsEcr(fid,maa,mdim,seg2,MED_FULL_INTERLACE,
165 nomseg2,MED_FAUX,numseg2,MED_VRAI,nufaseg2,nseg2,
166 MED_ARETE,MED_SEG2,MED_NOD);
167 printf("MEDelementsEcr : %d \n",ret);
169 /***************************************************************************/
170 /* ecriture des familles */
172 - toujours creer une famille de numero 0 ne comportant aucun attribut
173 ni groupe (famille de reference pour les noeuds ou les elements
174 qui ne sont rattaches a aucun groupe ni attribut)
175 - les numeros de familles de noeuds sont > 0
176 - les numeros de familles des elements sont < 0
177 - rien d'imposer sur les noms de familles
183 strcpy(nomfam,"FAMILLE_0");
185 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
191 - 1 familles d'elements de dimension (d-1)
193 - 1 familles d'elements de dimension (d-1)
195 - 1 familles d'elements de dimension (d)
196 en fait de face (-10)
202 strcpy(nomfam,"FAMILLE_EDGE_");
203 sprintf(nomfam,"%s%d",nomfam,-numfam);
207 strcpy(attdes,"description attribut");
208 strcpy(gro,"groupe1");
211 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
213 printf("MEDfamCr : %d\n",ret);
218 strcpy(nomfam,"FAMILLE_EDGE_");
219 sprintf(nomfam,"%s%d",nomfam,-numfam);
223 strcpy(attdes,"description attribut");
224 strcpy(gro,"groupe1");
227 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
229 printf("MEDfamCr : %d\n",ret);
234 strcpy(nomfam,"FAMILLE_CELL_");
235 sprintf(nomfam,"%s%d",nomfam,-numfam);
239 strcpy(attdes,"description attribut");
240 strcpy(gro,"groupe0");
243 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
245 printf("MEDfamCr : %d\n",ret);
247 /***************************************************************************/
253 ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
254 printf("MEDchampCr : %d \n",ret);
256 ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
257 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
258 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
259 MED_NOPDT," ", 0., MED_NONOR);
261 printf("MEDchampEcr : %d \n",ret);
267 ret = MEDchampCr(fid,champ2,MED_FLOAT64,champ2_comp,champ2_unit,1);
268 printf("MEDchampCr : %d \n",ret);
270 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
271 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
272 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
273 1,"S ", 1.1 , MED_NONOR);
274 printf("MEDchampEcr1 : %d \n",ret);
275 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
276 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
277 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
278 2,"S ", 1.2 , MED_NONOR);
279 printf("MEDchampEcr2 : %d \n",ret);
283 /* on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !*/
286 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
287 MED_NO_INTERLACE, nnoe, MED_NOGAUSS, MED_ALL,
288 MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
289 MED_NOPDT," ", 0. , MED_NONOR);
290 printf("MEDchampEcr : %d \n",ret);
295 ret = MEDchampCr(fid,champ3,MED_FLOAT64,champ3_comp,champ3_unit,2);
296 printf("MEDchampCr : %d \n",ret);
298 ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
299 MED_NO_INTERLACE, nquad4, MED_NOGAUSS, MED_ALL,
300 MED_NOPFL, MED_NO_PFLMOD, MED_MAILLE, MED_QUAD4,
301 MED_NOPDT," ", 0., MED_NONOR);
302 printf("MEDchampEcr : %d \n",ret);
306 /***************************************************************************/
308 ret = MEDfermer(fid);