MED fichier
Test_MEDmeshStructElementVarAttRd.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2023 EDF R&D, CEA/DEN
4  * MED is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * MED is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with MED. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 #include <med.h>
20 #define MESGERR 1
21 #include <med_utils.h>
22 #include <string.h>
23 
24 #ifdef DEF_LECT_ECR
25 #define MODE_ACCES MED_ACC_RDWR
26 #elif DEF_LECT_AJOUT
27 #define MODE_ACCES MED_ACC_RDEXT
28 #else
29 #define MODE_ACCES MED_ACC_CREAT
30 #endif
31 
32 int main (int argc, char **argv)
33 
34 {
35  med_err _ret=0;
36  med_idt _fid=0;
37  med_geometry_type _geotype=MED_NONE;
38  int _i=0;
39 
40  const char _elementname1[]="MED_BILLE";
41 /* med_int _elementdim1=3; */
42 /* const char _supportmeshname1[]="MED_BILLE_SUPPORT"; */
43 /* med_entity_type _entitytype1=MED_NODE; */
44 /* med_int _nnode1=1; */
45 /* med_int _ncell1=0; */
46 /* med_int _geocelltype1=MED_NONE; */
47 
48  const char _varattname1_1[MED_NAME_SIZE+1]="MED_VFOO_ATR1_1";
49  /* const med_attribute_type _varatttype1_1=MED_ATT_INT; */
50 /* const med_int _ncomponent1_1=1; */
51  const med_int _varatrvalue1_1[3]={ 22 , 24, 25 };
52  med_int _read_varatrvalue1_1[3];
53 
54 /* const char _varattname1_2[MED_NAME_SIZE+1]="MED_VFOO_ATR1_2"; */
55 /* const med_attribute_type _varatttype1_2=MED_ATT_FLOAT64; */
56 /* const med_int _ncomponent1_2=2; */
57 
58 /* const char _varattname1_3[MED_NAME_SIZE+1]="MED_VFOO_ATR1_3"; */
59 /* const med_attribute_type _varatttype1_3=MED_ATT_NAME; */
60 /* const med_int _ncomponent1_3=1; */
61 
62  const char _meshname[]="maa1";
63  const med_int _nentity = 3;
64 
65  const med_int _con[3]={ 2, 4 ,5}; /* (3 billes dont les centres sont les noeuds 2, 4 et 5 du maillage maa1 )*/
66  med_int _read_con[3];
67 
68  /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
69  _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
70  if (_fid < 0) {
71  MESSAGE("Erreur à l'ouverture du fichier current.med");
72  return -1;
73  }
74 
75  _geotype = MEDstructElementGeotype(_fid,_elementname1);
76 
77  /* lecture des connectivites des éléments de structure */
78  if ( MEDmeshElementConnectivityRd(_fid,_meshname, MED_NO_DT, MED_NO_IT,
79  MED_STRUCT_ELEMENT, _geotype, MED_NODAL,
80  MED_FULL_INTERLACE, _read_con) < 0 ) {
81  MESSAGE("Impossible de lire la connectivité des billes: ");
82  return -1;
83  }
84  for ( _i=0; _i < _nentity; ++_i ) {
85  fprintf(stdout,"Connectivité[%d]=%d.\n",_i,_read_con[_i]);
86  if ( _read_con[_i]!=_con[_i] ) {fprintf(stderr,"Erreur de cohérence de la connectivité lue.\n");return -1;}
87  }
88 
90  _meshname,
91  MED_NO_DT,
92  MED_NO_IT,
93  _geotype,
94  _varattname1_1,
95  _read_varatrvalue1_1
96  ) < 0 ) {
97  return -1;
98  }
99 
100  for ( _i=0; _i < _nentity; ++_i ) {
101  fprintf(stdout,"Vattr[%d]=%d.\n",_i,_read_varatrvalue1_1[_i]);
102  if ( _read_varatrvalue1_1[_i]!=_varatrvalue1_1[_i] ) {
103  fprintf(stderr,"Erreur de cohérence des valeurs"
104  " de l'attribut variable %s.\n",_varattname1_1);
105  return -1;}
106  }
107 
108  return _ret;
109 
110 }
111 
MEDmeshStructElementVarAttRd
MEDC_EXPORT med_err MEDmeshStructElementVarAttRd(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_geometry_type mgeotype, const char *const varattname, void *const value)
Cette routine lit les valeurs d'un attribut caractéristique variable sur les éléments de structure d'...
Definition: MEDmeshStructElementVarAttRd.c:43
MED_ACC_RDONLY
Definition: med.h:122
med_geometry_type
int med_geometry_type
Definition: med.h:196
med_idt
hid_t med_idt
Definition: med.h:333
med_err
herr_t med_err
Definition: med.h:334
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
MED_FULL_INTERLACE
Definition: med.h:98
med_int
int med_int
Definition: med.h:344
MED_STRUCT_ELEMENT
Definition: med.h:146
main
int main(int argc, char **argv)
Definition: Test_MEDmeshStructElementVarAttRd.c:32
MED_NO_DT
#define MED_NO_DT
Definition: med.h:322
MED_NONE
#define MED_NONE
Definition: med.h:233
MEDstructElementGeotype
MEDC_EXPORT med_geometry_type MEDstructElementGeotype(const med_idt fid, const char *const modelname)
Cette routine renvoie le type géométrique mgeotype associé au modèle d'éléments de structure de nom m...
Definition: MEDstructElementGeotype.c:38
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:83
med_utils.h
med.h
MED_NO_IT
#define MED_NO_IT
Definition: med.h:323
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
MED_NODAL
Definition: med.h:257
MEDmeshElementConnectivityRd
MEDC_EXPORT med_err MEDmeshElementConnectivityRd(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_connectivity_mode cmode, const med_switch_mode switchmode, med_int *const connectivity)
Cette routine permet de lire dans un maillage le tableau des connectivités pour un type géométrique d...
Definition: MEDmeshElementConnectivityRd.c:40