MEDsubdomainCorrespondenceWr.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
MEDsubdomainCorrespondenceWr(const med_idt fid,
const char * const localmeshname,
const char * const jointname,
const med_int numdt,
const med_int numit,
const med_entity_type localentitype,
const med_geometry_type localgeotype,
const med_entity_type remoteentitype,
const med_geometry_type remotegeotype,
const med_int nentity,
const med_int * const correspondence) {
med_access_mode _MED_ACCESS_MODE;
med_idt _root=0,_jntid=0,_meshid=0,_cstpid=0,_datagroup2=0;
med_idt _dataset=0;
med_err _ret=-1;
char _path[MED_JOINT_GRP_SIZE+2*MED_NAME_SIZE+2]=MED_JOINT_GRP;
char _computationstepname[2*MED_MAX_PARA+1]="";
char _datagroupname2[4*MED_TAILLE_NOM_ENTITE+4]="";
char _localgeotypename [MED_TAILLE_NOM_ENTITE+1]="";
char _remotegeotypename [MED_TAILLE_NOM_ENTITE+1]="";
med_sorting_type _sortingtype=0;
med_filter _filter = MED_FILTER_INIT;
med_int _localgeotype = MED_NONE;
med_int _localentitype = localentitype;
med_int _remotegeotype = MED_NONE;
med_int _remoteentitype = remoteentitype;
if ( localentitype == MED_NODE_ELEMENT ) _localgeotype=MED_NODE ;
if ( localentitype != MED_NODE ) _localgeotype = localgeotype ;
if ( remoteentitype != MED_NODE ) _remotegeotype = remotegeotype ;
/*
* 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;
}
/*
* Ouverture du dataGroup /JNT/
*/
if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
goto ERROR;
}
/*
* Ouverture du dataGroup <meshname>
*/
if ((_meshid = _MEDdatagroupOuvrir(_root,localmeshname)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,localmeshname);
SSCRUTE(_path);goto ERROR;
}
strcat(_path,localmeshname);
/*
* Ouverture du data Group "/JNT/<localmeshname>/<jointname>"
*/
if ((_jntid = _MEDdatagroupOuvrir(_meshid,jointname)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,jointname);
SSCRUTE(_path);goto ERROR;
}
strcat(_path,"/");
strcat(_path,jointname);
if ( MEDmeshSortingTypeRd(fid,localmeshname,&_sortingtype) < 0 ) {
MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API," MEDmeshSortingTypeRd");
SSCRUTE(localmeshname);ISCRUTE_int(_sortingtype);goto ERROR;
}
_MEDgetComputationStepName(_sortingtype,numdt,numit,_computationstepname);
if ((_cstpid = _MEDdatagroupOuvrir(_jntid,_computationstepname)) < 0)
if ((_cstpid = _MEDdatagroupCreer(_jntid,_computationstepname)) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_computationstepname);
SSCRUTE(_path);goto ERROR;
}
/*Cree ou ouvre l'attribut MED_NOM_NDT pour �criture */
if ( _MEDattributeIntWr(_cstpid,MED_NOM_NDT,&numdt) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
goto ERROR;
}
/*Cree ou ouvre l'attribut MED_NOM_NOR pour �criture */
if ( _MEDattributeIntWr(_cstpid,MED_NOM_NOR,&numit) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
goto ERROR;
}
/*
* Creation/Ouverture du datagroup de niveau
* <localentitype>[.<localgeotype>].<remoteentitype>[.<remotegeotype>]
*/
if (_MEDgetEntityTypeName(_datagroupname2,localentitype) < 0) {
MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
ISCRUTE_int(localentitype);SSCRUTE(jointname);goto ERROR;
}
if ( localentitype != MED_NODE ) {
if ( _MEDgetInternalGeometryTypeName(fid,_localgeotypename,localgeotype) < 0) {
MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRY,MED_ERR_VALUE_MSG);
ISCRUTE_int(localgeotype);SSCRUTE(jointname);goto ERROR;
}
strcat(_datagroupname2,".");
strcat(_datagroupname2,_localgeotypename);
}
strcat(_datagroupname2,".");
if (_MEDgetEntityTypeName(&_datagroupname2[strlen(_datagroupname2)],remoteentitype) < 0) {
MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
ISCRUTE_int(remoteentitype);SSCRUTE(jointname);goto ERROR;
}
if ( remoteentitype != MED_NODE ) {
if ( _MEDgetInternalGeometryTypeName(fid,_remotegeotypename,remotegeotype) < 0) {
MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRY,MED_ERR_VALUE_MSG);
ISCRUTE_int(remotegeotype);SSCRUTE(jointname);goto ERROR;
}
strcat(_datagroupname2,".");
strcat(_datagroupname2,_remotegeotypename);
}
if ( (_datagroup2 = _MEDdatagroupOuvrir(_cstpid,_datagroupname2)) < 0)
if ((_datagroup2 = _MEDdatagroupCreer(_cstpid,_datagroupname2)) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_datagroupname2);
SSCRUTE(_path);SSCRUTE(jointname);goto ERROR;
}
/*Cree ou ouvre l'attribut MED_NOM_ENT pour �criture */
if (_MEDattributeIntWr(_datagroup2,MED_NOM_ENT,&_localentitype) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_ENT);
ISCRUTE(_localentitype);goto ERROR;
}
/*Cree ou ouvre l'attribut MED_NOM_GEO pour �criture */
if (_MEDattributeIntWr(_datagroup2,MED_NOM_GEO,&_localgeotype) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_GEO);
ISCRUTE(_localgeotype);goto ERROR;
}
/*Cree ou ouvre l'attribut MED_NOM_END pour �criture */
if (_MEDattributeIntWr(_datagroup2,MED_NOM_END,&_remoteentitype) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_END);
ISCRUTE(_remoteentitype);goto ERROR;
}
/*Cree ou ouvre l'attribut MED_NOM_GED pour �criture */
if (_MEDattributeIntWr(_datagroup2,MED_NOM_GED,&_remotegeotype) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_GED);
ISCRUTE(_remotegeotype);goto ERROR;
}
if ( MEDfilterEntityCr(fid, nentity, 1, 2, MED_ALL_CONSTITUENT,
MED_NO_INTERLACE,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(_datagroup2,MED_NOM_COR,MED_INTERNAL_INT,&_filter, correspondence) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_COR);
SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
goto ERROR;
}
if ( MEDfilterClose(&_filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_SUBDOMAINJOINT_MSG);
SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
goto ERROR;
}
if ((_dataset = _MEDdatasetOuvrir(_datagroup2,MED_NOM_COR)) < 0) {
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATASET,MED_NOM_COR);
SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2);
goto ERROR;
}
if ( _MEDattributeIntWr(_dataset,MED_NOM_NBR,&nentity) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2);
SSCRUTE(MED_NOM_NBR);ISCRUTE(nentity);goto ERROR;
}
_ret=0;
ERROR:
if (_dataset>0) if (_MEDdatasetFermer(_dataset) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATASET,MED_NOM_COR);
ISCRUTE_id(_dataset);
}
if (_datagroup2>0) if (_MEDdatagroupFermer(_datagroup2) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname2);
ISCRUTE_id(_datagroup2);SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
}
if (_cstpid>0) if (_MEDdatagroupFermer(_cstpid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_computationstepname);
ISCRUTE_id(_cstpid);SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
}
if (_jntid>0) if (_MEDdatagroupFermer(_jntid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,jointname);
ISCRUTE_id(_jntid);SSCRUTE(_path);
}
if (_meshid>0) if (_MEDdatagroupFermer(_meshid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,localmeshname);
ISCRUTE_id(_meshid);
}
if (_root>0) if (_MEDdatagroupFermer(_root) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_JOINT_GRP);
ISCRUTE_id(_root);
}
return _ret;
}
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition build.python3.12/include/med.h:81
MED_NO_INTERLACE
@ MED_NO_INTERLACE
Definition build.python3.12/include/med.h:98
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_MAX_PARA
#define MED_MAX_PARA
Definition build.python3.12/include/med.h:76
med_sorting_type
med_sorting_type
Definition build.python3.12/include/med.h:300
MED_ALL_CONSTITUENT
#define MED_ALL_CONSTITUENT
Definition build.python3.12/include/med.h:293
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_NONE
#define MED_NONE
Definition build.python3.12/include/med.h:231
MED_INTERNAL_INT
@ MED_INTERNAL_INT
Definition build.python3.12/include/med.h:158
MED_NO_PROFILE
#define MED_NO_PROFILE
Definition build.python3.12/include/med.h:279
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_NODE_ELEMENT
@ MED_NODE_ELEMENT
Definition build.python3.12/include/med.h:144
med_err
herr_t med_err
Definition build.python3.12/include/med.h:323
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
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
MEDmeshSortingTypeRd
MEDC_EXPORT med_err MEDmeshSortingTypeRd(const med_idt fid, const char *const meshname, med_sorting_type *const sortingtype)
Cette routine lit l'ordre de tri des étapes évolutives du maillage.
Definition MEDmeshSortingTypeRd.c:35
MEDsubdomainCorrespondenceWr
med_err MEDsubdomainCorrespondenceWr(const med_idt fid, const char *const localmeshname, const char *const jointname, const med_int numdt, const med_int numit, const med_entity_type localentitype, const med_geometry_type localgeotype, const med_entity_type remoteentitype, const med_geometry_type remotegeotype, const med_int nentity, const med_int *const correspondence)
Cette routine permet l'écriture d'une correspondance dans un joint pour un type de couple d'entité en...
Definition MEDsubdomainCorrespondenceWr.c:47
MED_ERR_GEOMETRY
#define MED_ERR_GEOMETRY
Definition med_err.h:107
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition med_err.h:37
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_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_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_API
#define MED_ERR_API
Definition med_err.h:111
MED_ERR_VALUE_MSG
#define MED_ERR_VALUE_MSG
Definition med_err.h:184
MED_ERR_ENTITY
#define MED_ERR_ENTITY
Definition med_err.h:85
MED_ERR_SUBDOMAINJOINT_MSG
#define MED_ERR_SUBDOMAINJOINT_MSG
Definition med_err.h:172
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_DATASET
#define MED_ERR_DATASET
Definition med_err.h:98
_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)
_MEDdatasetFermer
MEDC_EXPORT med_err _MEDdatasetFermer(med_idt id)
_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)
_MEDdatasetOuvrir
MEDC_EXPORT med_idt _MEDdatasetOuvrir(med_idt pid, char *nom)
_MEDgetComputationStepName
MEDC_EXPORT med_err _MEDgetComputationStepName(const med_sorting_type sortingtype, const med_int numdt, const med_int numit, char *const datagroupname)
_MEDdatagroupOuvrir
MEDC_EXPORT med_idt _MEDdatagroupOuvrir(med_idt pid, const char *const nom)
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
_MEDgetInternalGeometryTypeName
MEDC_EXPORT med_err _MEDgetInternalGeometryTypeName(const med_idt fid, char *const geotypename, med_geometry_type geotype)
_MEDgetEntityTypeName
MEDC_EXPORT med_err _MEDgetEntityTypeName(char *const entitytypename, const med_entity_type entitytype)
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
MED_NOM_NOR
#define MED_NOM_NOR
Definition med_outils.h:145
MED_NOM_ENT
#define MED_NOM_ENT
Definition med_outils.h:135
MED_TAILLE_NOM_ENTITE
#define MED_TAILLE_NOM_ENTITE
Definition med_outils.h:38
MED_JOINT_GRP_SIZE
#define MED_JOINT_GRP_SIZE
Definition med_outils.h:253
MED_JOINT_GRP
#define MED_JOINT_GRP
Definition med_outils.h:252
MED_NOM_GED
#define MED_NOM_GED
Definition med_outils.h:136
MED_NOM_NDT
#define MED_NOM_NDT
Definition med_outils.h:142
MED_NOM_COR
#define MED_NOM_COR
Definition med_outils.h:55
MED_NOM_END
#define MED_NOM_END
Definition med_outils.h:137
MED_NOM_GEO
#define MED_NOM_GEO
Definition med_outils.h:133
MED_NOM_NBR
#define MED_NOM_NBR
Definition med_outils.h:40
med_outils.h
med_filter
Filtre de sélection.
Definition build.python3.12/include/med.h:346