MED fichier
test23.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2021 EDF R&D, CEA/DEN
4  * MED is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * MED is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with MED. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 /******************************************************************************
20  * - Nom du fichier : test23.c
21  *
22  * - Description : ecriture de mailles/faces de type MED_POLYGONE
23  * dans un maillage MED
24  *
25  *****************************************************************************/
26 
27 #include <med.h>
28 #define MESGERR 1
29 #include <med_utils.h>
30 
31 #ifdef DEF_LECT_ECR
32 #define MODE_ACCES MED_ACC_RDWR
33 #elif DEF_LECT_AJOUT
34 #define MODE_ACCES MED_ACC_RDEXT
35 #else
36 #define MODE_ACCES MED_ACC_CREAT
37 #endif
38 
39 int main (int argc, char **argv)
40 
41 
42 {
43  med_idt fid;
44  char maa[MED_NAME_SIZE+1] = "maa1";
45  med_int mdim = 3;
46  med_int index[4] = {1,6,12,17};
47  med_int con[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
48  med_int n=3,ni = 4;
49  /* 123456789012345612345678901234561234567890123456 */
50  char nom[MED_SNAME_SIZE*3+1]="poly1 poly2 poly3 ";
51  med_int num[3] = {1,2,3};
52  med_int fam[3] = {0,-1,-2};
53  char nomcoo[3*MED_SNAME_SIZE+1] = "x y z ";
54  char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm ";
55 
56  /* Creation du fichier test23.med */
57  fid = MEDfileOpen("test23.med",MODE_ACCES);
58  if (fid == -1) {
59  MESSAGE("Erreur a la creation du fichier test23.med");
60  return -1;
61  }
62  printf("Creation du fichier test23.med \n");
63 
64  /* Creation du maillage */
65  if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
66  "un maillage pour test23","s", MED_SORT_DTIT,
67  MED_CARTESIAN, nomcoo, unicoo) < 0) {
68  MESSAGE("Erreur a la creation du maillage");
69  return -1;
70  }
71  printf("Creation du maillage \n");
72 
73 
74  /* Ecriture de la connectivite des mailles polygones en mode nodal */
76  ni,index,con) < 0) {
77  MESSAGE("Erreur a l'ecriture de la connectivite des mailles MED_POLYGONE");
78  return -1;
79  }
80  printf("Ecriture des connectivites de mailles de type MED_POLYGONE en mode nodal \n");
81 
82  /* Ecriture des noms des polygones */
83  /* ecriture (optionnelle) des noms des polygones */
85  MED_CELL,MED_POLYGON,n,nom) < 0) {
86  MESSAGE("Erreur a l'ecriture des noms des polygones");
87  return -1;
88  }
89  printf("Ecriture des noms des polygones \n");
90 
91  /* ecriture (optionnelle) des numeros des polygones */
93  MED_CELL,MED_POLYGON,n,num) < 0) {
94  MESSAGE("Erreur a l'ecriture des numeros des polygones");
95  return -1;
96  }
97  printf("Ecriture des numeros des polygones \n");
98 
99  /* ecriture des numeros des familles des polygones */
101  MED_CELL,MED_POLYGON,n,fam) < 0) {
102  MESSAGE("Erreur a l'ecriture des numeros de familles des polygones");
103  return -1;
104  }
105  printf("Ecriture des numeros des familles des polygones \n");
106 
107  /* Fermeture du fichier */
108  if (MEDfileClose(fid) < 0) {
109  MESSAGE("Erreur a la fermeture du fichier");
110  return -1;
111  }
112  printf("Fermeture du fichier test23.med \n");
113 
114  return 0;
115 }
MED_CARTESIAN
Definition: med.h:258
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
MED_SORT_DTIT
Definition: med.h:309
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
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
MED_SNAME_SIZE
#define MED_SNAME_SIZE
Definition: med.h:82
MED_NODAL
Definition: med.h:255
med_idt
hid_t med_idt
Definition: med.h:331
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
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_CELL
Definition: med.h:143
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
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_int
int med_int
Definition: med.h:342
med.h
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
MODE_ACCES
#define MODE_ACCES
Definition: test23.c:35
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MED_UNSTRUCTURED_MESH
Definition: med.h:131
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
main
int main(int argc, char **argv)
Definition: test23.c:38
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:322
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
med_utils.h
MED_POLYGON
#define MED_POLYGON
Definition: med.h:223