test25.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 : test25.c
00021  *
00022  * - Description : ecriture de mailles de type MED_POLYEDRE
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 n=2;
00047   /* connectivite nodale */
00048   med_int indexf[3] = {1,5,9};
00049   med_int nf = 3;
00050   med_int indexn[9] = {1,4,7,10,13,16,19,22,25};
00051   med_int nn = 9;
00052   med_int conn[24] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
00053                       20,21,22,23,24};
00054   /* connectivite descendante */
00055   med_int indexf2[3] = {1,5,9};
00056   med_int nf2 = 3;
00057   med_int conn2[8] = {1,2,3,4,5,6,7,8};
00058   med_int indexn2[8] = {MED_TRIA3,MED_TRIA3,MED_TRIA3,MED_TRIA3,
00059                         MED_TRIA3,MED_TRIA3,MED_TRIA3,MED_TRIA3};
00060   med_int nn2=8;
00061   /*                             12345678901234561234567890123456*/
00062   char nom[MED_SNAME_SIZE*2+1]="polyedre1       polyedre2       ";
00063   med_int num[2] = {1,2};
00064   med_int fam[2] = {0,-1};
00065   char nomcoo[3*MED_SNAME_SIZE+1] = "x               y               z               ";
00066   char unicoo[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
00067 
00068   /* Creation du fichier test25.med */
00069   if ((fid = MEDfileOpen("test25.med",MODE_ACCES)) < 0) {
00070     MESSAGE("Erreur a la creation du fichier test25.med");
00071     return -1;
00072   }
00073   printf("Creation du fichier test25.med \n");
00074 
00075   /* Creation du maillage */
00076  if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
00077                  "un maillage pour test25","s", MED_SORT_DTIT,
00078                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
00079     MESSAGE("Erreur a la creation du maillage");
00080     return -1;
00081    }
00082   printf("Creation du maillage \n");
00083 
00084   /* Ecriture de la connectivite des mailles polyedres en mode nodal */
00085   if (MEDmeshPolyhedronWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MED_CELL,MED_NODAL,
00086                           nf,indexf,nn,indexn,conn) < 0) {
00087     MESSAGE("Erreur a l'ecriture de la connectivite des mailles MED_POLYGONE");
00088     return -1;
00089   }
00090   printf("Ecriture des connectivites de mailles de type MED_POLYEDRE en mode nodal \n");
00091 
00092   /* Ecriture des connectivites des mailles polyedres en mode descendant */
00093   if (MEDmeshPolyhedronWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MED_CELL,MED_DESCENDING,
00094                           nf2,indexf2,nn2,indexn2,conn2) < 0) {
00095     MESSAGE("Erreur a l'ecriture des connectivites des mailles MED_POLYEDRE en mode descendant");
00096     return -1;
00097   }
00098   printf("Ecriture des connectivites de mailles de type MED_POLYEDRE en mode descendant \n"); 
00099 
00100 
00101   /* Ecriture des noms des polyedres */
00102   /* ecriture (optionnelle) des noms des polyedres */
00103   if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
00104                           MED_CELL,MED_POLYHEDRON,n,nom) < 0) {
00105     MESSAGE("Erreur a l'ecriture des noms des polyedres");
00106     return -1;
00107   }
00108   printf("Ecriture des noms des polyedres \n");
00109 
00110   /* ecriture (optionnelle) des numeros des polyedres */
00111   if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00112                             MED_CELL,MED_POLYHEDRON,n,num) < 0) {
00113     MESSAGE("Erreur a l'ecriture des numeros des polyedres");
00114     return -1;
00115   }
00116   printf("Ecriture des numeros des polyedres \n");
00117 
00118   /* ecriture des numeros des familles des polyedres */
00119   if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00120                                   MED_CELL,MED_POLYHEDRON,n,fam) < 0) {
00121     MESSAGE("Erreur a l'ecriture des numeros de familles des polyedres");
00122     return -1;
00123   }
00124   printf("Ecriture des numeros des familles des polyedres \n");
00125 
00126   /* Fermeture du fichier */
00127   if (MEDfileClose(fid) < 0) {
00128     MESSAGE("Erreur a la fermeture du fichier");
00129     return -1;
00130   }
00131   printf("Fermeture du fichier test25.med \n");
00132 
00133   return 0; 
00134 }

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