      1 /*************************************************************************
      2 * COPYRIGHT (C) 1999 - 2007  EDF R&D, CEA/DEN
      3 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
      4 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE
      5 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
      6 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
      7 *
      8 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
      9 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
     10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
     11 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
     12 *
     13 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
     14 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
     15 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
     16 *
     17 *************************************************************************/
     18
     19 /******************************************************************************
     20  * - Nom du fichier : test16.c
     21  *
     22  * - Description : ecriture d'elements de maillages MED
     23  *                 via les routines de niveau 2
     24  *                 - equivalent a test6.c
     25  *
     26  *****************************************************************************/
     27
     28 #include <med.h>
     29 #define MESGERR
     30 #include <med_utils.h>
     31
     32 #ifdef DEF_LECT_ECR
     33 #define MODE_ACCES MED_LECTURE_ECRITURE
     34 #elif DEF_LECT_AJOUT
     35 #define MODE_ACCES MED_LECTURE_AJOUT
     36 #else
     37 #define MODE_ACCES MED_CREATION
     38 #endif
     39
     40 int main (int argc, char **argv)
     41
     42
     43 {
     44   med_idt fid;
     45   med_int nse2 = 5;
     46   med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
     47   /*                                12345678901234561234567890123456123456789012345612345678901234561234567890123456 */
     48   char nomse2[MED_TAILLE_PNOM*5+1]="se1             se2             se3             se4             se5             ";
     49   med_int numse2[5] = {1,2,3,4,5};
     50   med_int nufase2[5] = {-1,-1,0,-2,-3};
     51   med_int ntr3 = 2;
     52   med_int tr3[6] = {1,2,-5,-5,3,-4};
     53   char nomtr3[MED_TAILLE_PNOM*2+1] = "tr1           tr2             ";
     54   med_int numtr3[2] = {4,5};
     55   med_int nufatr3[2] = {0,-1};
     56   char maa[MED_TAILLE_NOM+1] = "maa1";
     57   med_int mdim = 2;
     58
     59   /* Creation du fichier test16.med */
     60   if ( (fid = MEDouvrir("test16.med",MODE_ACCES) ) < 0) {
     61     MESSAGE("Impossible de creer le fichier test16.med : ");
     62     return -1;
     63   }
     64
     65   /* Creation du maillage */
     66   if ( MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,
     67                    "un maillage pour test16") < 0 ) {
     68     MESSAGE("Impossible de creer le maillage : ");
     69     return -1;
     70   }
     71
     72   /* Ecriture des aretes segments MED_SEG2 :
     73      - connectivite
     74      - noms (optionnel)
     75      - numeros (optionnel)
     76      - numeros des familles */
     77   if ( MEDelementsEcr(fid,maa,mdim,se2,MED_NO_INTERLACE,nomse2,MED_VRAI,numse2,MED_VRAI,
     78                          nufase2,nse2,MED_ARETE,MED_SEG2,MED_DESC)< 0 ) {
     79     MESSAGE("Impossible d'ecrire la connectivité des aretes : ");
     80     return -1;
     81   }
     82
     83   /* Ecriture des mailles MED_TRIA3 :
     84      - Connectivite
     85      - Noms (optionnel)
     86      - Numeros (optionnel)
     87      - Numeros des familles */
     88   if ( MEDelementsEcr(fid,maa,mdim,tr3,MED_NO_INTERLACE,nomtr3,MED_VRAI,numtr3,MED_VRAI,
     89                          nufatr3,ntr3,MED_MAILLE,MED_TRIA3,MED_DESC) < 0 ) {
     90     MESSAGE("Impossible d'ecrire les éléments triangles : ");
     91     return -1;
     92   }
     93
     94   /* Fermeture du fichier */
     95   if (  MEDfermer(fid) < 0) {
     96     MESSAGE("Impossible de fermerle fichier : ");
     97     return -1;
     98   }
     99
    100   return 0;
    101
    102 }
    103
    104
    105
    106
    107
    108