c/test13.c
/* 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/>.
*/
/******************************************************************************
* - Nom du fichier : test13.c
*
* - Description : lecture des equivalences d'un maillage MED.
*
*****************************************************************************/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#ifdef DEF_LECT_ECR
#define MODE_ACCES MED_ACC_RDWR
#elif DEF_LECT_AJOUT
#define MODE_ACCES MED_ACC_RDEXT
#else
#define MODE_ACCES MED_ACC_CREAT
#endif
int main (int argc, char **argv)
{
med_err ret = 0;
med_idt fid = 0;
char maa[MED_NAME_SIZE+1]="";
med_int mdim=0,sdim=0;
med_int nequ=0,ncor=0,nstep=0,nocstpncor=0;
med_int *cor;
char equ[MED_NAME_SIZE+1] ="";
char des[MED_COMMENT_SIZE+1]="";
int i,j,k;
med_mesh_type type;
med_sorting_type sort;
char desc[MED_COMMENT_SIZE+1];
char dtunit[MED_SNAME_SIZE+1]="";
char nomcoo[3*MED_SNAME_SIZE+1];
char unicoo[3*MED_SNAME_SIZE+1];
med_axis_type rep;
med_geometry_type *typmai = MED_GET_CELL_GEOMETRY_TYPE;
med_geometry_type *typfac = MED_GET_FACE_GEOMETRY_TYPE;
med_geometry_type *typare = MED_GET_EDGE_GEOMETRY_TYPE;
if (argc != 2) {
MESSAGE("Il faut passer un fichier MED en paramètre");
return -1;
}
/* Ouverture du fichier passe en argument en lecture seule */
if ((fid = MEDfileOpen(argv[1],MED_ACC_RDONLY)) < 0) {
MESSAGE("Erreur a l'ouverture du fichier : "); SSCRUTE(argv[1]);
return -1;
}
if ((sdim=MEDmeshnAxis(fid, 1)) <0) {
MESSAGE("Erreur a la lecture de la dimension de l'espace du maillage :");
SSCRUTE(maa);
return -1;
}
/* Lecture des infos concernant le premier maillage */
if ( MEDmeshInfo( fid, 1, maa, &sdim, &mdim, &type, desc, dtunit, &sort,
&nstep, &rep, nomcoo,unicoo) < 0 ) {
MESSAGE("Erreur a la lecture des informations sur le maillage : ");SSCRUTE(maa);
return -1;
} else {
printf("Maillage de nom : |%s| , de dimension : "IFORMAT" , et de type %d\n",maa,mdim,type);
printf("\t -Dimension de l'espace : "IFORMAT"\n",sdim);
printf("\t -Description du maillage : %s\n",desc);
printf("\t -Noms des axes : |%s|\n",nomcoo);
printf("\t -Unités des axes : |%s|\n",unicoo);
printf("\t -Type de repère : %d\n",rep);
printf("\t -Nombre d'étapes de calcul : "IFORMAT"\n",nstep);
printf("\t -Unité des dates : |%s|\n",dtunit);
}
/* Lecture du nombre d'equivalence */
if ((nequ = MEDnEquivalence(fid,maa)) < 0)
{
MESSAGE("Erreur a la lecture du nombre d'equivalence");
return -1;
}
printf("Nombre d'equivalences : "IFORMAT" \n",nequ);
/* Lecture de toutes les equivalences du maillage */
if (nequ > 0)
for (i = 0;i<nequ;i++)
{
printf("Equivalence numero : %d \n",i+1);
/* Lecture des infos sur l'equivalence */
if (MEDequivalenceInfo(fid,maa,i+1,equ,des,&nstep,&nocstpncor) < 0)
{
MESSAGE("Erreur a la lecture de l'equivalence d'indice");
ISCRUTE_int(i+1);
return -1;
}
printf("Nom de l'equivalence: |%s| \n",equ);
printf("Description de l'equivalence : |%s| \n",des);
printf("Nombre d'étapes de calcul : "IFORMAT" \n",nstep);
printf("Nombre de correspondances pour l'étape de calcul MED_NO_DT,MED_NO_IT : "IFORMAT" \n",nocstpncor);
/* Lecture des correspondances sur les differents types d'entites */
/* Les noeuds */
if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,MED_NODE,MED_NONE,&ncor) < 0) {
MESSAGE("Erreur a la lecture du nombre de correspondance sur les noeuds");
return -1;
}
printf("Il y a "IFORMAT" correspondances sur les noeuds \n",ncor);
if (ncor > 0) {
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
MED_NODE,MED_NONE,cor) < 0) {
MESSAGE("Erreur a la lecture des correspondances sur les noeuds");
ret = -1;
}
if (ret == 0)
for (j=0;j<ncor;j++)
printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",j+1,*(cor+2*j),
*(cor+2*j+1));
free(cor);
}
/* Les mailles : on ne prend pas en compte les mailles 3D */
if (ret == 0)
for (j=1;j<=MED_N_CELL_FIXED_GEO;j++) {
if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,MED_CELL,typmai[j],&ncor) < 0) {
MESSAGE("Erreur a la lecture du nombre de correspondance sur les mailles : ");
SSCRUTE(MED_GET_CELL_GEOMETRY_TYPENAME[j]);
return -1;
}
printf("Il y a "IFORMAT" correspondances sur les mailles %s \n",ncor,
MED_GET_CELL_GEOMETRY_TYPENAME[j]);
if (ncor > 0) {
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
MED_CELL,typmai[j],cor) < 0) {
MESSAGE("Erreur a la lecture des correspondances sur les mailles : ");
SSCRUTE(MED_GET_CELL_GEOMETRY_TYPENAME[j]);
ret = -1;
}
if (ret == 0)
for (k=0;k<ncor;k++)
printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
*(cor+2*k+1));
free(cor);
}
}
/* Les faces */
if (ret == 0)
for (j=1;j<=MED_N_FACE_FIXED_GEO;j++) {
if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,
MED_DESCENDING_FACE,typfac[j],&ncor) < 0) {
MESSAGE("Erreur a la lecture du nombre de correspondance sur les faces : ");
SSCRUTE(MED_GET_FACE_GEOMETRY_TYPENAME[j]);
return -1;
}
printf("Il y a "IFORMAT" correspondances sur les faces %s \n",ncor,
MED_GET_FACE_GEOMETRY_TYPENAME[j]);
if (ncor > 0) {
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
MED_DESCENDING_FACE,typfac[j],cor) < 0) {
MESSAGE("Erreur a la lecture des correspondances sur les faces : ");
SSCRUTE(MED_GET_FACE_GEOMETRY_TYPENAME[j]);
ret = -1;
}
if (ret == 0)
for (k=0;k<ncor;k++)
printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
*(cor+2*k+1));
free(cor);
}
}
/* Les aretes */
if (ret == 0)
for (j=1;j<=MED_N_EDGE_FIXED_GEO;j++) {
if ( MEDequivalenceCorrespondenceSize(fid,maa,equ,MED_NO_DT,MED_NO_IT,
MED_DESCENDING_EDGE,typare[j],&ncor) < 0) {
MESSAGE("Erreur a la lecture du nombre de correspondance sur les aretes : ");
SSCRUTE(MED_GET_EDGE_GEOMETRY_TYPENAME[j]);
return -1;
}
printf("Il y a "IFORMAT" correspondances sur les aretes %s \n",ncor,
MED_GET_EDGE_GEOMETRY_TYPENAME[j]);
if (ncor > 0) {
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
if (MEDequivalenceCorrespondenceRd(fid,maa,equ,MED_NO_DT,MED_NO_IT,
MED_DESCENDING_EDGE,typare[j],cor) < 0) {
MESSAGE("Erreur a la lecture des correspondances sur les faces : ");
SSCRUTE(MED_GET_EDGE_GEOMETRY_TYPENAME[j]);
ret = -1;
}
if (ret == 0)
for (k=0;k<ncor;k++)
printf("Correspondance %d : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
*(cor+2*k+1));
free(cor);
}
}
}
/* Fermeture du fichier */
if (MEDfileClose(fid) < 0) {
MESSAGE("Erreur a la fermeture du fichier ");
return -1;
}
return ret;
}
main
int main(int argc, char **argv)
Definition 3.0.8/test10.c:51
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition build.python3.12/include/med.h:81
med_geometry_type
int med_geometry_type
Definition build.python3.12/include/med.h:194
MED_SNAME_SIZE
#define MED_SNAME_SIZE
Definition build.python3.12/include/med.h:82
MED_GET_EDGE_GEOMETRY_TYPE
MEDC_EXPORT med_geometry_type MED_GET_EDGE_GEOMETRY_TYPE[MED_N_EDGE_FIXED_GEO+2]
Definition MEDiterators.c:140
med_axis_type
med_axis_type
Definition build.python3.12/include/med.h:258
MED_GET_CELL_GEOMETRY_TYPENAME
MEDC_EXPORT const char *const MED_GET_CELL_GEOMETRY_TYPENAME[MED_N_CELL_FIXED_GEO+2]
Definition MEDiterators.c:84
med_sorting_type
med_sorting_type
Definition build.python3.12/include/med.h:300
MED_GET_FACE_GEOMETRY_TYPENAME
MEDC_EXPORT const char *const MED_GET_FACE_GEOMETRY_TYPENAME[MED_N_FACE_FIXED_GEO+2]
Definition MEDiterators.c:127
med_mesh_type
med_mesh_type
Definition build.python3.12/include/med.h:131
med_int
int med_int
Definition build.python3.12/include/med.h:333
MED_NO_DT
#define MED_NO_DT
Definition build.python3.12/include/med.h:311
MED_NO_IT
#define MED_NO_IT
Definition build.python3.12/include/med.h:312
MED_NONE
#define MED_NONE
Definition build.python3.12/include/med.h:231
MED_NODE
@ MED_NODE
Definition build.python3.12/include/med.h:143
MED_CELL
@ MED_CELL
Definition build.python3.12/include/med.h:143
MED_DESCENDING_FACE
@ MED_DESCENDING_FACE
Definition build.python3.12/include/med.h:143
MED_DESCENDING_EDGE
@ MED_DESCENDING_EDGE
Definition build.python3.12/include/med.h:143
MED_GET_FACE_GEOMETRY_TYPE
MEDC_EXPORT med_geometry_type MED_GET_FACE_GEOMETRY_TYPE[MED_N_FACE_FIXED_GEO+2]
Definition MEDiterators.c:114
MED_N_FACE_FIXED_GEO
#define MED_N_FACE_FIXED_GEO
Definition build.python3.12/include/med.h:243
MED_COMMENT_SIZE
#define MED_COMMENT_SIZE
Definition build.python3.12/include/med.h:79
MED_N_EDGE_FIXED_GEO
#define MED_N_EDGE_FIXED_GEO
Definition build.python3.12/include/med.h:247
med_err
herr_t med_err
Definition build.python3.12/include/med.h:323
MED_N_CELL_FIXED_GEO
#define MED_N_CELL_FIXED_GEO
Definition build.python3.12/include/med.h:239
MED_ACC_RDONLY
@ MED_ACC_RDONLY
Definition build.python3.12/include/med.h:120
MED_GET_EDGE_GEOMETRY_TYPENAME
MEDC_EXPORT const char * MED_GET_EDGE_GEOMETRY_TYPENAME[MED_N_EDGE_FIXED_GEO+2]
Definition MEDiterators.c:148
MED_GET_CELL_GEOMETRY_TYPE
MEDC_EXPORT med_geometry_type MED_GET_CELL_GEOMETRY_TYPE[MED_N_CELL_FIXED_GEO+2]
Definition MEDiterators.c:55
med_idt
hid_t med_idt
Definition build.python3.12/include/med.h:322
SSCRUTE
#define SSCRUTE(chaine)
Definition build.python3.12/include/med_utils.h:323
MESSAGE
#define MESSAGE(chaine)
Definition build.python3.12/include/med_utils.h:324
IFORMAT
#define IFORMAT
Definition build.python3.12/include/med_utils.h:145
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition build.python3.12/include/med_utils.h:314
MEDequivalenceInfo
MEDC_EXPORT med_err MEDequivalenceInfo(const med_idt fid, const char *const meshname, const int equivit, char *const equivname, char *const equivdescription, med_int *const nstep, med_int *const nocstpncorrespondence)
Cette routine permet lire les informations d'une équivalence portant sur les entités d'un maillage.
Definition MEDequivalenceInfo.c:40
MEDnEquivalence
MEDC_EXPORT med_int MEDnEquivalence(const med_idt fid, const char *const meshname)
Cette routine permet de lire le nombre d'équivalence dans un fichier.
Definition MEDnEquivalence.c:36
MEDequivalenceCorrespondenceSize
MEDC_EXPORT med_err MEDequivalenceCorrespondenceSize(const med_idt fid, const char *const meshname, const char *const equivname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, med_int *const nentity)
Cette routine permet de lire le nombre de correspondances dans une équivalence pour une étape de calc...
Definition MEDequivalenceCorrespondenceSize.c:41
MEDequivalenceCorrespondenceRd
MEDC_EXPORT med_err MEDequivalenceCorrespondenceRd(const med_idt fid, const char *const meshname, const char *const equivname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, med_int *const correspondence)
Cette routine permet de lire un tableau de correspondances entre les entités d'un maillage dans une é...
Definition MEDequivalenceCorrespondenceRd.c:41
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition MEDfileClose.c:30
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition MEDfileOpen.c:42
MEDmeshInfo
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
MEDmeshnAxis
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
typmai
const med_geometry_type *const typmai
Definition test13b.c:38
typfac
const med_geometry_type *const typfac
Definition test13b.c:39
typare
const med_geometry_type *const typare
Definition test13b.c:40