MEDstructElementConstAttRd.c
Aller à la documentation de ce fichier.
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 EDF R&D, CEA/DEN
* MED is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MED is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MED. If not, see <http://www.gnu.org/licenses/>.
*/
#include <med.h>
#include <med_config.h>
#include <med_outils.h>
#include <string.h>
#include <stdlib.h>
med_err
MEDstructElementConstAttRd(
const med_idt fid,
const char* const modelname,
const char* const constattname,
void* const value
)
{
med_err _ret=-1;
med_idt _attid=0, _elemid=0 ;
char _path[MED_ELSTRUCT_GRP_SIZE+MED_NAME_SIZE+1+MED_TAILLE_CSTATR+MED_NAME_SIZE+1]=MED_ELSTRUCT_GRP;
med_int _intentitytype = 0;
med_int _nentity = 0;
med_attribute_type _constatttype = MED_ATT_UNDEF;
med_int _ncomponent = 0;
med_entity_type _entitytype = MED_UNDEF_ENTITY_TYPE;
char _supportmeshname[MED_NAME_SIZE+1]="";
char _profilename [MED_NAME_SIZE+1]="";
med_int _profilesize = 0;
med_filter _filter = MED_FILTER_INIT;
med_int _medintsgeotype = MED_NONE;
med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
NOFINALBLANK(modelname,ERROR);
NOFINALBLANK(constattname,ERROR);
strcat(_path,modelname);
/*
* Si le DataGroup /STRUCT/<modelname> n'existe pas => erreur
*/
if ((_elemid = _MEDdatagroupOpen(fid,_path)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
goto ERROR;
}
strcat(_path,MED_CSTATR);
strcat(_path,constattname);
/*
* Si le DataGroup /STRUCT/<modelname>/CSTATT/<constattributename> n'existe pas => erreur
*/
if ((_attid = _MEDdatagroupOpen(fid,_path)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
goto ERROR;
}
/*
* Lecture de l'attribut MED_NOM_NOM (nom du maillage support)
*/
/* Chercher plutôt ds le maillage support et supprimer les attributs NBM et NBN */
if ( _MEDattrStringLire(_elemid,MED_NOM_NOM,MED_NAME_SIZE,_supportmeshname) < 0) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_NOM);SSCRUTE(_supportmeshname);
goto ERROR;
}
if (
MEDstructElementConstAttInfoByName(fid,
modelname,
constattname,
&_constatttype,
&_ncomponent,
&_entitytype,
_profilename,
&_profilesize
) < 0 ) {
MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,MED_ERR_STRUCT_MSG);
SSCRUTE(modelname);SSCRUTE(_path);SSCRUTE("MEDstructElementConstAttInfoByName");
goto ERROR;
}
if (strlen(_supportmeshname) ) {
if (_entitytype == MED_CELL )
/*
* Lecture de l'attribut MED_NOM_GEO (type géométrique des mailles support)
*/
if ( _MEDattrEntierLire(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
goto ERROR;
}
if ( (_nentity = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
MED_CELL,(med_geometry_type) _medintsgeotype,
MED_CONNECTIVITY,MED_NODAL,
&_chgt,&_trsf) ) < 0) {
MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
ISCRUTE(_nentity);goto ERROR;
}
if (_entitytype == MED_NODE )
if ( (_nentity = MEDmeshnEntity(fid,_supportmeshname,MED_NO_DT,MED_NO_IT,
MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,
&_chgt,&_trsf) ) <= 0) {
MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
ISCRUTE(_nentity);goto ERROR;
}
} else
_nentity = 1;
if ( MEDfilterEntityCr(fid, _nentity, 1, _ncomponent, MED_ALL_CONSTITUENT,
MED_FULL_INTERLACE,MED_COMPACT_STMODE,
_profilename, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
goto ERROR;
}
if ( _MEDdatasetRd(_attid,MED_NOM_COR,_constatttype,&_filter, (unsigned char * ) value) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_COR);
SSCRUTE(_path);
goto ERROR;
}
if ( MEDfilterClose(&_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_STRUCT_ELEMENT_MSG);
SSCRUTE(_path);
goto ERROR;
}
_ret=0;
ERROR:
if (_attid>0) if (_MEDdatagroupFermer(_attid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
ISCRUTE_id(_attid);
}
if (_elemid>0) if (_MEDdatagroupFermer(_elemid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
ISCRUTE_id(_elemid);
}
return _ret;
}
MED_CSTATR
#define MED_CSTATR
Definition: med_outils.h:193
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:27
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:55
_MEDattrStringLire
MEDC_EXPORT med_err _MEDattrStringLire(med_idt pere, char *nom, int longueur, char *val)
MED_FULL_INTERLACE
Definition: med.h:96
MED_ERR_API
#define MED_ERR_API
Definition: med_err.h:111
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
_MEDdatasetRd
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)
med_filter
Filtre de sélection.
Definition: med.h:355
MED_FILTER_INIT
#define MED_FILTER_INIT
Definition: med.h:374
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition: med_utils.h:319
MED_UNDEF_SIZE
#define MED_UNDEF_SIZE
Definition: med.h:306
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 étape de calcul donnée.
Definition: MEDmeshnEntity.c:44
med_geometry_type
int med_geometry_type
Definition: med.h:194
MED_NODAL
Definition: med.h:255
med_idt
hid_t med_idt
Definition: med.h:331
_MEDdatagroupOpen
MEDC_EXPORT med_idt _MEDdatagroupOpen(const med_idt pid, const char *const name)
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:160
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition: med_err.h:100
med_err
herr_t med_err
Definition: med.h:332
med_entity_type
med_entity_type
Definition: med.h:143
MED_NO_CMODE
Definition: med.h:255
MED_NOM_NOM
#define MED_NOM_NOM
Definition: med_outils.h:41
MED_FALSE
Definition: med.h:260
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:30
MEDstructElementConstAttInfoByName
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...
Definition: MEDstructElementConstAttInfoByName.c:44
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:37
MED_CELL
Definition: med.h:143
MED_ERR_FILTER
#define MED_ERR_FILTER
Definition: med_err.h:93
MED_NOM_GEO
#define MED_NOM_GEO
Definition: med_outils.h:133
med_int
int med_int
Definition: med.h:342
MED_NOM_COR
#define MED_NOM_COR
Definition: med_outils.h:55
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition: med_err.h:29
med_attribute_type
med_attribute_type
Definition: med.h:173
MED_ERR_CALL
#define MED_ERR_CALL
Definition: med_err.h:48
med.h
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:313
med_bool
med_bool
Definition: med.h:260
MED_ERR_READ
#define MED_ERR_READ
Definition: med_err.h:28
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
MED_NONE
#define MED_NONE
Definition: med.h:231
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_CONNECTIVITY
Definition: med.h:149
MED_NODE
Definition: med.h:143
MED_TAILLE_CSTATR
#define MED_TAILLE_CSTATR
Definition: med_outils.h:195
MED_ELSTRUCT_GRP
#define MED_ELSTRUCT_GRP
Definition: med_outils.h:174
MED_ERR_INTERNAL_MSG
#define MED_ERR_INTERNAL_MSG
Definition: med_err.h:196
MEDstructElementConstAttRd
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...
Definition: MEDstructElementConstAttRd.c:42
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
MED_ERR_DATASET
#define MED_ERR_DATASET
Definition: med_err.h:98
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:99
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MED_UNDEF_ENTITY_TYPE
Definition: med.h:145
med_outils.h
med_config.h
MED_ERR_STRUCT_ELEMENT_MSG
#define MED_ERR_STRUCT_ELEMENT_MSG
Definition: med_err.h:136
MED_ERR_STRUCT_MSG
#define MED_ERR_STRUCT_MSG
Definition: med_err.h:173
MED_ALL_CONSTITUENT
#define MED_ALL_CONSTITUENT
Definition: med.h:299
MED_COMPACT_STMODE
Definition: med.h:110
_MEDattrEntierLire
#define _MEDattrEntierLire(x, y, z)
Definition: med_hdfi.h:68
NOFINALBLANK
#define NOFINALBLANK(chaine, label)
Definition: med_utils.h:311
MED_ATT_UNDEF
Definition: med.h:176
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
MED_COORDINATE
Definition: med.h:149
MED_ELSTRUCT_GRP_SIZE
#define MED_ELSTRUCT_GRP_SIZE
Definition: med_outils.h:175