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.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";
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
94 char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 ";
95 med_int numseg2[6] = {1,2,3,4,5,6};
96 med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2};
98 char nomfam[MED_TAILLE_NOM+1];
100 char attdes[MED_TAILLE_DESC+1];
105 char gro[MED_TAILLE_LNOM+1];
111 Some fields : 2 on nodes : one int and one double , one on cells : double
113 char champ1[MED_TAILLE_NOM+1]="fieldnodeint" ;
114 char champ1_comp[MED_TAILLE_PNOM+1]="comp1 " ;
115 char champ1_unit[MED_TAILLE_PNOM+1]="M " ;
116 med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5};
118 char champ2[MED_TAILLE_NOM+1]="fieldnodedouble" ;
119 char champ2_comp[MED_TAILLE_PNOM+1]="comp1 " ;
120 char champ2_unit[MED_TAILLE_PNOM+1]="J " ;
121 med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.};
122 med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.};
124 char champ3[MED_TAILLE_NOM+1]="fieldcelldouble" ;
125 char champ3_comp[MED_TAILLE_PNOM*2+1]="comp1 comp2 " ;
126 char champ3_unit[MED_TAILLE_PNOM*2+1]="M/S m/s " ;
127 med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.};
129 /***************************************************************************/
130 fid = MEDouvrir("carre_en_quad4_seg2.med",MED_REMP);
137 /***************************************************************************/
139 ret = MEDmaaCr(fid,maa,mdim);
142 ret = MEDunvCr(fid,maa);
145 /***************************************************************************/
147 ret = MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART,
148 nomcoo,unicoo,nomnoe,MED_FAUX,numnoe,MED_VRAI,
149 nufano,nnoe,MED_ECRI);
152 /* ecriture des mailles MED_QUAD4 :
155 - numeros (optionnel)
156 - numeros des familles */
158 ret = MEDelementsEcr(fid,maa,mdim,quad4,MED_FULL_INTERLACE,
159 nomquad4,MED_FAUX,numquad4,MED_VRAI,nufaquad4,nquad4,
160 MED_MAILLE,MED_QUAD4,MED_NOD,MED_ECRI);
163 /* ecriture des mailles MED_SEG2 :
166 - numeros (optionnel)
167 - numeros des familles */
169 ret = MEDelementsEcr(fid,maa,mdim,seg2,MED_FULL_INTERLACE,
170 nomseg2,MED_FAUX,numseg2,MED_VRAI,nufaseg2,nseg2,
171 MED_ARETE,MED_SEG2,MED_NOD,MED_ECRI);
174 /***************************************************************************/
175 /* ecriture des familles */
177 - toujours creer une famille de numero 0 ne comportant aucun attribut
178 ni groupe (famille de reference pour les noeuds ou les elements
179 qui ne sont rattaches a aucun groupe ni attribut)
180 - les numeros de familles de noeuds sont > 0
181 - les numeros de familles des elements sont < 0
182 - rien d'imposer sur les noms de familles
188 strcpy(nomfam,"FAMILLE_0");
190 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0,
196 - 1 familles d'elements de dimension (d-1)
198 - 1 familles d'elements de dimension (d-1)
200 - 1 familles d'elements de dimension (d)
201 en fait de face (-10)
207 strcpy(nomfam,"FAMILLE_EDGE_");
208 sprintf(nomfam,"%s%d",nomfam,-numfam);
212 strcpy(attdes,"description attribut");
213 strcpy(gro,"groupe1");
216 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
218 printf("MEDfamCr : %d\n",ret);
223 strcpy(nomfam,"FAMILLE_EDGE_");
224 sprintf(nomfam,"%s%d",nomfam,-numfam);
228 strcpy(attdes,"description attribut");
229 strcpy(gro,"groupe1");
232 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
234 printf("MEDfamCr : %d\n",ret);
239 strcpy(nomfam,"FAMILLE_CELL_");
240 sprintf(nomfam,"%s%d",nomfam,-numfam);
244 strcpy(attdes,"description attribut");
245 strcpy(gro,"groupe0");
248 ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,
250 printf("MEDfamCr : %d\n",ret);
252 /***************************************************************************/
258 ret = MEDchampCr(fid,champ1,MED_INT32,champ1_comp,champ1_unit,1);
259 printf("MEDchampCr : %d \n",ret);
261 ret = MEDchampEcr(fid, maa, champ1, (unsigned char *)fieldnodeint,
262 MED_NO_INTERLACE, nnoe,
263 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
264 0, MED_NOPDT," ", 0., MED_NONOR);
266 printf("MEDchampEcr : %d \n",ret);
272 ret = MEDchampCr(fid,champ2,MED_REEL64,champ2_comp,champ2_unit,1);
273 printf("MEDchampCr : %d \n",ret);
275 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
276 MED_NO_INTERLACE, nnoe,
277 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
278 0, 1,"S ", 1.1 , MED_NONOR);
279 printf("MEDchampEcr1 : %d \n",ret);
280 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble2,
281 MED_NO_INTERLACE, nnoe,
282 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
283 0, 2,"S ", 1.2 , MED_NONOR);
284 printf("MEDchampEcr2 : %d \n",ret);
288 // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !
291 ret = MEDchampEcr(fid, maa, champ2, (unsigned char *)fieldnodedouble1,
292 MED_NO_INTERLACE, nnoe,
293 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD,
294 0, MED_NOPDT," ", 0. , MED_NONOR);
295 printf("MEDchampEcr : %d \n",ret);
300 ret = MEDchampCr(fid,champ3,MED_REEL64,champ3_comp,champ3_unit,2);
301 printf("MEDchampCr : %d \n",ret);
303 ret = MEDchampEcr(fid, maa, champ3, (unsigned char *)fieldcelldouble,
304 MED_NO_INTERLACE, nquad4,
305 MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE,
306 MED_QUAD4, MED_NOPDT," ", 0., MED_NONOR);
307 printf("MEDchampEcr : %d \n",ret);
311 /***************************************************************************/
313 ret = MEDfermer(fid);