# test16.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  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  * - Nom du fichier : test16.c
    00020  *
    00021  * - Description : ecriture d'elements de maillages MED
    00022  *                 via les routines de niveau 2
    00023  *                 - equivalent a test6.c
    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  = 0;
    00044   med_int nse2 = 5;
    00045   med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
    00046   /*                               12345678901234561234567890123456123456789012345612345678901234561234567890123456 */
    00047   char nomse2[MED_SNAME_SIZE*5+1]="se1             se2             se3             se4             se5             ";
    00048   med_int numse2[5] = {1,2,3,4,5};
    00049   med_int nufase2[5] = {-1,-1,0,-2,-3};
    00050   med_int ntr3 = 2;
    00051   med_int tr3[6] = {1,2,-5,-5,3,-4};
    00052   /*                                 1234567890123456123456789012345612345678901234561234567890123456 */
    00053   char nomtr3[MED_SNAME_SIZE*2+1] = "tr1             tr2             ";
    00054   med_int numtr3[2] = {4,5};
    00055   med_int nufatr3[2] = {0,-1};
    00056   char maa[MED_NAME_SIZE+1] = "maa1";
    00057   med_int mdim = 2;
    00058   /*                                 12345678901234561234567890123456 */
    00059   char nomcoo[2*MED_SNAME_SIZE+1] = "x               y               ";
    00060   char unicoo[2*MED_SNAME_SIZE+1] = "cm              cm              ";
    00061
    00062   /* Creation du fichier test16.med */
    00063   if ((fid = MEDfileOpen("test16.med",MODE_ACCES)) < 0) {
    00064     MESSAGE("Erreur a la creation du fichier test16.med");
    00065     return -1;
    00066   }
    00067
    00068
    00069   /* Creation du maillage */
    00070   if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
    00071                  "un maillage pour test16","s", MED_SORT_DTIT,
    00072                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
    00073     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
    00074     return -1;
    00075   }
    00076
    00077
    00078   /* Ecriture des aretes segments MED_SEG2 :
    00079      - connectivite
    00080      - noms (optionnel)
    00081      - numeros (optionnel)
    00082      - numeros des familles */
    00083   if ( MEDmeshElementWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,
    00084                         MED_DESCENDING_EDGE,MED_SEG2,MED_DESCENDING,MED_NO_INTERLACE,
    00085                         nse2,se2,MED_TRUE,nomse2,MED_TRUE,numse2,MED_TRUE,nufase2)< 0 ) {
    00086     MESSAGE("Impossible d'ecrire la connectivit� des aretes : ");
    00087     return -1;
    00088   }
    00089
    00090   /* Ecriture des mailles MED_TRIA3 :
    00091      - Connectivite
    00092      - Noms (optionnel)
    00093      - Numeros (optionnel)
    00094      - Numeros des familles */
    00095   if ( MEDmeshElementWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,
    00096                         MED_CELL,MED_TRIA3,MED_DESCENDING,MED_NO_INTERLACE,
    00097                         ntr3,tr3,MED_TRUE,nomtr3,MED_TRUE,numtr3,MED_TRUE,nufatr3)< 0 ) {
    00098     MESSAGE("Impossible d'ecrire les �l�ments triangles : ");
    00099     return -1;
    00100   }
    00101
    00102   /* Fermeture du fichier */
    00103   if (  MEDfileClose(fid) < 0) {
    00104     MESSAGE("Impossible de fermerle fichier : ");
    00105     return -1;
    00106   }
    00107
    00108   return 0;
    00109 }
    00110
    00111
    00112
    00113
    00114
    00115