test32.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 : test32.c
00020  *
00021  * - Description : lecture nominale d'une numerotation globale 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_err ret = 0;
00042   med_idt fid;
00043   med_int mdim,sdim;
00044   char maa[MED_NAME_SIZE+1];
00045   /* le nombre de noeuds */
00046   med_int nnoe = 0;
00047   /* table des numeros global */
00048   med_int *numglobalnoe=NULL;
00049   /* variable de stockage pour reperer le maillage */
00050   med_int i;
00051   char des[MED_COMMENT_SIZE+1]="";
00052   char dtunit[MED_SNAME_SIZE+1]="";
00053   char nomcoo[3*MED_SNAME_SIZE+1]="";
00054   char unicoo[3*MED_SNAME_SIZE+1]="";
00055   med_axis_type rep;
00056   med_mesh_type type;
00057   med_sorting_type sort;
00058   med_int nstep=0;
00059   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
00060 
00061 
00062 
00063   if (argc != 2) {
00064     MESSAGE("Il faut passer un fichier MED en param�tre");
00065     return -1;
00066   }
00067 
00068   /* Ouverture du fichier passe en argument */
00069   if ((fid = MEDfileOpen(argv[1],MED_ACC_RDWR)) < 0) {
00070     MESSAGE("Erreur a l'ouverture du fichier : "); SSCRUTE(argv[1]);
00071     return -1;
00072   }
00073 
00074   if ((sdim=MEDmeshnAxis(fid, 1)) <0) {
00075     MESSAGE("Erreur � la lecture de la dimension de l'espace du maillage :");
00076     SSCRUTE(maa);
00077     return -1;
00078   }
00079 
00080   /* Lecture des infos concernant le premier maillage */
00081   if ( MEDmeshInfo( fid, 1,  maa, &sdim, &mdim, &type, des, dtunit, &sort,
00082                     &nstep,  &rep, nomcoo,unicoo) < 0 ) {
00083     MESSAGE("Erreur a la lecture des informations sur le maillage : ");SSCRUTE(maa);
00084     return -1;
00085   } else {
00086     printf("Maillage de nom : |%s| , de dimension : "IFORMAT" , et de type %d\n",maa,mdim,type);
00087     printf("\t -Dimension de l'espace : "IFORMAT"\n",sdim);
00088     printf("\t -Description du maillage : %s\n",des);
00089     printf("\t -Noms des axes : %s\n",nomcoo);
00090     printf("\t -Unit�s des axes : %s\n",unicoo);
00091     printf("\t -Type de rep�re : %d\n",rep);
00092     printf("\t -Nombre d'�tapes de calcul : "IFORMAT"\n",nstep);
00093     printf("\t -Unit� des dates : %s\n\n",dtunit);
00094   }
00095 
00096   /* Lecture du nombre de noeuds */
00097   if ( (nnoe = MEDmeshnEntity(fid,maa,MED_NO_DT,MED_NO_IT,
00098                               MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
00099                               &chgt,&trsf)) < 0) {
00100     MESSAGE("Erreur a la lecture du nombre de noeuds ");
00101     return -1;
00102   }
00103   printf("Nombre de noeuds : "IFORMAT" \n",nnoe);
00104 
00105 
00106   /* Allocations memoires */
00107 
00108   /* table de la numerotation globale
00109      profil : (nombre de noeuds ) */
00110   if (nnoe > 0) {
00111     numglobalnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
00112   }
00113 
00114   /* lecture de la numerotation globale attachee aux noeuds*/
00115   if (MEDmeshGlobalNumberRd(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,MED_NONE,numglobalnoe)<0) {
00116     MESSAGE("Erreur a la lecture de de la numerotation globale");
00117     return -1;
00118   }
00119 
00120   /* ecriture a l'ecran des resultats */
00121   for (i=0;i<nnoe;i++)
00122     printf("Numero global du noeud "IFORMAT" : "IFORMAT" \n",i+1,numglobalnoe[i]);
00123 
00124   free(numglobalnoe);
00125 
00126   /* Fermeture du fichier */
00127   if (MEDfileClose(fid) < 0) {
00128     MESSAGE("Erreur a la fermeture du fichier ");
00129     return -1;
00130   }
00131 
00132   return 0;
00133 }
00134 

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