Test_MEDmeshStructElementVarAttRd.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 #include <med.h>
00020 #define MESGERR 1
00021 #include <med_utils.h>
00022 #include <string.h>
00023 
00024 #ifdef DEF_LECT_ECR
00025 #define MODE_ACCES MED_ACC_RDWR
00026 #elif DEF_LECT_AJOUT
00027 #define MODE_ACCES MED_ACC_RDEXT
00028 #else
00029 #define MODE_ACCES MED_ACC_CREAT
00030 #endif
00031 
00032 int main (int argc, char **argv)
00033 
00034 {
00035   med_err           _ret=0;
00036   med_idt           _fid=0;
00037   med_geometry_type _geotype=MED_NONE;
00038   int               _i=0;
00039 
00040   const char        _elementname1[]="MED_BILLE";
00041 /*   med_int           _elementdim1=3; */
00042 /*   const char        _supportmeshname1[]="MED_BILLE_SUPPORT"; */
00043 /*   med_entity_type   _entitytype1=MED_NODE; */
00044 /*   med_int           _nnode1=1; */
00045 /*   med_int           _ncell1=0; */
00046 /*   med_int           _geocelltype1=MED_NONE; */
00047 
00048   const char                _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1";
00049  /*  const med_attribute_type  _varatttype1_1=MED_ATT_INT; */
00050 /*   const med_int             _ncomponent1_1=1; */
00051   const med_int             _varatrvalue1_1[3]={ 22 , 24, 25 };
00052         med_int             _read_varatrvalue1_1[3];
00053 
00054 /*   const char                _varattname1_2[MED_NAME_SIZE+1]="MED_VFOO_ATR1_2"; */
00055 /*   const med_attribute_type  _varatttype1_2=MED_ATT_FLOAT64; */
00056 /*   const med_int             _ncomponent1_2=2; */
00057 
00058 /*   const char                _varattname1_3[MED_NAME_SIZE+1]="MED_VFOO_ATR1_3"; */
00059 /*   const med_attribute_type  _varatttype1_3=MED_ATT_NAME; */
00060 /*   const med_int             _ncomponent1_3=1; */
00061 
00062   const char   _meshname[]="maa1";
00063   const med_int _nentity = 3;
00064 
00065   const med_int _con[3]={ 2, 4 ,5}; /* (3 billes dont les centres sont les noeuds 2, 4 et 5 du maillage maa1 )*/
00066   med_int       _read_con[3];
00067 
00068   /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
00069   _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
00070   if (_fid < 0) {
00071     MESSAGE("Erreur à l'ouverture du fichier current.med");
00072     return -1;
00073   }
00074 
00075   _geotype = MEDstructElementGeotype(_fid,_elementname1);
00076 
00077   /* lecture des connectivites des éléments de structure  */
00078   if ( MEDmeshElementConnectivityRd(_fid,_meshname, MED_NO_DT, MED_NO_IT,
00079                                     MED_STRUCT_ELEMENT, _geotype, MED_NODAL,
00080                                     MED_FULL_INTERLACE, _read_con) < 0 ) {
00081     MESSAGE("Impossible de lire la connectivité des billes: ");
00082     return -1;
00083   }
00084   for ( _i=0; _i < _nentity; ++_i ) {
00085     fprintf(stdout,"Connectivité[%d]=%d.\n",_i,_read_con[_i]);
00086     if ( _read_con[_i]!=_con[_i] ) {fprintf(stderr,"Erreur de cohérence de la connectivité lue.\n");return -1;}
00087   }
00088 
00089   if (MEDmeshStructElementVarAttRd(_fid,
00090                                    _meshname,
00091                                    MED_NO_DT,
00092                                    MED_NO_IT,
00093                                    _geotype,
00094                                    _varattname1_1,
00095                                    _read_varatrvalue1_1
00096                                    ) < 0 ) {
00097     return -1;
00098   }
00099 
00100   for ( _i=0; _i < _nentity; ++_i ) {
00101     fprintf(stdout,"Vattr[%d]=%d.\n",_i,_read_varatrvalue1_1[_i]);
00102     if ( _read_varatrvalue1_1[_i]!=_varatrvalue1_1[_i] ) {
00103       fprintf(stderr,"Erreur de cohérence des valeurs"
00104               " de l'attribut variable %s.\n",_varattname1_1);
00105       return -1;}
00106   }
00107 
00108   return _ret;
00109 
00110 }
00111 

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