MEDstructElementCr.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>
/*PENSEZ A DOCUMENTER LE CAS DE PARTICULE (SANS MAILLAGE SUPPORT : MOT CLE A DEFINIR )*/
med_geometry_type
MEDstructElementCr(const med_idt fid,
const char* const modelname,
const med_int modeldim,
const char* const supportmeshname,
const med_entity_type sentitytype,
const med_geometry_type sgeotype
)
{
med_access_mode _MED_ACCESS_MODE;
med_err _err=-1;
med_idt _root=0,_elemid=0;
med_int _ret=-1;
char _path[MED_ELSTRUCT_GRP_SIZE+MED_NAME_SIZE+1]=MED_ELSTRUCT_GRP;
med_size _tmpn=0;
med_geometry_type _stgeotype=0;
med_int _medintstgeotype = 0;
med_int _medintsgeotype = sgeotype;
med_int _intentitytype = sentitytype;
med_int _nnode=0,_ncell=0;
med_bool _chgt=MED_FALSE,_trsf=MED_FALSE;
/* char _entitytypename[MED_TAILLE_NOM_ENTITE+1]=""; */
/*
* On inhibe le gestionnaire d'erreur
*/
_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;
}
/*
* Si le DataGroup /STRUCT/ n'existe pas, on le cree
*/
if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
if ((_root = _MEDdatagroupCrOrderCr(fid,_path)) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
goto ERROR;
}
NOFINALBLANK(modelname,ERROR);
/*
* Si le DataGroup /STRUCT/<modelname> n'existe pas, on le cree
*/
if ((_elemid = _MEDdatagroupOpen(_root,modelname)) < 0) {
if ((_elemid = _MEDdatagroupCreer(_root,modelname)) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,modelname);
SSCRUTE(_path);goto ERROR;
}
} else {
/*
* 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,&_medintstgeotype) < 0 ) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
goto ERROR;
}
_stgeotype = _medintstgeotype;
}
strcat(_path,modelname);
/*
* Creation/Ecriture de l'attribut MED_NOM_DIM (dimension de l'�l�ment)
*/
if ( _MEDattributeIntWr(_elemid,MED_NOM_DIM,&modeldim) < 0 ) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_DIM);ISCRUTE(modeldim);
goto ERROR;
}
/*
* Creation/Ecriture de l'attribut MED_NOM_NOM (nom du maillage support)
*/
if ( _MEDattributeStringWr(_elemid,MED_NOM_NOM,MED_NAME_SIZE,supportmeshname) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_NOM);SSCRUTE(supportmeshname);
goto ERROR;
}
/*
* Creation/Ecriture de l'attribut MED_NOM_ENT (type d'entit� support)
*/
/* if (_MEDgetEntityTypeName(_entitytypename,sentitytype) < 0) { */
/* MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG); */
/* ISCRUTE_int(sentitytype);SSCRUTE(_entitytypename);SSCRUTE(_path); */
/* goto ERROR; */
/* } */
if ( _MEDattributeIntWr(_elemid,MED_NOM_ENT,&_intentitytype) < 0 ) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_ENT);ISCRUTE(_intentitytype);
goto ERROR;
}
/*
Lecture dans le maillages support du nombre de noeuds
S'il n'y a pas de maillage support : 1
*/
if (strlen(supportmeshname)) {
if ( (_nnode = 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(_nnode);goto ERROR;
}
} else {
_nnode=1;
}
if (strlen(supportmeshname)) {
if ( (_ncell = 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(_ncell);goto ERROR;
}
} else {
_ncell=0;
}
/*
* Creation/Ecriture de l'attribut MED_NOM_GEO (type g�om�trique des mailles support)
*/
_medintsgeotype = sgeotype;
if ( _MEDattributeIntWr(_elemid,MED_NOM_GEO,&_medintsgeotype) < 0 ) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_GEO);ISCRUTE(_medintsgeotype);
goto ERROR;
}
/*
* Creation/Ecriture de l'attribut MED_NOM_NAV (nombre d'attributs variables associ�s � un �l�ment de structure)
*/
/* if ( _MEDattributeIntWr(_elemid,MED_NOM_NAV,&nvariableattribute) < 0 ) { */
/* MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/* SSCRUTE(MED_NOM_NAV);ISCRUTE(nvariableattribute); */
/* goto ERROR; */
/* } */
/*
* Creation/Ecriture de l'attribut MED_NOM_NAC (nombre d'attributs constant associ�s � un �l�ment de structure)
*/
/* if ( _MEDattributeIntWr(_elemid,MED_NOM_NAC,&nconstattribute) < 0 ) { */
/* MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
/* SSCRUTE(MED_NOM_NAC);ISCRUTE(nconstattribute); */
/* goto ERROR; */
/* } */
/*
* Nombre d'�l�ments de structure
*/
if ( !_stgeotype ) {
/*Si l'�l�ment de struture ne pr�-existait pas,
il a �t� cr�e en d�but de proc�dure (il y a au moins 1 �l�ment dans le groupe) */
if ((_err=_MEDnObjects(fid,MED_ELSTRUCT_GRP,&_tmpn)) <0) {
MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_STRUCT,MED_ELSTRUCT_GRP);
goto ERROR;
}
_stgeotype=_tmpn+MED_STRUCT_GEO_INTERNAL;
_medintstgeotype=_stgeotype;
/*
* Ecriture de l'attribut MED_NOM_NEO (num�ro de type g�om�trique associ� � un �l�ment de structure)
*/
if ( _MEDattributeIntWr(_elemid,MED_NOM_NEO,&_medintstgeotype) < 0 ) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
SSCRUTE(MED_NOM_NEO);ISCRUTE(_medintstgeotype);
goto ERROR;
}
}
_ret = _stgeotype;
ERROR:
if (_elemid>0) if (_MEDdatagroupFermer(_elemid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
ISCRUTE_id(_elemid);
}
if (_root>0) if (_MEDdatagroupFermer(_root) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_ELSTRUCT_GRP);
ISCRUTE_id(_root);
}
return _ret;
}
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
MEDstructElementCr
med_geometry_type MEDstructElementCr(const med_idt fid, const char *const modelname, const med_int modeldim, const char *const supportmeshname, const med_entity_type sentitytype, const med_geometry_type sgeotype)
Cette routine permet de créer un nouveau modèle d'éléments de structure dans un fichier MED.
Definition MEDstructElementCr.c:50
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition med.h:81
med_geometry_type
int med_geometry_type
Definition med.h:194
med_bool
med_bool
Definition med.h:260
MED_FALSE
@ MED_FALSE
Definition med.h:260
MED_CONNECTIVITY
@ MED_CONNECTIVITY
Definition med.h:149
MED_COORDINATE
@ MED_COORDINATE
Definition med.h:149
med_int
int med_int
Definition med.h:333
MED_NO_DT
#define MED_NO_DT
Definition med.h:311
MED_NO_IT
#define MED_NO_IT
Definition med.h:312
MED_NONE
#define MED_NONE
Definition med.h:231
med_entity_type
med_entity_type
Definition med.h:143
MED_NODE
@ MED_NODE
Definition med.h:143
MED_CELL
@ MED_CELL
Definition med.h:143
med_size
hsize_t med_size
Definition med.h:320
med_err
herr_t med_err
Definition med.h:323
MED_STRUCT_GEO_INTERNAL
#define MED_STRUCT_GEO_INTERNAL
Definition med.h:228
med_access_mode
med_access_mode
Definition med.h:120
MED_ACC_UNDEF
@ MED_ACC_UNDEF
Definition med.h:124
MED_ACC_RDONLY
@ MED_ACC_RDONLY
Definition med.h:120
med_idt
hid_t med_idt
Definition med.h:322
MED_NO_CMODE
@ MED_NO_CMODE
Definition med.h:255
MED_NODAL
@ MED_NODAL
Definition med.h:255
med.h
med_config.h
MED_ERR_ACCESSMODE
#define MED_ERR_ACCESSMODE
Definition med_err.h:104
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_INVALID
#define MED_ERR_INVALID
Definition med_err.h:40
MED_ERR_COUNT
#define MED_ERR_COUNT
Definition med_err.h:47
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_API
#define MED_ERR_API
Definition med_err.h:111
MED_ERR_READ
#define MED_ERR_READ
Definition med_err.h:28
MED_ERR_FILE_MSG
#define MED_ERR_FILE_MSG
Definition med_err.h:132
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_STRUCT
#define MED_ERR_STRUCT
Definition med_err.h:123
_MEDattributeStringWr
MEDC_EXPORT med_err _MEDattributeStringWr(med_idt pid, const char *const attname, const med_size attsize, const char *const val)
_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)
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
_MEDdatagroupCrOrderCr
MEDC_EXPORT med_idt _MEDdatagroupCrOrderCr(const med_idt pid, const char *const name)
_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)
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
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_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
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition med_utils.h:160
SSCRUTE
#define SSCRUTE(chaine)
Definition med_utils.h:323
ISCRUTE
#define ISCRUTE(entier)
Definition med_utils.h:313
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition med_utils.h:319
NOFINALBLANK
#define NOFINALBLANK(chaine, label)
Definition med_utils.h:311
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition med_utils.h:314