      1  /*************************************************************************
      2  * COPYRIGHT (C) 1999 - 2003  EDF R&D
      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  #include <med_utils.h>
     30  #include <stdio.h>
     31  #include <string.h>
     32  #include <stdlib.h>
     33
     34  int main (int argc, char **argv)
     35  {
     36    med_idt fid;
     37    med_int nse2 = 5;
     38    med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
     39    /*                                12345678901234561234567890123456123456789012345612345678901234561234567890123456 */
     40    char nomse2[MED_TAILLE_PNOM*5+1]="se1             se2             se3             se4             se5             ";
     41    med_int numse2[5] = {1,2,3,4,5};
     42    med_int nufase2[5] = {-1,-1,0,-2,-3};
     43    med_int ntr3 = 2;
     44    med_int tr3[6] = {1,2,-5,-5,3,-4};
     45    char nomtr3[MED_TAILLE_PNOM*2+1] = "tr1           tr2             ";
     46    med_int numtr3[2] = {4,5};
     47    med_int nufatr3[2] = {0,-1};
     48    char maa[MED_TAILLE_NOM+1] = "maa1";
     49    med_int mdim = 2;
     50
     51    /* Creation du fichier test16.med */
     52    if ( (fid = MEDouvrir("test16.med",MED_CREATION) ) < 0) {
     53      MESSAGE("Impossible de creer le fichier test16.med : ");
     54      return -1;
     55    }
     56
     57    /* Creation du maillage */
     58    if ( MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,
     59             "un maillage pour test16") < 0 ) {
     60      MESSAGE("Impossible de creer le maillage : ");
     61      return -1;
     62    }
     63
     64    /* Ecriture des aretes segments MED_SEG2 :
     65       - connectivite
     66       - noms (optionnel)
     67       - numeros (optionnel)
     68       - numeros des familles */
     69    if ( MEDelementsEcr(fid,maa,mdim,se2,MED_NO_INTERLACE,nomse2,MED_VRAI,numse2,MED_VRAI,
     70               nufase2,nse2,MED_ARETE,MED_SEG2,MED_DESC)< 0 ) {
     71      MESSAGE("Impossible d'ecrire la connectivité des aretes : ");
     72      return -1;
     73    }
     74
     75    /* Ecriture des mailles MED_TRIA3 :
     76       - Connectivite
     77       - Noms (optionnel)
     78       - Numeros (optionnel)
     79       - Numeros des familles */
     80    if ( MEDelementsEcr(fid,maa,mdim,tr3,MED_NO_INTERLACE,nomtr3,MED_VRAI,numtr3,MED_VRAI,
     81               nufatr3,ntr3,MED_MAILLE,MED_TRIA3,MED_DESC) < 0 ) {
     82      MESSAGE("Impossible d'ecrire les éléments triangles : ");
     83      return -1;
     84    }
     85
     86    /* Fermeture du fichier */
     87    if (  MEDfermer(fid) < 0) {
     88      MESSAGE("Impossible de fermerle fichier : ");
     89      return -1;
     90    }
     91
     92    return 0;
     93
     94  }
     95
     96
     97
     98
     99
    100