Test_MEDinterpBaseFunctionRd.c
Aller à la documentation de ce fichier.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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 med_int _ninterp=0;
00038 int _interpit =0;
00039 char _interpname[MED_NAME_SIZE+1]="";
00040 med_geometry_type _geotype =MED_NONE;
00041 med_bool _cellnodes =MED_FALSE;
00042 med_int _nbasisfunc =0;
00043 med_int _nvariable =0;
00044 med_int _maxdegree =0;
00045 med_int _nmaxcoefficient =0;
00046 int _basisfuncit =0;
00047 int _powerit =0;
00048 med_int _ncoefficient =0;
00049 med_int* _power =NULL;
00050 med_float* _coefficient =NULL;
00051 int _coefficientit =0;
00052
00053
00054
00055 _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
00056 if (_fid < 0) {
00057 MESSAGE("Erreur a la creation du fichier current.med");
00058 return -1;
00059 }
00060
00061 if ( (_ninterp = MEDnInterp(_fid)) <0) _ret=_ninterp;
00062
00063 ISCRUTE(_ninterp);
00064
00065 for ( _interpit=1; _interpit<= _ninterp; ++_interpit) {
00066
00067 if ( (_ret = MEDinterpInfo(_fid,
00068 _interpit,
00069 _interpname,
00070 &_geotype,
00071 &_cellnodes,
00072 &_nbasisfunc,
00073 &_nvariable,
00074 &_maxdegree,
00075 &_nmaxcoefficient
00076 ) <0) ) {
00077 MESSAGE("Erreur à la demande d'information de la fonction d'interpolation n°");
00078 ISCRUTE(_interpit);
00079 goto ERROR;
00080 }
00081
00082 fprintf(stdout,"Fonction d'interpolation n° %d |%s| sur le type géométrique n° %d\n",
00083 _interpit,_interpname, _geotype);
00084
00085 if ( _cellnodes )
00086 if ( _nbasisfunc == (_geotype % 100) )
00087 fprintf(stdout,"\t Les noeuds de construction sont les noeuds de la maille de référence.\n");
00088 else {
00089 MESSAGE("Erreur : le nombre de noeuds de construction "\
00090 "est différent du nombre de noeuds de la maille de référence.\n");
00091 ISCRUTE(_nbasisfunc); ISCRUTE(_geotype % 100);
00092 }
00093
00094 if ( _nvariable != (_geotype / 100) ) {
00095 MESSAGE("Erreur : le nombre de variables "\
00096 "est différent de la dimension de l'espace de la maille de référence.\n");
00097 ISCRUTE(_nvariable); ISCRUTE (_geotype / 100);
00098 } else
00099 fprintf(stdout,"\t Il y a %d fonctions de base avec %d variables\n ",_nbasisfunc,_nvariable);
00100 fprintf(stdout,"\t Le degré maximum des fonctions de base est %d et possèdent au maximum %d coefficients\n"
00101 ,_maxdegree,_nmaxcoefficient);
00102
00103
00104 _coefficient = (med_float*) calloc(sizeof(med_float),_nmaxcoefficient);
00105 _power = (med_int*) calloc(sizeof(med_int),_nvariable*_nmaxcoefficient);
00106
00107 for ( _basisfuncit=1; _basisfuncit<= _nbasisfunc; ++_basisfuncit) {
00108
00109
00110 if ( (_ret = MEDinterpBaseFunctionRd( _fid,
00111 _interpname,
00112 _basisfuncit,
00113 &_ncoefficient,
00114 _power,
00115 _coefficient
00116 ) <0) ) {
00117 MESSAGE("Erreur à la lecture de la fonction de base n°");ISCRUTE(_basisfuncit);goto ERROR;
00118 } else {
00119 fprintf(stdout,"\n\t Tableau de coefficients de la fonctions de base n° %d :\n\t",_basisfuncit);
00120 for ( _coefficientit=0; _coefficientit< _ncoefficient; ++_coefficientit)
00121 fprintf(stdout," %4f ",_coefficient[_coefficientit]);
00122
00123 fprintf(stdout,"\n\t Tableau de puissances de la fonctions de base n° %d :\n\t",_basisfuncit);
00124 for ( _powerit=0; _powerit< _nvariable*_ncoefficient; ++_powerit)
00125 fprintf(stdout," %4d ",_power[_powerit]);
00126 }
00127 }
00128 fprintf(stdout,"\n");
00129 free(_coefficient);
00130 free(_power);
00131
00132 }
00133
00134 _ret=0;
00135 ERROR:
00136 if (MEDfileClose(_fid) < 0) {
00137 MESSAGE("ERROR : file closing");
00138 return -1;
00139 }
00140
00141 return _ret;
00142
00143 }
00144