test14.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  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 : test14.c
00020  *
00021  * - Description : ecriture des noeuds d'un maillage MED
00022  *                 a l'aide des routines de niveau 2
00023  *                 equivalent a test4.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;
00044   /* la dimension du maillage */
00045   med_int mdim = 2;
00046   /* nom du maillage de longueur maxi MED_NAME_SIZE */
00047   char maa[MED_NAME_SIZE+1] = "maa1";
00048   /* le nombre de noeuds */
00049   med_int nnoe = 4;
00050   /* table des coordonnees  
00051      profil : (dimension * nombre de noeuds) */
00052   med_float coo[8] = {0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0};
00053   /* tables des noms et des unites des coordonnees 
00054      profil : (dimension*MED_SNAME_SIZE+1) */
00055   /*                                  12345678901234561234567890123456 */
00056   char nomcoo[2*MED_SNAME_SIZE+1] = "x               y               ";
00057   char unicoo[2*MED_SNAME_SIZE+1] = "cm              cm              ";
00058   /* tables des noms, numeros, numeros de familles des noeuds
00059      autant d'elements que de noeuds - les noms ont pout longueur
00060      MED_SNAME_SIZE */
00061   /*                                  1234567890123456123456789012345612345678901234561234567890123456 */
00062   char nomnoe[4*MED_SNAME_SIZE+1] = "nom1            nom2            nom3            nom4             ";
00063   med_int numnoe[4] = {1,2,3,4};
00064   med_int nufano[4] = {0,1,2,2};
00065 
00066   /* Creation du fichier test14.med */
00067   if ((fid = MEDfileOpen("test14.med",MODE_ACCES)) < 0) {
00068     MESSAGE("Erreur a la creation du fichier test14.med");
00069     return -1;
00070   }
00071 
00072 
00073   /* Creation du maillage */
00074   if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
00075                  "un maillage pour test14","s", MED_SORT_DTIT,
00076                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
00077     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
00078     return -1;
00079   }
00080 
00081   /* Ecriture des noeuds d'un maillage MED :
00082      - Des cooordonnees en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...)
00083      dans un repere cartesien
00084      - Des noms (optionnel dans un fichier MED)
00085      - Des numeros (optionnel dans un fichier MED)
00086      - Des numeros de familles des noeuds */
00087   if (MEDmeshNodeWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MED_FULL_INTERLACE,
00088                     nnoe,coo,MED_TRUE,nomnoe,MED_TRUE,numnoe,MED_TRUE,
00089                     nufano) < 0) {
00090     MESSAGE("Erreur a l'ecriture des noeuds du maillage");
00091     return -1;
00092   }
00093 
00094   /* Fermeture du fichier */
00095   if (MEDfileClose(fid) < 0) {
00096     MESSAGE("Erreur a la fermeture du fichier");
00097     return -1;
00098   }
00099 
00100   return 0;
00101 }
00102 
00103 
00104 
00105 

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1