MEDlocalizationWr.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 <string.h>
#include <stdlib.h>
med_err
MEDlocalizationWr(const med_idt fid,
const char * const localizationname,
const med_geometry_type geotype,
const med_int spacedimension,
const med_float* const elementcoordinate,
const med_switch_mode switchmode,
const med_int nipoint,
const med_float* const ipointcoordinate,
const med_float* const weight,
const char * const geointerpname,
const char * const sectionmeshname
)
{
med_access_mode _MED_ACCESS_MODE;
med_err _ret = -1;
med_idt _lzid=0, _root=0;
med_int _nentity=0;
med_int _intgeotype = -1;
char _path[MED_LOCALIZATION_GRP_SIZE+MED_NAME_SIZE+1]=MED_LOCALIZATION_GRP;
med_filter _filter = MED_FILTER_INIT;
/*
* On inhibe le gestionnaire d'erreur HDF 5
*/
_MEDmodeErreurVerrouiller();
if (_MEDcheckVersion30(fid) < 0) goto ERROR;
if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
goto ERROR;
}
if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
ISCRUTE_int(_MED_ACCESS_MODE);
goto ERROR;
}
/*
* MED_GAUSS_ELNO est un mot cle reserve
*/
if (! strcmp(localizationname,MED_GAUSS_ELNO)) {
MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_LOCALIZATION,localizationname);
goto ERROR;
}
/*
* Si le DataGroup /GAUSS/ n'existe pas, on le cree
*/
if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0)
if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
goto ERROR;
}
NOFINALBLANK(localizationname,ERROR);
/*
* Si le DataGroup /GAUSS/<localizationname> n'existe pas, on le cree
*/
if ((_lzid = _MEDdatagroupOuvrir(_root,localizationname)) < 0)
if ((_lzid = _MEDdatagroupCreer(_root,localizationname)) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,localizationname);
SSCRUTE(_path);goto ERROR;
}
strcat(_path,localizationname);
/*
* On stocke <nipoint> sous forme d'attribut
*/
if (_MEDattributeIntWr(_lzid,MED_NOM_NBR,&nipoint) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
SSCRUTE(localizationname);SSCRUTE(MED_NOM_NBR);ISCRUTE(nipoint);
goto ERROR;
}
/*
* On stocke <typgeo> sous forme d'attribut
*/
_intgeotype = (med_int) geotype;
/* sizeof(enum) tjrs = sizeof(int) en C, or
sur machines 64 bits par d�faut med_int==long,
du coup sur machines 64 bits _MEDattributeIntWr utilise
le type hdf NATIVE_LONG, ce qui pose un probl�me qd on passe
un enum.
*/
if (_MEDattributeIntWr(_lzid,MED_NOM_GEO,&_intgeotype) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intgeotype);
goto ERROR;
};
/*
* On stocke <spacedimension> sous forme d'attribut
*/
if (_MEDattributeIntWr(_lzid,MED_NOM_DIM,&spacedimension) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
SSCRUTE(localizationname);SSCRUTE(MED_NOM_DIM);ISCRUTE(spacedimension);
goto ERROR;
};
if ( ! ((geotype > MED_STRUCT_GEO_INTERNAL ) &&
(geotype < MED_STRUCT_GEO_SUP_INTERNAL) ) ) {
/*
* On stocke les coordonn�es de r�f�rence dans un dataset
*/
_nentity = (geotype%100);
if ( MEDfilterEntityCr(fid,_nentity, 1, spacedimension, MED_ALL_CONSTITUENT,
switchmode,MED_UNDEF_STMODE,
MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
goto ERROR;
}
if ( _MEDdatasetWr(_lzid,MED_NOM_COO,MED_INTERNAL_FLOAT64,&_filter, elementcoordinate) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_COO);SSCRUTE(_path);
goto ERROR;
}
if ( MEDfilterClose(&_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
goto ERROR;
}
} else {
/*
* Creation/Ecriture de l'attribut MED_NOM_NOM (nom du maillage de section)
*/
if ( _MEDattributeStringWr(_lzid,MED_NOM_NOM,MED_NAME_SIZE,sectionmeshname) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
SSCRUTE(localizationname);SSCRUTE(MED_NOM_NOM);SSCRUTE(sectionmeshname);
goto ERROR;
}
}
/*
* Creation/Ecriture de l'attribut MED_NOM_INM (nom de l'interpolation géométrique)
*/
if ( _MEDattributeStringWr(_lzid,MED_NOM_INM,MED_NAME_SIZE,geointerpname) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
SSCRUTE(localizationname);SSCRUTE(MED_NOM_INM);SSCRUTE(geointerpname);
goto ERROR;
}
/*
* On stocke les points d'int�gration dans un dataset
*/
_nentity = nipoint;
if ( MEDfilterEntityCr(fid,_nentity, 1, spacedimension, MED_ALL_CONSTITUENT,
switchmode,MED_UNDEF_STMODE,
MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
goto ERROR;
}
if ( _MEDdatasetWr(_lzid,MED_NOM_GAU,MED_INTERNAL_FLOAT64,&_filter, ipointcoordinate) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_GAU);SSCRUTE(_path);
goto ERROR;
}
if ( MEDfilterClose(&_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
goto ERROR;
}
/*
* On stocke les poids dans un dataset
*/
_nentity = nipoint;
if ( MEDfilterEntityCr(fid,_nentity, 1, 1, MED_ALL_CONSTITUENT,
switchmode,MED_UNDEF_STMODE,
MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
goto ERROR;
}
if ( _MEDdatasetWr(_lzid,MED_NOM_VAL,MED_INTERNAL_FLOAT64,&_filter, weight) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_VAL);SSCRUTE(_path);
goto ERROR;
}
if ( MEDfilterClose(&_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
goto ERROR;
}
_ret = 0;
ERROR:
if (_lzid>0) if (_MEDdatagroupFermer(_lzid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,localizationname);
ISCRUTE_id(_lzid);
}
if (_root>0) if (_MEDdatagroupFermer(_root) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_LOCALIZATION_GRP);
ISCRUTE_id(_root);
}
return _ret;
}
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition build.python3.12/include/med.h:81
med_switch_mode
med_switch_mode
Definition build.python3.12/include/med.h:96
med_geometry_type
int med_geometry_type
Definition build.python3.12/include/med.h:194
MED_FILTER_INIT
#define MED_FILTER_INIT
Definition build.python3.12/include/med.h:365
MED_UNDEF_STMODE
@ MED_UNDEF_STMODE
Definition build.python3.12/include/med.h:108
MED_ALL_CONSTITUENT
#define MED_ALL_CONSTITUENT
Definition build.python3.12/include/med.h:293
MED_STRUCT_GEO_SUP_INTERNAL
#define MED_STRUCT_GEO_SUP_INTERNAL
Definition build.python3.12/include/med.h:229
MED_GAUSS_ELNO
#define MED_GAUSS_ELNO
Definition build.python3.12/include/med.h:262
med_int
int med_int
Definition build.python3.12/include/med.h:333
MED_UNDEF_SIZE
#define MED_UNDEF_SIZE
Definition build.python3.12/include/med.h:297
MED_INTERNAL_FLOAT64
@ MED_INTERNAL_FLOAT64
Definition build.python3.12/include/med.h:156
MED_NO_PROFILE
#define MED_NO_PROFILE
Definition build.python3.12/include/med.h:279
med_float
double med_float
Definition build.python3.12/include/med.h:327
med_err
herr_t med_err
Definition build.python3.12/include/med.h:323
MED_STRUCT_GEO_INTERNAL
#define MED_STRUCT_GEO_INTERNAL
Definition build.python3.12/include/med.h:228
med_access_mode
med_access_mode
Definition build.python3.12/include/med.h:120
MED_ACC_UNDEF
@ MED_ACC_UNDEF
Definition build.python3.12/include/med.h:124
MED_ACC_RDONLY
@ MED_ACC_RDONLY
Definition build.python3.12/include/med.h:120
med_idt
hid_t med_idt
Definition build.python3.12/include/med.h:322
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
NOFINALBLANK
#define NOFINALBLANK(chaine, label)
Definition build.python3.12/include/med_utils.h:311
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition build.python3.12/include/med_utils.h:314
MEDfilterClose
MEDC_EXPORT med_err MEDfilterClose(med_filter *const filter)
Désalloue les ressources hdf détenues par un filtre.
Definition MEDfilterClose.c:35
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
MEDlocalizationWr
med_err MEDlocalizationWr(const med_idt fid, const char *const localizationname, const med_geometry_type geotype, const med_int spacedimension, const med_float *const elementcoordinate, const med_switch_mode switchmode, const med_int nipoint, const med_float *const ipointcoordinate, const med_float *const weight, const char *const geointerpname, const char *const sectionmeshname)
Cette routine permet l'écriture d'une localisation localizationname de points d'intégration dans/auto...
Definition MEDlocalizationWr.c:49
MED_ERR_ACCESSMODE
#define MED_ERR_ACCESSMODE
Definition med_err.h:104
MED_ERR_FILTER
#define MED_ERR_FILTER
Definition med_err.h:93
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_INVALID
#define MED_ERR_INVALID
Definition med_err.h:40
MED_ERR_LOCALIZATION_MSG
#define MED_ERR_LOCALIZATION_MSG
Definition med_err.h:139
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition med_err.h:100
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition med_err.h:27
MED_ERR_INTERNAL_MSG
#define MED_ERR_INTERNAL_MSG
Definition med_err.h:196
MED_ERR_FILE_MSG
#define MED_ERR_FILE_MSG
Definition med_err.h:132
MED_ERR_LOCALIZATION
#define MED_ERR_LOCALIZATION
Definition med_err.h:89
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition med_err.h:29
MED_ERR_UNRECOGNIZED
#define MED_ERR_UNRECOGNIZED
Definition med_err.h:39
MED_ERR_DATASET
#define MED_ERR_DATASET
Definition med_err.h:98
_MEDattributeStringWr
MEDC_EXPORT med_err _MEDattributeStringWr(med_idt pid, const char *const attname, const med_size attsize, const char *const val)
_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)
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
_MEDattributeIntWr
#define _MEDattributeIntWr(w, x, y)
Definition med_hdfi.h:45
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
_MEDdatagroupOuvrir
MEDC_EXPORT med_idt _MEDdatagroupOuvrir(med_idt pid, const char *const nom)
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
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_NOM_COO
#define MED_NOM_COO
Definition med_outils.h:56
MED_NOM_VAL
#define MED_NOM_VAL
Definition med_outils.h:53
MED_LOCALIZATION_GRP_SIZE
#define MED_LOCALIZATION_GRP_SIZE
Definition med_outils.h:239
MED_NOM_GAU
#define MED_NOM_GAU
Definition med_outils.h:138
MED_NOM_GEO
#define MED_NOM_GEO
Definition med_outils.h:133
MED_LOCALIZATION_GRP
#define MED_LOCALIZATION_GRP
Definition med_outils.h:238
MED_NOM_NBR
#define MED_NOM_NBR
Definition med_outils.h:40
MED_NOM_INM
#define MED_NOM_INM
Definition med_outils.h:150
med_outils.h
med_filter
Filtre de sélection.
Definition build.python3.12/include/med.h:346