# test12.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 : test12.c
    00020  *
    00021  * - Description : ecriture d'une equivalence dans un maillage MED
    00022  *
    00023  *****************************************************************************/
    00024
    00025 #include <med.h>
    00026 #define MESGERR 1
    00027 #include <med_utils.h>
    00028
    00029 #ifdef DEF_LECT_ECR
    00030 #define MODE_ACCES MED_ACC_RDWR
    00031 #elif DEF_LECT_AJOUT
    00032 #define MODE_ACCES MED_ACC_RDEXT
    00033 #else
    00034 #define MODE_ACCES MED_ACC_CREAT
    00035 #endif
    00036
    00037 int main (int argc, char **argv)
    00038
    00039
    00040 {
    00041   med_idt fid;
    00042   char maa[MED_NAME_SIZE+1]= "maa1";
    00043   char equ[MED_NAME_SIZE+1] = "equivalence";
    00044   char des[MED_COMMENT_SIZE+1] = "equivalence sur les mailles MED_TRIA3";
    00045   med_int mdim = 3;
    00046   med_int ncor = 3;
    00047   med_int cor[6] = {1,2,3,4,5,6};
    00048   char    nomcoo[3*MED_SNAME_SIZE+1] = "x               y               z               ";
    00049   char    unicoo[3*MED_SNAME_SIZE+1] = "cm              cm              cm              ";
    00050
    00051
    00052   /* Creation du fichier "test12.med" */
    00053   if ((fid = MEDfileOpen("test12.med",MODE_ACCES)) < 0) {
    00054     MESSAGE("Erreur a la creation du fichier test12.med");
    00055     return -1;
    00056   }
    00057
    00058   if (MEDmeshCr( fid, maa, 3, 3, MED_UNSTRUCTURED_MESH,
    00059                  "un maillage pour test12","s", MED_SORT_DTIT,
    00060                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
    00061     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
    00062     return -1;
    00063   }
    00064
    00065   /* Creation de l'equivalence */
    00066   if (MEDequivalenceCr(fid,maa,equ,des) < 0) {
    00067     MESSAGE("Erreur a la creation de l'equivalence");
    00068     return -1;
    00069   }
    00070
    00071   /* Ecriture des sur les mailles MED_TRIA3 */
    00072   if (MEDequivalenceCorrespondenceWr(fid,maa,equ,MED_NO_DT,MED_NO_IT,
    00073                                      MED_CELL,MED_TRIA3,ncor,cor) < 0) {
    00074     MESSAGE("Erreur a l'ecriture du tableau des correspondances");
    00075     return -1;
    00076   }
    00077   /* Fermeture du fichier */
    00078   if (MEDfileClose(fid) < 0) {
    00079     MESSAGE("Erreur a la fermeture du fichier");
    00080     return -1;
    00081   }
    00082
    00083   return 0;
    00084 }
    00085
    00086
    00087
    00088