MED fichier: Fichier source de MEDsubdomainCorrespondenceWr.c

MED fichier

- Documentation MED
- Guides d'utilisation
- Guides de référence

MEDsubdomainCorrespondenceWr.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 EDF R&D, CEA/DEN
4 * MED is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * MED is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with MED. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19 #include <med.h>
20 #include <med_config.h>
21 #include <med_outils.h>
22
23 #include <string.h>
24 #include <stdlib.h>
25
46 med_err
47 MEDsubdomainCorrespondenceWr(const med_idt fid,
48 const char * const localmeshname,
49 const char * const jointname,
50 const med_int numdt,
51 const med_int numit,
52 const med_entity_type localentitype,
53 const med_geometry_type localgeotype,
54 const med_entity_type remoteentitype,
55 const med_geometry_type remotegeotype,
56 const med_int nentity,
57 const med_int * const correspondence) {
58
59 med_access_mode _MED_ACCESS_MODE;
60 med_idt _root=0,_jntid=0,_meshid=0,_cstpid=0,_datagroup2=0;
61 med_idt _dataset=0;
62 med_err _ret=-1;
63 char _path[MED_JOINT_GRP_SIZE+2*MED_NAME_SIZE+2]=MED_JOINT_GRP;
64 char _computationstepname[2*MED_MAX_PARA+1]="";
65 char _datagroupname2[4*MED_TAILLE_NOM_ENTITE+4]="";
66 char _localgeotypename [MED_TAILLE_NOM_ENTITE+1]="";
67 char _remotegeotypename [MED_TAILLE_NOM_ENTITE+1]="";
68 med_sorting_type _sortingtype=0;
69 med_filter _filter = MED_FILTER_INIT;
70 med_int _localgeotype = MED_NONE;
71 med_int _localentitype = localentitype;
72 med_int _remotegeotype = MED_NONE;
73 med_int _remoteentitype = remoteentitype;
74
75 if ( localentitype == MED_NODE_ELEMENT ) _localgeotype=MED_NODE ;
76
77
78 if ( localentitype != MED_NODE ) _localgeotype = localgeotype ;
79 if ( remoteentitype != MED_NODE ) _remotegeotype = remotegeotype ;
80
81 /*
82 * On inhibe le gestionnaire d'erreur
83 */
84 _MEDmodeErreurVerrouiller();
85 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
86
87 if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
88 MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
89 goto ERROR;
90 }
91
92 if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
93 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
94 ISCRUTE_int(_MED_ACCESS_MODE);
95 goto ERROR;
96 }
97
98 /*
99 * Ouverture du dataGroup /JNT/
100 */
101 if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0) {
102 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
103 goto ERROR;
104 }
105
106 /*
107 * Ouverture du dataGroup <meshname>
108 */
109 if ((_meshid = _MEDdatagroupOuvrir(_root,localmeshname)) < 0) {
110 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,localmeshname);
111 SSCRUTE(_path);goto ERROR;
112 }
113
114 strcat(_path,localmeshname);
115
116 /*
117 * Ouverture du data Group "/JNT/<localmeshname>/<jointname>"
118 */
119 if ((_jntid = _MEDdatagroupOuvrir(_meshid,jointname)) < 0) {
120 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,jointname);
121 SSCRUTE(_path);goto ERROR;
122 }
123
124 strcat(_path,"/");
125 strcat(_path,jointname);
126
127 if ( MEDmeshSortingTypeRd(fid,localmeshname,&_sortingtype) < 0 ) {
128 MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API," MEDmeshSortingTypeRd");
129 SSCRUTE(localmeshname);ISCRUTE_int(_sortingtype);goto ERROR;
130 }
131
132 _MEDgetComputationStepName(_sortingtype,numdt,numit,_computationstepname);
133
134 if ((_cstpid = _MEDdatagroupOuvrir(_jntid,_computationstepname)) < 0)
135 if ((_cstpid = _MEDdatagroupCreer(_jntid,_computationstepname)) < 0 ) {
136 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_computationstepname);
137 SSCRUTE(_path);goto ERROR;
138 }
139
140 /*Cree ou ouvre l'attribut MED_NOM_NDT pour �criture */
141 if ( _MEDattributeIntWr(_cstpid,MED_NOM_NDT,&numdt) < 0) {
142 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
143 SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
144 goto ERROR;
145 }
146
147
148 /*Cree ou ouvre l'attribut MED_NOM_NOR pour �criture */
149 if ( _MEDattributeIntWr(_cstpid,MED_NOM_NOR,&numit) < 0) {
150 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
151 SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
152 goto ERROR;
153 }
154
155
156 /*
157 * Creation/Ouverture du datagroup de niveau
158 * <localentitype>[.<localgeotype>].<remoteentitype>[.<remotegeotype>]
159 */
160 if (_MEDgetEntityTypeName(_datagroupname2,localentitype) < 0) {
161 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
162 ISCRUTE_int(localentitype);SSCRUTE(jointname);goto ERROR;
163 }
164 if ( localentitype != MED_NODE ) {
165 if ( _MEDgetInternalGeometryTypeName(fid,_localgeotypename,localgeotype) < 0) {
166 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
167 ISCRUTE_int(localgeotype);SSCRUTE(jointname);goto ERROR;
168 }
169 strcat(_datagroupname2,".");
170 strcat(_datagroupname2,_localgeotypename);
171 }
172
173 strcat(_datagroupname2,".");
174
175 if (_MEDgetEntityTypeName(&_datagroupname2[strlen(_datagroupname2)],remoteentitype) < 0) {
176 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
177 ISCRUTE_int(remoteentitype);SSCRUTE(jointname);goto ERROR;
178 }
179 if ( remoteentitype != MED_NODE ) {
180 if ( _MEDgetInternalGeometryTypeName(fid,_remotegeotypename,remotegeotype) < 0) {
181 MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
182 ISCRUTE_int(remotegeotype);SSCRUTE(jointname);goto ERROR;
183 }
184 strcat(_datagroupname2,".");
185 strcat(_datagroupname2,_remotegeotypename);
186 }
187
188
189 if ( (_datagroup2 = _MEDdatagroupOuvrir(_cstpid,_datagroupname2)) < 0)
190 if ((_datagroup2 = _MEDdatagroupCreer(_cstpid,_datagroupname2)) < 0) {
191 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_datagroupname2);
192 SSCRUTE(_path);SSCRUTE(jointname);goto ERROR;
193 }
194
195 /*Cree ou ouvre l'attribut MED_NOM_ENT pour �criture */
196 if (_MEDattributeIntWr(_datagroup2,MED_NOM_ENT,&_localentitype) < 0) {
197 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_ENT);
198 ISCRUTE(_localentitype);goto ERROR;
199 }
200
201 /*Cree ou ouvre l'attribut MED_NOM_GEO pour �criture */
202 if (_MEDattributeIntWr(_datagroup2,MED_NOM_GEO,&_localgeotype) < 0) {
203 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_GEO);
204 ISCRUTE(_localgeotype);goto ERROR;
205 }
206
207 /*Cree ou ouvre l'attribut MED_NOM_END pour �criture */
208 if (_MEDattributeIntWr(_datagroup2,MED_NOM_END,&_remoteentitype) < 0) {
209 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_END);
210 ISCRUTE(_remoteentitype);goto ERROR;
211 }
212
213 /*Cree ou ouvre l'attribut MED_NOM_GED pour �criture */
214 if (_MEDattributeIntWr(_datagroup2,MED_NOM_GED,&_remotegeotype) < 0) {
215 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_GED);
216 ISCRUTE(_remotegeotype);goto ERROR;
217 }
218
219
220 if ( MEDfilterEntityCr(fid, nentity, 1, 2, MED_ALL_CONSTITUENT,
221 MED_NO_INTERLACE,MED_UNDEF_STMODE,
222 MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
223 MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
224 goto ERROR;
225 }
226
227 if ( _MEDdatasetWr(_datagroup2,MED_NOM_COR,MED_INTERNAL_INT,&_filter, correspondence) < 0) {
228 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_DATASET,MED_NOM_COR);
229 SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
230 goto ERROR;
231 }
232
233 if ( MEDfilterClose(&_filter) < 0 ) {
234 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_SUBDOMAINJOINT_MSG);
235 SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
236 goto ERROR;
237 }
238
239 if ((_dataset = _MEDdatasetOuvrir(_datagroup2,MED_NOM_COR)) < 0) {
240 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATASET,MED_NOM_COR);
241 SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2);
242 goto ERROR;
243 }
244
245 if ( _MEDattributeIntWr(_dataset,MED_NOM_NBR,&nentity) < 0) {
246 MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
247 SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);SSCRUTE(_datagroupname2);
248 SSCRUTE(MED_NOM_NBR);ISCRUTE(nentity);goto ERROR;
249 }
250
251
252
253 _ret=0;
254 ERROR:
255
256 if (_dataset>0) if (_MEDdatasetFermer(_dataset) < 0) {
257 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATASET,MED_NOM_COR);
258 ISCRUTE_id(_dataset);
259 }
260
261 if (_datagroup2>0) if (_MEDdatagroupFermer(_datagroup2) < 0) {
262 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname2);
263 ISCRUTE_id(_datagroup2);SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
264 }
265
266 if (_cstpid>0) if (_MEDdatagroupFermer(_cstpid) < 0) {
267 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_computationstepname);
268 ISCRUTE_id(_cstpid);SSCRUTE(_path);ISCRUTE(numdt);ISCRUTE(numit);
269 }
270
271 if (_jntid>0) if (_MEDdatagroupFermer(_jntid) < 0) {
272 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,jointname);
273 ISCRUTE_id(_jntid);SSCRUTE(_path);
274 }
275
276 if (_meshid>0) if (_MEDdatagroupFermer(_meshid) < 0) {
277 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,localmeshname);
278 ISCRUTE_id(_meshid);
279 }
280
281 if (_root>0) if (_MEDdatagroupFermer(_root) < 0) {
282 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_JOINT_GRP);
283 ISCRUTE_id(_root);
284 }
285
286 return _ret;
287 }
med_filter
Filtre de sélection.
Definition: med.h:350
MED_ERR_ATTRIBUTE
#define MED_ERR_ATTRIBUTE
Definition: med_err.h:99
MED_NOM_NBR
#define MED_NOM_NBR
Definition: med_outils.h:39
med_err
herr_t med_err
Definition: med.h:327
MED_ERR_VALUE_MSG
#define MED_ERR_VALUE_MSG
Definition: med_err.h:179
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:158
MED_NODE_ELEMENT
Definition: med.h:142
MED_ERR_FILE_MSG
#define MED_ERR_FILE_MSG
Definition: med_err.h:129
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:56
MED_ERR_INVALID
#define MED_ERR_INVALID
Definition: med_err.h:37
_MEDcheckVersion30
MEDC_EXPORT med_err _MEDcheckVersion30(med_idt fid)
_MEDmodeAcces
MEDC_EXPORT med_access_mode _MEDmodeAcces(med_idt oid)
med_access_mode
med_access_mode
Definition: med.h:118
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 séquences évolutives du maillage.
Definition: MEDmeshSortingTypeRd.c:35
MED_JOINT_GRP
#define MED_JOINT_GRP
Definition: med_outils.h:243
MED_NO_INTERLACE
Definition: med.h:96
MED_FILTER_INIT
#define MED_FILTER_INIT
Definition: med.h:369
_MEDgetInternalGeometryTypeName
MEDC_EXPORT med_err _MEDgetInternalGeometryTypeName(const med_idt fid, char *const geotypename, med_geometry_type geotype)
MED_UNDEF_STMODE
Definition: med.h:106
MED_ALL_CONSTITUENT
#define MED_ALL_CONSTITUENT
Definition: med.h:296
MED_NODE
Definition: med.h:141
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition: med_utils.h:307
MED_ERR_ACCESSMODE
#define MED_ERR_ACCESSMODE
Definition: med_err.h:103
med_sorting_type
med_sorting_type
Definition: med.h:306
MED_ERR_UNRECOGNIZED
#define MED_ERR_UNRECOGNIZED
Definition: med_err.h:36
MED_NOM_END
#define MED_NOM_END
Definition: med_outils.h:123
MED_ERR_SUBDOMAINJOINT_MSG
#define MED_ERR_SUBDOMAINJOINT_MSG
Definition: med_err.h:167
_MEDgetEntityTypeName
MEDC_EXPORT med_err _MEDgetEntityTypeName(char *const entitytypename, const med_entity_type entitytype)
MED_INTERNAL_INT
Definition: med.h:155
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition: med_err.h:26
MED_MAX_PARA
#define MED_MAX_PARA
Definition: med.h:74
med_entity_type
med_entity_type
Definition: med.h:141
MED_ERR_CALL
#define MED_ERR_CALL
Definition: med_err.h:45
MED_NONE
#define MED_NONE
Definition: med.h:228
MED_ERR_GEOMETRIC
#define MED_ERR_GEOMETRIC
Definition: med_err.h:104
MED_TAILLE_NOM_ENTITE
#define MED_TAILLE_NOM_ENTITE
Definition: med_outils.h:37
med_int
int med_int
Definition: med.h:337
med_config.h
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:24
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:306
_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)
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:27
_MEDdatasetFermer
MEDC_EXPORT med_err _MEDdatasetFermer(med_idt id)
_MEDattributeIntWr
#define _MEDattributeIntWr(w, x, y)
Definition: med_hdfi.h:45
MED_ACC_UNDEF
Definition: med.h:122
MED_NO_PROFILE
#define MED_NO_PROFILE
Definition: med.h:278
_MEDdatasetOuvrir
MEDC_EXPORT med_idt _MEDdatasetOuvrir(med_idt pid, char *nom)
MED_NOM_NOR
#define MED_NOM_NOR
Definition: med_outils.h:131
MEDfilterClose
MEDC_EXPORT med_err MEDfilterClose(med_filter *const filter)
Désalloue les ressources hdf détenues par un filtre.
Definition: MEDfilterClose.c:35
_MEDdatagroupOuvrir
MEDC_EXPORT med_idt _MEDdatagroupOuvrir(med_idt pid, const char *const nom)
MED_ERR_INTERNAL_MSG
#define MED_ERR_INTERNAL_MSG
Definition: med_err.h:191
MED_ERR_DATAGROUP
#define MED_ERR_DATAGROUP
Definition: med_err.h:98
MED_JOINT_GRP_SIZE
#define MED_JOINT_GRP_SIZE
Definition: med_outils.h:244
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:34
med_idt
hid_t med_idt
Definition: med.h:326
MED_ERR_ENTITY
#define MED_ERR_ENTITY
Definition: med_err.h:84
_MEDdatagroupFermer
MEDC_EXPORT med_err _MEDdatagroupFermer(med_idt id)
med_outils.h
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:79
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.h
ISCRUTE_id
#define ISCRUTE_id(entier)
Definition: med_utils.h:311
_MEDdatagroupCreer
MEDC_EXPORT med_idt _MEDdatagroupCreer(med_idt pid, const char *const nom)
MED_NOM_NDT
#define MED_NOM_NDT
Definition: med_outils.h:128
MED_UNDEF_SIZE
#define MED_UNDEF_SIZE
Definition: med.h:303
MED_NOM_GED
#define MED_NOM_GED
Definition: med_outils.h:122
MED_ERR_DATASET
#define MED_ERR_DATASET
Definition: med_err.h:97
med_geometry_type
int med_geometry_type
Definition: med.h:191
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:315
_MEDmodeErreurVerrouiller
MEDC_EXPORT void _MEDmodeErreurVerrouiller(void)
MED_ERR_FILTER
#define MED_ERR_FILTER
Definition: med_err.h:92
_MEDgetComputationStepName
MEDC_EXPORT med_err _MEDgetComputationStepName(const med_sorting_type sortingtype, const med_int numdt, const med_int numit, char *const datagroupname)
MED_ERR_API
#define MED_ERR_API
Definition: med_err.h:108
MED_NOM_ENT
#define MED_NOM_ENT
Definition: med_outils.h:121
MED_NOM_COR
#define MED_NOM_COR
Definition: med_outils.h:57
MED_NOM_GEO
#define MED_NOM_GEO
Definition: med_outils.h:119
MED_ACC_RDONLY
Definition: med.h:118