      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 : test29.c
     21  *
     22  * - Description : ecriture d'un joint dans un maillage MED
     23  *
     24  *****************************************************************************/
     25
     26 #include <med.h>
     27 #define MESGERR
     28 #include <med_utils.h>
     29
     30 #ifdef DEF_LECT_ECR
     31 #define MODE_ACCES MED_LECTURE_ECRITURE
     32 #elif DEF_LECT_AJOUT
     33 #define MODE_ACCES MED_LECTURE_AJOUT
     34 #else
     35 #define MODE_ACCES MED_CREATION
     36 #endif
     37
     38 int main (int argc, char **argv)
     39
     40
     41 {
     42   med_idt fid;
     43
     44   char maa[MED_TAILLE_NOM+1]= "maa1";
     45   char jnt[MED_TAILLE_NOM+1] = "joint";
     46   char des_jnt[MED_TAILLE_DESC+1] = "joint avec le sous-domaine 2";
     47   char maa_distant[MED_TAILLE_NOM+1]= "maa1";
     48   med_int dom_dist = 2;
     49
     50   med_int mdim = 3;
     51   med_int ncor = 3;
     52   med_int cor[6] = {1,2,3,4,5,6};
     53   med_int cor2[6] = {10,20,30,40,50,60};
     54
     55   /* Creation du fichier "test29.med" */
     56   if ((fid = MEDouvrir("test29.med",MODE_ACCES)) < 0) {
     57     MESSAGE("Erreur a la creation du fichier test29.med");
     58     return -1;
     59   }
     60
     61   /* Creation du maillage */
     62   if (MEDmaaCr(fid,maa,3,MED_NON_STRUCTURE,
     63                    "Un maillage pour test29") < 0) {
     64     MESSAGE("Erreur a la creation du maillage");
     65     return -1;
     66   }
     67
     68   /* Creation du joint */
     69   if (MEDjointCr(fid,maa,jnt,des_jnt,dom_dist,maa_distant) < 0) {
     70     MESSAGE("Erreur a la creation du joint");
     71     return -1;
     72   }
     73
     74   /* Ecriture de la correspondance Noeud, Noeud */
     75   if (MEDjointEcr(fid,maa,jnt,cor,ncor,
     76                       MED_NOEUD,0,MED_NOEUD,0) < 0) {
     77     MESSAGE("Erreur a l'ecriture du tableau des correspondances (noeud,noeud)");
     78     return -1;
     79   }
     80
     81
     82   /* Ecriture de la correspondance Noeud Maille */
     83   if (MEDjointEcr(fid,maa,jnt,cor2,ncor,
     84                       MED_NOEUD,0,MED_MAILLE,MED_TRIA3) < 0) {
     85     MESSAGE("Erreur a l'ecriture du tableau des correspondances (noeud,maille TRIA3)");
     86     return -1;
     87   }
     88
     89   /* Fermeture du fichier */
     90   if (MEDfermer(fid) < 0) {
     91     MESSAGE("Erreur a la fermeture du fichier");
     92     return -1;
     93   }
     94
     95   return 0;
     96 }
     97
     98
     99
    100