MED fichier

Test_MEDstructElementVarAttInfo.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2021 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 int _i =0;
38 int _j =0;
39 med_int _nstructelement=0;
40
41 med_geometry_type _geotype=MED_NONE;
42
43 char _elementname[MED_NAME_SIZE+1]="";
44 med_int _elementdim=0;
45 char _supportmeshname[MED_NAME_SIZE+1]="";
46 med_entity_type _entitytype=MED_UNDEF_ENTITY_TYPE;
47 med_int _nnode=0;
48 med_int _ncell=0;
49 med_geometry_type _geocelltype=MED_NONE;
50 med_int _nconstantattribute=0;
51 med_bool _anyprofile=0;
52 med_int _nvariableattribute=0;
53
54 char _constattname[MED_NAME_SIZE+1]="";
55 med_attribute_type _constatttype=MED_ATT_UNDEF;
56 char _varattname[MED_NAME_SIZE+1]="";
57 med_attribute_type _varatttype=MED_ATT_UNDEF;
58 med_int _ncomponent=0;
59 med_entity_type _attentitytype=MED_UNDEF_ENTITY_TYPE;
60 char _profilename[MED_NAME_SIZE+1]="";
61 med_int _profilesize=0;
62
63
64 /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
65 _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
66 if (_fid < 0) {
67 MESSAGE("Erreur à la lecture du fichier current.med");
68 return -1;
69 }
70
71 if ( (_nstructelement = MEDnStructElement(_fid)) <0) _ret=_nstructelement;
72
73 for ( _i=1; _i<= _nstructelement; ++_i) {
74
75 if (
76 MEDstructElementInfo(_fid,
77 _i,
78 _elementname,
79 &_geotype,
80 &_elementdim,
81 _supportmeshname,
82 &_entitytype,
83 &_nnode,
84 &_ncell,
85 &_geocelltype,
86 &_nconstantattribute,
87 &_anyprofile,
88 &_nvariableattribute
89 )
90 ) return -1;
91
92 fprintf(stdout,"Elément de structure n° %d |%s| de type géométrique n° %d et de dimension %d\n",
93 _i,_elementname,_geotype,_elementdim);
94 if ( strlen(_supportmeshname) ) {
95 fprintf(stdout,"\t Maillage support de nom |%s|",_supportmeshname);
96 if (_ncell)
97 fprintf(stdout," avec %d maille(s) de type %d et ",_ncell,_geocelltype);
98 if (_nnode)
99 fprintf(stdout," avec %d noeud(s)\n",_nnode);
100 else {
101 fprintf(stderr,"\n Erreur : les noeuds doivent être définis s'il existe un maillage support\n");
102 }
103 } else
104 fprintf(stdout,"\t Maillage support implicite sur noeud\n");
105 fprintf(stdout,"\t Nombre d'attribut(s) constant(s) : %d",_nconstantattribute);
106 if (_anyprofile) fprintf(stdout,", avec profil.\n"); else fprintf(stdout,", sans profil.\n");
107 if ( _nconstantattribute ) {
108 for (_j=1;_j<=_nconstantattribute;++_j) {
109 if ( MEDstructElementConstAttInfo(_fid,
110 _elementname,
111 _j,
112 _constattname,
113 &_constatttype,
114 &_ncomponent,
115 &_attentitytype,
116 _profilename,
117 &_profilesize
118 ) < 0
119 ) return -1;
120 fprintf(stdout,"\t\t Attribut constant de nom |%s| de type %d à %d composantes\n",
121 _constattname,_constatttype,_ncomponent);
122 fprintf(stdout,"\t\t Cet Attribut est attaché au type d'entité %d avec un profil |%s| de taille %d\n",
123 _attentitytype,_profilename,_profilesize);
124
125 }
126 }
127
128 fprintf(stdout,"\t Nombre d'attributs variables : %d\n",_nvariableattribute);
129 if ( _nvariableattribute ) {
130 for (_j=1;_j<=_nvariableattribute;++_j) {
131 if ( MEDstructElementVarAttInfo(_fid,
132 _elementname,
133 _j,
134 _varattname,
135 &_varatttype,
136 &_ncomponent ) < 0
137 ) return -1;
138 fprintf(stdout,"\t\t Attribut variable de nom |%s| de type %d à %d composantes\n",
139 _varattname,_varatttype,_ncomponent);
140 }
141 }
142
143 }
144
145
146 if (MEDfileClose(_fid) < 0) {
147 MESSAGE("ERROR : file closing");
148 return -1;
149 }
150
151 return _ret;
152
153
154 }
155
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_geometry_type
int med_geometry_type
Definition: med.h:194
med_idt
hid_t med_idt
Definition: med.h:331
MED_ACC_RDONLY
Definition: med.h:120
med_err
herr_t med_err
Definition: med.h:332
med_entity_type
med_entity_type
Definition: med.h:143
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:342
med_attribute_type
med_attribute_type
Definition: med.h:173
med.h
med_bool
med_bool
Definition: med.h:260
main
int main(int argc, char **argv)
Definition: Test_MEDstructElementVarAttInfo.c:32
MED_NONE
#define MED_NONE
Definition: med.h:231
MEDnStructElement
MEDC_EXPORT med_int MEDnStructElement(const med_idt fid)
Cette routine renvoie le nombre de modèles d'éléments de structure.
Definition: MEDnStructElement.c:35
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MED_UNDEF_ENTITY_TYPE
Definition: med.h:145
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
MEDstructElementConstAttInfo
MEDC_EXPORT med_err MEDstructElementConstAttInfo(const med_idt fid, const char *const modelname, const int attit, char *const constattname, med_attribute_type *const constatttype, med_int *const ncomponent, med_entity_type *const sentitytype, char *const profilename, med_int *const profilesize)
Cette routine décrit les caractéristiques d'un attribut constant de modèle d'élément de structure par...
Definition: MEDstructElementConstAttInfo.c:45
MEDstructElementInfo
MEDC_EXPORT med_err MEDstructElementInfo(const med_idt fid, const int mit, char *const modelname, med_geometry_type *const mgeotype, med_int *const modeldim, char *const supportmeshname, med_entity_type *const sentitytype, med_int *const snnode, med_int *const sncell, med_geometry_type *const sgeotype, med_int *const nconstantattribute, med_bool *const anyprofile, med_int *const nvariableattribute)
Cette routine décrit les caractéristiques d'un modèle d'élément de structure par itération.
Definition: MEDstructElementInfo.c:50
MED_ATT_UNDEF
Definition: med.h:176
MEDstructElementVarAttInfo
MEDC_EXPORT med_err MEDstructElementVarAttInfo(const med_idt fid, const char *const modelname, const int attit, char *const varattname, med_attribute_type *const varatttype, med_int *const ncomponent)
Cette routine décrit les caractéristiques d'un attribut variable de modèle d'élément de structure par...
Definition: MEDstructElementVarAttInfo.c:41
med_utils.h