MED fichier: Fichier source de MEDstructElementConstAttWithProfileWr.c

MED fichier

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

MEDstructElementConstAttWithProfileWr.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 <string.h>
24 #include <stdlib.h>
25
43 med_err
44 MEDstructElementConstAttWithProfileWr(const med_idt fid,
45 const char* const modelname,
46 const char* const constattname,
47 const med_attribute_type constatttype,
48 const med_int ncomponent,
49 const med_entity_type sentitytype,
50 const char* const profilename,
51 const void* const value
52 )
53 {
54 med_access_mode _MED_ACCESS_MODE;
55 med_err _ret=-1;
56 med_idt _attid=0, _elemid=0, _cstid=0;
57 char _path[MED_ELSTRUCT_GRP_SIZE+MED_NAME_SIZE+1+MED_TAILLE_CSTATR+MED_NAME_SIZE+1]=MED_ELSTRUCT_GRP;
58 char _supportmeshname[MED_NAME_SIZE+1]="";
59 med_int _intentitytype = sentitytype;
60 med_int _nentity = 0;
61 med_filter _filter = MED_FILTER_INIT;
62 med_int _false=0,_true=1,_true_or_false = _false;
63 med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
64 med_int _medintsgeotype =MED_NONE;
65 med_geometry_type _sgeotype =MED_NONE;
66 med_int _medintconstatttype= (med_int) constatttype;
67
68 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
69
70 if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
71 MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
72 goto ERROR;
73 }
74
75 if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
76 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
77 ISCRUTE_int(_MED_ACCESS_MODE);
78 goto ERROR;
79 }
80
81 NOFINALBLANK(modelname,ERROR);
82 NOFINALBLANK(constattname,ERROR);
83 NOFINALBLANK(profilename,ERROR);
84
85 strcat(_path,modelname);
86
87 /*
88 * Si le DataGroup /STRUCT/<modelname> n'existe pas => erreur
89 */
90 if ((_elemid = _MEDdatagroupOpen(fid,_path)) < 0) {
91 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
92 goto ERROR;
93 }
94
95 /*
96 * Lecture de l'attribut MED_NOM_NOM (nom du maillage support)
97 */
98 if ( _MEDattrStringLire(_elemid,MED_NOM_NOM,MED_NAME_SIZE,_supportmeshname) < 0) {
99 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
100 SSCRUTE(MED_NOM_NOM);SSCRUTE(_supportmeshname);
101 goto ERROR;
102 }
103
104 if (strlen(_supportmeshname) ) {
105
106 if (sentitytype == MED_CELL ) {
107 /*
108 * Lecture de l'attribut MED_NOM_GEO (type géométrique des mailles support)
109 */
110 if ( _MEDattrEntierLire(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
111 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
112 SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
113 goto ERROR;
114 }
115
116 _sgeotype= (med_geometry_type) _medintsgeotype;
117 }
118
119 if ( (_nentity = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
120 MED_CELL,_sgeotype,MED_CONNECTIVITY,MED_NODAL,
121 &_chgt,&_trsf) ) < 0) {
122 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
123 ISCRUTE(_nentity);goto ERROR;
124 }
125
126 if (sentitytype == MED_NODE )
127 if ( (_nentity = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
128 MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
129 &_chgt,&_trsf) ) <= 0) {
130 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
131 ISCRUTE(_nentity);goto ERROR;
132 }
133 } else
134 _nentity = 1;
135
136 /*
137 * Si le DataGroup /STRUCT/<modelname>/CSTATR/ n'existe pas on le crée
138 */
139 if ((_cstid = _MEDdatagroupOpen(_elemid,MED_CSTATR_NOM)) < 0)
140 if ((_cstid = _MEDdatagroupCreer(_elemid,MED_CSTATR_NOM)) < 0) {
141 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
142 SSCRUTE(_path);goto ERROR;
143 }
144 strcat(_path,MED_CSTATR);
145
146 /*
147 * Si le DataGroup /STRUCT/<modelname>/CSTATR/<constattname> n'existe pas on le crée
148 */
149 if ((_attid = _MEDdatagroupOpen(_cstid,constattname)) < 0)
150 if ((_attid = _MEDdatagroupCreer(_cstid,constattname)) < 0) {
151 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,constattname);
152 SSCRUTE(_path);goto ERROR;
153 }
154 strcat(_path,constattname);
155
156 /*
157 * Creation/Ecriture de l'attribut MED_NOM_ATT (type des valeurs de l'attribut.)
158 */
159 if ( _MEDattributeIntWr(_attid,MED_NOM_ATT,&_medintconstatttype) < 0 ) {
160 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
161 SSCRUTE(MED_NOM_ATT);ISCRUTE(_medintconstatttype);
162 goto ERROR;
163 }
164
165 /*
166 * Creation/Ecriture de l'attribut MED_NOM_NCO (nombre de composantes des valeurs de l'attribut.)
167 */
168 if ( _MEDattributeIntWr(_attid,MED_NOM_NCO,&ncomponent) < 0 ) {
169 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
170 SSCRUTE(MED_NOM_NCO);ISCRUTE(ncomponent);
171 goto ERROR;
172 }
173
174 /*
175 * Creation/Ecriture de l'attribut MED_NOM_ENT (type d'entité support concerné par l'attribut)
176 */
177 if ( _MEDattributeIntWr(_attid,MED_NOM_ENT,&_intentitytype) < 0 ) {
178 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
179 SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
180 goto ERROR;
181 }
182
183 /*
184 * Creation/Ecriture de l'attribut MED_NOM_PFL (nom de profil sur le maillage support)
185 */
186 if ( strlen(profilename) ) {
187 /* _profilename=(const char *)profilename; */
188 _true_or_false=_true;
189 }
190
191 if ( _MEDattributeIntWr(_cstid,MED_NOM_PFU,&_true_or_false) < 0) {
192 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_STRUCT_MSG);
193 SSCRUTE(modelname);;SSCRUTE(MED_NOM_PFU);
194 goto ERROR;
195 }
196
197 if ( _MEDattributeStringWr(_attid,MED_NOM_PFL,MED_NAME_SIZE,profilename) < 0) {
198 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
199 SSCRUTE(MED_NOM_PFL);SSCRUTE(profilename);
200 goto ERROR;
201 }
202
203 if ( MEDfilterEntityCr(fid, _nentity, 1, ncomponent, MED_ALL_CONSTITUENT,
204 MED_FULL_INTERLACE,MED_COMPACT_STMODE,
205 profilename, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
206 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
207 goto ERROR;
208 }
209
210 if ( _MEDdatasetWr(_attid,MED_NOM_COR,constatttype,&_filter, value) < 0) {
211 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_COR);
212 SSCRUTE(_path);
213 goto ERROR;
214 }
215
216 if ( MEDfilterClose(&_filter) < 0 ) {
217 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_STRUCT_ELEMENT_MSG);
218 SSCRUTE(_path);
219 goto ERROR;
220 }
221
222 /* ??? */
223 /* if ((_dataset = _MEDdatasetOuvrir(_datagroup2,MED_NOM_COR)) < 0) { */
224 /* MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATASET,MED_NOM_COR); */
225 /* SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2); */
226 /* goto ERROR; */
227 /* } */
228
229 /* if ( _MEDattributeIntWr(_dataset,MED_NOM_NBR,&nentity) < 0) { */
230 /* MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_EQUIVALENCE_MSG); */
231 /* SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2); */
232 /* SSCRUTE(MED_NOM_NBR);ISCRUTE(nentity);goto ERROR; */
233 /* } */
234 /* ??? */
235
236
237 _ret=0;
238 ERROR:
239
240 if (_attid>0) if (_MEDdatagroupFermer(_attid) < 0) {
241 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
242 ISCRUTE_id(_attid);
243 }
244
245 if (_cstid>0) if (_MEDdatagroupFermer(_cstid) < 0) {
246 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
247 ISCRUTE_id(_cstid);
248 }
249
250 if (_elemid>0) if (_MEDdatagroupFermer(_elemid) < 0) {
251 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
252 ISCRUTE_id(_elemid);
253 }
254
255 return _ret;
256 }
med_filter
Filtre de sélection.
Definition: med.h:350
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_NOM_PFL
#define MED_NOM_PFL
Definition: med_outils.h:126
med_err
herr_t med_err
Definition: med.h:327
MED_TAILLE_CSTATR
#define MED_TAILLE_CSTATR
Definition: med_outils.h:186
NOFINALBLANK
#define NOFINALBLANK(chaine, label)
Definition: med_utils.h:304
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_FILE_MSG
#define MED_ERR_FILE_MSG
Definition: med_err.h:129
MEDfilterEntityCr
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)
Definition: MEDfilterEntityCr.c:56
MED_ERR_INVALID
#define MED_ERR_INVALID
Definition: med_err.h:37
MED_ERR_READ
#define MED_ERR_READ
Definition: med_err.h:25
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
med_access_mode
med_access_mode
Definition: med.h:118
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_FULL_INTERLACE
Definition: med.h:94
MED_FILTER_INIT
#define MED_FILTER_INIT
Definition: med.h:369
_MEDattributeStringWr
MEDC_EXPORT med_err _MEDattributeStringWr(med_idt pid, const char *const attname, const med_size attsize, const char *const val)
MED_ALL_CONSTITUENT
#define MED_ALL_CONSTITUENT
Definition: med.h:296
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
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition: med_utils.h:307
MED_ERR_ACCESSMODE
#define MED_ERR_ACCESSMODE
Definition: med_err.h:103
MED_COMPACT_STMODE
Definition: med.h:108
MED_ERR_UNRECOGNIZED
#define MED_ERR_UNRECOGNIZED
Definition: med_err.h:36
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition: med_err.h:26
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_config.h
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:24
MED_FALSE
Definition: med.h:257
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:306
_MEDdatasetWr
MEDC_EXPORT med_err _MEDdatasetWr(const med_idt id, const char *const datasetname, const med_internal_type datatype, const med_filter *const filter, const void *const value)
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:27
MED_NOM_NOM
#define MED_NOM_NOM
Definition: med_outils.h:40
MEDstructElementConstAttWithProfileWr
med_err MEDstructElementConstAttWithProfileWr(const med_idt fid, const char *const modelname, const char *const constattname, const med_attribute_type constatttype, const med_int ncomponent, const med_entity_type sentitytype, const char *const profilename, const void *const value)
Cette routine définit un attribut caractéristique constant d'un modèle d'éléments de structure...
Definition: MEDstructElementConstAttWithProfileWr.c:44
_MEDattributeIntWr
#define _MEDattributeIntWr(w, x, y)
Definition: med_hdfi.h:45
MED_CSTATR
#define MED_CSTATR
Definition: med_outils.h:184
MED_ACC_UNDEF
Definition: med.h:122
MED_NO_CMODE
Definition: med.h:252
MEDfilterClose
MEDC_EXPORT med_err MEDfilterClose(med_filter *const filter)
Désalloue les ressources hdf détenues par un filtre.
Definition: MEDfilterClose.c:35
MED_ERR_INTERNAL_MSG
#define MED_ERR_INTERNAL_MSG
Definition: med_err.h:191
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:98
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:34
MED_NOM_NCO
#define MED_NOM_NCO
Definition: med_outils.h:50
MED_NOM_ATT
#define MED_NOM_ATT
Definition: med_outils.h:48
_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_ERR_STRUCT_ELEMENT_MSG
#define MED_ERR_STRUCT_ELEMENT_MSG
Definition: med_err.h:133
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
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
MED_UNDEF_SIZE
#define MED_UNDEF_SIZE
Definition: med.h:303
MED_ERR_DATASET
#define MED_ERR_DATASET
Definition: med_err.h:97
med_geometry_type
int med_geometry_type
Definition: med.h:191
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:315
MED_ERR_FILTER
#define MED_ERR_FILTER
Definition: med_err.h:92
MED_ERR_API
#define MED_ERR_API
Definition: med_err.h:108
med_attribute_type
med_attribute_type
Definition: med.h:170
MED_NOM_ENT
#define MED_NOM_ENT
Definition: med_outils.h:121
MED_NOM_COR
#define MED_NOM_COR
Definition: med_outils.h:57
_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
MED_ACC_RDONLY
Definition: med.h:118