MED fichier
MEDstructElementConstAttRd.c
Aller à la documentation de ce fichier.
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#include <med_config.h>
21#include <med_outils.h>
22
23#include <string.h>
24#include <stdlib.h>
25
43 const med_idt fid,
44 const char* const modelname,
45 const char* const constattname,
46 void* const value
47 )
48{
49 med_err _ret=-1;
50 med_idt _attid=0, _elemid=0 ;
52 med_int _intentitytype = 0;
53 med_int _nentity = 0;
54 med_attribute_type _constatttype = MED_ATT_UNDEF;
55 med_int _ncomponent = 0;
57 char _supportmeshname[MED_NAME_SIZE+1]="";
58 char _profilename [MED_NAME_SIZE+1]="";
59 med_int _profilesize = 0;
61 med_int _medintsgeotype = MED_NONE;
62 med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
63
64 NOFINALBLANK(modelname,ERROR);
65 NOFINALBLANK(constattname,ERROR);
66
67 strcat(_path,modelname);
68
69
70 /*
71 * Si le DataGroup /STRUCT/<modelname> n'existe pas => erreur
72 */
73 if ((_elemid = _MEDdatagroupOpen(fid,_path)) < 0) {
75 goto ERROR;
76 }
77
78 strcat(_path,MED_CSTATR);
79 strcat(_path,constattname);
80
81 /*
82 * Si le DataGroup /STRUCT/<modelname>/CSTATT/<constattributename> n'existe pas => erreur
83 */
84 if ((_attid = _MEDdatagroupOpen(fid,_path)) < 0) {
86 goto ERROR;
87 }
88
89
90 /*
91 * Lecture de l'attribut MED_NOM_NOM (nom du maillage support)
92 */
93 /* Chercher plutôt ds le maillage support et supprimer les attributs NBM et NBN */
94 if ( _MEDattrStringLire(_elemid,MED_NOM_NOM,MED_NAME_SIZE,_supportmeshname) < 0) {
96 SSCRUTE(MED_NOM_NOM);SSCRUTE(_supportmeshname);
97 goto ERROR;
98 }
99
100 if (
102 modelname,
103 constattname,
104 &_constatttype,
105 &_ncomponent,
106 &_entitytype,
107 _profilename,
108 &_profilesize
109 ) < 0 ) {
111 SSCRUTE(modelname);SSCRUTE(_path);SSCRUTE("MEDstructElementConstAttInfoByName");
112 goto ERROR;
113 }
114
115
116 if (strlen(_supportmeshname) ) {
117
118 if (_entitytype == MED_CELL )
119
120 /*
121 * Lecture de l'attribut MED_NOM_GEO (type géométrique des mailles support)
122 */
123 if ( _MEDattrEntierLire(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
125 SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
126 goto ERROR;
127 }
128
129 if ( (_nentity = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
130 MED_CELL,(med_geometry_type) _medintsgeotype,
132 &_chgt,&_trsf) ) < 0) {
133 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
134 ISCRUTE(_nentity);goto ERROR;
135 }
136
137 if (_entitytype == MED_NODE )
138 if ( (_nentity = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
140 &_chgt,&_trsf) ) <= 0) {
141 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
142 ISCRUTE(_nentity);goto ERROR;
143 }
144 } else
145 _nentity = 1;
146
147 if ( MEDfilterEntityCr(fid, _nentity, 1, _ncomponent, MED_ALL_CONSTITUENT,
149 _profilename, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
151 goto ERROR;
152 }
153
154 if ( _MEDdatasetRd(_attid,MED_NOM_COR,_constatttype,&_filter, (unsigned char * ) value) < 0) {
156 SSCRUTE(_path);
157 goto ERROR;
158 }
159
160 if ( MEDfilterClose(&_filter) < 0 ) {
162 SSCRUTE(_path);
163 goto ERROR;
164 }
165
166 _ret=0;
167 ERROR:
168
169 if (_attid>0) if (_MEDdatagroupFermer(_attid) < 0) {
171 ISCRUTE_id(_attid);
172 }
173
174 if (_elemid>0) if (_MEDdatagroupFermer(_elemid) < 0) {
176 ISCRUTE_id(_elemid);
177 }
178
179 return _ret;
180}
181
MEDC_EXPORT med_err MEDfilterClose(med_filter *const filter)
Désalloue les ressources hdf détenues par un filtre.
MEDC_EXPORT med_err MEDfilterEntityCr(const med_idt fid, const med_int nentity, const med_int nvaluesperentity, const med_int nconstituentpervalue, const med_int constituentselect, const med_switch_mode switchmode, const med_storage_mode storagemode, const char *const profilename, const med_int filterarraysize, const med_int *const filterarray, med_filter *const filter)
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 étape de calcul donnée.
med_err MEDstructElementConstAttRd(const med_idt fid, const char *const modelname, const char *const constattname, void *const value)
Cette routine lit la valeur d'un attribut caractéristique constant d'un modèle d'éléments de structur...
MEDC_EXPORT med_err MEDstructElementConstAttInfoByName(const med_idt fid, const char *const modelname, const 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 à p...
#define MED_NAME_SIZE
Definition med.h:81
@ MED_FULL_INTERLACE
Definition med.h:96
int med_geometry_type
Definition med.h:194
#define MED_FILTER_INIT
Definition med.h:365
med_bool
Definition med.h:260
@ MED_FALSE
Definition med.h:260
@ MED_CONNECTIVITY
Definition med.h:149
@ MED_COORDINATE
Definition med.h:149
@ MED_COMPACT_STMODE
Definition med.h:110
#define MED_ALL_CONSTITUENT
Definition med.h:293
int med_int
Definition med.h:333
#define MED_UNDEF_SIZE
Definition med.h:297
#define MED_NO_DT
Definition med.h:311
#define MED_NO_IT
Definition med.h:312
#define MED_NONE
Definition med.h:231
med_entity_type
Definition med.h:143
@ MED_NODE
Definition med.h:143
@ MED_UNDEF_ENTITY_TYPE
Definition med.h:145
@ MED_CELL
Definition med.h:143
med_attribute_type
Definition med.h:173
@ MED_ATT_UNDEF
Definition med.h:176
herr_t med_err
Definition med.h:323
hid_t med_idt
Definition med.h:322
@ MED_NO_CMODE
Definition med.h:255
@ MED_NODAL
Definition med.h:255
#define MED_ERR_OPEN
Definition med_err.h:37
#define MED_ERR_FILTER
Definition med_err.h:93
#define MED_ERR_CALL
Definition med_err.h:48
#define MED_ERR_DATAGROUP
Definition med_err.h:99
#define MED_ERR_CLOSE
Definition med_err.h:30
#define MED_ERR_STRUCT_ELEMENT_MSG
Definition med_err.h:136
#define MED_ERR_ATTRIBUTE
Definition med_err.h:100
#define MED_ERR_CREATE
Definition med_err.h:27
#define MED_ERR_INTERNAL_MSG
Definition med_err.h:196
#define MED_ERR_API
Definition med_err.h:111
#define MED_ERR_READ
Definition med_err.h:28
#define MED_ERR_WRITE
Definition med_err.h:29
#define MED_ERR_STRUCT_MSG
Definition med_err.h:173
#define MED_ERR_DATASET
Definition med_err.h:98
MEDC_EXPORT med_err _MEDdatasetRd(const med_idt id, const char *const datasetname, const med_internal_type datatype, const med_filter *const filter, unsigned char *const value)
#define _MEDattrEntierLire(x, y, z)
Definition med_hdfi.h:68
MEDC_EXPORT med_idt _MEDdatagroupOpen(const med_idt pid, const char *const name)
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
MEDC_EXPORT med_err _MEDattrStringLire(med_idt pere, char *nom, int longueur, char *val)
#define MED_NOM_NOM
Definition med_outils.h:41
#define MED_ELSTRUCT_GRP_SIZE
Definition med_outils.h:175
#define MED_TAILLE_CSTATR
Definition med_outils.h:195
#define MED_ELSTRUCT_GRP
Definition med_outils.h:174
#define MED_NOM_COR
Definition med_outils.h:55
#define MED_NOM_GEO
Definition med_outils.h:133
#define MED_CSTATR
Definition med_outils.h:193
#define MED_ERR_(rt, r1, r2, r3)
Definition med_utils.h:160
#define SSCRUTE(chaine)
Definition med_utils.h:323
#define ISCRUTE(entier)
Definition med_utils.h:313
#define ISCRUTE_id(entier)
Definition med_utils.h:319
#define NOFINALBLANK(chaine, label)
Definition med_utils.h:311
Filtre de sélection.
Definition med.h:346