MED fichier

test25.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 : test25.c
21 *
22 * - Description : ecriture de mailles de type MED_POLYEDRE
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 n=2;
47 /* connectivite nodale */
48 med_int indexf[3] = {1,5,9};
49 med_int nf = 3;
50 med_int indexn[9] = {1,4,7,10,13,16,19,22,25};
51 med_int nn = 9;
52 med_int conn[24] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
53 20,21,22,23,24};
54 /* connectivite descendante */
55 med_int indexf2[3] = {1,5,9};
56 med_int nf2 = 3;
57 med_int conn2[8] = {1,2,3,4,5,6,7,8};
58 med_int indexn2[8] = {MED_TRIA3,MED_TRIA3,MED_TRIA3,MED_TRIA3,
59 MED_TRIA3,MED_TRIA3,MED_TRIA3,MED_TRIA3};
60 med_int nn2=8;
61 /* 12345678901234561234567890123456*/
62 char nom[MED_SNAME_SIZE*2+1]="polyedre1 polyedre2 ";
63 med_int num[2] = {1,2};
64 med_int fam[2] = {0,-1};
65 char nomcoo[3*MED_SNAME_SIZE+1] = "x y z ";
66 char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm ";
67
68 /* Creation du fichier test25.med */
69 if ((fid = MEDfileOpen("test25.med",MODE_ACCES)) < 0) {
70 MESSAGE("Erreur a la creation du fichier test25.med");
71 return -1;
72 }
73 printf("Creation du fichier test25.med \n");
74
75 /* Creation du maillage */
76 if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
77 "un maillage pour test25","s", MED_SORT_DTIT,
78 MED_CARTESIAN, nomcoo, unicoo) < 0) {
79 MESSAGE("Erreur a la creation du maillage");
80 return -1;
81 }
82 printf("Creation du maillage \n");
83
84 /* Ecriture de la connectivite des mailles polyedres en mode nodal */
85 if (MEDmeshPolyhedronWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MED_CELL,MED_NODAL,
86 nf,indexf,nn,indexn,conn) < 0) {
87 MESSAGE("Erreur a l'ecriture de la connectivite des mailles MED_POLYGONE");
88 return -1;
89 }
90 printf("Ecriture des connectivites de mailles de type MED_POLYEDRE en mode nodal \n");
91
92 /* Ecriture des connectivites des mailles polyedres en mode descendant */
93 if (MEDmeshPolyhedronWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_UNDEF_DT,MED_CELL,MED_DESCENDING,
94 nf2,indexf2,nn2,indexn2,conn2) < 0) {
95 MESSAGE("Erreur a l'ecriture des connectivites des mailles MED_POLYEDRE en mode descendant");
96 return -1;
97 }
98 printf("Ecriture des connectivites de mailles de type MED_POLYEDRE en mode descendant \n");
99
100
101 /* Ecriture des noms des polyedres */
102 /* ecriture (optionnelle) des noms des polyedres */
103 if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
104 MED_CELL,MED_POLYHEDRON,n,nom) < 0) {
105 MESSAGE("Erreur a l'ecriture des noms des polyedres");
106 return -1;
107 }
108 printf("Ecriture des noms des polyedres \n");
109
110 /* ecriture (optionnelle) des numeros des polyedres */
111 if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
112 MED_CELL,MED_POLYHEDRON,n,num) < 0) {
113 MESSAGE("Erreur a l'ecriture des numeros des polyedres");
114 return -1;
115 }
116 printf("Ecriture des numeros des polyedres \n");
117
118 /* ecriture des numeros des familles des polyedres */
119 if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
120 MED_CELL,MED_POLYHEDRON,n,fam) < 0) {
121 MESSAGE("Erreur a l'ecriture des numeros de familles des polyedres");
122 return -1;
123 }
124 printf("Ecriture des numeros des familles des polyedres \n");
125
126 /* Fermeture du fichier */
127 if (MEDfileClose(fid) < 0) {
128 MESSAGE("Erreur a la fermeture du fichier");
129 return -1;
130 }
131 printf("Fermeture du fichier test25.med \n");
132
133 return 0;
134 }
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_SORT_DTIT
Definition: med.h:309
MEDmeshPolyhedronWr
MEDC_EXPORT med_err MEDmeshPolyhedronWr(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 faceindexsize, const med_int *const faceindex, const med_int nodeindexsize, const med_int *const nodeindex, const med_int *const connectivity)
Cette routine permet l'écriture dans un maillage des connectivités de polyèdres.
Definition: MEDmeshPolyhedronWr.c:47
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
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
MODE_ACCES
#define MODE_ACCES
Definition: test25.c:35
main
int main(int argc, char **argv)
Definition: test25.c:38
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
MED_UNDEF_DT
#define MED_UNDEF_DT
Definition: med.h:322
MED_NO_IT
#define MED_NO_IT
Definition: med.h:321
MED_POLYHEDRON
#define MED_POLYHEDRON
Definition: med.h:225
med_utils.h