test6.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 : test6.c
00021  *
00022  * - Description : ecriture d'elements dans un maillage MED
00023  *
00024  *****************************************************************************/
00025 
00026 #include <med.h>
00027 #define MESGERR 1
00028 #include <med_utils.h>
00029 
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_ACC_RDWR
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_ACC_RDEXT
00034 #else
00035 #define MODE_ACCES MED_ACC_CREAT
00036 #endif
00037 
00038 int main (int argc, char **argv)
00039 
00040 
00041 {
00042   med_idt fid;
00043   med_int nse2 = 5;
00044   med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
00045   /*                                12345678901234561234567890123456123456789012345612345678901234561234567890123456*/
00046   char nomse2[MED_SNAME_SIZE*5+1]="se1             se2             se3             se4             se5             ";
00047   med_int numse2[5] = {1,2,3,4,5};
00048   med_int nufase2[5] = {-1,-1,0,-2,-3};
00049   med_int ntr3 = 2;
00050   med_int tr3[6] = {1,2,-5,-5,3,-4};
00051   /*                                  12345678901234561234567890123456*/
00052   char nomtr3[MED_SNAME_SIZE*2+1] = "tr1             tr2             ";
00053   med_int numtr3[2] = {4,5};
00054   med_int nufatr3[2] = {0,-1};
00055   char maa[MED_NAME_SIZE+1] = "maa1";
00056   med_int mdim = 2;
00057   char nomcoo[2*MED_SNAME_SIZE+1] = "x               y               ";
00058   char unicoo[2*MED_SNAME_SIZE+1] = "cm              cm              ";
00059 
00060   /* ouverture du fichier */
00061   if ((fid = MEDfileOpen("test6.med",MODE_ACCES)) < 0) {
00062     MESSAGE("Impossible de creer le fichier test6.med : ");
00063     return -1;
00064   }
00065 
00066   if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
00067                  "un maillage pour test6","s", MED_SORT_DTIT,
00068                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
00069     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
00070     return -1;
00071   }
00072 
00073 
00074   /* ecriture des connectivites des segments */
00075   if ( MEDmeshElementConnectivityWr(fid,maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00076                                     MED_DESCENDING_EDGE, MED_SEG2, MED_DESCENDING,
00077                                     MED_FULL_INTERLACE, nse2,se2) < 0 ) {
00078     MESSAGE("Impossible d'ecrire la connectivité des segments: ");
00079     return -1;
00080   }
00081 
00082 
00083 
00084   /* ecriture (optionnelle) des noms des segments */
00085    if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
00086                            MED_DESCENDING_EDGE,MED_SEG2,nse2,nomse2) < 0) {
00087     MESSAGE("Erreur a l'ecriture des noms des segments");
00088     return -1;
00089   }
00090 
00091   /* ecriture (optionnelle) des numeros des segments */
00092   if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00093                             MED_DESCENDING_EDGE,MED_SEG2,nse2,numse2) < 0) {
00094     MESSAGE("Erreur a l'ecriture des numeros des segments");
00095     return -1;
00096   }
00097 
00098   /* ecriture des numeros des familles des segments */
00099   if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00100                                   MED_DESCENDING_EDGE,MED_SEG2,nse2,nufase2) < 0) {
00101     MESSAGE("Erreur a l'ecriture des numeros de familles des segments");
00102     return -1;
00103   }
00104 
00105   /* ecriture des connectivites des triangles */
00106   if ( MEDmeshElementConnectivityWr(fid,maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00107                                     MED_CELL, MED_TRIA3, MED_DESCENDING,
00108                                     MED_FULL_INTERLACE, ntr3,tr3) < 0 ) {
00109     MESSAGE("Impossible d'ecrire la connectivité des triangles : ");
00110     return -1;
00111   }
00112 
00113   /* ecriture (optionnelle) des noms des triangles */
00114    if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
00115                            MED_CELL, MED_TRIA3,ntr3,nomtr3) < 0) {
00116     MESSAGE("Erreur a l'ecriture des noms des triangles");
00117     return -1;
00118   }
00119 
00120   /* ecriture (optionnelle) des numeros des triangles */
00121   if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00122                             MED_CELL, MED_TRIA3,ntr3,numtr3) < 0) {
00123     MESSAGE("Erreur a l'ecriture des numeros des triangles");
00124     return -1;
00125   }
00126 
00127   /* ecriture des numeros des familles des triangles */
00128   if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00129                                   MED_CELL, MED_TRIA3,ntr3,nufatr3) < 0) {
00130     MESSAGE("Erreur a l'ecriture des numeros de familles des triangles");
00131     return -1;
00132   }
00133 
00134   /* fermeture du fichier */
00135   if ( MEDfileClose(fid) < 0 ) {
00136     MESSAGE("Impossible de fermerle fichier : ");
00137     return -1;
00138   }
00139 
00140   return 0;
00141  
00142 }
00143 
00144 
00145 

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