00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
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   
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   
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   
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   
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   
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   
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   
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   
00102   
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   
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   
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   
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 }