Test_MEDinterpBaseFunctionWr.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  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 #include <med.h>
00019 #define MESGERR 1
00020 #include <med_utils.h>
00021 #include <string.h>
00022 
00023 #ifdef DEF_LECT_ECR
00024 #define MODE_ACCES MED_ACC_RDWR
00025 #elif DEF_LECT_AJOUT
00026 #define MODE_ACCES MED_ACC_RDEXT
00027 #else
00028 #define MODE_ACCES MED_ACC_CREAT
00029 #endif
00030 
00031 int main (int argc, char **argv)
00032 
00033 {
00034   med_err           _ret=-1;
00035   med_idt           _fid=0;
00036 
00037   /*Exemple 1 :
00038 
00039   - Elément de référence de type géométrique MED_TRIA3
00040   - Point X(X1,X2) quelconque dans le plan de l'élément de référence
00041   - Fonctions de base : P1(X)=1-X1-X2 ; P2(X)=X1; P3(X)=X2;
00042     (issu du choix de la base polynomiale (1,X1,X2)
00043      et des trois noeuds de la maille de référence pour
00044      construire l'interpolation)
00045   */
00046   const char         _interpname1[]   ="interpname1";
00047   med_geometry_type  _geotype1        =MED_TRIA3;
00048   med_bool           _cellnodes1      =MED_TRUE;
00049   med_int            _nbasisfunc1  =3;
00050   med_int            _nvariable1   =2;
00051   med_int            _maxdegree1      =1;
00052   med_int            _nmaxcoefficient1=3;
00053 
00054   const med_int         _ncoefficient1_1 = 3;
00055   const med_int   const _power1_1[]         = {0,0,1,0,0,1};
00056   const med_float const _coefficient1_1[]   = {1,-1,-1};
00057 
00058   const med_int         _ncoefficient1_2 = 1;
00059   const med_int   const _power1_2[]         = {0,0,1,0,0,0};
00060   const med_float const _coefficient1_2[]   = {0,1,0};
00061 
00062   const med_int         _ncoefficient1_3 = 1;
00063   const med_int   const _power1_3[]         = {0,0,0,0,0,1};
00064   const med_float const _coefficient1_3[]   = {0,0,1};
00065 
00066  /* Ouverture en mode creation du fichier "current.med" */
00067   _fid = MEDfileOpen("current.med",MODE_ACCES);
00068   if (_fid < 0) {
00069     MESSAGE("Erreur a la creation du fichier current.med");
00070     return -1;
00071   }
00072 
00073   if ( (_ret = MEDinterpBaseFunctionWr( _fid,
00074                                         _interpname1,
00075                                         1,
00076                                         _ncoefficient1_1,
00077                                         _power1_1,
00078                                         _coefficient1_1) <0) ) {
00079     MESSAGE("Erreur à l'écriture de la fonction de base n°1 de la fct. d'intp n°1");
00080     goto ERROR;
00081   }
00082 
00083   if ( (_ret = MEDinterpBaseFunctionWr( _fid,
00084                                         _interpname1,
00085                                         2,
00086                                         _ncoefficient1_2,
00087                                         _power1_2,
00088                                         _coefficient1_2) <0) ) {
00089     MESSAGE("Erreur à l'écriture de la fonction de base n°2 de la fct. d'intp n°1");
00090     goto ERROR;
00091   }
00092 
00093   if ( (_ret = MEDinterpBaseFunctionWr( _fid,
00094                                         _interpname1,
00095                                         3,
00096                                         _ncoefficient1_3,
00097                                         _power1_3,
00098                                         _coefficient1_3) <0) ) {
00099     MESSAGE("Erreur à l'écriture de la fonction de base n°3 de la fct. d'intp n°1");
00100     goto ERROR;
00101   }
00102 
00103   _ret=0;
00104 
00105  ERROR:
00106 
00107   if (MEDfileClose(_fid) < 0) {
00108     MESSAGE("ERROR : file closing");
00109     return -1;
00110   }
00111 
00112 
00113   return _ret;
00114 
00115 }
00116 

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1