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

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