MED fichier
test6.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 : test6.c
21  *
22  * - Description : ecriture d'elements dans un maillage MED
23  *
24  *****************************************************************************/
25 
26 #include <med.h>
27 #define MESGERR 1
28 #include <med_utils.h>
29 
30 #ifdef DEF_LECT_ECR
31 #define MODE_ACCES MED_ACC_RDWR
32 #elif DEF_LECT_AJOUT
33 #define MODE_ACCES MED_ACC_RDEXT
34 #else
35 #define MODE_ACCES MED_ACC_CREAT
36 #endif
37 
38 int main (int argc, char **argv)
39 
40 
41 {
42  med_idt fid;
43  med_int nse2 = 5;
44  med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
45  /* 12345678901234561234567890123456123456789012345612345678901234561234567890123456*/
46  char nomse2[MED_SNAME_SIZE*5+1]="se1 se2 se3 se4 se5 ";
47  med_int numse2[5] = {1,2,3,4,5};
48  med_int nufase2[5] = {-1,-1,0,-2,-3};
49  med_int ntr3 = 2;
50  med_int tr3[6] = {1,2,-5,-5,3,-4};
51  /* 12345678901234561234567890123456*/
52  char nomtr3[MED_SNAME_SIZE*2+1] = "tr1 tr2 ";
53  med_int numtr3[2] = {4,5};
54  med_int nufatr3[2] = {0,-1};
55  char maa[MED_NAME_SIZE+1] = "maa1";
56  med_int mdim = 2;
57  char nomcoo[2*MED_SNAME_SIZE+1] = "x y ";
58  char unicoo[2*MED_SNAME_SIZE+1] = "cm cm ";
59 
60  /* ouverture du fichier */
61  if ((fid = MEDfileOpen("test6.med",MODE_ACCES)) < 0) {
62  MESSAGE("Impossible de creer le fichier test6.med : ");
63  return -1;
64  }
65 
66  if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
67  "un maillage pour test6","s", MED_SORT_DTIT,
68  MED_CARTESIAN, nomcoo, unicoo) < 0) {
69  MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
70  return -1;
71  }
72 
73 
74  /* ecriture des connectivites des segments */
77  MED_FULL_INTERLACE, nse2,se2) < 0 ) {
78  MESSAGE("Impossible d'ecrire la connectivité des segments: ");
79  return -1;
80  }
81 
82 
83 
84  /* ecriture (optionnelle) des noms des segments */
86  MED_DESCENDING_EDGE,MED_SEG2,nse2,nomse2) < 0) {
87  MESSAGE("Erreur a l'ecriture des noms des segments");
88  return -1;
89  }
90 
91  /* ecriture (optionnelle) des numeros des segments */
93  MED_DESCENDING_EDGE,MED_SEG2,nse2,numse2) < 0) {
94  MESSAGE("Erreur a l'ecriture des numeros des segments");
95  return -1;
96  }
97 
98  /* ecriture des numeros des familles des segments */
100  MED_DESCENDING_EDGE,MED_SEG2,nse2,nufase2) < 0) {
101  MESSAGE("Erreur a l'ecriture des numeros de familles des segments");
102  return -1;
103  }
104 
105  /* ecriture des connectivites des triangles */
108  MED_FULL_INTERLACE, ntr3,tr3) < 0 ) {
109  MESSAGE("Impossible d'ecrire la connectivité des triangles : ");
110  return -1;
111  }
112 
113  /* ecriture (optionnelle) des noms des triangles */
115  MED_CELL, MED_TRIA3,ntr3,nomtr3) < 0) {
116  MESSAGE("Erreur a l'ecriture des noms des triangles");
117  return -1;
118  }
119 
120  /* ecriture (optionnelle) des numeros des triangles */
122  MED_CELL, MED_TRIA3,ntr3,numtr3) < 0) {
123  MESSAGE("Erreur a l'ecriture des numeros des triangles");
124  return -1;
125  }
126 
127  /* ecriture des numeros des familles des triangles */
129  MED_CELL, MED_TRIA3,ntr3,nufatr3) < 0) {
130  MESSAGE("Erreur a l'ecriture des numeros de familles des triangles");
131  return -1;
132  }
133 
134  /* fermeture du fichier */
135  if ( MEDfileClose(fid) < 0 ) {
136  MESSAGE("Impossible de fermerle fichier : ");
137  return -1;
138  }
139 
140  return 0;
141 
142 }
143 
144 
145 
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_TRIA3
#define MED_TRIA3
Definition: med.h:203
MED_FULL_INTERLACE
Definition: med.h:96
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_idt
hid_t med_idt
Definition: med.h:331
MODE_ACCES
#define MODE_ACCES
Definition: test6.c:34
MED_SEG2
#define MED_SEG2
Definition: med.h:200
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
med_int
int med_int
Definition: med.h:342
MED_DESCENDING
Definition: med.h:255
med.h
MED_NO_DT
#define MED_NO_DT
Definition: med.h:320
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
main
int main(int argc, char **argv)
Definition: test6.c:37
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
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:322
MEDmeshElementConnectivityWr
MEDC_EXPORT med_err MEDmeshElementConnectivityWr(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_geometry_type geotype, const med_connectivity_mode cmode, const med_switch_mode switchmode, const med_int nentity, const med_int *const connectivity)
Cette routine permet d'écrire dans un maillage le tableau des connectivités pour un type géométrique ...
Definition: MEDmeshElementConnectivityWr.c:42
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
med_utils.h
MED_DESCENDING_EDGE
Definition: med.h:143