test13b.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/>.
*/
/******************************************************************************
* - 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
const med_geometry_type * const typmai = MED_GET_CELL_GEOMETRY_TYPE+1;
const med_geometry_type * const typfac = MED_GET_FACE_GEOMETRY_TYPE+1;
const med_geometry_type * const typare = MED_GET_EDGE_GEOMETRY_TYPE+1;
const char * const *nommai = MED_GET_CELL_GEOMETRY_TYPENAME+1;
const char * const *nomfac = MED_GET_FACE_GEOMETRY_TYPENAME+1;
const char * const *nomare = MED_GET_EDGE_GEOMETRY_TYPENAME+1;
void lecture_equivalence_maillage(med_idt fid,const char * const nommaa,med_int nequ)
{
med_int i,j,k;
med_int ncor;
med_int *cor;
char equ[MED_NAME_SIZE+1];
char des[MED_COMMENT_SIZE+1];
med_err ret = 0;
med_int nstep=0,nocstpncor=0;
int _cstpit=0;
med_int _numdt,_numit;
int structure = 0;
if ( (nequ != 0) ) {
fprintf(stdout,"\n(******************************)\n");
fprintf(stdout,"(* EQUIVALENCES DU MAILLAGE : *)\n");
fprintf(stdout,"(******************************)\n");
}
/* lecture de toutes les equivalences associes a nommaa */
for (i = 0;i<nequ;i++) {
/* lecture des infos sur l'equivalence */
ret = MEDequivalenceInfo(fid,nommaa,i+1,equ,des,&nstep,&nocstpncor);
EXIT_IF(ret < 0,"lors de la lecture des informations sur une equivalence",
NULL);
fprintf(stdout,"- Equivalence numero : "IFORMAT" ",i+1);
fprintf(stdout,"\n - Nom de l'equivalence: %s \n",equ);
fprintf(stdout,"\n - Description de l'equivalence : %s \n",des);
if (nstep > 1)
fprintf(stdout,"\n - L'equivalence est définie sur "IFORMAT" étapes de calcul\n",nstep);
for (_cstpit=1; _cstpit <= nstep; ++_cstpit) {
ret = MEDequivalenceComputingStepInfo (fid, nommaa, equ, _cstpit,
& _numdt, &_numit,&nocstpncor);
EXIT_IF(ret < 0,
"lors de la lecture des valeurs de étape de calcul d'une equivalence",
NULL);
if ( (_numdt != MED_NO_DT) || (_numit != MED_NO_IT) )
fprintf(stdout,"\n - Étape de calcul définie sur (numdt,numit) ("IFORMAT","IFORMAT") :\n",_numdt,_numit);
/* lecture des correspondances sur les differents types d'entites */
/* les noeuds */
ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,MED_NODE,MED_NONE,&ncor);
EXIT_IF(ret < 0,
"lors de la lecture du nombre de correspondances d'une equivalence",
NULL);
fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les noeuds \n",ncor);
if (ncor > 0) {
/* allocation memoire */
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
EXIT_IF(cor == NULL,NULL,NULL);
ret= MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
MED_NODE,MED_NONE,cor);
EXIT_IF(ret < 0,"lors de la lecture du tableau des correspondances",
NULL);
if (!structure) {
for (j=0;j<ncor;j++)
fprintf(stdout,"\n - Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",j+1,*(cor+2*j),
*(cor+2*j+1));
}
free(cor);
}
/* sur les mailles : */
for (j=0;j<MED_N_CELL_FIXED_GEO;j++) {
ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,MED_CELL,typmai[j],&ncor);
EXIT_IF(ret < 0,
"lors de la lecture du nombre de correspondances dans une equivalence",
NULL);
fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les mailles %s \n",ncor,
nommai[j]);
if (ncor > 0) {
/* allocation memoire */
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
EXIT_IF(cor == NULL,NULL,NULL);
ret = MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
MED_CELL,typmai[j],cor);
EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
NULL);
if (!structure) {
for (k=0;k<ncor;k++)
fprintf(stdout,"\n - Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",k+1,
*(cor+2*k),*(cor+2*k+1));
}
free(cor);
}
}
/* sur les faces */
for (j=0;j<MED_N_FACE_FIXED_GEO;j++) {
ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,
MED_DESCENDING_FACE,typfac[j],&ncor);
EXIT_IF(ret < 0,
"lors de la lecture du nombre de correspondances dans une equivalence",
NULL);
fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les faces %s\n",ncor,
nomfac[j]);
if (ncor > 0) {
/* allocation memoire */
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
EXIT_IF(cor == NULL,NULL,NULL);
ret = MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
MED_DESCENDING_FACE,typfac[j],cor);
EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
NULL);
if (!structure) {
for (k=0;k<ncor;k++)
fprintf(stdout,"\n - Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
*(cor+2*k+1));
}
free(cor);
}
}
/* sur les aretes */
for (j=0;j<MED_N_NODE_FIXED_GEO;j++) {
ret = MEDequivalenceCorrespondenceSize(fid,nommaa,equ,_numdt,_numit,
MED_DESCENDING_EDGE,typare[j],&ncor);
EXIT_IF(ret < 0,"lors de la lecture du nombre de correspondances",
NULL);
fprintf(stdout,"\n - Il y a "IFORMAT" correspondances sur les aretes %s \n",
ncor,nomare[j]);
if (ncor > 0) {
/* allocation memoire */
cor = (med_int*) malloc(sizeof(med_int)*ncor*2);
EXIT_IF(cor == NULL,NULL,NULL);
ret =MEDequivalenceCorrespondenceRd(fid,nommaa,equ,_numdt,_numit,
MED_DESCENDING_EDGE,typare[j],cor);
EXIT_IF(ret < 0,"lors de la lecture du tableau des equivalences",
NULL);
if (!structure) {
for (k=0;k<ncor;k++)
fprintf(stdout,"\n Correspondance "IFORMAT" : "IFORMAT" et "IFORMAT" \n",k+1,*(cor+2*k),
*(cor+2*k+1));
}
free(cor);
}
}
}
}
return;
}
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 */
lecture_equivalence_maillage(fid,maa,nequ);
/* Fermeture du fichier */
if (MEDfileClose(fid) < 0) {
MESSAGE("Erreur a la fermeture du fichier ");
return -1;
}
return ret;
}
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_N_NODE_FIXED_GEO
#define MED_N_NODE_FIXED_GEO
Definition build.python3.12/include/med.h:251
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_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
EXIT_IF
#define EXIT_IF(expression, message, arg)
Definition build.python3.12/include/med_utils.h:343
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
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
MEDequivalenceComputingStepInfo
MEDC_EXPORT med_err MEDequivalenceComputingStepInfo(const med_idt fid, const char *const meshname, const char *const equivname, const int csit, med_int *const numdt, med_int *const numit, med_int *const ncorrespondence)
Cette routine permet de lire les informations relatives à une équivalence pour une étape de calcul do...
Definition MEDequivalenceComputingStepInfo.c:40
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
structure
int structure
Definition mdump2.c:112
nomare
const char *const * nomare
Definition test13b.c:44
nomfac
const char *const * nomfac
Definition test13b.c:43
typmai
const med_geometry_type *const typmai
Definition test13b.c:38
main
int main(int argc, char **argv)
Definition test13b.c:216
typfac
const med_geometry_type *const typfac
Definition test13b.c:39
typare
const med_geometry_type *const typare
Definition test13b.c:40
lecture_equivalence_maillage
void lecture_equivalence_maillage(med_idt fid, const char *const nommaa, med_int nequ)
Definition test13b.c:46
nommai
const char *const * nommai
Definition test13b.c:42