MED fichier
test30.c
Aller à la documentation de ce fichier.
1/* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2020 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 * - Nom du fichier : test30.c
20 *
21 * - Description : lecture des joints d'un maillage MED.
22 *
23 *****************************************************************************/
24
25#include <med.h>
26#define MESGERR 1
27#include <med_utils.h>
28
29#ifdef DEF_LECT_ECR
30#define MODE_ACCES MED_ACC_RDWR
31#elif DEF_LECT_AJOUT
32#define MODE_ACCES MED_ACC_RDEXT
33#else
34#define MODE_ACCES MED_ACC_CREAT
35#endif
36
37int afficheCorres(med_idt fid, char *maa, char *jnt,
38 med_entity_type typ_ent_local, med_geometry_type typ_geo_local,
39 med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant,
40 char *type);
41
42int main (int argc, char **argv)
43
44
45{
46 med_err ret = 0;
47 med_idt fid;
48 char maa[MED_NAME_SIZE+1],maa_dist[MED_NAME_SIZE+1];
49 med_int mdim,sdim;
50 med_int njnt,ncor,ndom,nc;
51 char jnt[MED_NAME_SIZE+1],corr[MED_NAME_SIZE+1];
52 char des[MED_COMMENT_SIZE+1];
53 char dtunit[MED_SNAME_SIZE+1]="";
54 char nomcoo[3*MED_SNAME_SIZE+1];
55 char unicoo[3*MED_SNAME_SIZE+1];
56 med_axis_type rep;
57 med_mesh_type type;
59 med_int nstep=0,njstep=0,nodtitncor=0,nentity=0;
60 med_entity_type typ_ent_local,typ_ent_distant;
61 med_geometry_type typ_geo_local,typ_geo_distant;
62 int i,j,k;
63
64 if (argc != 2) {
65 MESSAGE("Il faut passer un fichier MED en paramètre");
66 return -1;
67 }
68
69 /* Ouverture du fichier passe en argument en lecture seule */
70 if ((fid = MEDfileOpen(argv[1],MED_ACC_RDONLY)) < 0) {
71 MESSAGE("Erreur à l'ouverture du fichier : "); SSCRUTE(argv[1]);
72 return -1;
73 }
74
75 if ((sdim=MEDmeshnAxis(fid, 1)) <0) {
76 MESSAGE("Erreur à la lecture de la dimension de l'espace du maillage :");
77 SSCRUTE(maa);
78 return -1;
79 }
80
81 /* Lecture des infos concernant le premier maillage */
82 if ( MEDmeshInfo( fid, 1, maa, &sdim, &mdim, &type, des, dtunit, &sort,
83 &nstep, &rep, nomcoo,unicoo) < 0 ) {
84 MESSAGE("Erreur a la lecture des informations sur le maillage : ");SSCRUTE(maa);
85 return -1;
86 } else {
87 printf("Maillage de nom : |%s| , de dimension : "IFORMAT" , et de type %d\n",maa,mdim,type);
88 printf("\t -Dimension de l'espace : "IFORMAT"\n",sdim);
89 printf("\t -Description du maillage : |%s|\n",des);
90 printf("\t -Noms des axes : |%s|\n",nomcoo);
91 printf("\t -Unités des axes : |%s|\n",unicoo);
92 printf("\t -Type de repère : %d\n",rep);
93 printf("\t -Nombre d'étapes de calcul : "IFORMAT"\n",nstep);
94 printf("\t -Unité des dates : |%s|\n\n",dtunit);
95 }
96
97 /* Lecture du nombre de joints */
98 if ((njnt = MEDnSubdomainJoint(fid,maa)) < 0) {
99 MESSAGE("Erreur a la lecture du nombre de joints");
100 return -1;
101 }
102 printf("Nombre de joints : "IFORMAT" \n",njnt);
103
104 /* Lecture de tous les joints du maillage */
105 for (i = 0;i<njnt;i++) {
106 printf("Joint numero : %d \n",i+1);
107
108 /* Lecture des infos sur le joints */
109 if (MEDsubdomainJointInfo(fid,maa,i+1,jnt,des,&ndom,maa_dist,&njstep,&nodtitncor) < 0) {
110 MESSAGE("Erreur a la lecture du joint d'indice");
111 ISCRUTE_int(i+1);
112 return -1;
113 }
114 printf("Nom du joint: |%s| \n",jnt);
115 printf("Description du joint : |%s| \n",des);
116 printf("Domaine en regard : "IFORMAT" \n",ndom);
117 printf("Maillage distant : |%s| \n",maa_dist);
118 printf("Nombre d'étapes de calcul : "IFORMAT" \n",njstep);
119 printf("Nombre de correspondance pour (NO_DT,NO_IT) : "IFORMAT" \n",nodtitncor);
120
121
122
123 /* lecture des correspondances une par une
124 en connaissant leur type a priori */
125
126 /* Lecture de la correspondance Noeud Noeud */
127 afficheCorres(fid,maa,jnt,MED_NODE,0,MED_NODE,0,"noeud/noeud");
128
129 /* Lecture de la correspondance Noeud Maille */
130 afficheCorres(fid,maa,jnt,MED_NODE,0,MED_CELL,MED_TRIA3,"noeud/TRIA3");
131
132
133 /* lecture des correspondances une par une
134 sans connaitre leur type a priori
135 -> utilisation de la fonction MEDjointTypeCorres */
136
137 ncor=1;
138
139 while ( ncor <= nodtitncor ) {
140 ISCRUTE(ncor);
142 &typ_ent_local,&typ_geo_local,&typ_ent_distant,&typ_geo_distant,
143 &nentity) < 0 ) {
144 MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard");
145 return -1;
146 }
147
148 /* Lecture de la correspondance Noeud Noeud */
149 afficheCorres(fid,maa,jnt,typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,"------");
150
151 ncor++;
152 }
153
154 }
155
156 /* Fermeture du fichier */
157 if (MEDfileClose(fid) < 0) {
158 MESSAGE("Erreur a la fermeture du fichier ");
159 return -1;
160 }
161
162 return ret;
163}
164
165
166
167
168int afficheCorres(med_idt fid, char *maa, char *jnt,
169 med_entity_type typ_ent_local, med_geometry_type typ_geo_local,
170 med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant,
171 char *type)
172{
173 med_int nc;
174 med_int *cortab;
175 int k,ncor,ret=0;
176
177 ISCRUTE_int(typ_ent_local);ISCRUTE_int(typ_geo_local);
178 ISCRUTE_int(typ_ent_distant);ISCRUTE_int(typ_geo_distant);
180 typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
181 &nc) < 0) {
182 MESSAGE("Erreur a la lecture des infos sur le nombre d'entite en regard de type");
183 SSCRUTE(type);
184 return -1;
185 }
186
187 printf("nb de couples d'entites en regard |%s|: "IFORMAT" \n",type,nc);
188
189 if (nc > 0) {
190 cortab = (med_int*) malloc(sizeof(med_int)*nc*2);
192 typ_ent_local,typ_geo_local,typ_ent_distant,typ_geo_distant,
193 cortab)) < 0) {
194 MESSAGE("Erreur a la lecture des correspondances sur ");
195 SSCRUTE(type);
196 ret = -1;
197 }
198 if (ret == 0)
199 for (k=0;k<nc;k++)
200 printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cortab+2*k),
201 *(cortab+2*k+1));
202 free(cortab);
203 }
204 return ret;
205}
206
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
MEDC_EXPORT med_err MEDmeshInfo(const med_idt fid, const int meshit, char *const meshname, med_int *const spacedim, med_int *const meshdim, med_mesh_type *const meshtype, char *const description, char *const dtunit, med_sorting_type *const sortingtype, med_int *const nstep, med_axis_type *const axistype, char *const axisname, char *const axisunit)
Cette routine permet de lire les informations relatives à un maillage dans un fichier.
Definition: MEDmeshInfo.c:43
MEDC_EXPORT med_int MEDmeshnAxis(const med_idt fid, const int meshit)
Cette routine permet de lire dans un maillage le nombre d'axes du repère des coordonnées des noeuds.
Definition: MEDmeshnAxis.c:35
MEDC_EXPORT med_err MEDsubdomainJointInfo(const med_idt fid, const char *const meshname, const int jointit, char *const jointname, char *const description, med_int *const domainnumber, char *const remotemeshname, med_int *const nstep, med_int *const nocstpncorrespondence)
Cette routine permet de lire les informations sur un joint dans un maillage.
MEDC_EXPORT med_err MEDsubdomainCorrespondenceSize(const med_idt fid, const char *const meshname, const char *const jointname, const med_int numdt, const med_int numit, const med_entity_type localentitytype, const med_geometry_type localgeotype, const med_entity_type remoteentitytype, const med_geometry_type remotegeotype, med_int *const nentity)
Cette routine permet la lecture du nombre d'entités en correspondance dans un joint pour un couple d'...
MEDC_EXPORT med_err MEDsubdomainCorrespondenceRd(const med_idt fid, const char *const meshname, const char *const jointname, const med_int numdt, const med_int numit, const med_entity_type localentitytype, const med_geometry_type localgeotype, const med_entity_type remoteentitytype, const med_geometry_type remotegeotype, med_int *const correspondence)
Cette routine permet la lecture d'une correspondance dans un joint pour un type de couple d'entité en...
MEDC_EXPORT med_int MEDnSubdomainJoint(const med_idt fid, const char *const meshname)
Cette routine permet la lecture du nombre de joint dans un maillage.
MEDC_EXPORT med_err MEDsubdomainCorrespondenceSizeInfo(const med_idt fid, const char *const meshname, const char *const jointname, const med_int numdt, const med_int numit, const int corit, med_entity_type *const localentitytype, med_geometry_type *const localgeotype, med_entity_type *const remoteentitytype, med_geometry_type *const remotegeotype, med_int *const nentity)
Cette routine permet de lire les informations sur les couples d'entités en correspondance dans un joi...
#define MED_NAME_SIZE
Definition: med.h:81
int med_geometry_type
Definition: med.h:194
#define MED_SNAME_SIZE
Definition: med.h:82
#define MED_TRIA3
Definition: med.h:203
med_axis_type
Definition: med.h:258
med_sorting_type
Definition: med.h:300
med_mesh_type
Definition: med.h:131
int med_int
Definition: med.h:333
#define MED_NO_DT
Definition: med.h:311
#define MED_NO_IT
Definition: med.h:312
med_entity_type
Definition: med.h:143
@ MED_NODE
Definition: med.h:143
@ MED_CELL
Definition: med.h:143
#define MED_COMMENT_SIZE
Definition: med.h:79
herr_t med_err
Definition: med.h:323
@ MED_ACC_RDONLY
Definition: med.h:120
hid_t med_idt
Definition: med.h:322
#define SSCRUTE(chaine)
Definition: med_utils.h:323
#define MESSAGE(chaine)
Definition: med_utils.h:324
#define ISCRUTE(entier)
Definition: med_utils.h:313
#define IFORMAT
Definition: med_utils.h:145
#define ISCRUTE_int(entier)
Definition: med_utils.h:314
int main(int argc, char **argv)
Definition: test30.c:42
int afficheCorres(med_idt fid, char *maa, char *jnt, med_entity_type typ_ent_local, med_geometry_type typ_geo_local, med_entity_type typ_ent_distant, med_geometry_type typ_geo_distant, char *type)
Definition: test30.c:168