MEDstructElementInfoByName.c
Aller à la documentation de ce fichier.
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2020 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 <stdlib.h>
#include <string.h>
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
)
{
med_err _ret=-1;
med_idt _elemid=0, _cstid=0;
char _path[MED_ELSTRUCT_GRP_SIZE+MED_NAME_SIZE+1]=MED_ELSTRUCT_GRP;
char __profilename [MED_NAME_SIZE+1]=MED_NO_PROFILE_INTERNAL;
const char* _profilename = __profilename;
med_int _intentitytype = MED_UNDEF_ENTITY_TYPE;
med_int _nentity = 0;
med_size _tmpn = 0;
med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
med_int _medintmgeotype = MED_NONE;
med_int _medintsgeotype = MED_NONE;
med_int _intanyprofile = 0;
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;
}
/*
* Lecture de l'attribut MED_NOM_NEO (numéro de type géométrique associé à un élément de structure)
*/
if ( _MEDattrEntierLire(_elemid,MED_NOM_NEO,&_medintmgeotype) < 0 ) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintmgeotype);
goto ERROR;
}
*mgeotype=_medintmgeotype;
/*
* Lecture de l'attribut MED_NOM_DIM (dimension de l'élément)
*/
if ( _MEDattrEntierLire(_elemid,MED_NOM_DIM,modeldim) < 0 ) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_DIM);ISCRUTE(*modeldim);
goto ERROR;
}
/*
* Lecture de l'attribut MED_NOM_NOM (nom du maillage support)
*/
/* TODO : Chercher plutôt ds le maillage support et supprimer les attributs NBM et NBN : .. A évaluer ...*/
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;
}
/*
* Lecture de l'attribut MED_NOM_ENT (type d'entité support)
*/
if ( _MEDattrEntierLire(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
goto ERROR;
}
*sentitytype = (med_entity_type) _intentitytype;
/*
* 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;
}
*sgeotype=_medintsgeotype;
/*
* Lecture du nombre de noeuds support
*/
if (strlen(supportmeshname)) {
if ( (*snnode = 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(*snnode);goto ERROR;
}
} else {
*snnode=1;
}
/*
* Lecture du nombre de mailles support
*/
if (strlen(supportmeshname)) {
if ( (*sncell = MEDmeshnEntity(fid,supportmeshname,MED_NO_DT,MED_NO_IT,
MED_CELL,*sgeotype,MED_CONNECTIVITY,MED_NODAL,
&_chgt,&_trsf) ) < 0) {
MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"MEDmeshnEntity");
ISCRUTE(*sncell);goto ERROR;
}
} else {
*sncell=0;
}
_MEDnObjects(_elemid,MED_CSTATR_NOM,&_tmpn);
if ( _tmpn > 0) {
if ((_cstid = _MEDdatagroupOpen(_elemid,MED_CSTATR_NOM)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
SSCRUTE(_path);goto ERROR;
}
if ( _MEDattrEntierLire(_cstid,MED_NOM_PFU,&_intanyprofile) < 0) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_STRUCT_MSG);
SSCRUTE(modelname);SSCRUTE(MED_NOM_PFU);
goto ERROR;
}
*anyprofile=_intanyprofile;
*nconstantattribute = (med_int) _tmpn;
} else {
*anyprofile = MED_FALSE;
*nconstantattribute = 0;
}
_MEDnObjects(_elemid,MED_VARATR_NOM,&_tmpn);
if ( _tmpn > 0)
*nvariableattribute = (med_int) _tmpn;
else
*nvariableattribute = (med_int) 0;
_ret=0;
ERROR:
if (_cstid>0) if (_MEDdatagroupFermer(_cstid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_CSTATR_NOM);
ISCRUTE_id(_cstid);
}
if (_elemid>0) if (_MEDdatagroupFermer(_elemid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,modelname);
ISCRUTE_id(_elemid);
}
return _ret;
}
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition build.python3.12/include/med.h:81
med_geometry_type
int med_geometry_type
Definition build.python3.12/include/med.h:194
med_bool
med_bool
Definition build.python3.12/include/med.h:260
MED_FALSE
@ MED_FALSE
Definition build.python3.12/include/med.h:260
MED_CONNECTIVITY
@ MED_CONNECTIVITY
Definition build.python3.12/include/med.h:149
MED_COORDINATE
@ MED_COORDINATE
Definition build.python3.12/include/med.h:149
MED_NO_PROFILE_INTERNAL
#define MED_NO_PROFILE_INTERNAL
Definition build.python3.12/include/med.h:290
med_int
int med_int
Definition build.python3.12/include/med.h:333
MED_NO_DT
#define MED_NO_DT
Definition build.python3.12/include/med.h:311
MED_NO_IT
#define MED_NO_IT
Definition build.python3.12/include/med.h:312
MED_NONE
#define MED_NONE
Definition build.python3.12/include/med.h:231
med_entity_type
med_entity_type
Definition build.python3.12/include/med.h:143
MED_NODE
@ MED_NODE
Definition build.python3.12/include/med.h:143
MED_UNDEF_ENTITY_TYPE
@ MED_UNDEF_ENTITY_TYPE
Definition build.python3.12/include/med.h:145
MED_CELL
@ MED_CELL
Definition build.python3.12/include/med.h:143
med_size
hsize_t med_size
Definition build.python3.12/include/med.h:320
med_err
herr_t med_err
Definition build.python3.12/include/med.h:323
med_idt
hid_t med_idt
Definition build.python3.12/include/med.h:322
MED_NO_CMODE
@ MED_NO_CMODE
Definition build.python3.12/include/med.h:255
MED_NODAL
@ MED_NODAL
Definition build.python3.12/include/med.h:255
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition build.python3.12/include/med_utils.h:160
SSCRUTE
#define SSCRUTE(chaine)
Definition build.python3.12/include/med_utils.h:323
ISCRUTE
#define ISCRUTE(entier)
Definition build.python3.12/include/med_utils.h:313
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition build.python3.12/include/med_utils.h:319
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
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:37
MED_ERR_CALL
#define MED_ERR_CALL
Definition med_err.h:48
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition med_err.h:99
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition med_err.h:30
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition med_err.h:100
MED_ERR_API
#define MED_ERR_API
Definition med_err.h:111
MED_ERR_READ
#define MED_ERR_READ
Definition med_err.h:28
MED_ERR_STRUCT_MSG
#define MED_ERR_STRUCT_MSG
Definition med_err.h:173
_MEDnObjects
MEDC_EXPORT med_err _MEDnObjects(const med_idt fid, const char *const path, med_size *n)
_MEDattrEntierLire
#define _MEDattrEntierLire(x, y, z)
Definition med_hdfi.h:68
_MEDdatagroupOpen
MEDC_EXPORT med_idt _MEDdatagroupOpen(const med_idt pid, const char *const name)
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
_MEDattrStringLire
MEDC_EXPORT med_err _MEDattrStringLire(med_idt pere, char *nom, int longueur, char *val)
MED_CSTATR_NOM
#define MED_CSTATR_NOM
Definition med_outils.h:194
MED_VARATR_NOM
#define MED_VARATR_NOM
Definition med_outils.h:199
MED_NOM_ENT
#define MED_NOM_ENT
Definition med_outils.h:135
MED_NOM_DIM
#define MED_NOM_DIM
Definition med_outils.h:49
MED_NOM_NOM
#define MED_NOM_NOM
Definition med_outils.h:41
MED_ELSTRUCT_GRP_SIZE
#define MED_ELSTRUCT_GRP_SIZE
Definition med_outils.h:175
MED_NOM_NEO
#define MED_NOM_NEO
Definition med_outils.h:134
MED_NOM_PFU
#define MED_NOM_PFU
Definition med_outils.h:141
MED_ELSTRUCT_GRP
#define MED_ELSTRUCT_GRP
Definition med_outils.h:174
MED_NOM_GEO
#define MED_NOM_GEO
Definition med_outils.h:133
med_outils.h