MED fichier
test16.c
Aller à la documentation de ce fichier.
1/* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2020 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 * - Nom du fichier : test16.c
20 *
21 * - Description : ecriture d'elements de maillages MED
22 * via les routines de niveau 2
23 * - equivalent a test6.c
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
39int main (int argc, char **argv)
40
41
42{
43 med_idt fid = 0;
44 med_int nse2 = 5;
45 med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
46 /* 12345678901234561234567890123456123456789012345612345678901234561234567890123456 */
47 char nomse2[MED_SNAME_SIZE*5+1]="se1 se2 se3 se4 se5 ";
48 med_int numse2[5] = {1,2,3,4,5};
49 med_int nufase2[5] = {-1,-1,0,-2,-3};
50 med_int ntr3 = 2;
51 med_int tr3[6] = {1,2,-5,-5,3,-4};
52 /* 1234567890123456123456789012345612345678901234561234567890123456 */
53 char nomtr3[MED_SNAME_SIZE*2+1] = "tr1 tr2 ";
54 med_int numtr3[2] = {4,5};
55 med_int nufatr3[2] = {0,-1};
56 char maa[MED_NAME_SIZE+1] = "maa1";
57 med_int mdim = 2;
58 /* 12345678901234561234567890123456 */
59 char nomcoo[2*MED_SNAME_SIZE+1] = "x y ";
60 char unicoo[2*MED_SNAME_SIZE+1] = "cm cm ";
61
62 /* Creation du fichier test16.med */
63 if ((fid = MEDfileOpen("test16.med",MODE_ACCES)) < 0) {
64 MESSAGE("Erreur a la creation du fichier test16.med");
65 return -1;
66 }
67
68
69 /* Creation du maillage */
70 if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
71 "un maillage pour test16","s", MED_SORT_DTIT,
72 MED_CARTESIAN, nomcoo, unicoo) < 0) {
73 MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
74 return -1;
75 }
76
77
78 /* Ecriture des aretes segments MED_SEG2 :
79 - connectivite
80 - noms (optionnel)
81 - numeros (optionnel)
82 - numeros des familles */
85 nse2,se2,MED_TRUE,nomse2,MED_TRUE,numse2,MED_TRUE,nufase2)< 0 ) {
86 MESSAGE("Impossible d'ecrire la connectivit� des aretes : ");
87 return -1;
88 }
89
90 /* Ecriture des mailles MED_TRIA3 :
91 - Connectivite
92 - Noms (optionnel)
93 - Numeros (optionnel)
94 - Numeros des familles */
97 ntr3,tr3,MED_TRUE,nomtr3,MED_TRUE,numtr3,MED_TRUE,nufatr3)< 0 ) {
98 MESSAGE("Impossible d'ecrire les �l�ments triangles : ");
99 return -1;
100 }
101
102 /* Fermeture du fichier */
103 if ( MEDfileClose(fid) < 0) {
104 MESSAGE("Impossible de fermerle fichier : ");
105 return -1;
106 }
107
108 return 0;
109}
110
111
112
113
114
115
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
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
MEDC_EXPORT med_err MEDmeshElementWr(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, const med_bool withelementname, const char *const elementname, const med_bool withelementnumber, const med_int *const elementnumber, const med_bool withfamnumber, const med_int *const famnumber)
Cette routine permet l'écriture d'un type d'élément d'un maillage non structuré pour une étape de cal...
#define MED_NAME_SIZE
Definition: med.h:81
@ MED_NO_INTERLACE
Definition: med.h:98
#define MED_SNAME_SIZE
Definition: med.h:82
@ MED_TRUE
Definition: med.h:260
#define MED_SEG2
Definition: med.h:200
#define MED_TRIA3
Definition: med.h:203
@ MED_CARTESIAN
Definition: med.h:258
@ MED_SORT_DTIT
Definition: med.h:300
#define MED_UNDEF_DT
Definition: med.h:313
@ MED_UNSTRUCTURED_MESH
Definition: med.h:131
int med_int
Definition: med.h:333
#define MED_NO_DT
Definition: med.h:311
#define MED_NO_IT
Definition: med.h:312
@ MED_CELL
Definition: med.h:143
@ MED_DESCENDING_EDGE
Definition: med.h:143
hid_t med_idt
Definition: med.h:322
@ MED_DESCENDING
Definition: med.h:255
#define SSCRUTE(chaine)
Definition: med_utils.h:323
#define MESSAGE(chaine)
Definition: med_utils.h:324
#define MODE_ACCES
Definition: test16.c:36
int main(int argc, char **argv)
Definition: test16.c:39