MED fichier: Fichier source de Test_MEDinterpBaseFunctionWr.c

MED fichier

- Documentation MED
- Guides d'utilisation
- Guides de référence

Test_MEDinterpBaseFunctionWr.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 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 #include <med.h>
19 #define MESGERR 1
20 #include <med_utils.h>
21 #include <string.h>
22
23 #ifdef DEF_LECT_ECR
24 #define MODE_ACCES MED_ACC_RDWR
25 #elif DEF_LECT_AJOUT
26 #define MODE_ACCES MED_ACC_RDEXT
27 #else
28 #define MODE_ACCES MED_ACC_CREAT
29 #endif
30
31 int main (int argc, char **argv)
32
33 {
34 med_err _ret=-1;
35 med_idt _fid=0;
36
37 /*Exemple 1 :
38
39 - Elément de référence de type géométrique MED_TRIA3
40 - Point X(X1,X2) quelconque dans le plan de l'élément de référence
41 - Fonctions de base : P1(X)=1-X1-X2 ; P2(X)=X1; P3(X)=X2;
42 (issu du choix de la base polynomiale (1,X1,X2)
43 et des trois noeuds de la maille de référence pour
44 construire l'interpolation)
45 */
46 const char _interpname1[] ="interpname1";
47 med_geometry_type _geotype1 =MED_TRIA3;
48 med_bool _cellnodes1 =MED_TRUE;
49 med_int _nbasisfunc1 =3;
50 med_int _nvariable1 =2;
51 med_int _maxdegree1 =1;
52 med_int _nmaxcoefficient1=3;
53
54 const med_int _ncoefficient1_1 = 3;
55 const med_int const _power1_1[] = {0,0,1,0,0,1};
56 const med_float const _coefficient1_1[] = {1,-1,-1};
57
58 const med_int _ncoefficient1_2 = 1;
59 const med_int const _power1_2[] = {0,0,1,0,0,0};
60 const med_float const _coefficient1_2[] = {0,1,0};
61
62 const med_int _ncoefficient1_3 = 1;
63 const med_int const _power1_3[] = {0,0,0,0,0,1};
64 const med_float const _coefficient1_3[] = {0,0,1};
65
66 /* Ouverture en mode creation du fichier "current.med" */
67 _fid = MEDfileOpen("current.med",MODE_ACCES);
68 if (_fid < 0) {
69 MESSAGE("Erreur a la creation du fichier current.med");
70 return -1;
71 }
72
73 if ( (_ret = MEDinterpBaseFunctionWr( _fid,
74 _interpname1,
75 1,
76 _ncoefficient1_1,
77 _power1_1,
78 _coefficient1_1) <0) ) {
79 MESSAGE("Erreur à l'écriture de la fonction de base n°1 de la fct. d'intp n°1");
80 goto ERROR;
81 }
82
83 if ( (_ret = MEDinterpBaseFunctionWr( _fid,
84 _interpname1,
85 2,
86 _ncoefficient1_2,
87 _power1_2,
88 _coefficient1_2) <0) ) {
89 MESSAGE("Erreur à l'écriture de la fonction de base n°2 de la fct. d'intp n°1");
90 goto ERROR;
91 }
92
93 if ( (_ret = MEDinterpBaseFunctionWr( _fid,
94 _interpname1,
95 3,
96 _ncoefficient1_3,
97 _power1_3,
98 _coefficient1_3) <0) ) {
99 MESSAGE("Erreur à l'écriture de la fonction de base n°3 de la fct. d'intp n°1");
100 goto ERROR;
101 }
102
103 _ret=0;
104
105 ERROR:
106
107 if (MEDfileClose(_fid) < 0) {
108 MESSAGE("ERROR : file closing");
109 return -1;
110 }
111
112
113 return _ret;
114
115 }
116
MED_TRIA3
#define MED_TRIA3
Definition: med.h:200
med_err
herr_t med_err
Definition: med.h:327
med_utils.h
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:41
MODE_ACCES
#define MODE_ACCES
Definition: Test_MEDinterpBaseFunctionWr.c:28
med_float
double med_float
Definition: med.h:331
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:316
MED_TRUE
Definition: med.h:257
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
med_int
int med_int
Definition: med.h:337
MEDinterpBaseFunctionWr
MEDC_EXPORT med_err MEDinterpBaseFunctionWr(const med_idt fid, const char *const interpname, const med_int basisfuncit, const med_int ncoef, const med_int *const power, const med_float *const coefficient)
Cette routine permet l'écriture d'une fonction de base/forme de l'interpolation interpname.
Definition: MEDinterpBaseFunctionWr.c:41
main
int main(int argc, char **argv)
Definition: Test_MEDinterpBaseFunctionWr.c:31
med_idt
hid_t med_idt
Definition: med.h:326
med.h
med_bool
med_bool
Definition: med.h:257
med_geometry_type
int med_geometry_type
Definition: med.h:191