MED fichier

Concepts et fonctionnalités avancés sur les champs de résultat

Créer et lire des champs avec gestion des profils

Lire des champs créés avec MED 2.x et définis sur plusieurs maillages

Créer et lire un champ aux points d'intégration des éléments

Créer et lire un champ aux noeuds des éléments

Créer et lire un champ lié à un maillage contenant des éléments de structure

Ecrire et lire un maillage ou un champ en filtrant les données

Ecriture et lecture en parallèle dans un seul fichier

### Créer et lire des champs avec gestion des profils

Au même titre que pour un maillage évolutif, il est possible d'utiliser les profils pour sélectionner les valeurs des champs de résultats. Les champs ne peuvent être definis que sur une partie du maillage. Le profil d'un champ indique sur quelles entités du maillage se trouvent les valeurs.

A l'écriture des champs, l'utilisation des profils est possible pour l'écriture des valeurs du champ avec les routines MEDfieldValueWithProfileWr / mfdrpw, mfdipw.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Field use case 7 : write a field with computing steps and profiles
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid;
const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh";
const char fieldname[MED_NAME_SIZE+1] = "TEMPERATURE_FIELD";
const med_int ncomponent = 1;
const char componentname[MED_SNAME_SIZE+1] = "TEMPERATURE";
const char componentunit[MED_SNAME_SIZE+1] = "C";
const med_float tria3values_step1_profile1[3] = {1000., 4000., 8000.};
const med_float tria3values_step2_profile1[8] = {1500., 0., 0., 4500., 0., 0., 0., 8500.};
const med_float tria3values_step2_profile2[8] = { 0., 2500., 3500., 0., 5500., 6500., 7500., 0.};
const med_float quad4values_step1[4] = {10000., 20000., 30000., 40000.};
const med_float quad4values_step2[4] = {15000., 25000., 35000., 45000.};
const char profile1name[MED_NAME_SIZE+1] = "MED_TRIA3_PROFILE1";
const med_int profile1[3] = {1, 4, 8};
const med_int profile1size = 3;
const char profile2name[MED_NAME_SIZE+1] = "MED_TRIA3_PROFILE2";
const med_int profile2[5] = {2, 3, 5, 6, 7};
const med_int profile2size = 5;
const med_int ntria3 = 8;
const med_int nquad4 = 4;
int ret=-1;
/* file creation */
fid = MEDfileOpen("UsesCase_MEDfield_7.med",MED_ACC_CREAT);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* create mesh link */
if (MEDlinkWr(fid,meshname,"./UsesCase_MEDmesh_1.med") < 0) {
MESSAGE("ERROR : create mesh link ...");
goto ERROR;
}
/* create the profiles in the file */
if (MEDprofileWr(fid, profile1name, profile1size, profile1 ) < 0) {
MESSAGE("ERROR : create profile ...");
goto ERROR;
}
if (MEDprofileWr(fid, profile2name, profile2size, profile2 ) < 0) {
MESSAGE("ERROR : create profile ...");
goto ERROR;
}
/* field creation : temperature field : 1 component in celsius degree
* the mesh is the 2D unstructured mesh of UsecaseMEDmesh_1.c
* use case.
* Computation step unit in 'ms'
*/
if (MEDfieldCr(fid, fieldname, MED_FLOAT64, ncomponent,
componentname, componentunit,"ms", meshname) < 0) {
MESSAGE("ERROR : create field");
goto ERROR;
}
/* two computation steps */
/* write values at cell centers : 8 MED_TRIA3 and 4 MED_QUAD4 */
/* STEP 1 : dt1 = 5.5, it = 1*/
/* MED_TRIA3 : with a profile of 3 values in compact memory storage mode */
if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_CELL,MED_TRIA3,
MED_COMPACT_STMODE, profile1name, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, ntria3,
(unsigned char*) tria3values_step1_profile1) < 0) {
MESSAGE("ERROR : write field values on MED_TRIA3");
goto ERROR;
}
/* MED_QUAD4 : with no profile */
if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_CELL, MED_QUAD4,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, nquad4,
(unsigned char*) quad4values_step1) < 0) {
MESSAGE("ERROR : write field values on MED_QUAD4 ");
goto ERROR;
}
/* STEP 2 : dt2 = 8.9, it = 1*/
/* MED_TRIA3 : with a profile of 3 values then a profile of 5 values in global memory storage mode */
if (MEDfieldValueWithProfileWr(fid, fieldname, 2 , 1 , 8.9 , MED_CELL, MED_TRIA3,
MED_GLOBAL_STMODE, profile1name, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, ntria3,
(unsigned char*) tria3values_step2_profile1) < 0) {
MESSAGE("ERROR : write field values on MED_TRIA3 ...");
goto ERROR;
}
if (MEDfieldValueWithProfileWr(fid, fieldname, 2 , 1 , 8.9 , MED_CELL, MED_TRIA3,
MED_GLOBAL_STMODE, profile2name, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, ntria3,
(unsigned char*) tria3values_step2_profile2) < 0) {
MESSAGE("ERROR : write field values on MED_TRIA3 ...");
goto ERROR;
}
/* MED_QUAD4 : with no profile */
if (MEDfieldValueWithProfileWr(fid, fieldname, 2, 1, 8.9, MED_CELL, MED_QUAD4,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, nquad4,
(unsigned char*) quad4values_step2) < 0) {
MESSAGE("ERROR : write field values on MED_QUAD4 ... ");
goto ERROR;
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

A la lecture, la routine MEDfieldnProfile / mfdnpf permet de lire le nombre de profil dans un champ pour une séquence de calcul donnée. La routine MEDfieldnValueWithProfile / mfdnvp permet de lire le nombre de valeurs à lire en tenant compte du profil et mode de stockage des données en mémoire (MED_GLOBAL_STMODE ou MED_COMPACT_STMODE). Les routines MEDfieldValueWithProfileRd / mfdrpr, mfdipr permettent de lire les valeurs du champ avec ou sans profil.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
/*
* Field use case 9 : read a field with computing steps and profiles (generic approach)
*/
int main (int argc, char **argv) {
med_idt fid;
med_idt nfield, i, j;
char meshname[MED_NAME_SIZE+1]="";
med_bool localmesh;
char fieldname[MED_NAME_SIZE+1]="";
med_field_type fieldtype;
char *componentname = NULL;
char *componentunit = NULL;
char dtunit[MED_SNAME_SIZE+1]="";
med_float *values = NULL;
med_int nstep, nvalues;
med_int ncomponent;
med_int csit, numit, numdt, it;
med_float dt;
med_geometry_type geotype;
med_geometry_type *geotypes = MED_GET_CELL_GEOMETRY_TYPE;
med_int nprofile, pit, profilesize;
char profilename[MED_NAME_SIZE+1]="";
med_int nintegrationpoint;
char localizationname[MED_NAME_SIZE+1]="";
int ret=-1;
/* open file */
fid = MEDfileOpen("UsesCase_MEDfield_7.med",MED_ACC_RDONLY);
if (fid < 0) {
MESSAGE("ERROR : open file ...");
return -1;
}
/*
* generic approach : how many fields in the file and identification
* of each field.
*/
if ((nfield = MEDnField(fid)) < 0) {
MESSAGE("ERROR : How many fields in the file ...");
return -1;
}
/*
* read values for each field
*/
for (i=0; i<nfield; i++) {
if ((ncomponent = MEDfieldnComponent(fid,i+1)) < 0) {
MESSAGE("ERROR : number of field component ...");
return -1;
}
if ((componentname = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if ((componentunit = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if (MEDfieldInfo(fid, i+1, fieldname, meshname, &localmesh, &fieldtype,
componentname, componentunit, dtunit, &nstep) < 0) {
MESSAGE("ERROR : Field info ...");
free(componentname);
free(componentunit);
return -1;
}
free(componentname);
free(componentunit);
/*
* Read field values for each computing step
*/
for (csit=0; csit<nstep; csit++) {
if (MEDfieldComputingStepInfo(fid, fieldname, csit+1, &numdt, &numit, &dt) < 0) {
MESSAGE("ERROR : Computing step info ...");
return -1;
}
/*
* ... In our case, we suppose that the field values are only defined on cells ...
*/
for (it=1; it<=MED_N_CELL_FIXED_GEO; it++) {
geotype = geotypes[it];
/*
* How many profile for each geometry type ?
*/
if ((nprofile = MEDfieldnProfile(fid, fieldname, numdt, numit, MED_CELL, geotype,
profilename, localizationname)) < 0) {
MESSAGE("ERROR : read number of profile ");
return -1;
}
/*
* Read values for each profile
* We suppose that we have no localization name
*/
for (pit=0; pit<nprofile; pit++) {
if ((nvalues = MEDfieldnValueWithProfile(fid, fieldname, numdt, numit, MED_CELL, geotype,
pit+1, MED_COMPACT_STMODE, profilename, &profilesize,
localizationname, &nintegrationpoint)) < 0) {
MESSAGE("ERROR : read number of values with a profile ...");
return -1;
}
if (nvalues) {
if ((values = (med_float *) malloc(sizeof(med_float)*nvalues*ncomponent)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if (MEDfieldValueWithProfileRd(fid, fieldname, numdt, numit, MED_CELL, geotype,
MED_COMPACT_STMODE, profilename,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT, (unsigned char*)values) < 0) {
MESSAGE("ERROR : read fields values for cells ...");
free(values);
return -1;
}
free(values);
}
}
}
}
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

### Lire des champs créés avec MED 2.x et définis sur plusieurs maillages

Dans MED 2.x, les champs pouvaient être définis sur plusieurs maillages. Cette possibilité disparaît avec MED 3.0 et l'apparition des maillages évolutifs. MED 3.0 fournit néanmoins des routines permettant la lecture de fichier MED 2.x pouvant contenir des champs définis sur plusieurs maillages. Ces routines spécifiques sont à utiliser en lieu et place de celles utilisées dans le cas d'utilisation précédent (ces routines peuvent évidemment également lire des champs dans des fichiers MED 3.0), il s'agit de MEDfield23ComputingStepMeshInfo / mfdoci, MEDfield23nValueWithProfile / mfdonv, MEDfield23ValueWithProfileRd / mfdorr, mfdoir.

Le cas d'utilisation suivant propose une approche générique pour lire les champs d'un fichier MED, basés sur un ou plusieurs maillages.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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 : test11b.c
*
* - Description : lecture de champs de resultats MED (API23)
*
*****************************************************************************/
#include <med.h>
#define MESGERR 1
#include "med_utils.h"
#include <string.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
#ifndef USER_INTERLACE
#define USER_INTERLACE MED_FULL_INTERLACE
#endif
#define USER_MODE MED_COMPACT_STMODE
med_err getFieldsOn(med_idt fid, char * nomcha, med_field_type typcha, med_int ncomp,
med_entity_type entite, med_switch_mode stockage, med_int ncstp);
int main (int argc, char **argv)
{
med_err ret,lret;
med_idt fid;
char * fichier = NULL;
char maa[MED_NAME_SIZE+1]="";
char desc[MED_COMMENT_SIZE+1]="";
char pflname[MED_NAME_SIZE+1]="",nomlien[MED_NAME_SIZE+1]="";
char _meshname [MED_NAME_SIZE+1]="";
char _dtunit [MED_SNAME_SIZE+1]="";
char locname[MED_NAME_SIZE+1]="";
char * lien = NULL;
char *comp= NULL, *unit= NULL;
char nomcha [MED_NAME_SIZE+1]="";
med_int mdim=0,sdim=0,ncomp,ncha,npro,nln,pflsize,*pflval,nval;
med_int _ncstp=0,ngauss=0,nloc=0,locsdim=0,lnsize=0;
int t1,t2,t3;
med_field_type typcha;
med_geometry_type type_geo;
med_float *refcoo, *gscoo, *wg;
int i,j;
med_bool _local;
char dtunit[MED_SNAME_SIZE+1]="";
char nomcoo[3*MED_SNAME_SIZE+1]="";
char unicoo[3*MED_SNAME_SIZE+1]="";
char geointerpname[MED_NAME_SIZE+1]="";
char ipointstructmeshname[MED_NAME_SIZE+1]="";
med_mesh_type type;
med_sorting_type sort;
med_int nstep=0;
med_axis_type rep;
med_int nsectionmeshcell;
med_geometry_type sectiongeotype;
if (argc != 2) {
MESSAGE("Aucun nom de fichier precise, fichier test10.med utilise ");
fichier = "test10.med";
} else {
fichier = argv[1];
};
/* Ouverture du fichier med */
if ((fid = MEDfileOpen(fichier,MED_ACC_RDONLY)) < 0){
MESSAGE("Erreur a l'ouverture du fichier : ");SSCRUTE(fichier);
return -1;
}
ret = 0;
/* 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);
}
/* combien de champs dans le fichier */
if ((ncha = MEDnField(fid)) < 0) {
MESSAGE("Impossible de lire le nombre de champs : ");ISCRUTE(ncha);
return ncha;
}
printf("Nombre de champs : "IFORMAT" \n",ncha);
/* lecture de tous les champs */
for (i =0;i<ncha;i++) {
lret = 0;
printf("\nChamp numero : %d \n",i+1);
/* Lecture du nombre de composantes */
if ((ncomp = MEDfieldnComponent(fid,i+1)) < 0) {
MESSAGE("Erreur a la lecture du nombre de composantes : "); ISCRUTE(ncomp);
ret = -1; continue;
}
/* Lecture du type du champ, des noms des composantes et du nom de l'unite*/
comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
EXIT_IF(comp == NULL,NULL,NULL);
unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
EXIT_IF(unit == NULL,NULL,NULL);
if ( MEDfieldInfo(fid,i+1,nomcha,_meshname,&_local,&typcha,comp,unit,_dtunit,&_ncstp) < 0 ) {
MESSAGE("Erreur a la demande d'information sur les champs : ");
ISCRUTE_int(i+1);SSCRUTE(nomcha);ISCRUTE_int(typcha);SSCRUTE(comp);SSCRUTE(unit);
ISCRUTE(ncomp);
ret = -1; continue;
}
printf("Nom du champ : |%s| de type %d\n",nomcha,typcha);
printf("Nom des composantes : |%s|\n",comp);
printf("Unites des composantes : |%s| \n",unit);
printf("Unites des dates : |%s| \n",_dtunit);
printf("Le maillage associé est |%s|\n",_meshname);
printf("Nombre d'étapes de calcul |"IFORMAT"|\n",_ncstp);
/* Le maillage reference est-il porte par un autre fichier */
if ( !_local ) {
if ( (lnsize=MEDlinkInfoByName(fid,_meshname) ) < 0 ) {
MESSAGE("Erreur a la lecture de la taille du lien : ");
SSCRUTE(_meshname);
ret = -1;
} else {
lien = malloc((lnsize+1)*sizeof(char));
EXIT_IF(lien == NULL,NULL,NULL);
if ( MEDlinkRd(fid,_meshname, lien) < 0 ) {
MESSAGE("Erreur a la lecture du lien : ");
SSCRUTE(_meshname);SSCRUTE(lien);
ret = -1;
} else {
printf("\tLe maillage |%s| est porte par un fichier distant |%s|\n",_meshname,lien);
}
free(lien);
}
}
free(comp);
free(unit);
lret = getFieldsOn(fid, nomcha, typcha, ncomp, MED_NODE, USER_INTERLACE,_ncstp );
if (lret == 0) lret = getFieldsOn(fid, nomcha, typcha, ncomp, MED_CELL, USER_INTERLACE,_ncstp );
else { MESSAGE("Erreur a la lecture des champs aux noeuds "); ret = -1; continue;}
if (lret == 0) lret = getFieldsOn(fid, nomcha, typcha, ncomp, MED_DESCENDING_FACE,USER_INTERLACE,_ncstp);
else { MESSAGE("Erreur a la lecture des champs aux mailles "); ret = -1; continue;}
if (lret == 0) lret = getFieldsOn(fid, nomcha, typcha, ncomp, MED_DESCENDING_EDGE,USER_INTERLACE,_ncstp);
else {MESSAGE("Erreur a la lecture des champs aux faces "); ret = -1; continue;}
if (lret == 0) lret = getFieldsOn(fid, nomcha, typcha, ncomp, MED_NODE_ELEMENT,USER_INTERLACE,_ncstp);
else {MESSAGE("Erreur a la lecture des champs aux aretes"); ret = -1; continue;}
/*TODO */
/* if (lret == 0) lret = getFieldsOn(fid, nomcha, typcha, ncomp, MED_STRUCT_ELEMENT,USER_INTERLACE,_ncstp); */
/* else {MESSAGE("Erreur a la lecture des champs aux éléments de structure"); ret = -1; continue;} */
if (lret != 0) {MESSAGE("Erreur a la lecture des champs aux noeuds des mailles "); ret = -1;};
}
/* Interrogation des profils */
npro = MEDnProfile(fid);
printf("\nNombre de profils stockes : "IFORMAT"\n\n",npro);
for (i=1 ; i <= npro ; i++ ) {
if ( MEDprofileInfo(fid, i, pflname, &nval) < 0) {
MESSAGE("Erreur a la demande d'information sur le profil n° : "); ISCRUTE_int(i);
ret = -1;continue;
}
printf("\t- Profil n°%i de nom |%s| et de taille "IFORMAT"\n",i,pflname,nval);
pflval = (med_int*) malloc(sizeof(med_int)*nval);
if ( MEDprofileRd(fid, pflname, pflval) < 0) {
MESSAGE("Erreur a la lecture des valeurs du profil : ");
SSCRUTE(pflname);
ret = -1;
} else {
printf("\t");
for (j=0;j<nval;j++) printf(" "IFORMAT" ",*(pflval+j));
printf("\n\n");
}
free(pflval);
}
/* Interrogation des liens */
nln = MEDnLink(fid);
printf("\nNombre de liens stockes : "IFORMAT"\n\n",nln);
for (i=1 ; i <= nln ; i++ ) {
if ( MEDlinkInfo(fid, i, nomlien, &nval) < 0) {
MESSAGE("Erreur a la demande d'information sur le lien n° : "); ISCRUTE_int(i);
ret = -1;continue;
}
printf("\t- Lien n°%i de nom |%s| et de taille "IFORMAT"\n",i,nomlien,nval);
lien = (char * ) malloc((nval+1)*sizeof(char));
EXIT_IF(lien == NULL,NULL,NULL);
if ( MEDlinkRd(fid, nomlien, lien ) < 0 ) {
MESSAGE("Erreur a la lecture du lien : ");
SSCRUTE(nomlien);SSCRUTE(lien);
ret = -1;
} else {
lien[nval] = '\0';
printf("\t\t|%s|\n\n",lien);
}
free(lien);
}
/* Interrogation des localisations des points de GAUSS */
nloc = MEDnLocalization(fid);
printf("\nNombre de localisations stockees : "IFORMAT"\n\n",nloc);
for (i=1 ; i <= nloc ; i++ ) {
if ( MEDlocalizationInfo(fid, i, locname, &type_geo, &locsdim,&ngauss,
geointerpname, ipointstructmeshname,&nsectionmeshcell,
&sectiongeotype) < 0) {
MESSAGE("Erreur a la demande d'information sur la localisation n° : "); ISCRUTE_int(i);
ret = -1;continue;
}
printf("\t- Loc. n°%i de nom |%s| de dimension "IFORMAT" avec "IFORMAT" pts de GAUSS \n",i,locname,locsdim,ngauss);
t1 = (type_geo%100)*(type_geo/100);
t2 = ngauss*(type_geo/100);
t3 = ngauss;
refcoo = (med_float *) malloc(sizeof(med_float)*t1 );
gscoo = (med_float *) malloc(sizeof(med_float)*t2 );
wg = (med_float *) malloc(sizeof(med_float)*t3 );
if ( MEDlocalizationRd(fid, locname, USER_INTERLACE, refcoo, gscoo, wg ) < 0) {
MESSAGE("Erreur a la lecture des valeurs de la localisation : ");
SSCRUTE(locname);
ret = -1;
} else {
printf("\t Coordonnees de l'element de reference de type %i :\n\t\t",type_geo);
for (j=0;j<t1;j++) printf(" %f ",*(refcoo+j));
printf("\n");
printf("\t Localisation des points de GAUSS : \n\t\t");
for (j=0;j<t2;j++) printf(" %f ",*(gscoo+j));
printf("\n");
printf("\t Poids associes aux points de GAUSS :\n\t\t");
for (j=0;j<t3;j++) printf(" %f ",*(wg+j));
printf("\n\n");
}
free(refcoo);
free(gscoo);
free(wg);
}
/* fermeture du fichier */
if ( MEDfileClose(fid) < 0) return -1;
return ret;
}
med_err getFieldsOn(med_idt fid, char * nomcha, med_field_type typcha, med_int ncomp,
med_entity_type entite, med_switch_mode stockage, med_int ncstp) {
int i,j,k,l,m,n,nb_geo=0;
med_int nbpdtnor=0,pflsize,*pflval,ngauss=0,ngroup,*vale=NULL,nval;
med_int numdt=0,numo=0,_nprofile;
med_int meshnumdt=0,meshnumit=0;
med_float *valr=NULL,dt=0.0;
med_err ret=0;
char pflname [MED_NAME_SIZE+1]="";
char locname [MED_NAME_SIZE+1]="";
char meshname [MED_NAME_SIZE+1]="";
char * lien = NULL;
char dt_unit [MED_SNAME_SIZE+1]="unknown";
med_bool localmesh;
med_int nmesh=0;
med_geometry_type * type_geo;
const char * const * AFF;
const char * const * AFF_ENT=MED_GET_ENTITY_TYPENAME+1;
switch (entite) {
case MED_NODE :
type_geo = MED_GET_NODE_GEOMETRY_TYPE;
nb_geo = MED_N_NODE_FIXED_GEO;
AFF = MED_GET_NODE_GEOMETRY_TYPENAME;
break;
case MED_CELL :
case MED_NODE_ELEMENT :
type_geo = MED_GET_CELL_GEOMETRY_TYPE;
nb_geo = MED_N_CELL_FIXED_GEO;
AFF = MED_GET_CELL_GEOMETRY_TYPENAME;
break;
case MED_DESCENDING_FACE :
type_geo = MED_GET_FACE_GEOMETRY_TYPE;
nb_geo = MED_N_FACE_FIXED_GEO;
AFF = MED_GET_FACE_GEOMETRY_TYPENAME;
break;
case MED_DESCENDING_EDGE :
type_geo = MED_GET_EDGE_GEOMETRY_TYPE;
nb_geo = MED_N_EDGE_FIXED_GEO;
AFF = MED_GET_EDGE_GEOMETRY_TYPENAME;
break;
}
for (k=1;k<=nb_geo;k++) {
/* Combien de (PDT,NOR) a lire */
nbpdtnor = ncstp;
if (nbpdtnor < 1 ) continue;
for (j=0;j<nbpdtnor;j++) {
if ( MEDfield23ComputingStepMeshInfo(fid,nomcha,j+1, &numdt, &numo, &dt,
&nmesh, meshname,&localmesh, &meshnumdt, &meshnumit ) <0) {
MESSAGE("Erreur a la demande d'information sur (pdt,nor) : ");
ISCRUTE(numdt); ISCRUTE(numo);ISCRUTE(nmesh);SSCRUTE(meshname);ISCRUTE_int(localmesh);
ISCRUTE(meshnumdt);ISCRUTE(meshnumit);
ret = -1; continue;
}
for (i=0;i< nmesh;++i) {
if ( (_nprofile = MEDfield23nProfile(fid,nomcha,numdt,numo,entite,type_geo[k],i+1,meshname,
pflname,locname ) ) < 0 ) {
MESSAGE("Erreur a la demande du nombre de profils referencés par le champ : ");
SSCRUTE(nomcha); ISCRUTE(numdt); ISCRUTE(numo);SSCRUTE(meshname);
ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);SSCRUTE(pflname);SSCRUTE(locname);
SSCRUTE(AFF_ENT[(int)entite]);SSCRUTE(AFF[k]);
ret = -1; continue;
};
for (l=0;l<_nprofile;l++) {
if ( (nval = MEDfield23nValueWithProfile(fid, nomcha, numdt, numo, entite, type_geo[k],meshname,
l+1, USER_MODE, pflname,&pflsize,
locname, &ngauss) ) < 0 ) {
MESSAGE("Erreur a la lecture du nombre de valeurs du champ : ");
SSCRUTE(nomcha);ISCRUTE(numdt);ISCRUTE(numo);SSCRUTE(meshname);
ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
ISCRUTE_int(USER_MODE);
ret = -1; continue;
};
printf("\n +Pas de Temps n."IFORMAT" (%f) [%s], n. d'ordre "IFORMAT", avec "IFORMAT" valeur(s) par entité.\n",numdt,dt,dt_unit,numo,ngauss);
printf("\t- Il y a "IFORMAT" entités qui portent des valeurs en mode %i. Chaque entite %s\
de type geometrique %s associes au profile |%s| a "IFORMAT" valeurs associées \n",
nval,USER_MODE,AFF_ENT[(int)entite],AFF[k],pflname,ngauss);
printf("\t- Le maillage associé est |%s|\n",meshname);
/*Lecture des valeurs du champ */
if (typcha == MED_FLOAT64) {
valr = (med_float*) calloc(ncomp*nval*ngauss,sizeof(med_float));
EXIT_IF(valr == NULL,NULL,NULL);
if (MEDfield23ValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],meshname,
USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
(unsigned char*) valr) < 0 ) {
MESSAGE("Erreur a la lecture des valeurs du champ : ");
SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
ISCRUTE(numdt);ISCRUTE(numo);
ret = -1;
}
} else {
vale = (med_int*) calloc(ncomp*nval*ngauss,sizeof(med_int));
EXIT_IF(vale == NULL,NULL,NULL);
if (MEDfield23ValueWithProfileRd(fid, nomcha, numdt,numo, entite,type_geo[k],meshname,
USER_MODE, pflname, stockage,MED_ALL_CONSTITUENT,
(unsigned char*) vale) < 0 ) {
MESSAGE("Erreur a la lecture des valeurs du champ : ");
SSCRUTE(nomcha);ISCRUTE_int(entite);ISCRUTE_int(type_geo[k]);
ISCRUTE(numdt);ISCRUTE(numo);
ret = -1;
};
}
if ( strlen(locname) )
printf("\t- Modèle de localisation des points de Gauss de nom |%s|\n",locname);
if (entite == MED_NODE_ELEMENT)
ngroup = (type_geo[k] % 100);
else
ngroup = ngauss;
switch (stockage) {
case MED_FULL_INTERLACE :
printf("\t- Valeurs :\n\t");
for (m=0;m<(nval*ngauss)/ngroup;m++) {
printf("|");
for (n=0;n<ngroup*ncomp;n++)
if (typcha == MED_FLOAT64)
printf(" %f ",*(valr+(m*ngroup*ncomp)+n));
else
printf(" "IFORMAT" ",*(vale+(m*ngroup*ncomp)+n));
}
break;
/*Affichage en fonction du profil à traiter*/
case MED_NO_INTERLACE :
printf("\t- Valeurs :\n\t");
for (m=0;m<ncomp;m++) {
printf("|");
for (n=0;n<(nval*ngauss);n++)
if (typcha == MED_FLOAT64)
printf(" %f ",*(valr+(m*nval)+n));
else
printf(" "IFORMAT" ",*(vale+(m*nval)+n));
}
break;
}
printf("|\n");
if (typcha == MED_FLOAT64) {
if ( valr ) {free(valr);valr = NULL;}}
else
if (vale) { free(vale);vale = NULL; }
/*Lecture du profil associe */
if (strcmp(pflname,MED_NO_PROFILE) == 0 )
printf("\t- Profil : MED_NO_PROFILE\n");
else {
if ( (pflsize = MEDprofileSizeByName(fid,pflname)) <0 ) {
MESSAGE("Erreur a la lecture du nombre de valeurs du profil : ");
SSCRUTE(pflname);
ret = -1; continue;
}
printf("\t- Profil : |%s| de taille "IFORMAT"\n",pflname,pflsize);
pflval = (med_int*) malloc(sizeof(med_int)*pflsize);
EXIT_IF(pflval == NULL,NULL,NULL);
if ( MEDprofileRd(fid,pflname,pflval) <0) {
MESSAGE("Erreur a la lecture des valeurs du profil : ");
SSCRUTE(pflname);
ret = -1;
}
printf("\t");
for (m=0;m<pflsize;m++) printf(" "IFORMAT" ",*(pflval+m));
printf("\n");
free(pflval);
}
}
}
}
} /* fin for sur les mailles*/
return ret;
}

### Créer et lire un champ aux points d'intégration des éléments

MED fournit la possibilité d'exprimer les champs de résultat sur les points de Gauss (ou points d'intégration) des éléments d'un maillage. Dans ce cadre, il est possible de localiser ces points sur des éléments de référence en des lieux différents selon la modélisation numérique choisie. Pour chaque type de modélisation, il est possible de spécifier cette localisation sur des éléments de référence. On distingue différentes familles de points de Gauss en fonction du nombre de points d'intégration. Chaque point d'intégration est localisé au sein d'un élément de référence par ses coordonnées et se voit associer un poids.

La localisation des points de Gauss pour un élément de référence nécessite donc de connaître le type géométrique de l'élément, les coordonnées des noeuds de l'élément, les coordonnées et le poids de chaque point de Gauss. L'expression des coordonnées d'un élément de référence peut se faire dans un repère de coordonnées dont la dimension est supérieure à celle de l'élément de référence. La référence à un élément de référence se fait à l'appel des routines d'écriture et lecture des valeurs des champs.

Si les points de Gauss se confondent avec les noeuds de l'élément, il est inutile de créer une localisation factice avec des poids qui ne signifient rien et des coordonnées des points de Gauss identiques à celles des noeuds. Dans ce cas de figure, il faut utiliser le mot clé réservé MED_GAUSS_ELNO à l'écriture des valeurs d'un champ pour indiquer le type de localisation.

Il est possible pour une même type géométrique d'élément d'associer plusieurs éléments de référence. Il suffit pour cela d'associer chaque localisation avec un profil lors de l'appel d'écriture et lecture des valeurs des champs.

MED permet également la prise en compte des fonctions de forme et des familles d'interpolation. Une famille d'interpolation est l'ensemble d'interpolations disponibles pour un champ donné. Chacune des interpolations est décrite par des fonctions de forme polynomiales. Le nombre de variable des fonctions de forme est égale à la dimension de l'espace de la maille de référence utilisée pour le construire. Il est donc possible d'associer à un champ plusieurs interpolations définies sur des mailles de référence des différents types géométriques du maillage de calcul sur lequel repose le champ de résultat.

L'écriture des fonctions de forme et des familles d'interpolation est optionnelle pour échanger des champs aux points d'intégration.

A l'écriture, la création d'un élément de référence se fait avec la routine MEDlocalizationWr / mlclow. Un élément de référence peut être associé à une famille d'interpolation. La création d'une fonction d'interpolation se fait avec la routine MEDinterpBaseFunctionWr / mipcre. L'écriture d'une fonction de forme se fait avec la routine MEDinterpBaseFunctionWr / mipbfw. La routine MEDfieldInterpWr / mfdinw permet d'associer une famille d'interpolation à un champ résultat.

Le cas d'utilisation suivant montre un exemple d'écriture des valeurs des champs aux points de Gauss avec définition des éléments de référence et référence à une famille d'interpolation.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Field use case 10 : write a field in a MED file with computing steps,
* profiles, integration points and interpolation families
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid;
const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh";
const char fieldname[MED_NAME_SIZE+1] = "TEMPERATURE_FIELD";
const med_int ncomponent = 1;
const char componentname[MED_SNAME_SIZE+1] = "TEMPERATURE";
const char componentunit[MED_SNAME_SIZE+1] = "C";
const med_float tria3values_step1_profile1[9] = {1000.,1010.,1020.,
4000.,4010.,4020.,
8000.,8010.,8020. };
const med_float tria3values_step2_profile1[24] = {1500.,1510.,1520.,
0., 0., 0.,
0., 0., 0.,
4500.,4510,4520.,
0., 0., 0.,
0., 0., 0.,
0., 0., 0.,
8500., 8510, 8520 };
const med_float tria3values_step2_profile2[32] = { 0., 0., 0., 0.,
2500.,2510.,2520,2530.,
3500.,3510.,3520.,3530.,
0., 0., 0., 0.,
5500.,5510.,5520.,5530.,
6500.,6510.,6520.,6530.,
7500.,7510.,7520.,7530.,
0., 0., 0., 0. };
const med_int ntria3 = 8;
const med_int nquad4 = 4;
const med_float quad4values_step1[4] = {10000., 20000., 30000., 40000.};
const med_float quad4values_step2[4] = {15000., 25000., 35000., 45000.};
const char profile1name[MED_NAME_SIZE+1] = "MED_TRIA3_PROFILE1";
const med_int profile1[3] = {1, 4, 8};
const med_int profile1size = 3;
const char profile2name[MED_NAME_SIZE+1] = "MED_TRIA3_PROFILE2";
const med_int profile2[5] = {2, 3, 5, 6, 7};
const med_int profile2size = 5;
const char localization1name[MED_NAME_SIZE+1] = "TRIA3_INTEGRATION_POINTS_3";
const med_float weight1[3] = {1.0/6, 1.0/6, 1.0/6};
const med_float elementcoordinate[6] = {0.0, 0.0, 1.0, 0.0, 0.0,1.0};
const med_float ipoint1coordinate[6] = {1.0/6, 1.0/6, 2.0/3, 1.0/6, 1.0/6, 2.0/6};
const char localization2name[MED_NAME_SIZE+1] = "TRIA3_INTEGRATION_POINTS_4";
const med_float weight2[6] = {25.0/(24*4), 25.0/(24*4), 25.0/(24*4), -27.0/(24*4)};
const med_float ipoint2coordinate[8] = {1.0/5, 1.0/5, 3.0/5, 1.0/5, 1.0/5, 3.0/5, 1.0/3, 1.0/3};
med_int nipoint, spacedim;
const char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
int ret=-1;
/* file creation */
fid = MEDfileOpen("UsesCase_MEDfield_10.med",MED_ACC_CREAT);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* create mesh link */
if (MEDlinkWr(fid,meshname,"./UsesCase_MEDmesh_1.med") < 0) {
MESSAGE("ERROR : create mesh link ...");
goto ERROR;
}
/* create the profiles in the file */
if (MEDprofileWr(fid, profile1name, profile1size, profile1 ) < 0) {
MESSAGE("ERROR : create profile ...");
goto ERROR;
}
if (MEDprofileWr(fid, profile2name, profile2size, profile2 ) < 0) {
MESSAGE("ERROR : create profile ...");
goto ERROR;
}
/* create the localization elements for integration points */
spacedim = 2;
nipoint = 3;
if (MEDlocalizationWr(fid, localization1name, MED_TRIA3, spacedim,
elementcoordinate, MED_FULL_INTERLACE,
nipoint, ipoint1coordinate, weight1,
MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT) < 0) {
MESSAGE("ERROR : create famlily of integration points ...");
goto ERROR;
}
spacedim = 2;
nipoint = 4;
if (MEDlocalizationWr(fid, localization2name, MED_TRIA3, spacedim,
elementcoordinate, MED_FULL_INTERLACE,
nipoint, ipoint2coordinate, weight2,
MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT) < 0) {
MESSAGE("ERROR : create famlily of integration points ...");
goto ERROR;
}
/*
* Temperature field creation :
* - 1 component
* - component unit : celsius degree
* - mesh is the 2D unstructured mesh of UsecaseMEDmesh_1.c use case.
* - computation step unit in 'ms'
*/
if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
ncomponent, componentname, componentunit,
"ms", meshname) < 0) {
MESSAGE("ERROR : create field");
goto ERROR;
}
/* write interpolation family name for MED_TRIA3 cell type */
/* The interpolation family "interpname" is created in the UsesCase_MEDinterp_1
use case */
if (MEDfieldInterpWr(fid,fieldname,interpname) <0) {
MESSAGE("ERROR : write field interpolation family name ...");
goto ERROR;
}
/* two computation steps */
/* write values at cell centers : 8 MED_TRIA3 and 4 MED_QUAD4 */
/* STEP 1 : dt1 = 5.5, it = 1*/
/* MED_TRIA3 : with a profile of 3 values in compact memory storage mode
and a family of 3 integration points */
if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_CELL,MED_TRIA3,
MED_COMPACT_STMODE, profile1name, localization1name,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
ntria3, (unsigned char*) tria3values_step1_profile1) < 0) {
MESSAGE("ERROR : write field values on MED_TRIA3");
goto ERROR;
}
/* MED_QUAD4 : with no profile */
if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_CELL, MED_QUAD4,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
nquad4, (unsigned char*) quad4values_step1) < 0) {
MESSAGE("ERROR : write field values on MED_QUAD4 ");
goto ERROR;
}
/* STEP 2 : dt2 = 8.9, it = 1*/
/* MED_TRIA3 : with a profile of 3 values then a profile of 5 values in global memory storage mode
* For each profile, a family of 3 and then 4 integration points */
if (MEDfieldValueWithProfileWr(fid, fieldname, 2 , 1 , 8.9 , MED_CELL, MED_TRIA3,
MED_GLOBAL_STMODE, profile1name, localization1name,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
ntria3, (unsigned char*) tria3values_step2_profile1) < 0) {
MESSAGE("ERROR : write field values on MED_TRIA3 ...");
goto ERROR;
}
if (MEDfieldValueWithProfileWr(fid, fieldname, 2 , 1 , 8.9 , MED_CELL, MED_TRIA3,
MED_GLOBAL_STMODE, profile2name, localization2name,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
ntria3, (unsigned char*) tria3values_step2_profile2) < 0) {
MESSAGE("ERROR : write field values on MED_TRIA3 ...");
goto ERROR;
}
/* MED_QUAD4 : with no profile */
if (MEDfieldValueWithProfileWr(fid, fieldname, 2, 1, 8.9, MED_CELL, MED_QUAD4,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
nquad4, (unsigned char*) quad4values_step2) < 0) {
MESSAGE("ERROR : write field values on MED_QUAD4 ... ");
goto ERROR;
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

A la lecture, la routine MEDlocalizationInfoByName / mlclni permet de lire les informations relatives à un élément de référence dont on connaît le nom. Une autre possibilité est de lire le nombre d'élément de référence avec la routine MEDnLocalization / mlcnlc et d'itérer afin de récupérer à chaque itération les informations relatives à l'élément de référence avec la routine MEDlocalizationInfo / mlclci et lire l'élément de référence avec la routine MEDlocalizationRd / mlclor.

Pour les fonctions d'interpolation, la routine MEDinterpInfoByName / mipiin informe des caractéristiques de la fonction d'interpolation dont on connaît le nom. Il est également possible de lire le nombre de famille d'interpolation avec la routine MEDnInterp / mipnip et d'itérer sur ces familles. Ces deux fonctions renvoie le nombre de fonctions de forme. Il reste donc à itérer sur chacune d'entre elles et d'appeler la routine MEDinterpBaseFunctionRd / mipbfr pour lire chaque polynôme.

Dans un champ de résultat, il est possible de lire le nombre de famille d'interpolation associé aux champ avec la routine MEDfieldnInterp / mfdnin . En itérant sur toutes ces familles, on peut lire le nom de chacune d'entre elles avec la routine MEDfieldInterpInfo / mfdini.

Le cas d'utilisation suivant propose une approche générique pour lire des champs aux points de Gauss définies sur les mailles d'un maillage.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
/*
* Field use case 12 : read a field (generic approach) in a MED file with computing steps,
* profiles, integration points and interpolation families
*/
int main (int argc, char **argv) {
med_idt fid;
med_idt nfield, i, j;
char meshname[MED_NAME_SIZE+1]="";
med_bool localmesh;
char fieldname[MED_NAME_SIZE+1]="";
med_field_type fieldtype;
char *componentname = NULL;
char *componentunit = NULL;
char dtunit[MED_SNAME_SIZE+1]="";
med_float *values = NULL;
med_int nstep, nvalues;
med_int ncomponent;
med_int csit, numit, numdt, it;
med_float dt;
med_geometry_type geotype;
med_geometry_type *geotypes = MED_GET_CELL_GEOMETRY_TYPE;
med_int nprofile, pit, profilesize;
char profilename[MED_NAME_SIZE+1]="";
med_int nintegrationpoint;
char localizationname[MED_NAME_SIZE+1]="";
int k;
med_int ninterp;
char interpname[MED_NAME_SIZE+1];
int ret=-1;
/* open file */
fid = MEDfileOpen("UsesCase_MEDfield_10.med",MED_ACC_RDONLY);
if (fid < 0) {
MESSAGE("ERROR : open file ...");
return -1;
}
/*
* generic approach : how many fields in the file and identification
* of each field.
*/
if ((nfield = MEDnField(fid)) < 0) {
MESSAGE("ERROR : How many fields in the file ...");
return -1;
}
/*
* read values for each field
*/
for (i=0; i<nfield; i++) {
if ((ncomponent = MEDfieldnComponent(fid,i+1)) < 0) {
MESSAGE("ERROR : number of field component ...");
return -1;
}
if ((componentname = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if ((componentunit = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if (MEDfieldInfo(fid, i+1, fieldname, meshname, &localmesh, &fieldtype,
componentname, componentunit, dtunit, &nstep) < 0) {
MESSAGE("ERROR : Field info ...");
free(componentname);
free(componentunit);
return -1;
}
free(componentname);
free(componentunit);
/*
* Read how many interpolation family name in the field ?
*/
if ((ninterp = MEDfieldnInterp(fid, fieldname)) < 0) {
MESSAGE("ERROR : Read how many interpolation functions for the field ...");
return -1;
}
/* - Read each interlolation family name
* - The way to read an interploation family and it's basis functions
* is described in UsesCase_MEDinterp_2 and UsesCase_MEDinterp_3 uses case
*/
for (it=0; it<ninterp; it++) {
if (MEDfieldInterpInfo(fid,fieldname,it+1,interpname) < 0) {
MESSAGE("ERROR : read interpolation family name ...");
return -1;
}
}
/*
* Read field values for each computing step
*/
for (csit=0; csit<nstep; csit++) {
if (MEDfieldComputingStepInfo(fid, fieldname, csit+1, &numdt, &numit, &dt) < 0) {
MESSAGE("ERROR : Computing step info ...");
return -1;
}
/*
* ... In our case, we suppose that the field values are only defined on cells ...
*/
for (it=1; it<=MED_N_CELL_FIXED_GEO; it++) {
geotype = geotypes[it];
/*
* How many profile for each geometry type ?
*/
if ((nprofile = MEDfieldnProfile(fid, fieldname, numdt, numit, MED_CELL, geotype,
profilename, localizationname)) < 0) {
MESSAGE("ERROR : read number of profile ");
return -1;
}
/*
* Read values for each profile
*/
for (pit=0; pit<nprofile; pit++) {
if ((nvalues = MEDfieldnValueWithProfile(fid, fieldname, numdt, numit, MED_CELL, geotype,
pit+1, MED_COMPACT_STMODE, profilename, &profilesize,
localizationname, &nintegrationpoint)) < 0) {
MESSAGE("ERROR : read number of values with a profile ...");
return -1;
}
if (nvalues) {
if ((values = (med_float *) malloc(sizeof(med_float)*nvalues*ncomponent*nintegrationpoint)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if (MEDfieldValueWithProfileRd(fid, fieldname, numdt, numit, MED_CELL, geotype,
MED_COMPACT_STMODE, profilename,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
(unsigned char*) values) < 0) {
MESSAGE("ERROR : read fields values for cells ...");
free(values);
return -1;
}
free(values);
}
}
}
}
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

Le cas d'utilisation suivant montre un exemple de création d'une famille d'interpolation.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Interp use case 1 : write an interpolation family
* In this example, the interpolation family can be used with
* the TEMPERATURE field of UsesCase_MEDfield_10 use case
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid;
char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
const med_int nvariable=2;
const med_int maxdegree=1;
const med_int nmaxcoefficient=3;
const med_int ncoefficient1_1 = 3;
const med_int const power1_1[] = {0,0,1,0,0,1};
const med_float const coefficient1_1[] = {1,-1,-1};
const med_int ncoefficient1_2 = 1;
const med_int const power1_2[] = {1,0};
const med_float const coefficient1_2[] = {1};
const med_int ncoefficient1_3 = 1;
const med_int const power1_3[] = {0,1};
const med_float const coefficient1_3[] = {1};
int ret=-1;
/* file creation */
fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_CREAT);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* Family interpolation creation :
- reference element = MED_TRIA3
- integration points of UsesCase_MEDfield_10 use case
are used to build the interpolation
- basis functions are P1(X)= 1-X1-X2, P2(X)= X1, P3(X)= X2
*/
if (MEDinterpCr(fid, interpname, MED_TRIA3, MED_FALSE, nvariable, maxdegree, nmaxcoefficient) < 0) {
MESSAGE("ERROR : interpolation family creation ...");
goto ERROR;
}
/* Basis functions creation */
if (MEDinterpBaseFunctionWr(fid,interpname,1,ncoefficient1_1,power1_1,coefficient1_1) < 0) {
MESSAGE("ERROR : first base function creation ...");
goto ERROR;
}
if (MEDinterpBaseFunctionWr(fid,interpname,2,ncoefficient1_2,power1_2,coefficient1_2) < 0) {
MESSAGE("ERROR : second base function creation ...");
goto ERROR;
}
if (MEDinterpBaseFunctionWr(fid,interpname,3,ncoefficient1_3,power1_3,coefficient1_3) < 0) {
MESSAGE("ERROR : third base function creation ...");
goto ERROR;
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

Le cas d'utilisation suivant montre un exemple de lecture de famille d'interpolation dont on connaît le nom.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Interp use case 2 : read an interpolation family with a direct access by name
* In this example, the interpolation family can be used with
* the TEMPERATURE field of UsesCase_MEDfield_10 use case
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid;
const char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
med_geometry_type geotype =MED_NONE;
med_bool cellnodes =MED_FALSE;
med_int nbasisfunc =0;
med_int nvariable =0;
med_int maxdegree =0;
med_int nmaxcoefficient =0;
int basisfuncit =0;
int powerit =0;
med_int ncoefficient =0;
med_int* power =NULL;
med_float* coefficient =NULL;
int coefficientit =0;
int ret=-1;
/* file creation */
fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_RDONLY);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* with direct access by the family name */
if (MEDinterpInfoByName(fid,interpname,&geotype,&cellnodes,&nbasisfunc,
&nvariable,&maxdegree,&nmaxcoefficient) < 0) {
MESSAGE("ERROR : interpolation function information ...");
goto ERROR;
}
/* read each basis function */
for ( basisfuncit=1; basisfuncit<= nbasisfunc; ++basisfuncit) {
if ((ncoefficient = MEDinterpBaseFunctionCoefSize(fid,interpname,basisfuncit) ) <0 ) {
MESSAGE("ERROR : read number of coefficient in the base function ...");
goto ERROR;
}
coefficient = (med_float*) calloc(sizeof(med_float),ncoefficient);
power = (med_int*) calloc(sizeof(med_int),nvariable*ncoefficient);
if (MEDinterpBaseFunctionRd(fid,interpname,basisfuncit,&ncoefficient,power,coefficient) < 0) {
MESSAGE("ERROR : read base function ...");
free(coefficient); free(power);
goto ERROR;
}
free(coefficient);
free(power);
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

Le cas d'utilisation suivant montre un exemple de lecture de famille d'interpolation par une approche itérative.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Interp use case 1 : read an interpolation family with a generic access by an iterator.
* In this example, the interpolation family can be used with
* the TEMPERATURE field of UsesCase_MEDfield_10 use case
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid;
char interpname[MED_NAME_SIZE+1]="";
med_int ninterp =0;
int it =0;
med_geometry_type geotype =MED_NONE;
med_bool cellnodes =MED_FALSE;
med_int nbasisfunc =0;
med_int nvariable =0;
med_int maxdegree =0;
med_int nmaxcoefficient =0;
int basisfuncit =0;
int powerit =0;
med_int ncoefficient =0;
med_int* power =NULL;
med_float* coefficient =NULL;
int coefficientit =0;
int ret=-1;
/* file creation */
fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_RDONLY);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* how many interpolation family in the file ? */
if ((ninterp = MEDnInterp(fid)) < 0) {
MESSAGE("ERROR : read number of interpolation ...");
goto ERROR;
}
/* read each interpolation family */
/* with an access by an iterator */
for (it=1; it<= ninterp; it++) {
if (MEDinterpInfo(fid,it,interpname,&geotype,&cellnodes,&nbasisfunc,
&nvariable,&maxdegree,&nmaxcoefficient) < 0) {
MESSAGE("ERROR : interpolation function information ...");
goto ERROR;
}
/* read each basis function */
for ( basisfuncit=1; basisfuncit<= nbasisfunc; ++basisfuncit) {
if ((ncoefficient = MEDinterpBaseFunctionCoefSize(fid,interpname,basisfuncit) ) <0 ) {
MESSAGE("ERROR : read number of coefficient in the base function ...");
goto ERROR;
}
coefficient = (med_float*) calloc(sizeof(med_float),ncoefficient);
power = (med_int*) calloc(sizeof(med_int),nvariable*ncoefficient);
if (MEDinterpBaseFunctionRd(fid,interpname,basisfuncit,&ncoefficient,power,coefficient) < 0) {
MESSAGE("ERROR : read base function ...");
free(coefficient); free(power);
goto ERROR;
}
free(coefficient);
free(power);
}
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

### Créer et lire un champ aux noeuds des éléments

MED permet d'écrire et lire des champs aux noeuds des éléments d'un maillage. Pour cela, il suffit d'indiquer le mot clé MED_NODE_ELEMENT comme type d'entité lors de l'appel des routines d'écriture / lecture des valeurs des champs comme le montrent les deux cas d'utilisation suivants.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Field use case 13 : write a field on nodes elements in a MED file
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid;
const char meshname[MED_NAME_SIZE+1] = "2D unstructured mesh";
const char fieldname[MED_NAME_SIZE+1] = "TEMPERATURE_FIELD";
const med_int ncomponent = 1;
const char componentname[MED_SNAME_SIZE+1] = "TEMPERATURE";
const char componentunit[MED_SNAME_SIZE+1] = "C";
const med_int nquad4 = 4;
const med_float quad4values_step1[4*4] = { 10000., 20000., 30000., 40000.,
50000., 60000., 70000., 80000.,
90000., 100000., 110000., 120000.,
130000., 140000., 150000., 160000. };
const med_float quad4values_step2[4*4] = { 100., 200., 300., 400.,
500., 600., 700., 800.,
900., 1000., 1100., 1200.,
1300., 1400., 1500., 1600. };
int ret=-1;
/* file creation */
fid = MEDfileOpen("UsesCase_MEDfield_13.med",MED_ACC_CREAT);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* create mesh link */
if (MEDlinkWr(fid,meshname,"./UsesCase_MEDmesh_1.med") < 0) {
MESSAGE("ERROR : create mesh link ...");
goto ERROR;
}
/*
* Temperature field creation :
* - 1 component
* - component unit : celsius degree
* - mesh is the 2D unstructured mesh of UsecaseMEDmesh_1.c use case.
* - computation step unit in 'ms'
*/
if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
ncomponent, componentname, componentunit,
"ms", meshname) < 0) {
MESSAGE("ERROR : create field");
goto ERROR;
}
/* two computation steps */
/* write values at nodes elements : 4 MED_QUAD4 */
/* STEP 1 : dt1 = 5.5, it = 1*/
/* MED_QUAD4 : with no profile */
if (MEDfieldValueWithProfileWr(fid, fieldname, 1, 1, 5.5, MED_NODE_ELEMENT, MED_QUAD4,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
nquad4, (unsigned char*) quad4values_step1) < 0) {
MESSAGE("ERROR : write field values on MED_QUAD4 ");
goto ERROR;
}
/* STEP 2 : dt2 = 8.9, it = 1*/
/* MED_QUAD4 : with no profile */
if (MEDfieldValueWithProfileWr(fid, fieldname, 2, 1, 8.9, MED_NODE_ELEMENT, MED_QUAD4,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
nquad4, (unsigned char*) quad4values_step2) < 0) {
MESSAGE("ERROR : write field values on MED_QUAD4 ... ");
goto ERROR;
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
/*
* Field use case 14 : read a field on nodes elements (generic approach) in a MED file
*/
int main (int argc, char **argv) {
med_idt fid;
med_idt nfield, i, j;
char meshname[MED_NAME_SIZE+1]="";
med_bool localmesh;
char fieldname[MED_NAME_SIZE+1]="";
med_field_type fieldtype;
char *componentname = NULL;
char *componentunit = NULL;
char dtunit[MED_SNAME_SIZE+1]="";
med_float *values = NULL;
med_int nstep, nvalues;
med_int ncomponent;
med_int csit, numit, numdt, it;
med_float dt;
med_geometry_type geotype;
med_geometry_type *geotypes = MED_GET_CELL_GEOMETRY_TYPE;
med_int nprofile, pit, profilesize;
char profilename[MED_NAME_SIZE+1]="";
med_int nintegrationpoint;
char localizationname[MED_NAME_SIZE+1]="";
int k;
int ret=-1;
/* open file */
fid = MEDfileOpen("UsesCase_MEDfield_13.med",MED_ACC_RDONLY);
if (fid < 0) {
MESSAGE("ERROR : open file ...");
goto ERROR;
}
/*
* generic approach : how many fields in the file and identification
* of each field.
*/
if ((nfield = MEDnField(fid)) < 0) {
MESSAGE("ERROR : How many fields in the file ...");
goto ERROR;
}
/*
* read values for each field
*/
for (i=0; i<nfield; i++) {
if ((ncomponent = MEDfieldnComponent(fid,i+1)) < 0) {
MESSAGE("ERROR : number of field component ...");
goto ERROR;
}
if ((componentname = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
goto ERROR;
}
if ((componentunit = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
goto ERROR;
}
if (MEDfieldInfo(fid, i+1, fieldname, meshname, &localmesh, &fieldtype,
componentname, componentunit, dtunit, &nstep) < 0) {
MESSAGE("ERROR : Field info ...");
free(componentname);
free(componentunit);
goto ERROR;
}
free(componentname);
free(componentunit);
/*
* Read field values for each computing step
*/
for (csit=0; csit<nstep; csit++) {
if (MEDfieldComputingStepInfo(fid, fieldname, csit+1, &numdt, &numit, &dt) < 0) {
MESSAGE("ERROR : Computing step info ...");
goto ERROR;
}
/*
* ... In our case, we suppose that the field values are only defined on nodes element ...
*/
for (it=1; it<= MED_N_CELL_FIXED_GEO; it++) {
geotype = geotypes[it];
/*
* How many profile for each geometry type ?
*/
if ((nprofile = MEDfieldnProfile(fid, fieldname, numdt, numit, MED_NODE_ELEMENT, geotype,
profilename, localizationname)) < 0) {
MESSAGE("ERROR : read number of profile ");
goto ERROR;
}
/*
* Read values for each profile
*/
for (pit=0; pit<nprofile; pit++) {
if ((nvalues = MEDfieldnValueWithProfile(fid, fieldname, numdt, numit, MED_NODE_ELEMENT, geotype,
pit+1, MED_COMPACT_STMODE, profilename, &profilesize,
localizationname, &nintegrationpoint)) < 0) {
MESSAGE("ERROR : read number of values with a profile ...");
goto ERROR;
}
if (nvalues) {
if ((values = (med_float *) malloc(sizeof(med_float)*nvalues*ncomponent*nintegrationpoint)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
goto ERROR;
}
if (MEDfieldValueWithProfileRd(fid, fieldname, numdt, numit, MED_NODE_ELEMENT, geotype,
MED_COMPACT_STMODE, profilename,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
(unsigned char*) values) < 0) {
MESSAGE("ERROR : read fields values for node elements ...");
free(values);
goto ERROR;
}
free(values);
}
}
}
}
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

### Créer et lire un champ lié à un maillage contenant des éléments de structure

Au même titre que pour types d'éléments pré-définis dans le modèle MED, MED permet l'écriture et la lecture de champs sur les éléments de structure. Pour cela, il suffit d'indiquer le mot clé MED_STRUCT_ELEMENT comme type d'entité lors de l'appel des routines d'écriture / lecture des valeurs des champs comme le montrent les deux cas d'utilisation suivants.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Field use case 15 : write a field in a MED file with
* values defined on struct elements
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid=0,mfid=0;
const char meshname[MED_NAME_SIZE+1] = "COMPUT_MESH";
const char fieldname[MED_NAME_SIZE+1] = "SPEED";
const med_int ncomponent = 3;
/* 123456789012345612345678901234561234567890123456 */
const char componentname[3*MED_SNAME_SIZE+1] = "Vx Vy Vz";
const char componentunit[3*MED_SNAME_SIZE+1] = "m/s m/s m/s";
med_geometry_type geotype=MED_NONE;
const med_int npart = 3;
char structelementname[MED_NAME_SIZE+1]="";
const med_float part_speed1[3*3] = { 1.1, 2.2, 3.3,
4.4, 5.5, 6.6,
7.7, 8.8, 9.9 };
int ret=-1;
/* File creation to write the field */
fid = MEDfileOpen("UsesCase_MEDfield_15.med",MED_ACC_CREAT);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
/* Create mesh link */
if (MEDlinkWr(fid,meshname,"./UsesCase_MEDstructElement_1.med") < 0) {
MESSAGE("ERROR : create mesh link ...");
goto ERROR;
}
/*
* Read struct element geometric type
*/
if (( mfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_ELSTRUCT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
goto ERROR;
}
strcpy(structelementname,MED_PARTICLE_NAME);
geotype = MEDstructElementGeotype(fid,structelementname);
/*
* Speed field creation for particles :
* - 3 component
* - component unit : m/s
* - mesh is the 3D computation mesh of UsesCase_MEDstructElement_1 use case.
* - computation step unit in 'ms'
*/
if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
ncomponent, componentname, componentunit,
"ms", meshname) < 0) {
MESSAGE("ERROR : create field");
goto ERROR;
}
if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_STRUCT_ELEMENT, geotype,
MED_COMPACT_STMODE, MED_NO_PROFILE, MED_NO_LOCALIZATION,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
npart, (unsigned char*) part_speed1) < 0) {
MESSAGE("ERROR : write field values on MED_PARTICLE ");
goto ERROR;
}
if ( MEDfileObjectsUnmount(fid, mfid, MED_ELSTRUCT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
goto ERROR;
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
/*
* Field use case 16 : read a field (generic approach) in a MED file with
* - values defined on struct elements
*/
int main (int argc, char **argv) {
med_idt fid,mfid,sfid;
med_idt nfield, i, j;
char meshname[MED_NAME_SIZE+1]="";
med_bool localmesh;
char fieldname[MED_NAME_SIZE+1]="";
med_field_type fieldtype;
char *componentname = NULL;
char *componentunit = NULL;
char dtunit[MED_SNAME_SIZE+1]="";
med_float *values = NULL;
med_int nstep, nvalues;
med_int ncomponent;
med_int csit, numit, numdt, it;
med_float dt;
med_geometry_type *geotypes, geotype;
med_int nmodels;
med_int nprofile, pit, profilesize;
char profilename[MED_NAME_SIZE+1]="";
med_int nintegrationpoint;
char localizationname[MED_NAME_SIZE+1]="";
int k;
char elementname[MED_NAME_SIZE+1];
char supportmeshname[MED_NAME_SIZE+1];
med_entity_type entitype;
med_int elementdim;
med_int nnode,ncell;
med_geometry_type geocelltype;
med_bool anyprofile=0;
med_int nconstatt, *nvaratt;
int ret=-1;
/* open file */
fid = MEDfileOpen("UsesCase_MEDfield_15.med",MED_ACC_RDWR);
if (fid < 0) {
MESSAGE("ERROR : open file ...");
goto ERROR;
}
if (( mfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_MESH_SUPPORT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
goto ERROR;
}
if (( sfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_ELSTRUCT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
goto ERROR;
}
/* How many struct element models ? */
if ((nmodels = MEDnStructElement(mfid)) < 0) {
MESSAGE("ERROR : read number of struct element models ...");
goto ERROR;
}
geotypes = (med_geometry_type *) malloc(sizeof(med_geometry_type)*nmodels);
nvaratt = (med_int *) malloc(sizeof(med_int)*nmodels);
for (it=0; it<nmodels; it++) {
if (MEDstructElementInfo(mfid, it+1, elementname, geotypes+it, &elementdim,
supportmeshname, &entitype, &nnode, &ncell,
&geocelltype, &nconstatt, &anyprofile, nvaratt+it) < 0) {
MESSAGE("ERROR : struct element models information ...");
free(nvaratt);
goto ERROR;
}
}
free(nvaratt);
/*
* generic approach : how many fields in the file and identification
* of each field.
*/
if ((nfield = MEDnField(fid)) < 0) {
MESSAGE("ERROR : How many fields in the file ...");
goto ERROR;
}
/*
* read values for each field
*/
for (i=0; i<nfield; i++) {
if ((ncomponent = MEDfieldnComponent(fid,i+1)) < 0) {
MESSAGE("ERROR : number of field component ...");
goto ERROR;
}
if ((componentname = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
goto ERROR;
}
if ((componentunit = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
goto ERROR;
}
if (MEDfieldInfo(fid, i+1, fieldname, meshname, &localmesh, &fieldtype,
componentname, componentunit, dtunit, &nstep) < 0) {
MESSAGE("ERROR : Field info ...");
free(componentname);
free(componentunit);
goto ERROR;
}
free(componentname);
free(componentunit);
/*
* Read field values for each computing step
*/
for (csit=0; csit<nstep; csit++) {
if (MEDfieldComputingStepInfo(fid, fieldname, csit+1, &numdt, &numit, &dt) < 0) {
MESSAGE("ERROR : Computing step info ...");
goto ERROR;
}
/*
* ... In our case, we suppose that the field values are only defined on struct element ...
*/
for (it=0; it<nmodels; it++) {
geotype = *(geotypes+it);
/*
* How many profile for each geometry type ?
*/
if ((nprofile = MEDfieldnProfile(fid, fieldname, numdt, numit, MED_STRUCT_ELEMENT, geotype,
profilename, localizationname)) < 0) {
MESSAGE("ERROR : read number of profile ");
goto ERROR;
}
/*
* Read values for each profile
*/
for (pit=0; pit<nprofile; pit++) {
if ((nvalues = MEDfieldnValueWithProfile(fid, fieldname, numdt, numit, MED_STRUCT_ELEMENT, geotype,
pit+1, MED_COMPACT_STMODE, profilename, &profilesize,
localizationname, &nintegrationpoint)) < 0) {
MESSAGE("ERROR : read number of values with a profile ...");
goto ERROR;
}
if (nvalues) {
if ((values = (med_float *) malloc(sizeof(med_float)*nvalues*ncomponent*nintegrationpoint)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
goto ERROR;
}
if (MEDfieldValueWithProfileRd(fid, fieldname, numdt, numit, MED_STRUCT_ELEMENT, geotype,
MED_COMPACT_STMODE, profilename,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
(unsigned char*) values) < 0) {
MESSAGE("ERROR : read fields values for cells ...");
goto ERROR;
free(values);
}
free(values);
}
}
}
}
}
ret=0;
ERROR :
free(geotypes);
if ( MEDfileObjectsUnmount(fid, sfid, MED_ELSTRUCT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
ret=-1;
}
if ( MEDfileObjectsUnmount(fid, mfid, MED_MESH_SUPPORT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
ret= -1;
}
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret= -1;
}
return ret;
}

Il est également possible de définir des champs aux points d'intégration des éléments de structure. Dans ce cas là, l'élément de référence est déjà décrit à la définition de l'élément de structure. Les coordonnées des points d'intégration y sont relatives. Il est possible d'indiquer l'utilisation d'un maillage support définissant une section du modèle d'élément de structure. Ce maillage support est alors utilisé comme section de l'élément de structure à chaque point d'intégration. Auquel cas un champ utilisant cette localisation définira autant de valeur par élément qu'il y a de maille dans le maillage section de chaque point d'intégration comme montrent les deux cas d'utilisation suivants.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
/*
* Field use case 17 : write a field in a MED file with
* values defined on integration points
* on struct elements
*/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
med_idt fid=0,mfid=0,sfid=0;
const med_int spacedim = 3;
const char meshname[MED_NAME_SIZE+1] = "COMPUT_MESH";
const char fieldname[MED_NAME_SIZE+1] = "TEMPERATURE";
const med_int ncomponent = 1;
/* 1234567890123456123456*/
const char componentname[MED_SNAME_SIZE+1] = "TEMP ";
const char componentunit[MED_SNAME_SIZE+1] = "CELSIUS ";
med_geometry_type geotype=MED_NONE;
const med_int nbeam = 1;
char structelementname[MED_NAME_SIZE+1];
const med_float tempvalue[3*1*4] = { 1.1, 2.2, 3.3, 4.4,
5.5, 6.6, 7.7, 8.8,
9.9, 10.1,11.11, 12.12};
const char localization[MED_NAME_SIZE+1] = "BEAM_INTEGRATION_POINTS";
const char localization2[MED_NAME_SIZE+1] = "BEAM_INTEGRATION_TRANSF";
const med_float elementcoordinate[3*3] = { 0.0,0.0,0.0,
0.0,0.0,0.0,
0.0,0.0,0.0,};
const med_float ipointcoordinate[3*3] = { 0.0,0.0,2.5,
0.0,0.0,3.5,
0.0,0.0,4.5};
const med_float weight[4] = {1.0/4, 1.0/4, 1.0/4, 1.0/4};
const char beamsectionname[MED_NAME_SIZE+1]="BEAM_SECTION_MESH";
const med_int nipoint = 3;
char interpname[MED_NAME_SIZE+1] = "geometrical transformation";
const med_int nvariable=2;
const med_int maxdegree=1;
const med_int nmaxcoefficient=3;
const med_int ncoefficient1_1 = 3;
const med_int const power1_1[] = {0,0,1,0,0,1};
const med_float const coefficient1_1[] = {1,-1,-1};
const med_int ncoefficient1_2 = 1;
const med_int const power1_2[] = {1,0};
const med_float const coefficient1_2[] = {1};
const med_int ncoefficient1_3 = 1;
const med_int const power1_3[] = {0,1};
const med_float const coefficient1_3[] = {1};
int ret=-1;
/* Open file to write the field */
fid = MEDfileOpen("UsesCase_MEDfield_17.med",MED_ACC_CREAT);
if (fid < 0) {
MESSAGE("ERROR : file creation ...");
goto ERROR;
}
if (( mfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_MESH_SUPPORT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
goto ERROR;
}
if (( sfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_ELSTRUCT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
goto ERROR;
}
/* Create mesh link */
if (MEDlinkWr(fid,meshname,"./UsesCase_MEDstructElement_1.med") < 0) {
MESSAGE("ERROR : create mesh link ...");
goto ERROR;
}
/*
* Read struct element geometric type
*/
strcpy(structelementname,MED_BEAM_NAME);
geotype = MEDstructElementGeotype(fid,structelementname);
/* create a geometrical transformation fonction */
if (MEDinterpCr(fid, interpname, geotype, MED_FALSE, nvariable, maxdegree, nmaxcoefficient) < 0) {
MESSAGE("ERROR : interpolation family creation ...");
goto ERROR;
}
/* Basis functions creation */
if (MEDinterpBaseFunctionWr(fid,interpname,1,ncoefficient1_1,power1_1,coefficient1_1) < 0) {
MESSAGE("ERROR : first base function creation ...");
goto ERROR;
}
if (MEDinterpBaseFunctionWr(fid,interpname,2,ncoefficient1_2,power1_2,coefficient1_2) < 0) {
MESSAGE("ERROR : second base function creation ...");
goto ERROR;
}
if (MEDinterpBaseFunctionWr(fid,interpname,3,ncoefficient1_3,power1_3,coefficient1_3) < 0) {
MESSAGE("ERROR : third base function creation ...");
goto ERROR;
}
/* create the families of integration points
for the struct element */
if (MEDlocalizationWr(fid, localization, geotype, spacedim,
elementcoordinate, MED_FULL_INTERLACE,
nipoint, ipointcoordinate, weight,
MED_NO_INTERPOLATION, beamsectionname) < 0) {
MESSAGE("ERROR : create famlily of integration points ...");
goto ERROR;
}
if (MEDlocalizationWr(fid, localization2, geotype, spacedim,
elementcoordinate, MED_FULL_INTERLACE,
nipoint, ipointcoordinate, weight,
interpname, beamsectionname) < 0) {
MESSAGE("ERROR : create famlily of integration points ...");
goto ERROR;
}
/*
* Temperature field creation for beam struct element :
* - 1 component, 3 integration points, 4 cells in the support mesh for each
* the section of each integration point
* - mesh is the 3D computation mesh of UsesCase_MEDstructElement_1 use case.
*/
if (MEDfieldCr(fid, fieldname, MED_FLOAT64,
ncomponent, componentname, componentunit,
"ms", meshname) < 0) {
MESSAGE("ERROR : create field");
goto ERROR;
}
if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
MED_STRUCT_ELEMENT, geotype,
MED_COMPACT_STMODE, MED_NO_PROFILE, localization,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
nbeam, (unsigned char*) tempvalue) < 0) {
MESSAGE("ERROR : write field values on MED_BEAM ");
goto ERROR;
}
if (MEDfieldValueWithProfileWr(fid, fieldname, MED_NO_DT, 1, MED_UNDEF_DT,
MED_STRUCT_ELEMENT, geotype,
MED_COMPACT_STMODE, MED_NO_PROFILE, localization2,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
nbeam, (unsigned char*) tempvalue) < 0) {
MESSAGE("ERROR : write field values on MED_BEAM ");
goto ERROR;
}
/* unmount file objects */
if ( MEDfileObjectsUnmount(fid, mfid, MED_MESH_SUPPORT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
goto ERROR;
}
if ( MEDfileObjectsUnmount(fid, sfid, MED_ELSTRUCT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
goto ERROR;
}
ret=0;
ERROR:
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
/*
* Field use case 18 : read a field (generic approach) in a MED file with
* values defined on integration points on struct elements
*/
int main (int argc, char **argv) {
med_idt fid,mfid,sfid,cmfid;
med_idt nfield, i, j;
char meshname[MED_NAME_SIZE+1]="";
med_bool localmesh;
char fieldname[MED_NAME_SIZE+1]="";
med_field_type fieldtype;
char *componentname = NULL;
char *componentunit = NULL;
char dtunit[MED_SNAME_SIZE+1]="";
med_float *values = NULL;
med_int nstep, nvalues;
med_int ncomponent;
med_int csit, numit, numdt, it;
med_float dt;
med_geometry_type *geotypes=NULL, geotype;
med_int nmodels;
med_int nprofile, pit, profilesize;
char profilename[MED_NAME_SIZE+1]="";
med_int nintegrationpoint;
char localizationname[MED_NAME_SIZE+1]="";
int k;
char elementname[MED_NAME_SIZE+1]="";
char supportmeshname[MED_NAME_SIZE+1]="";
med_entity_type entitype;
med_int elementdim;
med_int nnode,ncell;
med_geometry_type geocelltype;
med_bool anyprofile=0;
med_int nconstatt, *nvaratt=NULL;
med_bool coordinatechangement;
med_bool geotransformation;
int ret=-1;
/* open file */
fid = MEDfileOpen("UsesCase_MEDfield_17.med",MED_ACC_RDWR);
if (fid < 0) {
MESSAGE("ERROR : open file ...");
return -1;
}
if (( mfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_MESH_SUPPORT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
return -1;
}
if (( sfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_ELSTRUCT)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
return -1;
}
if (( cmfid=MEDfileObjectsMount(fid, "UsesCase_MEDstructElement_1.med",MED_MESH)) < 0 ) {
MESSAGE("ERROR : file mounting ...");
return -1;
}
/*
* generic approach : how many fields in the file and identification
* of each field.
*/
if ((nfield = MEDnField(fid)) < 0) {
MESSAGE("ERROR : How many fields in the file ...");
return -1;
}
/*
* read values for each field
*/
for (i=0; i<nfield; i++) {
if ((ncomponent = MEDfieldnComponent(fid,i+1)) < 0) {
MESSAGE("ERROR : number of field component ...");
return -1;
}
if ((componentname = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if ((componentunit = (char *) malloc(ncomponent*MED_SNAME_SIZE+1)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if (MEDfieldInfo(fid, i+1, fieldname, meshname, &localmesh, &fieldtype,
componentname, componentunit, dtunit, &nstep) < 0) {
MESSAGE("ERROR : Field info ...");
free(componentname);
free(componentunit);
return -1;
}
free(componentname);
free(componentunit);
/* read how many struct element models in the mesh ? */
if ((nmodels = MEDmeshnEntity(fid, meshname, MED_NO_DT, MED_NO_IT, MED_STRUCT_ELEMENT, MED_GEO_ALL,
MED_UNDEF_DATATYPE, MED_NO_CMODE,&coordinatechangement,
&geotransformation)) < 0) {
MESSAGE("ERROR : number of nodes ...");
return -1;
}
geotypes = (med_geometry_type *) malloc(sizeof(med_geometry_type)*nmodels);
nvaratt = (med_int *) malloc(sizeof(med_int)*nmodels);
for (it=0; it<nmodels; it++) {
if (MEDstructElementInfo(mfid, it+1, elementname, geotypes+it, &elementdim,
supportmeshname, &entitype, &nnode, &ncell,
&geocelltype, &nconstatt, &anyprofile, nvaratt+it) < 0) {
MESSAGE("ERROR : struct element models information ...");
return -1;
}
}
/*
* Read field values for each computing step
*/
for (csit=0; csit<nstep; csit++) {
if (MEDfieldComputingStepInfo(fid, fieldname, csit+1, &numdt, &numit, &dt) < 0) {
MESSAGE("ERROR : Computing step info ...");
return -1;
}
/*
* ... In our case, we suppose that the field values are only defined on struct element ...
*/
for (it=0; it<nmodels; it++) {
geotype = *(geotypes+it);
/*
* How many profile for each geometry type ?
*/
if ((nprofile = MEDfieldnProfile(fid, fieldname, numdt, numit, MED_STRUCT_ELEMENT, geotype,
profilename, localizationname)) < 0) {
MESSAGE("ERROR : read number of profile ");
return -1;
}
/*
* Read values for each profile
*/
for (pit=0; pit<nprofile; pit++) {
if ((nvalues = MEDfieldnValueWithProfile(fid, fieldname, numdt, numit, MED_STRUCT_ELEMENT, geotype,
pit+1, MED_COMPACT_STMODE, profilename, &profilesize,
localizationname, &nintegrationpoint)) < 0) {
MESSAGE("ERROR : read number of values with a profile ...");
return -1;
}
if (nvalues) {
if ((values = (med_float *) malloc(sizeof(med_float)*nvalues*ncomponent*nintegrationpoint)) == NULL) {
MESSAGE("ERROR : memory allocation ...");
return -1;
}
if (MEDfieldValueWithProfileRd(fid, fieldname, numdt, numit, MED_STRUCT_ELEMENT, geotype,
MED_COMPACT_STMODE, profilename,
MED_FULL_INTERLACE, MED_ALL_CONSTITUENT,
(unsigned char*) values) < 0) {
MESSAGE("ERROR : read fields values for cells ...");
free(values);
return -1;
}
free(values);
}
}
}
}
ret=0;
ERROR:
if (nvaratt)
free(nvaratt);
if (geotypes)
free(geotypes);
}
if ( MEDfileObjectsUnmount(fid, mfid, MED_MESH_SUPPORT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
ret=-1;
}
if ( MEDfileObjectsUnmount(fid, sfid, MED_ELSTRUCT) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
ret=-1;
}
if ( MEDfileObjectsUnmount(fid, cmfid, MED_MESH) < 0 ) {
MESSAGE("ERROR : file unmounting ...");
ret=-1;
}
/* close file */
if (MEDfileClose(fid) < 0) {
MESSAGE("ERROR : close file ...");
ret=-1;
}
return ret;
}

### Ecrire et lire un maillage ou un champ en filtrant les données

Dans MED, un filtre de données peut être utilisé pour contrôler un sous-ensemble d'entités concernées par un appel à l'API.

En mode séquentiel, la routine MEDfilterEntityCr / mfrcre permet de créer un filtre élémentaire en sélectionnant les entités pour lesquelles on veut lire/écrire des valeurs. Cette sélection permet une lecture/écriture avancée vers/depuis les emplacements mémoire sélectionnés. Elle s'utilise uniquement en mode séquentiel (un seul processus).

Une fois créé un filtre peut être passé en arguments aux routines avancées de l'API. Ces routines ne manipuleront que les données filtrées. Ces routines avancées sont celles qui permettent d'écrire et lire les coordonnées des noeuds, la connectivité des éléments d'un maillage non structuré, les valeurs des champs de résultats : MEDfieldValueAdvancedWr / mfdraw, mfdiaw, MEDfieldValueAdvancedRd / mfdrar, mfdiar, MEDmeshElementConnectivityAdvancedWr / mmhyaw, MEDmeshElementConnectivityAdvancedRd / mmhyar, MEDmeshNodeCoordinateAdvancedWr / mmhcaw, MEDmeshNodeCoordinateAdvancedRd / mmhcar.

Il est possible d'allouer un tableau de filtre avec la routine MEDfilterAllocate / mfrall, puis de le dé-allouer avec la routine MEDfilterDeAllocate / mfrdea.

### Ecriture et lecture en parallèle dans un seul fichier

En mode parallèle, le filtre est un moyen de définir le domaine concerné par chacun des processeurs. Les écritures et lectures peuvent donc se faire en parallèle entre plusieurs processeurs dans un seul et même fichier MED.

La routine MEDfilterBlockOfEntityCr / mfrblc permet de créer un filtre en sélectionnant les entités par blocs continus de taille constante pour lesquelles on veut lire/écrire des valeurs. Cette sélection permet une lecture/écriture avancée vers/depuis les emplacements mémoire sélectionnés. Elle s'utilise aussi bien en mode séquentiel qu'en mode parallèle (un ou plusieurs processus).

Dans ce cadre d'utilisation, le fichier doit être ouvert avec la routine MEDparFileOpen / mfipfo.

L'exemple suivant montre un cas d'utilisation en parallèle en écriture et lecture de champs de résultats.

/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2021 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/>.
*/
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#include <med.h>
#define MESGERR 1
#include "med_utils.h"
#include "med_config.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef PPRO_NT_CALL
// Windows Header Files:
# include <windows.h>
# include <Lmcons.h>
# include <sys/timeb.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# endif
#include <time.h>
#ifndef HAVE_UNISTD_H
#error "unistd.h required."
#endif
#include "getBlocksOfEntitiesPartition.h"
#include "generateDatas.h"
#include "generateFilterArray.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
/*Valeur de l'enum dans med.h.in*/
/* #define MED_NO_INTERLACE 2 */
/* #define MED_FULL_INTERLACE 1 */
/* #ifndef USER_INTERLACE */
/* #define USER_INTERLACE MED_FULL_INTERLACE */
/* #warning "Defining MED_FULL_INTERLACE mode..." */
/* #endif */
/* #if USER_INTERLACE == MED_NO_INTERLACE */
/* #define generateDatas generateNoIDatas */
/* #warning "Using generateNoIDatas..." */
/* #elif USER_INTERLACE == MED_FULL_INTERLACE */
/* #define generateDatas generateFullIDatas */
/* #warning "Using generateFullIDatas..." */
/* #else */
/* #error "The USER_INTERLACE macro value match neither MED_NO_INTERLACE nor MED_FULL_INTERLACE" */
/* #endif */
/* #define USER_MODE MED_COMPACT */
typedef struct {
MPI_Info info;
MPI_Comm comm;
int mpi_size;
int mpi_rank;
med_int nentitiesfiltered;
med_int *filterarray;
} COM_info;
med_err generateFieldFile( const med_size nentities, const med_size nvaluesperentity, const med_size nconstituentpervalue,
const med_switch_mode constituentmode,GetBlocksOfEntitiesType getBlockOfEntities, const med_int nbblocksperproc,
GenerateDataType generateDatas,
const med_storage_mode storagemode, const med_size profilearraysize, const char * const fieldnameprefix, COM_info * const cominfo ) {
/* static int _fileno=0; */
med_err _ret=-1;
char _filename [255]="";
char _meshname[MED_NAME_SIZE+1]="Empty mesh";
med_int _meshdim=3;
char _meshcomponentname[3*MED_SNAME_SIZE+1] = "x y z ";
char _meshcomponentunit[3*MED_SNAME_SIZE+1] = "cm cm cm ";
char _fieldname [MED_NAME_SIZE+1]="";
char *componentname,*componentunit;
char _profilename[MED_NAME_SIZE+1]=MED_NO_PROFILE;
med_int *_profilearray=0;
int _i=0,_j=0,_k=0, _lastusedrank=0;
med_size _blocksize=0,_lastblocksize=0,_count=0,_stride=0,_start=0,_index=0;
med_float *_arrayvalues;
med_filter filter = MED_FILTER_INIT;
med_size _nusedentities = nentities;
med_size _io_count = nbblocksperproc;
med_idt _fidseq,_fid;
MPI_Info info = cominfo->info;
MPI_Comm comm = cominfo->comm;
int mpi_size = cominfo->mpi_size;
int mpi_rank = cominfo->mpi_rank;
char *_MED_MODE_SWITCH_MSG[3]={"MED_FULL_INTERLACE", "MED_NO_INTERLACE","MED_UNDEF_INTERLACE",};
char *_MED_STORAGE_MODE_MSG[3]={"MED_NO_STMODE","MED_GLOBAL_STMODE", "MED_COMPACT_STMODE"};
med_geometry_type _geotype = MED_TRIA6;
med_int _geodim = _geotype/100;
med_int _geonnodes = _geotype%100;
char _ipointname[MED_NAME_SIZE+1];
med_float* _ipointrefcoo = 0;
med_int _ipoint = nvaluesperentity;
med_float* _ipointcoo = 0;
med_float* _ipointwg = 0;
sprintf(_filename,"%s_CPU-%03d_@_%s_%s.med",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
/* SSCRUTE(_filename); */
/* Ouverture du fichier en mode parallel */
if ((_fid = MEDparFileOpen(_filename, MODE_ACCES ,comm, info)) < 0){
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
goto ERROR;
}
/* SSCRUTE(_meshname); */
if (MEDmeshCr( _fid,_meshname,_meshdim,_meshdim, MED_UNSTRUCTURED_MESH,
"Un maillage pour le test parallel","s", MED_SORT_DTIT,
MED_CARTESIAN, _meshcomponentname, _meshcomponentunit) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_MESH,_meshname);
goto ERROR;
};
componentname = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
componentunit = (char*) malloc((nconstituentpervalue*MED_SNAME_SIZE+1)*sizeof(char));
/*TODO : Compléter le nom */
strcpy(componentname,"");
strcpy(componentunit,"");
strcpy(_fieldname,fieldnameprefix);
if ( MEDfieldCr(_fid,_fieldname,MED_FLOAT64,nconstituentpervalue,componentname,componentunit,"s",_meshname ) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FIELD,_fieldname);
goto ERROR;
};
free(componentname);
free(componentunit);
if ( _ipoint > 1 ) {
MESSAGE("Creating a localization of integration points...");
strcpy(_ipointname,_fieldname);
strcat(_ipointname,"_loc");
/*Attention ancienne spec*/
_ipointrefcoo = (med_float *) calloc(_geodim*_geonnodes,sizeof(med_float));
_ipointcoo = (med_float *) calloc(_ipoint*_geodim,sizeof(med_float));
_ipointwg = (med_float *) calloc(_ipoint,sizeof(med_float));
if (MEDlocalizationWr(_fid, _ipointname, _geotype, _geotype/100, _ipointrefcoo, constituentmode,
_ipoint, _ipointcoo, _ipointwg, MED_NO_INTERPOLATION, MED_NO_MESH_SUPPORT ) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_LOCALIZATION,_ipointname);
ISCRUTE_int(constituentmode);
goto ERROR;
}
free(_ipointrefcoo );
free(_ipointcoo );
free(_ipointwg );
} else {
strcpy(_ipointname,MED_NO_LOCALIZATION);
}
if (profilearraysize) {
MESSAGE("Creating a profile...");
strcpy(_profilename,_fieldname);strcat(_profilename,"_profile");
_profilearray = (med_int*) calloc(profilearraysize,sizeof(med_int));
for (_i=0; _i < profilearraysize; ++_i) _profilearray[_i]=_i;
if ( MEDprofileWr(_fid,_profilename,profilearraysize,_profilearray) < 0) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_PROFILE,_profilename);
goto ERROR;
};
_nusedentities = profilearraysize;
} else {
strcpy(_profilename,MED_NO_PROFILE);
}
MESSAGE("Generating partition...");
getBlockOfEntities ( mpi_rank , mpi_size, _nusedentities,
&_start, &_stride, &_io_count, &_blocksize,
&_lastusedrank, &_lastblocksize);
_count=_io_count;
MESSAGE("Generating filter...");
if ( MEDfilterBlockOfEntityCr(_fid, nentities, nvaluesperentity, nconstituentpervalue,
MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
_start,_stride,_count,_blocksize,_lastblocksize, &filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
goto ERROR;
}
MESSAGE("Generating datas...");
generateDatas(mpi_rank, _lastusedrank, sizeof(med_float),
storagemode, profilearraysize, _profilearray,
_start, _stride, _count, _blocksize, _lastblocksize,
nentities, nvaluesperentity, nconstituentpervalue,
&_arrayvalues );
MESSAGE("Writing field...");
if ( MEDfieldValueAdvancedWr(_fid,_fieldname,MED_NO_DT,MED_NO_IT,0.0, MED_CELL, _geotype,
_ipointname, &filter, (unsigned char*)_arrayvalues ) < 0) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldname);
ISCRUTE(mpi_rank);
goto ERROR;
}
/* Test de lecture du même fichier avec filtre simple par un seul processeur */
/* TODO : Créer MEDflush */
H5Fflush(_fid, H5F_SCOPE_GLOBAL );
/*Le flush suffit pas besoin de synchroniser les processus : MPI_Barrier(MPI_COMM_WORLD); */
if (mpi_rank == 0 ) {
MESSAGE("Reading field...");
med_int _nentitiesarrayvalues=0;
med_float *_filteredarrayvalues=NULL;
med_filter filter2=MED_FILTER_INIT;
int _ind=0;
FILE * _asciifile;
char _asciifilename[255]="";
if ((_fidseq = MEDfileOpen(_filename, MED_ACC_RDONLY )) < 0){
MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_FILE,_filename);
goto ERROR;
}
sprintf(_asciifilename,"%s_CPU-%03d_@_%s_%s.ascii",fieldnameprefix,mpi_size,_MED_MODE_SWITCH_MSG[constituentmode],_MED_STORAGE_MODE_MSG[storagemode]);
_asciifile=fopen(_asciifilename, "w");
/*Génère un filtre de selection simple s'il n'a pas déjà été généré lors d'un précédent appel */
/*TODO : Déplacer cette appel dans le main après avoir externaliser la génération du profile */
if (!(cominfo->filterarray))
if ( generateFilterArray( nentities, nvaluesperentity, nconstituentpervalue,
profilearraysize, _profilearray,
&(cominfo->nentitiesfiltered), &(cominfo->filterarray) ) < 0 ) {
goto ERROR;
}
ISCRUTE(cominfo->nentitiesfiltered);
/*Stocke le filtre utilisé dans le fichier .ascii*/
for (_i=0; _i < cominfo->nentitiesfiltered; ++_i ) {
/* ISCRUTE(cominfo->filterarray[_i]); */
fprintf(_asciifile,"%d ",cominfo->filterarray[_i]) ;
}
fprintf(_asciifile,"\n") ;
/*Pas de profile possible (profilearraysize == 0) en MED_GLOBAL_STMODE sur un fichier géré en parallel */
if ( profilearraysize ) {
_nentitiesarrayvalues = profilearraysize;
} else {
_nentitiesarrayvalues = nentities;
}
/*Attention allocation mémoire potentiellement grosse car réalisée uniquement par le processus 0
qui rassemble les données.*/
/* C'est une taille maxi qui ne prend pas en compte le COMPACT+filter */
/* TODO : Ajuster la taille au storage_mode*/
_filteredarrayvalues = (med_float*) malloc(_nentitiesarrayvalues*
nvaluesperentity*
nconstituentpervalue*sizeof(med_float));
/* Permet de vérifier une erreur d'indiçage après la lecture */
for (_i=0;_i<_nentitiesarrayvalues*nvaluesperentity*nconstituentpervalue; ++_i)
_filteredarrayvalues[_i]=-_i;
/*Création d'un filtre de sélection simple, pour une lecture séquentielle par le processys 0*/
if ( MEDfilterEntityCr(_fidseq, nentities, nvaluesperentity, nconstituentpervalue,
MED_ALL_CONSTITUENT, constituentmode, storagemode, _profilename,
cominfo->nentitiesfiltered,cominfo->filterarray, &filter2) < 0 ) {
MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,"");
goto ERROR;
}
if ( MEDfieldValueAdvancedRd(_fidseq,_fieldname,MED_NO_DT,MED_NO_IT, MED_CELL, _geotype,
&filter2, (unsigned char*)_filteredarrayvalues ) < 0) {
MED_ERR_(_ret,MED_ERR_READ,MED_ERR_FIELD,_fieldname);
ISCRUTE(mpi_rank);
goto ERROR;
}
/*AFFICHAGE TOUJOURS EN FULL INTERLACE QUELQUES SOIENT LES COMBINAISONS*/
/*TODO : Externaliser l'affichage*/
if ( storagemode == MED_GLOBAL_STMODE ) {
switch (constituentmode) {
case MED_FULL_INTERLACE:
for (_i=0; _i < cominfo->nentitiesfiltered; ++_i)
for (_j=0; _j < nvaluesperentity; ++_j)
for (_k=0; _k < nconstituentpervalue; ++_k) {
_ind = (cominfo->filterarray[_i]-1)*nvaluesperentity*nconstituentpervalue+ _j*nconstituentpervalue+_k;
/* fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLGLB[",_ind,"]",_filteredarrayvalues[_ind]) ; */
fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
}
break;
case MED_NO_INTERLACE:
for (_j=0; _j < cominfo->nentitiesfiltered; ++_j)
for (_k=0; _k < nvaluesperentity; ++_k)
for (_i=0; _i < nconstituentpervalue; ++_i) {
_ind =_i*nentities*nvaluesperentity+ (cominfo->filterarray[_j]-1)*nvaluesperentity +_k;
/* fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOGLB[",_ind,"]",_filteredarrayvalues[_ind]); */
fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
}
break;
}
} else
switch (constituentmode) {
case MED_FULL_INTERLACE:
for (_i=0; _i < cominfo->nentitiesfiltered; ++_i )
for (_j=0; _j < nvaluesperentity; ++_j)
for (_k=0; _k < nconstituentpervalue; ++_k) {
_ind = _i*nvaluesperentity*nconstituentpervalue+_j*nconstituentpervalue+_k;
/* fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesFULLCP[",_ind,"]",_filteredarrayvalues[_ind]) ; */
fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]) ;
}
break;
case MED_NO_INTERLACE:
for (_j=0; _j < cominfo->nentitiesfiltered; ++_j)
for (_k=0; _k < nvaluesperentity; ++_k)
for (_i=0; _i < nconstituentpervalue; ++_i) {
_ind =_i*cominfo->nentitiesfiltered*nvaluesperentity+ _j*nvaluesperentity +_k;
/* _ind =_i*_nentitiesarrayvalues*nvaluesperentity+ (_filterarray[_j]-1)*nvaluesperentity +_k; */
/* fprintf(stdout,"%s%3d%s = %f\n","_filteredarrayvaluesNOCP[",_ind,"]",_filteredarrayvalues[_ind]); */
fprintf(_asciifile,"%f\n",_filteredarrayvalues[_ind]);
}
break;
}
free(_filteredarrayvalues);
fclose(_asciifile);
if ( MEDfilterClose(&filter2) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
goto ERROR;
}
} /*fin if (mpi_rank == 0) */
if ( MEDfilterClose(&filter) < 0 ) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,"");
goto ERROR;
}
_ret=0;
ERROR:
if (_arrayvalues) free(_arrayvalues);
if (profilearraysize) free(_profilearray);
if ( MEDfileClose(_fid) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
}
if (mpi_rank == 0 ) {
if ( MEDfileClose(_fidseq) < 0) {
MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILE,""); _ret = -1;
}
}
return _ret;
}
int main (int argc, char **argv)
{
med_err _ret=0;
COM_info _cominfo;
_cominfo.comm = MPI_COMM_WORLD;
_cominfo.info = MPI_INFO_NULL;
_cominfo.nentitiesfiltered=0;
_cominfo.filterarray =NULL;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &(_cominfo.mpi_size));
MPI_Comm_rank(MPI_COMM_WORLD, &(_cominfo.mpi_rank));
med_size _nbblocksperproc = 0;
int _nentities = 0;
int _nvaluesperentity = 0;
int _nconstituentpervalue = 0;
if (_cominfo.mpi_rank == 0 ) {
struct tm *_tm ;
time_t _tt=time(0);
_tm = localtime(&_tt);
srandom((*_tm).tm_sec * (*_tm).tm_min );
_nbblocksperproc = 1 + (int) (_cominfo.mpi_size * (random() / (RAND_MAX + 1.0)));
_nentities = 1 + (int) (1000.0 * (random() / (RAND_MAX + 1.0)));
_nvaluesperentity = 1 + (int) (11.0 * (random() / (RAND_MAX + 1.0)));
_nconstituentpervalue = 1 + (int) (7.0 * (random() / (RAND_MAX + 1.0)));
/* _nbblocksperproc = 1 + (int) (mpi_size * (random() / (RAND_MAX + 1.0))); */
/* _nentities = 1 + (int) (5.0 * (random() / (RAND_MAX + 1.0))); */
/* _nvaluesperentity = 1 + (int) (3.0 * (random() / (RAND_MAX + 1.0))); */
/* _nconstituentpervalue = 1 + (int) (3.0 * (random() / (RAND_MAX + 1.0))); */
/* _nbblocksperproc = 2; */
/* _nentities = 4; */
/* _nvaluesperentity = 1; */
/* _nconstituentpervalue = 1; */
}
if ( (sizeof(med_size)%(sizeof(MPI_LONG)))==0 ) {
MPI_Bcast(&_nbblocksperproc , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
MPI_Bcast(&_nentities , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
MPI_Bcast(&_nvaluesperentity , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
MPI_Bcast(&_nconstituentpervalue , sizeof(med_size)/sizeof(MPI_LONG), MPI_LONG, 0, MPI_COMM_WORLD);
} else {
assert(sizeof(med_size) == (sizeof(MPI_LONG)));
}
char _fieldnameprefix[256] = "";
sprintf(_fieldnameprefix,"NENT-%03d_NVAL-%03d_NCST-%03d_NBL-%03llu",_nentities,_nvaluesperentity,
_nconstituentpervalue,_nbblocksperproc);
GenerateDataType generateDatas = 0;
med_switch_mode _switchmode = MED_UNDEF_INTERLACE;
med_storage_mode _storagemode = MED_UNDEF_STMODE;
/*Pour que les 4 fichiers générés soient identiques, on désactive l'utilisation des profils
qui n'est pas utilisable en mode GLOBAL+// */
med_int _profilearraysize=0;
/* med_int _profilearraysize=_nentities/2; */
for (_switchmode = MED_FULL_INTERLACE ; _switchmode <= MED_NO_INTERLACE; ++_switchmode) {
if ( _switchmode == MED_FULL_INTERLACE ) generateDatas = generateFullIDatas;
else generateDatas = generateNoIDatas;
for (_storagemode = MED_GLOBAL_STMODE ; _storagemode <= MED_COMPACT_STMODE; ++_storagemode) {
if ( (_storagemode == MED_GLOBAL_STMODE ) && (_profilearraysize) ) _profilearraysize=0;
if ( generateFieldFile( _nentities, _nvaluesperentity, _nconstituentpervalue,
_switchmode, getCyclicBlocksOfEntities, _nbblocksperproc, generateDatas,
_storagemode, _profilearraysize, _fieldnameprefix, & _cominfo) < 0 ) {
MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_FIELD,_fieldnameprefix);
ISCRUTE(_cominfo.mpi_rank);
goto ERROR;
}
}
}
_ret = 0;
ERROR:
if ( _cominfo.filterarray = NULL ) free( _cominfo.filterarray );
/*pour arch. BLueGene : Sync entre GPFS et LSF : sleep(360) */
/* MPI_Finalize must be called AFTER MEDclose which may use MPI calls */
MPI_Finalize();
/* Catcher l'erreur en retour mpirun et .sh*/
return _ret;
}

generateFullIDatas
void generateFullIDatas(const int myrank, const int lastrank, const int sizeoftype, const med_storage_mode profilemode, const med_size profilesize, const med_int *const profilearray, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, const int nentities, const int nvaluesperentity, const int nconstituentpervalue, med_float **valuesarray)
Definition: generateDatas.c:31
MED_ERR_CREATE
#define MED_ERR_CREATE
Definition: med_err.h:27
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
MED_CARTESIAN
Definition: med.h:258
MEDfieldCr
MEDC_EXPORT med_err MEDfieldCr(const med_idt fid, const char *const fieldname, const med_field_type fieldtype, const med_int ncomponent, const char *const componentname, const char *const componentunit, const char *const dtunit, const char *const meshname)
Cette fonction crée un champ dans un fichier.
Definition: MEDfieldCr.c:44
MED_GET_EDGE_GEOMETRY_TYPENAME
const char * MED_GET_EDGE_GEOMETRY_TYPENAME[MED_N_EDGE_FIXED_GEO+2]
Definition: MEDiterators.c:148
MEDlinkInfo
MEDC_EXPORT med_err MEDlinkInfo(const med_idt fid, const int linkit, char *const meshname, med_int *const linksize)
Cette routine permet de lire les informations sur un lien dans un fichier MED.
Definition: MEDlinkInfo.c:38
MED_TRIA3
#define MED_TRIA3
Definition: med.h:203
MED_FULL_INTERLACE
Definition: med.h:96
MEDnInterp
MEDC_EXPORT med_int MEDnInterp(const med_idt fid)
Cette routine renvoie le nombre d'interpolations disponibles dans le fichier.
Definition: MEDnInterp.c:34
MED_SORT_DTIT
Definition: med.h:309
MED_COMMENT_SIZE
#define MED_COMMENT_SIZE
Definition: med.h:79
MED_ERR_FIELD
#define MED_ERR_FIELD
Definition: med_err.h:91
MEDfieldValueAdvancedWr
MEDC_EXPORT med_err MEDfieldValueAdvancedWr(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_float dt, const med_entity_type entitype, const med_geometry_type geotype, const char *const localizationname, const med_filter *const filter, const unsigned char *const value)
Cette fonction permet d'écire les valeurs d'un champ définies sur des entités d'un maillage pour une ...
Definition: MEDfieldValueAdvancedWr.c:46
generateFieldFile
med_err generateFieldFile(const med_size nentities, const med_size nvaluesperentity, const med_size nconstituentpervalue, const med_switch_mode constituentmode, GetBlocksOfEntitiesType getBlockOfEntities, const med_int nbblocksperproc, GenerateDataType generateDatas, const med_storage_mode storagemode, const med_size profilearraysize, const char *const fieldnameprefix, COM_info *const cominfo)
Definition: filterBlockOfentities.c:95
MEDnProfile
MEDC_EXPORT med_int MEDnProfile(const med_idt fid)
Cette routine permet de lire le nombre de profils dans un fichier MED.
Definition: MEDnProfile.c:37
med_filter
Filtre de sélection.
Definition: med.h:355
MEDfield23ValueWithProfileRd
MEDC_EXPORT med_err MEDfield23ValueWithProfileRd(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const char *const meshname, const med_storage_mode storagemode, const char *const profilename, const med_switch_mode switchmode, const med_int componentselect, unsigned char *const value)
Cette fonction permet de lire les valeurs d'un champ définies sur des entités d'un maillage pour une ...
Definition: MEDfield23ValueWithProfileRd.c:43
MED_FILTER_INIT
#define MED_FILTER_INIT
Definition: med.h:374
MED_ERR_LOCALIZATION
#define MED_ERR_LOCALIZATION
Definition: med_err.h:89
MEDmeshCr
MEDC_EXPORT med_err MEDmeshCr(const med_idt fid, const char *const meshname, const med_int spacedim, const med_int meshdim, const med_mesh_type meshtype, const char *const description, const char *const dtunit, const med_sorting_type sortingtype, const med_axis_type axistype, const char *const axisname, const char *const axisunit)
Cette routine permet de créer un maillage dans un fichier.
Definition: MEDmeshCr.c:45
MEDmeshnEntity
MEDC_EXPORT med_int MEDmeshnEntity(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_data_type datatype, const med_connectivity_mode cmode, med_bool *const changement, med_bool *const transformation)
Cette routine permet de lire le nombre d'entités dans un maillage pour une étape de calcul donnée.
Definition: MEDmeshnEntity.c:44
MEDnLink
MEDC_EXPORT med_int MEDnLink(const med_idt fid)
Cette routine permet la lecture du nombre de lien dans un fichier MED.
Definition: MEDnLink.c:34
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
GenerateDataType
void(* GenerateDataType)(const int myrank, const int lastrank, const int sizeoftype, const med_storage_mode profilemode, const med_size profilesize, const med_int *const profilearray, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, const int nentities, const int nvaluesperentity, const int nconstituentpervalue, med_float **valuesarray)
Definition: generateDatas.h:27
med_geometry_type
int med_geometry_type
Definition: med.h:194
MED_SNAME_SIZE
#define MED_SNAME_SIZE
Definition: med.h:82
MEDnField
MEDC_EXPORT med_int MEDnField(const med_idt fid)
Cette fonction permet de lire le nombre de champs dans un fichier.
Definition: MEDnField.c:35
MED_PARTICLE_NAME
#define MED_PARTICLE_NAME
Definition: med.h:454
ISCRUTE_int
#define ISCRUTE_int(entier)
Definition: med_utils.h:314
MED_DESCENDING_FACE
Definition: med.h:143
med_size
hsize_t med_size
Definition: med.h:329
MEDinterpBaseFunctionWr
MEDC_EXPORT med_err MEDinterpBaseFunctionWr(const med_idt fid, const char *const interpname, const med_int basisfuncit, const med_int ncoef, const med_int *const power, const med_float *const coefficient)
Cette routine permet l'écriture d'une fonction de base/forme de l'interpolation interpname.
Definition: MEDinterpBaseFunctionWr.c:41
med_idt
hid_t med_idt
Definition: med.h:331
MEDinterpCr
MEDC_EXPORT med_err MEDinterpCr(const med_idt fid, const char *const interpname, const med_geometry_type geotype, const med_bool cellnodes, const med_int nvariable, const med_int maxdegree, const med_int nmaxcoef)
Cette routine permet de créer une nouvelle fonction d'interpolation polynômiale nommée interpname.
Definition: MEDinterpCr.c:43
MED_ERR_
#define MED_ERR_(rt, r1, r2, r3)
Definition: med_utils.h:160
MEDinterpInfoByName
MEDC_EXPORT med_err MEDinterpInfoByName(const med_idt fid, const char *const interpname, med_geometry_type *const geotype, med_bool *const cellnode, med_int *const nbasisfunc, med_int *const nvariable, med_int *const maxdegree, med_int *const nmaxcoef)
Cette fonction informe des caractéristiques de la fonction d'interpolation nommée interpname.
Definition: MEDinterpInfoByName.c:41
MEDfieldnInterp
MEDC_EXPORT med_int MEDfieldnInterp(const med_idt fid, const char *const fieldname)
Cette routine renvoie le nombre de fonctions d'interpolation associées au champ résultat fieldname.
Definition: MEDfieldnInterp.c:35
MEDfieldValueAdvancedRd
MEDC_EXPORT med_err MEDfieldValueAdvancedRd(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_filter *const filter, unsigned char *const value)
Cette fonction permet de lire les valeurs d'un champ définies sur des entités d'un maillage pour une ...
Definition: MEDfieldValueAdvancedRd.c:43
MED_ACC_RDONLY
Definition: med.h:120
USER_INTERLACE
#define USER_INTERLACE
Definition: 3.0.8/test10.c:45
getFieldsOn
med_err getFieldsOn(med_idt fid, char *nomcha, med_field_type typcha, med_int ncomp, med_entity_type entite, med_switch_mode stockage, med_int ncstp)
Definition: test11.c:303
MED_UNDEF_STMODE
Definition: med.h:108
generateNoIDatas
void generateNoIDatas(const int myrank, const int lastrank, const int sizeoftype, const med_storage_mode storagemode, const med_size profilearraysize, const med_int *const profilearray, const med_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, const int nentities, const int nvaluesperentity, const int nconstituentpervalue, med_float **valuesarray)
Definition: generateDatas.c:103
COM_info::filterarray
med_int * filterarray
Definition: filterBlockOfentities.c:90
MED_STRUCT_ELEMENT
Definition: med.h:144
med_err
herr_t med_err
Definition: med.h:332
MEDfileObjectsUnmount
MEDC_EXPORT med_err MEDfileObjectsUnmount(const med_idt fid, const med_idt mid, const med_class medclass)
Une fois le démontage effectué, les données précédemment montées ne sont plus accessibles.
Definition: MEDfileObjectsUnmount.c:33
MED_N_NODE_FIXED_GEO
#define MED_N_NODE_FIXED_GEO
Definition: med.h:251
med_sorting_type
med_sorting_type
Definition: med.h:309
MED_GET_FACE_GEOMETRY_TYPE
med_geometry_type MED_GET_FACE_GEOMETRY_TYPE[MED_N_FACE_FIXED_GEO+2]
Definition: MEDiterators.c:114
MEDfilterBlockOfEntityCr
MEDC_EXPORT med_err MEDfilterBlockOfEntityCr(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_size start, const med_size stride, const med_size count, const med_size blocksize, const med_size lastblocksize, med_filter *const filter)
Crée un filtre en selectionnant par blocs les entités pour lesquelles on veut lire/écrire des valeurs...
Definition: MEDfilterBlockOfEntityCr.c:52
MED_NO_LOCALIZATION
#define MED_NO_LOCALIZATION
Definition: med.h:275
med_entity_type
med_entity_type
Definition: med.h:143
MED_NO_CMODE
Definition: med.h:255
getBlocksOfEntitiesPartition.h
MED_FALSE
Definition: med.h:260
MED_ERR_CLOSE
#define MED_ERR_CLOSE
Definition: med_err.h:30
MED_ERR_OPEN
#define MED_ERR_OPEN
Definition: med_err.h:37
MED_CELL
Definition: med.h:143
MEDfieldnValueWithProfile
MEDC_EXPORT med_int MEDfieldnValueWithProfile(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const int profileit, const med_storage_mode storagemode, char *const profilename, med_int *const profilesize, char *const localizationname, med_int *const nintegrationpoint)
Cette fonction permet de lire le nombre de valeurs à lire dans un champ pour une étape de calcul,...
Definition: MEDfieldnValueWithProfile.c:45
COM_info::comm
MPI_Comm comm
Definition: filterBlockOfentities.c:86
MED_ERR_FILTER
#define MED_ERR_FILTER
Definition: med_err.h:93
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
MEDlinkWr
MEDC_EXPORT med_err MEDlinkWr(const med_idt fid, const char *const meshname, const char *const link)
Cette routine permet d'écrire un lien dans un fichier MED.
Definition: MEDlinkWr.c:36
MEDlocalizationRd
MEDC_EXPORT med_err MEDlocalizationRd(const med_idt fid, const char *const localizationname, const med_switch_mode switchmode, med_float *const elementcoordinate, med_float *const ipointcoordinate, med_float *const weight)
Cette routine permet la lecture d'une localisation localizationname de points d'intégration dans/auto...
Definition: MEDlocalizationRd.c:44
med_int
int med_int
Definition: med.h:342
MED_NO_MESH_SUPPORT
#define MED_NO_MESH_SUPPORT
Definition: med.h:273
med_field_type
med_field_type
Definition: med.h:165
MED_ERR_FILE
#define MED_ERR_FILE
Definition: med_err.h:82
MED_UNDEF_DATATYPE
Definition: med.h:152
MED_ERR_WRITE
#define MED_ERR_WRITE
Definition: med_err.h:29
MED_ACC_RDWR
Definition: med.h:121
MEDfield23ComputingStepMeshInfo
MEDC_EXPORT med_err MEDfield23ComputingStepMeshInfo(const med_idt fid, const char *const fieldname, const int csit, med_int *const numdt, med_int *const numit, med_float *const dt, med_int *const nmesh, char *const meshname, med_bool *const localmesh, med_int *const meshnumdt, med_int *const meshnumit)
Cette fonction permet de lire les informations caractérisant une étape de calcul : numéro de pas de t...
Definition: MEDfield23ComputingStepMeshInfo.c:43
MEDfieldInterpWr
MEDC_EXPORT med_err MEDfieldInterpWr(const med_idt fid, const char *const fieldname, const char *const interpname)
Cette routine associe une fonction d'interpolation interpname au champ résultat fieldname.
Definition: MEDfieldInterpWr.c:36
MEDnLocalization
MEDC_EXPORT med_int MEDnLocalization(const med_idt fid)
Cette routine permet de lire le nombre de localisations de points d'intégration contenues dans un fic...
Definition: MEDnLocalization.c:36
MED_GET_CELL_GEOMETRY_TYPE
med_geometry_type MED_GET_CELL_GEOMETRY_TYPE[MED_N_CELL_FIXED_GEO+2]
Definition: MEDiterators.c:55
med.h
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:313
med_bool
med_bool
Definition: med.h:260
MEDlinkRd
MEDC_EXPORT med_err MEDlinkRd(const med_idt fid, const char *const meshname, char *const link)
Cette routine permet de lire un lien dans un fichier MED.
Definition: MEDlinkRd.c:37
MEDfield23nProfile
MEDC_EXPORT med_int MEDfield23nProfile(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const int meshit, char *const meshname, char *const defaultprofilename, char *const defaultlocalizationname)
Cette fonction permet de lire le nombre de profils référencés dans un champ pour une étape de calcul,...
Definition: MEDfield23nProfile.c:41
MED_MESH_SUPPORT
Definition: med.h:189
MEDfieldInterpInfo
MEDC_EXPORT med_err MEDfieldInterpInfo(const med_idt fid, const char *const fieldname, const int interpit, char *const interpname)
Cette routine indique le nom interpname de la interpit ème fonction d'interpolation associées au cham...
Definition: MEDfieldInterpInfo.c:37
med_float
double med_float
Definition: med.h:336
MED_ERR_READ
#define MED_ERR_READ
Definition: med_err.h:28
MED_GET_NODE_GEOMETRY_TYPENAME
const char * MED_GET_NODE_GEOMETRY_TYPENAME[MED_N_NODE_FIXED_GEO+2]
Definition: MEDiterators.c:162
COM_info::mpi_rank
int mpi_rank
Definition: filterBlockOfentities.c:88
MED_GEO_ALL
#define MED_GEO_ALL
Definition: med.h:236
MEDinterpBaseFunctionCoefSize
MEDC_EXPORT med_int MEDinterpBaseFunctionCoefSize(const med_idt fid, const char *const interpname, const med_int basisfuncit)
Cette routine retourne ne nombre de coefficients/monômes de la fonction de base/forme n° basisfunctit...
Definition: MEDinterpBaseFunctionCoeffSize.c:37
IFORMAT
#define IFORMAT
Definition: med_utils.h:145
MEDfileObjectsMount
MEDC_EXPORT med_idt MEDfileObjectsMount(const med_idt fid, const char *const filename, const med_class medclass)
Cette routine permet de monter dans le fichier courant un type de données (exemples les maillages,...
Definition: MEDfileObjectsMount.c:40
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
MED_NONE
#define MED_NONE
Definition: med.h:231
MEDparFileOpen
med_idt MEDparFileOpen(const char *const filename, const med_access_mode accessmode, const MPI_Comm comm, const MPI_Info info)
Ouverture d'un fichier MED pour une utilisation parallèle.
Definition: MEDparFileOpen.c:49
MEDfilterClose
MEDC_EXPORT med_err MEDfilterClose(med_filter *const filter)
Désalloue les ressources hdf détenues par un filtre.
Definition: MEDfilterClose.c:35
COM_info::info
MPI_Info info
Definition: filterBlockOfentities.c:85
generateFilterArray.h
MED_BEAM_NAME
#define MED_BEAM_NAME
Definition: med.h:456
MEDinterpInfo
MEDC_EXPORT med_err MEDinterpInfo(const med_idt fid, const int interpit, char *const interpname, med_geometry_type *const geotype, med_bool *const cellnode, med_int *const nbasisfunc, med_int *const nvariable, med_int *const maxdegree, med_int *const nmaxcoef)
Cette fonction informe des caractéristiques de la fonction d'interpolation n° interpit.
Definition: MEDinterpInfo.c:43
MED_UNDEF_INTERLACE
Definition: med.h:100
MED_NODE
Definition: med.h:143
MED_GET_CELL_GEOMETRY_TYPENAME
const char *const MED_GET_CELL_GEOMETRY_TYPENAME[MED_N_CELL_FIXED_GEO+2]
Definition: MEDiterators.c:84
MED_N_FACE_FIXED_GEO
#define MED_N_FACE_FIXED_GEO
Definition: med.h:243
MEDfieldnProfile
MEDC_EXPORT med_int MEDfieldnProfile(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type enttype, const med_geometry_type geotype, char *const defaultprofilename, char *const defaultlocalizationname)
Cette fonction permet de lire le nombre de profils référencés dans un champ pour une étape de calcul,...
Definition: MEDfieldnProfile.c:40
MEDinterpBaseFunctionRd
MEDC_EXPORT med_err MEDinterpBaseFunctionRd(const med_idt fid, const char *const interpname, const int basisfuncit, med_int *const ncoef, med_int *const power, med_float *const coefficient)
Cette routine permet la lecture d'une fonction de base/forme de l'interpolation interpname.
Definition: MEDinterpBaseFunctionRd.c:41
MEDprofileSizeByName
MEDC_EXPORT med_int MEDprofileSizeByName(const med_idt fid, const char *const profilename)
Cette routine permet de lire la taille d'un profil dont on connait le nom.
Definition: MEDprofileSizeByName.c:37
MED_MESH
Definition: med.h:188
generateFilterArray
med_err generateFilterArray(const med_size nentities, const med_size nvaluesperentity, const med_size nconstituentpervalue, const med_size profilearraysize, const med_int *const profilearray, med_int *const nentitiesfiltered, med_int **filterarray)
Definition: generateFilterArray.c:30
MEDnStructElement
MEDC_EXPORT med_int MEDnStructElement(const med_idt fid)
Cette routine renvoie le nombre de modèles d'éléments de structure.
Definition: MEDnStructElement.c:35
getCyclicBlocksOfEntities
void getCyclicBlocksOfEntities(const int myrank, const int nproc, const int nentities, med_size *const start, med_size *const stride, med_size *const io_count, med_size *blocksize, int *const lastusedrank, med_size *const lastblocksize)
Definition: getBlocksOfEntitiesPartition.c:79
MED_N_CELL_FIXED_GEO
#define MED_N_CELL_FIXED_GEO
Definition: med.h:239
MED_GET_ENTITY_TYPENAME
const char *const MED_GET_ENTITY_TYPENAME[MED_N_ENTITY_TYPES+2]
Definition: MEDiterators.c:36
med_mesh_type
med_mesh_type
Definition: med.h:131
MODE_ACCES
#define MODE_ACCES
Definition: 3.0.8/test10.c:34
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
MEDlocalizationInfo
MEDC_EXPORT med_err MEDlocalizationInfo(const med_idt fid, const int localizationit, char *const localizationname, med_geometry_type *const geotype, med_int *const spacedimension, med_int *const nipoint, char *const geointerpname, char *const sectionmeshname, med_int *const nsectionmeshcell, med_geometry_type *const sectiongeotype)
Cette routine permet d'obtenir la description de la localisation de points d'intégration n° localizat...
Definition: MEDlocalizationInfo.c:46
MED_GET_NODE_GEOMETRY_TYPE
med_geometry_type MED_GET_NODE_GEOMETRY_TYPE[MED_N_NODE_FIXED_GEO+2]
Definition: MEDiterators.c:156
MEDfieldValueWithProfileRd
MEDC_EXPORT med_err MEDfieldValueWithProfileRd(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const med_storage_mode storagemode, const char *const profilename, const med_switch_mode switchmode, const med_int componentselect, unsigned char *const value)
Cette fonction permet de lire les valeurs d'un champ définies sur des entités d'un maillage pour une ...
Definition: MEDfieldValueWithProfileRd.c:42
MED_ACC_CREAT
Definition: med.h:123
MED_GLOBAL_STMODE
Definition: med.h:109
MEDfield23nValueWithProfile
MEDC_EXPORT med_int MEDfield23nValueWithProfile(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_entity_type entitype, const med_geometry_type geotype, const char *const meshname, const int profileit, const med_storage_mode storagemode, char *const profilename, med_int *const profilesize, char *const localizationname, med_int *const nintegrationpoint)
Cette fonction permet de lire le nombre de valeurs à lire dans un champ pour une étape de calcul,...
Definition: MEDfield23nValueWithProfile.c:46
MEDstructElementGeotype
MEDC_EXPORT med_geometry_type MEDstructElementGeotype(const med_idt fid, const char *const modelname)
Cette routine renvoie le type géométrique mgeotype associé au modèle d'éléments de structure de nom m...
Definition: MEDstructElementGeotype.c:38
med_switch_mode
med_switch_mode
Definition: med.h:96
MEDprofileWr
MEDC_EXPORT med_err MEDprofileWr(const med_idt fid, const char *const profilename, const med_int profilesize, const med_int *const profilearray)
Cette routine permet d'écrire un profil dans un fichier MED.
Definition: MEDprofileWr.c:40
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MEDfieldComputingStepInfo
MEDC_EXPORT med_err MEDfieldComputingStepInfo(const med_idt fid, const char *const fieldname, const int csit, med_int *const numdt, med_int *const numit, med_float *const dt)
Cette fonction permet de lire les informations caractérisant une étape de calcul : numéro de pas de t...
Definition: MEDfieldComputingStepInfo.c:39
MED_UNSTRUCTURED_MESH
Definition: med.h:131
generateDatas.h
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
med_config.h
MED_N_EDGE_FIXED_GEO
#define MED_N_EDGE_FIXED_GEO
Definition: med.h:247
MED_ALL_CONSTITUENT
#define MED_ALL_CONSTITUENT
Definition: med.h:299
MEDfieldValueWithProfileWr
MEDC_EXPORT med_err MEDfieldValueWithProfileWr(const med_idt fid, const char *const fieldname, const med_int numdt, const med_int numit, const med_float dt, const med_entity_type entitype, const med_geometry_type geotype, const med_storage_mode storagemode, const char *const profilename, const char *const localizationname, const med_switch_mode switchmode, const med_int componentselect, const med_int nentity, const unsigned char *const value)
Cette fonction permet d'écrire les valeurs d'un champ définies sur des entités d'un maillage pour une...
Definition: MEDfieldValueWithProfileWr.c:48
EXIT_IF
#define EXIT_IF(expression, message, arg)
Definition: med_utils.h:343
MED_COMPACT_STMODE
Definition: med.h:110
MED_GET_FACE_GEOMETRY_TYPENAME
const char *const MED_GET_FACE_GEOMETRY_TYPENAME[MED_N_FACE_FIXED_GEO+2]
Definition: MEDiterators.c:127
MED_NO_PROFILE
#define MED_NO_PROFILE
Definition: med.h:281
MED_NO_INTERLACE
Definition: med.h:98
COM_info
Definition: filterBlockOfentities.c:84
MEDfieldInfo
MEDC_EXPORT med_err MEDfieldInfo(const med_idt fid, const int ind, char *const fieldname, char *const meshname, med_bool *const localmesh, med_field_type *const fieldtype, char *const componentname, char *const componentunit, char *const dtunit, med_int *const ncstp)
Cette fonction permet de lire les informations concernant le champ d'indice ind .
Definition: MEDfieldInfo.c:42
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:322
med_axis_type
med_axis_type
Definition: med.h:258
COM_info::mpi_size
int mpi_size
Definition: filterBlockOfentities.c:87
GetBlocksOfEntitiesType
void(* GetBlocksOfEntitiesType)(const int myrank, const int nproc, const int nentities, med_size *const start, med_size *const stride, med_size *const count, med_size *blocksize, int *const lastusedrank, med_size *const lastblocksize)
Definition: getBlocksOfEntitiesPartition.h:28
MED_FLOAT64
Definition: med.h:166
MEDstructElementInfo
MEDC_EXPORT med_err MEDstructElementInfo(const med_idt fid, const int mit, char *const modelname, med_geometry_type *const mgeotype, med_int *const modeldim, char *const supportmeshname, med_entity_type *const sentitytype, med_int *const snnode, med_int *const sncell, med_geometry_type *const sgeotype, med_int *const nconstantattribute, med_bool *const anyprofile, med_int *const nvariableattribute)
Cette routine décrit les caractéristiques d'un modèle d'élément de structure par itération.
Definition: MEDstructElementInfo.c:50
MEDlinkInfoByName
MEDC_EXPORT med_int MEDlinkInfoByName(const med_idt fid, const char *const meshname)
Cette routine permet de lire les informations sur un lien dans un fichier MED.
Definition: MEDlinkInfoByName.c:36
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
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
med_storage_mode
med_storage_mode
Definition: med.h:108
MED_GET_EDGE_GEOMETRY_TYPE
med_geometry_type MED_GET_EDGE_GEOMETRY_TYPE[MED_N_EDGE_FIXED_GEO+2]
Definition: MEDiterators.c:140
MEDprofileRd
MEDC_EXPORT med_err MEDprofileRd(const med_idt fid, const char *const profilename, med_int *const profilearray)
Cette routine permet de lire un profil dans un fichier MED.
Definition: MEDprofileRd.c:39
COM_info::nentitiesfiltered
med_int nentitiesfiltered
Definition: filterBlockOfentities.c:89
MED_ELSTRUCT
Definition: med.h:189
MED_NO_INTERPOLATION
#define MED_NO_INTERPOLATION
Definition: med.h:277
MED_ERR_PROFILE
#define MED_ERR_PROFILE
Definition: med_err.h:94
MEDfieldnComponent
MEDC_EXPORT med_int MEDfieldnComponent(const med_idt fid, const int ind)
Cette fonction lit le nombre de composantes d'un champ.
Definition: MEDfieldnComponent.c:34
MEDlocalizationWr
MEDC_EXPORT med_err MEDlocalizationWr(const med_idt fid, const char *const localizationname, const med_geometry_type geotype, const med_int spacedimension, const med_float *const elementcoordinate, const med_switch_mode switchmode, const med_int nipoint, const med_float *const ipointcoordinate, const med_float *const weight, const char *const geointerpname, const char *const ipointstructmeshname)
Cette routine permet l'écriture d'une localisation localizationname de points d'intégration dans/auto...
Definition: MEDlocalizationWr.c:49
main
int main(int argc, char **argv)
Definition: 3.0.8/test10.c:50
MEDprofileInfo
MEDC_EXPORT med_err MEDprofileInfo(const med_idt fid, const int profileit, char *const profilename, med_int *const profilesize)
Cette routine permet de lire les informations sur un profil dans un fichier MED.
Definition: MEDprofileInfo.c:40
med_utils.h
MED_QUAD4
#define MED_QUAD4
Definition: med.h:204
MED_TRIA6
#define MED_TRIA6
Definition: med.h:205
USER_MODE
#define USER_MODE
Definition: 3.0.8/test10.c:48
MED_NODE_ELEMENT
Definition: med.h:144
MED_DESCENDING_EDGE
Definition: med.h:143
MED_ERR_MESH
#define MED_ERR_MESH
Definition: med_err.h:83