MED fichier

UsesCase_MEDinterp_1.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 * Interp use case 1 : write an interpolation family
20 * In this example, the interpolation family can be used with
21 * the TEMPERATURE field of UsesCase_MEDfield_10 use case
22 */
23
24 #include <med.h>
25 #define MESGERR 1
26 #include <med_utils.h>
27
28 #include <string.h>
29
30 int main (int argc, char **argv) {
31 med_idt fid;
32 char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
33 const med_int nvariable=2;
34 const med_int maxdegree=1;
35 const med_int nmaxcoefficient=3;
36 const med_int ncoefficient1_1 = 3;
37 const med_int const power1_1[] = {0,0,1,0,0,1};
38 const med_float const coefficient1_1[] = {1,-1,-1};
39
40 const med_int ncoefficient1_2 = 1;
41 const med_int const power1_2[] = {1,0};
42 const med_float const coefficient1_2[] = {1};
43
44 const med_int ncoefficient1_3 = 1;
45 const med_int const power1_3[] = {0,1};
46 const med_float const coefficient1_3[] = {1};
47 int ret=-1;
48
49 /* file creation */
50 fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_CREAT);
51 if (fid < 0) {
52 MESSAGE("ERROR : file creation ...");
53 goto ERROR;
54 }
55
56 /* Family interpolation creation :
57 - reference element = MED_TRIA3
58 - integration points of UsesCase_MEDfield_10 use case
59 are used to build the interpolation
60 - basis functions are P1(X)= 1-X1-X2, P2(X)= X1, P3(X)= X2
61 */
62 if (MEDinterpCr(fid, interpname, MED_TRIA3, MED_FALSE, nvariable, maxdegree, nmaxcoefficient) < 0) {
63 MESSAGE("ERROR : interpolation family creation ...");
64 goto ERROR;
65 }
66
67 /* Basis functions creation */
68 if (MEDinterpBaseFunctionWr(fid,interpname,1,ncoefficient1_1,power1_1,coefficient1_1) < 0) {
69 MESSAGE("ERROR : first base function creation ...");
70 goto ERROR;
71 }
72
73 if (MEDinterpBaseFunctionWr(fid,interpname,2,ncoefficient1_2,power1_2,coefficient1_2) < 0) {
74 MESSAGE("ERROR : second base function creation ...");
75 goto ERROR;
76 }
77
78 if (MEDinterpBaseFunctionWr(fid,interpname,3,ncoefficient1_3,power1_3,coefficient1_3) < 0) {
79 MESSAGE("ERROR : third base function creation ...");
80 goto ERROR;
81 }
82
83 ret=0;
84 ERROR:
85
86 /* close file */
87 if (MEDfileClose(fid) < 0) {
88 MESSAGE("ERROR : close file ...");
89 ret=-1;
90 }
91
92 return ret;
93 }
MED_TRIA3
#define MED_TRIA3
Definition: med.h:203
MEDfileOpen
MEDC_EXPORT med_idt MEDfileOpen(const char *const filename, const med_access_mode accessmode)
Ouverture d'un fichier MED.
Definition: MEDfileOpen.c:42
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
med_idt
hid_t med_idt
Definition: med.h:331
MEDinterpCr
MEDC_EXPORT med_err MEDinterpCr(const med_idt fid, const char *const interpname, const med_geometry_type geotype, const med_bool cellnodes, const med_int nvariable, const med_int maxdegree, const med_int nmaxcoef)
Cette routine permet de créer une nouvelle fonction d'interpolation polynômiale nommée interpname.
Definition: MEDinterpCr.c:43
MED_FALSE
Definition: med.h:260
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:342
med.h
med_float
double med_float
Definition: med.h:336
MED_ACC_CREAT
Definition: med.h:123
main
int main(int argc, char **argv)
Definition: UsesCase_MEDinterp_1.c:30
MED_NAME_SIZE
#define MED_NAME_SIZE
Definition: med.h:81
MEDfileClose
MEDC_EXPORT med_err MEDfileClose(med_idt fid)
Fermeture d'un fichier MED.
Definition: MEDfileClose.c:30
med_utils.h