2.3.6/test4.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 /******************************************************************************
00020  * - Nom du fichier : test4.c
00021  *
00022  * - Description : ecriture des noeuds d'un maillage MED.
00023  *
00024  *****************************************************************************/
00025 
00026 #include <med.h>
00027 #define MESGERR 1
00028 #include <med_utils.h> 
00029 
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_LECTURE_ECRITURE
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_LECTURE_AJOUT
00034 #else
00035 #define MODE_ACCES MED_CREATION
00036 #endif
00037 
00038 int main (int argc, char **argv)
00039 
00040 
00041 {
00042   med_err ret = 0;
00043   med_idt fid;
00044   /* la dimension du maillage */
00045   med_int mdim = 2;
00046   /* nom du maillage de longueur maxi MED_TAILLE_NOM */
00047   char maa[MED_TAILLE_NOM+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, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
00053   /* tables des noms et des unites des coordonnees  
00054      profil : (dimension*MED_TAILLE_PNOM+1) */
00055   /*                                  12345678901234561234567890123456*/ 
00056   char nomcoo[2*MED_TAILLE_PNOM+1] = "x               y               ";
00057   char unicoo[2*MED_TAILLE_PNOM+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_TAILLE_PNOM */
00061   /*                                  1234567890123456123456789012345612345678901234561234567890123456*/
00062   char nomnoe[4*MED_TAILLE_PNOM+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 "test4.med" */
00067   fid = MEDouvrir("test4.med",MODE_ACCES);
00068   if (fid < 0) {
00069     MESSAGE("Erreur a la creation du fichier test4.med");
00070     return -1;
00071   }
00072 
00073   /* Creation du maillage "maa" de type MED_NON_STRUCURE 
00074      et de dimension 2 */
00075   if (MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,
00076                "un maillage pour test4") < 0) {
00077     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
00078     ret = -1;
00079   }
00080 
00081   /* Ecriture des coordonnees des noeuds en mode MED_FULL_INTERLACE :
00082      (X1,Y1, X2,Y2, X3,Y3, ...) dans un repere cartesien */
00083   if (MEDcoordEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,nnoe,
00084                   MED_CART,nomcoo,unicoo) < 0) {
00085     MESSAGE("Erreur a l'ecriture des coordonnees des noeuds");
00086     ret = -1;
00087   }
00088 
00089   /* Ecriture des noms des noeuds (optionnel dans un maillage MED) */
00090   if (MEDnomEcr(fid,maa,nomnoe,nnoe,MED_NOEUD,0) < 0) {
00091     MESSAGE("Erreur a l'ecriture des noms des noeuds");
00092     ret = -1;
00093   }
00094 
00095   /* Ecriture des numeros des noeuds (optionnel dans un maillage MED) */
00096   if (MEDnumEcr(fid,maa,numnoe,nnoe,MED_NOEUD,0) < 0) {
00097     MESSAGE("Erreur a l'ecriture des numeros des noeuds");
00098     ret = -1;
00099   }
00100 
00101   /* Ecriture des numeros de famille des noeuds */            
00102   if (MEDfamEcr(fid,maa,nufano,nnoe,MED_NOEUD,0) < 0) {
00103     MESSAGE("Erreur a l'ecriture des numeros de familles des noeuds");
00104     ret = -1;
00105   }
00106 
00107   /* Fermeture du fichier */
00108   if (MEDfermer(fid) < 0) {
00109     MESSAGE("Erreur a la fermeture du fichier test4.med");
00110     return -1;
00111   }
00112   
00113   return ret;
00114 }
00115 
00116 
00117 
00118 

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