MED fichier: Fichier source de MEDstructElementInfoByName.c

MED fichier

- Documentation MED
- Guides d'utilisation
- Guides de référence

MEDstructElementInfoByName.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 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 #include <med_config.h>
21 #include <med_outils.h>
22
23 #include <stdlib.h>
24 #include <string.h>
25
48 med_err
49 MEDstructElementInfoByName(const med_idt fid,
50 const char * const modelname,
51 med_geometry_type * const mgeotype,
52 med_int* const modeldim,
53 char* const supportmeshname,
54 med_entity_type* const sentitytype,
55 med_int* const snnode,
56 med_int* const sncell,
57 med_geometry_type* const sgeotype,
58 med_int* const nconstantattribute,
59 med_bool* const anyprofile,
60 med_int* const nvariableattribute
61 )
62 {
63
64 med_err _ret=-1;
65 med_idt _elemid=0, _cstid=0;
66 char _path[MED_ELSTRUCT_GRP_SIZE+MED_NAME_SIZE+1]=MED_ELSTRUCT_GRP;
67 char __profilename [MED_NAME_SIZE+1]=MED_NO_PROFILE_INTERNAL;
68 const char* _profilename = __profilename;
69 med_int _intentitytype = MED_UNDEF_ENTITY_TYPE;
70 med_int _nentity = 0;
71 med_size _tmpn = 0;
72 med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
73 med_int _medintmgeotype = MED_NONE;
74 med_int _medintsgeotype = MED_NONE;
75 med_int _intanyprofile = 0;
76
77 strcat(_path,modelname);
78
79 /*
80 * Si le DataGroup /STRUCT/<modelname> n'existe pas => erreur
81 */
82 if ((_elemid = _MEDdatagroupOpen(fid,_path)) < 0) {
83 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
84 goto ERROR;
85 }
86
87 /*
88 * Lecture de l'attribut MED_NOM_NEO (numéro de type géométrique associé à un élément de structure)
89 */
90 if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintmgeotype) < 0 ) {
91 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
92 SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintmgeotype);
93 goto ERROR;
94 }
95 *mgeotype=_medintmgeotype;
96
97 /*
98 * Lecture de l'attribut MED_NOM_DIM (dimension de l'élément)
99 */
100 if ( _MEDattrEntierLire(_elemid,MED_NOM_DIM,modeldim) < 0 ) {
101 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
102 SSCRUTE(MED_NOM_DIM);ISCRUTE(*modeldim);
103 goto ERROR;
104 }
105
106 /*
107 * Lecture de l'attribut MED_NOM_NOM (nom du maillage support)
108 */
109 /* TODO : Chercher plutôt ds le maillage support et supprimer les attributs NBM et NBN : .. A évaluer ...*/
110 if ( _MEDattrStringLire(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
111 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
112 SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
113 goto ERROR;
114 }
115
116 /*
117 * Lecture de l'attribut MED_NOM_ENT (type d'entité support)
118 */
119 if ( _MEDattrEntierLire(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
120 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
121 SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
122 goto ERROR;
123 }
124
125 *sentitytype = (med_entity_type) _intentitytype;
126
127 /*
128 * Lecture de l'attribut MED_NOM_GEO (type géométrique des mailles support)
129 */
130 if ( _MEDattrEntierLire(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
131 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
132 SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
133 goto ERROR;
134 }
135 *sgeotype=_medintsgeotype;
136
137 /*
138 * Lecture du nombre de noeuds support
139 */
140 if (strlen(supportmeshname)) {
141 if ( (*snnode = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
142 MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
143 &_chgt,&_trsf) ) <= 0) {
144 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
145 ISCRUTE(*snnode);goto ERROR;
146 }
147 } else {
148 *snnode=1;
149 }
150 /*
151 * Lecture du nombre de mailles support
152 */
153
154 if (strlen(supportmeshname)) {
155 if ( (*sncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
156 MED_CELL,*sgeotype,MED_CONNECTIVITY,MED_NODAL,
157 &_chgt,&_trsf) ) < 0) {
158 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
159 ISCRUTE(*sncell);goto ERROR;
160 }
161 } else {
162 *sncell=0;
163 }
164
165
166 _MEDnObjects(_elemid,MED_CSTATR_NOM,&_tmpn);
167
168 if ( _tmpn > 0) {
169
170 if ((_cstid = _MEDdatagroupOpen(_elemid,MED_CSTATR_NOM)) < 0) {
171 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
172 SSCRUTE(_path);goto ERROR;
173 }
174
175 if ( _MEDattrEntierLire(_cstid,MED_NOM_PFU,&_intanyprofile) < 0) {
176 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_STRUCT_MSG);
177 SSCRUTE(modelname);SSCRUTE(MED_NOM_PFU);
178 goto ERROR;
179 }
180 *anyprofile=_intanyprofile;
181
182 *nconstantattribute = (med_int) _tmpn;
183
184 } else {
185 *anyprofile = MED_FALSE;
186 *nconstantattribute = 0;
187 }
188
189 _MEDnObjects(_elemid,MED_VARATR_NOM,&_tmpn);
190 if ( _tmpn > 0)
191 *nvariableattribute = (med_int) _tmpn;
192 else
193 *nvariableattribute = (med_int) 0;
194
195 _ret=0;
196
197 ERROR:
198
199 if (_cstid>0) if (_MEDdatagroupFermer(_cstid) < 0) {
200 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
201 ISCRUTE_id(_cstid);
202 }
203
204 if (_elemid>0) if (_MEDdatagroupFermer(_elemid) < 0) {
205 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
206 ISCRUTE_id(_elemid);
207 }
208
209 return _ret;
210 }
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition: med_err.h:99
MED_COORDINATE
Definition: med.h:147
MED_CONNECTIVITY
Definition: med.h:147
med_err
herr_t med_err
Definition: med.h:327
MED_NO_IT
#define MED_NO_IT
Definition: med.h:316
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:158
MED_ERR_READ
#define MED_ERR_READ
Definition: med_err.h:25
MED_NODAL
Definition: med.h:252
MEDmeshnEntity
MEDC_EXPORT med_int MEDmeshnEntity(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_data_type datatype, const med_connectivity_mode cmode, med_bool *const changement, med_bool *const transformation)
Cette routine permet de lire le nombre d'entités dans un maillage pour une séquence de calcul donnée...
Definition: MEDmeshnEntity.c:44
med_size
hsize_t med_size
Definition: med.h:324
MED_NO_PROFILE_INTERNAL
#define MED_NO_PROFILE_INTERNAL
Definition: med.h:293
MED_VARATR_NOM
#define MED_VARATR_NOM
Definition: med_outils.h:190
MED_NOM_DIM
#define MED_NOM_DIM
Definition: med_outils.h:58
MED_CSTATR_NOM
#define MED_CSTATR_NOM
Definition: med_outils.h:185
MED_ELSTRUCT_GRP
#define MED_ELSTRUCT_GRP
Definition: med_outils.h:171
MED_NODE
Definition: med.h:141
MED_ELSTRUCT_GRP_SIZE
#define MED_ELSTRUCT_GRP_SIZE
Definition: med_outils.h:172
med_entity_type
med_entity_type
Definition: med.h:141
MED_ERR_CALL
#define MED_ERR_CALL
Definition: med_err.h:45
MED_CELL
Definition: med.h:141
MED_NONE
#define MED_NONE
Definition: med.h:228
MED_ERR_STRUCT_MSG
#define MED_ERR_STRUCT_MSG
Definition: med_err.h:168
MED_NOM_PFU
#define MED_NOM_PFU
Definition: med_outils.h:127
med_int
int med_int
Definition: med.h:337
MED_NOM_NEO
#define MED_NOM_NEO
Definition: med_outils.h:120
med_config.h
MED_FALSE
Definition: med.h:257
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:306
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:27
MED_NOM_NOM
#define MED_NOM_NOM
Definition: med_outils.h:40
MED_UNDEF_ENTITY_TYPE
Definition: med.h:143
MED_NO_CMODE
Definition: med.h:252
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:98
MEDstructElementInfoByName
med_err MEDstructElementInfoByName(const med_idt fid, const 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 à partir de son nom...
Definition: MEDstructElementInfoByName.c:49
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:34
_MEDattrEntierLire
#define _MEDattrEntierLire(x, y, z)
Definition: med_hdfi.h:64
med_idt
hid_t med_idt
Definition: med.h:326
MED_NO_DT
#define MED_NO_DT
Definition: med.h:315
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
med_outils.h
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:79
_MEDattrStringLire
MEDC_EXPORT med_err _MEDattrStringLire(med_idt pere, char *nom, int longueur, char *val)
med.h
med_bool
med_bool
Definition: med.h:257
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition: med_utils.h:311
_MEDnObjects
MEDC_EXPORT med_err _MEDnObjects(const med_idt fid, const char *const path, med_size *n)
med_geometry_type
int med_geometry_type
Definition: med.h:191
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:315
MED_ERR_API
#define MED_ERR_API
Definition: med_err.h:108
MED_NOM_ENT
#define MED_NOM_ENT
Definition: med_outils.h:121
_MEDdatagroupOpen
MEDC_EXPORT med_idt _MEDdatagroupOpen(const med_idt pid, const char *const name)
MED_NOM_GEO
#define MED_NOM_GEO
Definition: med_outils.h:119