MED fichier: c/test23.c

MED fichier

c/test23.c
/* This file is part of MED.
*
* COPYRIGHT (C) 1999 - 2023 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 : test23.c
*
* - Description : ecriture de mailles/faces de type MED_POLYGONE
* dans un maillage MED
*
*****************************************************************************/
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#ifdef DEF_LECT_ECR
#define MODE_ACCES MED_ACC_RDWR
#elif DEF_LECT_AJOUT
#define MODE_ACCES MED_ACC_RDEXT
#else
#define MODE_ACCES MED_ACC_CREAT
#endif
int main (int argc, char **argv)
{
med_idt fid;
char maa[MED_NAME_SIZE+1] = "maa1";
med_int mdim = 3;
med_int index[4] = {1,6,12,17};
med_int con[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
med_int n=3,ni = 4;
/* 123456789012345612345678901234561234567890123456 */
char nom[MED_SNAME_SIZE*3+1]="poly1 poly2 poly3 ";
med_int num[3] = {1,2,3};
med_int fam[3] = {0,-1,-2};
char nomcoo[3*MED_SNAME_SIZE+1] = "x y z ";
char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm ";
/* Creation du fichier test23.med */
fid = MEDfileOpen("test23.med",MODE_ACCES);
if (fid == -1) {
MESSAGE("Erreur a la creation du fichier test23.med");
return -1;
}
printf("Creation du fichier test23.med \n");
/* Creation du maillage */
if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
"un maillage pour test23","s", MED_SORT_DTIT,
MED_CARTESIAN, nomcoo, unicoo) < 0) {
MESSAGE("Erreur a la creation du maillage");
return -1;
}
printf("Creation du maillage \n");
/* Ecriture de la connectivite des mailles polygones en mode nodal */
if (MEDmeshPolygonWr(fid,maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT, MED_CELL, MED_NODAL,
ni,index,con) < 0) {
MESSAGE("Erreur a l'ecriture de la connectivite des mailles MED_POLYGONE");
return -1;
}
printf("Ecriture des connectivites de mailles de type MED_POLYGONE en mode nodal \n");
/* Ecriture des noms des polygones */
/* ecriture (optionnelle) des noms des polygones */
if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
MED_CELL, MED_POLYGON,n,nom) < 0) {
MESSAGE("Erreur a l'ecriture des noms des polygones");
return -1;
}
printf("Ecriture des noms des polygones \n");
/* ecriture (optionnelle) des numeros des polygones */
if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
MED_CELL,MED_POLYGON,n,num) < 0) {
MESSAGE("Erreur a l'ecriture des numeros des polygones");
return -1;
}
printf("Ecriture des numeros des polygones \n");
/* ecriture des numeros des familles des polygones */
if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
MED_CELL,MED_POLYGON,n,fam) < 0) {
MESSAGE("Erreur a l'ecriture des numeros de familles des polygones");
return -1;
}
printf("Ecriture des numeros des familles des polygones \n");
/* Fermeture du fichier */
if (MEDfileClose(fid) < 0) {
MESSAGE("Erreur a la fermeture du fichier");
return -1;
}
printf("Fermeture du fichier test23.med \n");
return 0;
}
MED_UNSTRUCTURED_MESH
Definition: med.h:133
MED_SNAME_SIZE
#define MED_SNAME_SIZE
Definition: med.h:84
med_idt
hid_t med_idt
Definition: med.h:333
MEDmeshEntityNumberWr
MEDC_EXPORT med_err MEDmeshEntityNumberWr(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_int nentity, const med_int *const number)
Cette routine permet d'écrire les numéros d'un type d'entité d'un maillage.
Definition: MEDmeshEntityNumberWr.c:39
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:344
MED_SORT_DTIT
Definition: med.h:311
MEDmeshEntityFamilyNumberWr
MEDC_EXPORT med_err MEDmeshEntityFamilyNumberWr(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_int nentity, const med_int *const number)
Cette routine permet l'écriture des numéros de famille d'un type d'entité d'un maillage.
Definition: MEDmeshEntityFamilyNumberWr.c:39
MED_NO_DT
#define MED_NO_DT
Definition: med.h:322
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
MODE_ACCES
#define MODE_ACCES
Definition: 3.0.8/test10.c:34
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
MED_CELL
Definition: med.h:145
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:83
MED_CARTESIAN
Definition: med.h:260
med_utils.h
MEDmeshEntityNameWr
MEDC_EXPORT med_err MEDmeshEntityNameWr(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_int nentity, const char *const name)
Cette routine permet d'écrire les noms d'un type d'entité d'un maillage.
Definition: MEDmeshEntityNameWr.c:39
MEDmeshPolygonWr
MEDC_EXPORT med_err MEDmeshPolygonWr(const med_idt fid, const char *const meshname, const med_int numdt, const med_int numit, const med_float dt, const med_entity_type entitype, const med_connectivity_mode cmode, const med_int indexsize, const med_int *const polyindex, const med_int *const connectivity)
Cette routine permet l'écriture des connectivités de polygones.
Definition: MEDmeshPolygonWr.c:45
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:324
med.h
MED_NO_IT
#define MED_NO_IT
Definition: med.h:323
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
main
int main(int argc, char **argv)
Definition: 3.0.8/test10.c:50
MED_NODAL
Definition: med.h:257
MED_POLYGON
#define MED_POLYGON
Definition: med.h:225