# UsesCase_MEDinterp_1.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018 /*
    00019  * Interp use case 1 : write an interpolation family
    00020  * In this example, the interpolation family can be used with
    00021  * the TEMPERATURE field of UsesCase_MEDfield_10 use case
    00022  */
    00023
    00024 #include <med.h>
    00025 #define MESGERR 1
    00026 #include <med_utils.h>
    00027
    00028 #include <string.h>
    00029
    00030 int main (int argc, char **argv) {
    00031   med_idt fid;
    00032   char interpname[MED_NAME_SIZE+1] = "MED_TRIA3 interpolation family";
    00033   const med_int nbofvariable=2;
    00034   const med_int maxdegree=1;
    00035   const med_int nmaxcoefficient=3;
    00036   const med_int         nbofcoefficient1_1 = 3;
    00037   const med_int   const power1_1[]         = {0,0,1,0,0,1};
    00038   const med_float const coefficient1_1[]   = {1,-1,-1};
    00039
    00040   const med_int         nbofcoefficient1_2 = 1;
    00041   const med_int   const power1_2[]         = {1,0};
    00042   const med_float const coefficient1_2[]   = {1};
    00043
    00044   const med_int         nbofcoefficient1_3 = 1;
    00045   const med_int   const power1_3[]         = {0,1};
    00046   const med_float const coefficient1_3[]   = {1};
    00047   int ret=-1;
    00048
    00049   /* file creation */
    00050   fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_CREAT);
    00051   if (fid < 0) {
    00052     MESSAGE("ERROR : file creation ...");
    00053     goto ERROR;
    00054   }
    00055
    00056   /* Family interpolation creation :
    00057      - reference element = MED_TRIA3
    00058      - integration points of UsesCase_MEDfield_10 use case
    00059      are used to build the interpolation
    00060      - basis functions are P1(X)= 1-X1-X2, P2(X)= X1, P3(X)= X2
    00061    */
    00062   if (MEDinterpCr(fid, interpname, MED_TRIA3, MED_FALSE, nbofvariable, maxdegree, nmaxcoefficient) < 0) {
    00063     MESSAGE("ERROR : interpolation family creation ...");
    00064     goto ERROR;
    00065   }
    00066
    00067   /* Basis functions creation */
    00068   if (MEDinterpBaseFunctionWr(fid,interpname,1,nbofcoefficient1_1,power1_1,coefficient1_1) < 0) {
    00069     MESSAGE("ERROR : first base function creation ...");
    00070     goto ERROR;
    00071   }
    00072
    00073   if (MEDinterpBaseFunctionWr(fid,interpname,2,nbofcoefficient1_2,power1_2,coefficient1_2) < 0) {
    00074     MESSAGE("ERROR : second base function creation ...");
    00075     goto ERROR;
    00076   }
    00077
    00078   if (MEDinterpBaseFunctionWr(fid,interpname,3,nbofcoefficient1_3,power1_3,coefficient1_3) < 0) {
    00079     MESSAGE("ERROR : third base function creation ...");
    00080     goto ERROR;
    00081   }
    00082
    00083   ret=0;
    00084  ERROR:
    00085
    00086   /* close file */
    00087   if (MEDfileClose(fid) < 0) {
    00088     MESSAGE("ERROR : close file ...");
    00089     ret=-1;
    00090   }
    00091
    00092   return ret;
    00093 }