test23.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 /******************************************************************************
00020  * - Nom du fichier : test23.c
00021  *
00022  * - Description : ecriture de mailles/faces de type MED_POLYGONE
00023  *                 dans un maillage MED
00024  *
00025  *****************************************************************************/
00026 
00027 #include <med.h>
00028 #define MESGERR 1
00029 #include <med_utils.h>
00030 
00031 #ifdef DEF_LECT_ECR
00032 #define MODE_ACCES MED_ACC_RDWR
00033 #elif DEF_LECT_AJOUT
00034 #define MODE_ACCES MED_ACC_RDEXT
00035 #else
00036 #define MODE_ACCES MED_ACC_CREAT
00037 #endif
00038 
00039 int main (int argc, char **argv)
00040 
00041 
00042 {
00043   med_idt fid;
00044   char maa[MED_NAME_SIZE+1] = "maa1";
00045   med_int mdim = 3;
00046   med_int index[4] = {1,6,12,17};
00047   med_int con[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
00048   med_int n=3,ni = 4;
00049   /*                            123456789012345612345678901234561234567890123456 */
00050   char nom[MED_SNAME_SIZE*3+1]="poly1           poly2           poly3           ";
00051   med_int num[3] = {1,2,3};
00052   med_int fam[3] = {0,-1,-2};
00053   char nomcoo[3*MED_SNAME_SIZE+1] = "x               y               z               ";
00054   char unicoo[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
00055 
00056   /* Creation du fichier test23.med */
00057   fid = MEDfileOpen("test23.med",MODE_ACCES);
00058   if (fid == -1) {
00059     MESSAGE("Erreur a la creation du fichier test23.med");
00060     return -1;
00061   }
00062   printf("Creation du fichier test23.med \n");
00063 
00064   /* Creation du maillage */
00065   if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
00066                  "un maillage pour test23","s", MED_SORT_DTIT,
00067                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
00068     MESSAGE("Erreur a la creation du maillage");
00069     return -1;
00070   }
00071   printf("Creation du maillage \n");
00072 
00073 
00074   /* Ecriture de la connectivite des mailles polygones en mode nodal */
00075   if (MEDmeshPolygonWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MED_CELL,MED_NODAL,
00076                        ni,index,con) < 0) {
00077     MESSAGE("Erreur a l'ecriture de la connectivite des mailles MED_POLYGONE");
00078     return -1;
00079   }
00080   printf("Ecriture des connectivites de mailles de type MED_POLYGONE en mode nodal \n");
00081 
00082   /* Ecriture des noms des polygones */
00083   /* ecriture (optionnelle) des noms des polygones */
00084   if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
00085                           MED_CELL,MED_POLYGON,n,nom) < 0) {
00086     MESSAGE("Erreur a l'ecriture des noms des polygones");
00087     return -1;
00088   }
00089   printf("Ecriture des noms des polygones \n");
00090 
00091   /* ecriture (optionnelle) des numeros des polygones */
00092   if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00093                             MED_CELL,MED_POLYGON,n,num) < 0) {
00094     MESSAGE("Erreur a l'ecriture des numeros des polygones");
00095     return -1;
00096   }
00097   printf("Ecriture des numeros des polygones \n");
00098 
00099   /* ecriture des numeros des familles des polygones */
00100   if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00101                                   MED_CELL,MED_POLYGON,n,fam) < 0) {
00102     MESSAGE("Erreur a l'ecriture des numeros de familles des polygones");
00103     return -1;
00104   }
00105   printf("Ecriture des numeros des familles des polygones \n");
00106 
00107   /* Fermeture du fichier */
00108   if (MEDfileClose(fid) < 0) {
00109     MESSAGE("Erreur a la fermeture du fichier");
00110     return -1;
00111   }
00112   printf("Fermeture du fichier test23.med \n");
00113 
00114   return 0;
00115 }

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1