Debian Codegraph @

tests/unittests/c/Test_MEDstructElementConstAttInfo.c

raw
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2020 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 med_int _ncomponent=0;
57 med_entity_type _attentitytype=MED_UNDEF_ENTITY_TYPE;
58 char _profilename[MED_NAME_SIZE+1]="";
59 med_int _profilesize=0;
60
61
62 /* Ouverture en mode lecture du fichier Test_MEDstructuElement.med */
63 _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
64 if (_fid < 0) {
65 MESSAGE("Erreur à la lecture du fichier current.med");
66 return -1;
67 }
68
69 if ( (_nstructelement = MEDnStructElement(_fid)) <0) _ret=_nstructelement;
70
71 for ( _i=1; _i<= _nstructelement; ++_i) {
72
73 if (
74 MEDstructElementInfo(_fid,
75 _i,
76 _elementname,
77 &_geotype,
78 &_elementdim,
79 _supportmeshname,
80 &_entitytype,
81 &_nnode,
82 &_ncell,
83 &_geocelltype,
84 &_nconstantattribute,
85 &_anyprofile,
86 &_nvariableattribute
87 )
88 ) return -1;
89
90 fprintf(stdout,"Elément de structure n° %d |%s| de type géométrique n° %d et de dimension %d\n",
91 _i,_elementname,_geotype,_elementdim);
92 if ( strlen(_supportmeshname) ) {
93 fprintf(stdout,"\t Maillage support de nom |%s|",_supportmeshname);
94 if (_ncell)
95 fprintf(stdout," avec %d maille(s) de type %d et ",_ncell,_geocelltype);
96 if (_nnode)
97 fprintf(stdout," avec %d noeud(s)\n",_nnode);
98 else {
99 fprintf(stderr,"\n Erreur : les noeuds doivent être définis s'il existe un maillage support\n");
100 }
101 } else
102 fprintf(stdout,"\t Maillage support implicite sur noeud\n");
103 fprintf(stdout,"\t Nombre d'attribut(s) constant(s) : %d",_nconstantattribute);
104 if (_anyprofile) fprintf(stdout,", avec profil.\n"); else fprintf(stdout,", sans profil.\n");
105 if ( _nconstantattribute ) {
106 for (_j=1;_j<=_nconstantattribute;++_j) {
107 if ( MEDstructElementConstAttInfo(_fid,
108 _elementname,
109 _j,
110 _constattname,
111 &_constatttype,
112 &_ncomponent,
113 &_attentitytype,
114 _profilename,
115 &_profilesize
116 ) < 0
117 ) return -1;
118 fprintf(stdout,"\t\t Attribut constant de nom |%s| de type %d à %d composantes\n",
119 _constattname,_constatttype,_ncomponent);
120 fprintf(stdout,"\t\t Cet Attribut est attaché au type d'entité %d avec un profil |%s| de taille %d\n",
121 _attentitytype,_profilename,_profilesize);
122
123 }
124 }
125 fprintf(stdout,"\t Nombre d'attributs variables : %d\n",_nvariableattribute);
126
127 }
128
129
130 if (MEDfileClose(_fid) < 0) {
131 MESSAGE("ERROR : file closing");
132 return -1;
133 }
134
135 return _ret;
136
137
138 }
139