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 _nbofbasisfunc =0;
00043 med_int _nbofvariable =0;
00044 med_int _maxdegree =0;
00045 med_int _nmaxcoefficient =0;
00046 int _basisfuncit =0;
00047 int _powerit =0;
00048 med_int _nbofcoefficient =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 &_nbofbasisfunc,
00073 &_nbofvariable,
00074 &_maxdegree,
00075 &_nmaxcoefficient
00076 ) <0) ) {
00077 MESSAGE("Erreur à la création 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 ( _nbofbasisfunc == (_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(_nbofbasisfunc); ISCRUTE(_geotype % 100);
00091 }
00092
00093 if ( _nbofvariable != (_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(_nbofvariable); ISCRUTE (_geotype / 100);
00097 } else
00098 fprintf(stdout,"\t Il y a %d fonctions de base avec %d variables\n ",_nbofbasisfunc,_nbofvariable);
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 _coefficient = (med_float*) calloc(sizeof(med_float),_nmaxcoefficient);
00104 _power = (med_int*) calloc(sizeof(med_int),_nbofvariable*_nmaxcoefficient);
00105
00106 for ( _basisfuncit=1; _basisfuncit<= _nbofbasisfunc; ++_basisfuncit) {
00107
00108
00109 if ( (_ret = MEDinterpBaseFunctionRd( _fid,
00110 _interpname,
00111 _basisfuncit,
00112 &_nbofcoefficient,
00113 _power,
00114 _coefficient
00115 ) <0) ) {
00116 MESSAGE("Erreur à la lecture de la fonction de base n°");ISCRUTE(_basisfuncit);goto ERROR;
00117 } else {
00118 fprintf(stdout,"\n\t Tableau de coefficients de la fonctions de base n° %d :\n\t",_basisfuncit);
00119 for ( _coefficientit=1; _coefficientit<= _nbofcoefficient; ++_coefficientit)
00120 fprintf(stdout," %4f ",_coefficient[_coefficientit]);
00121
00122 fprintf(stdout,"\n\t Tableau de puissances de la fonctions de base n° %d :\n\t",_basisfuncit);
00123 for ( _powerit=1; _powerit<= _nbofvariable*_nbofcoefficient; ++_powerit)
00124 fprintf(stdout," %4d ",_power[_powerit]);
00125 }
00126 }
00127 fprintf(stdout,"\n");
00128 free(_coefficient);
00129 free(_power);
00130
00131 }
00132
00133 _ret=0;
00134 ERROR:
00135 if (MEDfileClose(_fid) < 0) {
00136 MESSAGE("ERROR : file closing");
00137 return -1;
00138 }
00139
00140 return _ret;
00141
00142 }
00143