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_c2q4s2_wrong.c
27 ----------------------------------------------------------------------------*/
30 creation d'une geometrie 2d : un cube [0,1]^2
31 maillé uniformement en quadrangle reguliers;
32 avec en plus une partie des aretes (une partie
33 des arretes 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] = "carre_en_quad4_seg2_wrong";
61 char nomcoo[2*MED_TAILLE_PNOM+1] = "x y ";
62 char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm ";
63 /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/
65 med_int numnoe[9] = {1,2,3,4,5,6,7,8,9};
66 med_int nufano[9] = {0,0,0,0,0,0,0,0,0};
77 char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";
78 med_int numquad4[4] = {1,2,3,4};
79 med_int nufaquad4[4] = {-10,-10,0,0};
82 Les Faces qui dans ce cas (2D) sont des arretes
84 a face is wrongly oriented, it is just to test the applidation
98 char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 ";
99 med_int numseg2[6] = {1,2,3,4,5,6};
100 med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2};
102 char nomfam[MED_TAILLE_NOM+1];
104 char attdes[MED_TAILLE_DESC+1];
109 char gro[MED_TAILLE_LNOM+1];
115 Some fields : 2 on nodes : one int and one double , one on cells : double
117 char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
118 char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
119 char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
120 med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5};
122 char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
123 char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
124 char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
125 med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
126 med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
128 char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
129 char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
130 char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
131 med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
133 /***************************************************************************/
134 fid = MEDouvrir("carre_en_quad4_seg2_wrong.med",MED_REMP);
141 /***************************************************************************/
143 ret = MEDmaaCr(fid,maa,mdim);
146 ret = MEDunvCr(fid,maa);
149 /***************************************************************************/
151 ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
152 nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
153 nufano,nnoe,MED_ECRI);
156 /* ecriture des mailles MED_QUAD4 :
159 - numeros (optionnel)
160 - numeros des familles */
162 ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
163 nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
164 MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
167 /* ecriture des mailles MED_SEG2 :
170 - numeros (optionnel)
171 - numeros des familles */
173 ret = MEDelementsEcr(fid,maa,mdim,seg2,MED_FULL_INTERLACE,
174 nomseg2,MED_FAUX,numseg2,MED_VRAI,nufaseg2,nseg2,
175 MED_ARETE,MED_SEG2,MED_NOD,MED_ECRI);
178 /***************************************************************************/
179 /* ecriture des familles */
181 - toujours creer une famille de numero 0 ne comportant aucun attribut
182 ni groupe (famille de reference pour les noeuds ou les elements
183 qui ne sont rattaches a aucun groupe ni attribut)
184 - les numeros de familles de noeuds sont > 0
185 - les numeros de familles des elements sont < 0
186 - rien d'imposer sur les noms de familles
192 strcpy(nomfam,"FAMILLE_0");
194 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
200 - 1 familles d'elements de dimension (d-1)
202 - 1 familles d'elements de dimension (d-1)
204 - 1 familles d'elements de dimension (d)
205 en fait de face (-10)
211 strcpy(nomfam,"FAMILLE_EDGE_");
212 sprintf(nomfam,"%s%d",nomfam,-numfam);
216 strcpy(attdes,"description attribut");
217 strcpy(gro,"groupe1");
220 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
222 printf("MEDfamCr : %d\n",ret);
227 strcpy(nomfam,"FAMILLE_EDGE_");
228 sprintf(nomfam,"%s%d",nomfam,-numfam);
232 strcpy(attdes,"description attribut");
233 strcpy(gro,"groupe1");
236 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
238 printf("MEDfamCr : %d\n",ret);
243 strcpy(nomfam,"FAMILLE_CELL_");
244 sprintf(nomfam,"%s%d",nomfam,-numfam);
248 strcpy(attdes,"description attribut");
249 strcpy(gro,"groupe0");
252 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
254 printf("MEDfamCr : %d\n",ret);
256 /***************************************************************************/
262 ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
263 printf("MEDchampCr : %d \n",ret);
265 ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
266 MED_NO_INTERLACE, nnoe,
267 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
268 0, MED_NOPDT," ", 0., MED_NONOR);
270 printf("MEDchampEcr : %d \n",ret);
276 ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
277 printf("MEDchampCr : %d \n",ret);
279 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
280 MED_NO_INTERLACE, nnoe,
281 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
282 0, 1,"S ", 1.1 , MED_NONOR);
283 printf("MEDchampEcr1 : %d \n",ret);
284 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
285 MED_NO_INTERLACE, nnoe,
286 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
287 0, 2,"S ", 1.2 , MED_NONOR);
288 printf("MEDchampEcr2 : %d \n",ret);
292 // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
295 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
296 MED_NO_INTERLACE, nnoe,
297 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
298 0, MED_NOPDT," ", 0. , MED_NONOR);
299 printf("MEDchampEcr : %d \n",ret);
304 ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,2);
305 printf("MEDchampCr : %d \n",ret);
307 ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
308 MED_NO_INTERLACE, nquad4,
309 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
310 MED_QUAD4, MED_NOPDT," ", 0., MED_NONOR);
311 printf("MEDchampEcr : %d \n",ret);
315 /***************************************************************************/
317 ret = MEDfermer(fid);