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_LECTURE_ECRITURE 00033 #elif DEF_LECT_AJOUT 00034 #define MODE_ACCES MED_LECTURE_AJOUT 00035 #else 00036 #define MODE_ACCES MED_CREATION 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_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, 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_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 /* Erreur sur la taille du dernier nom : nom4" */ 00063 char nomnoe[4*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4"; 00064 med_int numnoe[4] = {1,2,3,4}; 00065 med_int nufano[4] = {0,1,2,2};; 00066 00067 /* Creation du fichier test14.med */ 00068 if ((fid = MEDouvrir("test14.med",MODE_ACCES)) < 0) { 00069 MESSAGE("Erreur a la creation du fichier test14.med"); 00070 return -1; 00071 } 00072 00073 /* Creation du maillage */ 00074 if (MEDmaaCr(fid,maa,mdim,MED_NON_STRUCTURE,"Un maillage pour test14") < 0) { 00075 MESSAGE("Erreur a la creation du maillage"); 00076 SSCRUTE(maa) 00077 return -1; 00078 } 00079 00080 /* Ecriture des noeuds d'un maillage MED : 00081 - Des cooordonnees en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...) 00082 dans un repere cartesien 00083 - Des noms (optionnel dans un fichier MED) 00084 - Des numeros (optionnel dans un fichier MED) 00085 - Des numeros de familles des noeuds */ 00086 if (MEDnoeudsEcr(fid,maa,mdim,coo,MED_FULL_INTERLACE,MED_CART, 00087 nomcoo,unicoo,nomnoe,MED_VRAI,numnoe,MED_VRAI, 00088 nufano,nnoe) < 0) { 00089 MESSAGE("Erreur a l'ecriture des noeuds du maillage"); 00090 return -1; 00091 } 00092 00093 /* Fermeture du fichier */ 00094 if (MEDfermer(fid) < 0) { 00095 MESSAGE("Erreur a la fermeture du fichier"); 00096 return -1; 00097 } 00098 00099 return 0; 00100 } 00101 00102 00103 00104