Test_MEDinterpBaseFunctionCoeffSize.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;goto ERROR;}
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 à lecture d'informations de la fonction d'interpolation n°");ISCRUTE(_interpit);
00078 goto ERROR;
00079 }
00080
00081 fprintf(stdout,"Fonction d'interpolation n° %d |%s| sur le type géométrique n° %d\n",
00082 _interpit,_interpname, _geotype);
00083
00084 if ( _cellnodes )
00085 if ( _nbasisfunc == (_geotype % 100) )
00086 fprintf(stdout,"\t Les noeuds de construction sont les noeuds de la maille de référence.\n");
00087 else {
00088 MESSAGE("Erreur : le nombre de noeuds de construction "\
00089 "est différent du nombre de noeuds de la maille de référence.\n");
00090 ISCRUTE(_nbasisfunc); ISCRUTE(_geotype % 100);
00091 }
00092
00093 if ( _nvariable != (_geotype / 100) ) {
00094 MESSAGE("Erreur : le nombre de variables "\
00095 "est différent de la dimension de l'espace de la maille de référence.\n");
00096 ISCRUTE(_nvariable); ISCRUTE (_geotype / 100);
00097 } else
00098 fprintf(stdout,"\t Il y a %d fonctions de base avec %d variables\n ",_nbasisfunc,_nvariable);
00099 fprintf(stdout,"\t Le degré maximum des fonctions de base est %d et possèdent au maximum %d coefficients\n"
00100 ,_maxdegree,_nmaxcoefficient);
00101
00102
00103
00104 for ( _basisfuncit=1; _basisfuncit<= _nbasisfunc; ++_basisfuncit) {
00105
00106 if ( (_ncoefficient = MEDinterpBaseFunctionCoefSize( _fid,
00107 _interpname,
00108 _basisfuncit) ) <0 ) {
00109 MESSAGE("Erreur à la lecture du nombre de coefficients de la fonction de base n°");ISCRUTE(_basisfuncit);
00110 goto ERROR;
00111 }
00112
00113 _coefficient = (med_float*) calloc(sizeof(med_float),_ncoefficient);
00114 _power = (med_int*) calloc(sizeof(med_int),_nvariable*_ncoefficient);
00115
00116 if ( (_ret = MEDinterpBaseFunctionRd( _fid,
00117 _interpname,
00118 _basisfuncit,
00119 &_ncoefficient,
00120 _power,
00121 _coefficient
00122 ) <0) ) {
00123 MESSAGE("Erreur à la lecture de la fonction de base n°");ISCRUTE(_basisfuncit);
00124 free(_coefficient);free(_power);goto ERROR;
00125 } else {
00126 fprintf(stdout,"\n\t Tableau de coefficients de la fonctions de base n° %d :\n\t",_basisfuncit);
00127 for ( _coefficientit=0; _coefficientit< _ncoefficient; ++_coefficientit)
00128 fprintf(stdout," %4f ",_coefficient[_coefficientit]);
00129
00130 fprintf(stdout,"\n\t Tableau de puissances de la fonctions de base n° %d :\n\t",_basisfuncit);
00131 for ( _powerit=0; _powerit< _nvariable*_ncoefficient; ++_powerit)
00132 fprintf(stdout," %4d ",_power[_powerit]);
00133 }
00134 free(_coefficient);
00135 free(_power);
00136 }
00137 fprintf(stdout,"\n");
00138
00139 }
00140
00141
00142 _ret=0;
00143 ERROR:
00144 if (MEDfileClose(_fid) < 0) {
00145 MESSAGE("ERROR : file closing");
00146 return -1;
00147 }
00148
00149
00150 return _ret;
00151
00152 }
00153