Changeset 12280
- Timestamp:
- 05/23/12 16:47:41 (13 years ago)
- Location:
- issm/branches/trunk-jpl-damage/src
- Files:
-
- 17 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/branches/trunk-jpl-damage/src/c/Container/Observations.cpp ¶
r12258 r12280 78 78 } 79 79 else{ 80 //We need to average with the current observations (not done yet) 80 /*We need to average with the current observations*/ 81 this->quadtree->AddAndAverage(x[i],y[i],observations_list[i]); 81 82 } 82 83 } -
TabularUnified issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/EnumDefinitions.h ¶
r12004 r12280 155 155 PetscProfilingCurrentFlopsEnum, 156 156 PetscProfilingSolutionTimeEnum, 157 MaxIterationConvergenceFlagEnum, 157 158 SteadystateMaxiterEnum, 158 159 SteadystateNumRequestedOutputsEnum, -
TabularUnified issm/branches/trunk-jpl-damage/src/c/EnumDefinitions/Synchronize.sh ¶
r12168 r12280 2 2 #Synchronize EnumToStringx.cpp and StringToEnumx.cpp and matlab Enums 3 3 4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column> put everything in file temp5 cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,/ /g" | awk '{ printf "%s %s\n", NR, $0}' > temp4 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas > put everything in file temp 5 cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," | grep -v include | sed -e "s/,/ /g" | awk '{print $1}' > temp 6 6 7 7 #Removed existing files … … 13 13 NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}'); 14 14 15 #Build EnumToStringx.cpp {{{ 115 #Build EnumToStringx.cpp {{{ 16 16 #Header 17 17 cat <<END > $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp … … 35 35 END 36 36 #core 37 cat temp | awk '{print "\t\t" "case " $ 2" : return \"" substr($2,1,length($2)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp37 cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp 38 38 #Footer 39 39 cat <<END >> $ISSM_DIR/src/c/modules/EnumToStringx/EnumToStringx.cpp … … 83 83 echo " if(stage==$i){" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 84 84 awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp | 85 awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($ 2,1,length($2)-4) "\")==0) return " $2";"}' >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp85 awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($1,1,length($1)-4) "\")==0) return " $1 ";"}' >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 86 86 echo " else stage=$(($i+1));" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp 87 87 echo " }" >> $ISSM_DIR//src/c/modules/StringToEnumx/StringToEnumx.cpp … … 101 101 102 102 # go through the lines of temp 103 for (( i=1 ; i<=$NUMENUMS ; i++ )); do 103 ENUM=0; 104 for NAMEENUM in $(cat temp); do 104 105 105 106 #Get name and enum of the line i 106 NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$2);}');107 107 NAME=$(echo $NAMEENUM | sed -e "s/Enum//g") 108 ENUM=$i;109 108 #offset Enum by one (Enum begins with 0 and not 1!) 110 let ENUM=$ENUM -1109 let ENUM=$ENUM+1 111 110 112 111 #print info {{{ 113 if [ $ i-lt 10 ]112 if [ $ENUM -lt 10 ] 114 113 then 115 114 printf "\r " 116 printf "\r $ i/$NUMENUMS Adding "$NAME"..."115 printf "\r $ENUM/$NUMENUMS Adding "$NAME"..." 117 116 else 118 if [ $ i-lt 100 ]117 if [ $ENUM -lt 100 ] 119 118 then 120 119 printf "\r " 121 printf "\r $ i/$NUMENUMS Adding "$NAME"..."120 printf "\r $ENUM/$NUMENUMS Adding "$NAME"..." 122 121 else 123 122 printf "\r " 124 printf "\r$ i/$NUMENUMS Adding "$NAME"..."123 printf "\r$ENUM/$NUMENUMS Adding "$NAME"..." 125 124 fi 126 125 fi … … 143 142 144 143 done 144 #MaximumNumberOfEnums{{{ 145 cat <<END > $ISSM_DIR/src/m/enum/MaximumNumberOfEnums.m 146 function macro=MaximumNumberOfEnums() 147 %$(echo "MaximumNumberOfEnums" | awk {'print toupper($1)'}) - Enum of MaximumNumberOfEnums 148 % 149 % WARNING: DO NOT MODIFY THIS FILE 150 % this file has been automatically generated by src/c/EnumDefinitions/Synchronize.sh 151 % Please read src/c/EnumDefinitions/README for more information 152 % 153 % Usage: 154 % macro=MaximumNumberOfEnums() 155 156 macro=$(cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[a-zA-Z]Enum" | grep -v include \ 157 | awk '{ printf "%s %s\n", NR-1, $0 }' \ 158 | grep "MaximumNumberOfEnums" | awk '{print $1}'); 159 END 160 #}}} 145 161 146 162 #clean up{{{ -
TabularUnified issm/branches/trunk-jpl-damage/src/c/modules/EnumToStringx/EnumToStringx.cpp ¶
r12004 r12280 159 159 case PetscProfilingCurrentFlopsEnum : return "PetscProfilingCurrentFlops"; 160 160 case PetscProfilingSolutionTimeEnum : return "PetscProfilingSolutionTime"; 161 case MaxIterationConvergenceFlagEnum : return "MaxIterationConvergenceFlag"; 161 162 case SteadystateMaxiterEnum : return "SteadystateMaxiter"; 162 163 case SteadystateNumRequestedOutputsEnum : return "SteadystateNumRequestedOutputs"; -
TabularUnified issm/branches/trunk-jpl-damage/src/c/modules/StringToEnumx/StringToEnumx.cpp ¶
r12253 r12280 163 163 else if (strcmp(name,"PetscProfilingCurrentFlops")==0) return PetscProfilingCurrentFlopsEnum; 164 164 else if (strcmp(name,"PetscProfilingSolutionTime")==0) return PetscProfilingSolutionTimeEnum; 165 else if (strcmp(name,"MaxIterationConvergenceFlag")==0) return MaxIterationConvergenceFlagEnum; 165 166 else if (strcmp(name,"SteadystateMaxiter")==0) return SteadystateMaxiterEnum; 166 167 else if (strcmp(name,"SteadystateNumRequestedOutputs")==0) return SteadystateNumRequestedOutputsEnum; … … 259 260 else if (strcmp(name,"Input")==0) return InputEnum; 260 261 else if (strcmp(name,"IntInput")==0) return IntInputEnum; 261 else if (strcmp(name,"IntParam")==0) return IntParamEnum;262 262 else stage=3; 263 263 } 264 264 if(stage==3){ 265 if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum; 265 if (strcmp(name,"IntParam")==0) return IntParamEnum; 266 else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum; 266 267 else if (strcmp(name,"MacAyeal2dIceFront")==0) return MacAyeal2dIceFrontEnum; 267 268 else if (strcmp(name,"MacAyeal3dIceFront")==0) return MacAyeal3dIceFrontEnum; … … 382 383 else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum; 383 384 else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum; 384 else if (strcmp(name,"IceVolume")==0) return IceVolumeEnum;385 385 else stage=4; 386 386 } 387 387 if(stage==4){ 388 if (strcmp(name,"P0")==0) return P0Enum; 388 if (strcmp(name,"IceVolume")==0) return IceVolumeEnum; 389 else if (strcmp(name,"P0")==0) return P0Enum; 389 390 else if (strcmp(name,"P1")==0) return P1Enum; 390 391 else if (strcmp(name,"P1DG")==0) return P1DGEnum; -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Elements/Tria.cpp ¶
r12274 r12280 629 629 basal_melting_input->GetInputValue(&basal_melting_g,gauss); 630 630 thickness_input->GetInputValue(&thickness_g,gauss); 631 if(basal_melting_correction_input) basal_melting_correction_input->GetInputValue(&basal_melting_correction_g,gauss); 631 if(basal_melting_correction_input) 632 basal_melting_correction_input->GetInputValue(&basal_melting_correction_g,gauss); 633 else 634 basal_melting_correction_g=0.; 632 635 633 636 for(i=0;i<numdof;i++) pe->values[i]+=Jdettria*gauss->weight*(thickness_g+dt*(surface_mass_balance_g-basal_melting_g-basal_melting_correction_g))*L[i]; -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/IoModel.cpp ¶
r12168 r12280 45 45 this->fid=iomodel_handle; 46 46 47 /*Check that Enums are Synchronized*/ 48 this->CheckEnumSync(); 49 47 50 /*Initialize and read constants:*/ 48 51 this->constants=new Parameters(); … … 89 92 /*}}}*/ 90 93 94 /*FUNCTION IoModel::CheckEnumSync{{{1*/ 95 void IoModel::CheckEnumSync(void){ 96 97 extern int my_rank; 98 int record_enum = 0; 99 100 101 /*Check that some fields have been allocated*/ 102 _assert_(this->fid || my_rank); 103 104 105 /*Go find in the binary file, the position of the data we want to fetch: */ 106 if(my_rank==0){ //cpu 0 107 108 /*First set FILE* position to the beginning of the file: */ 109 fseek(this->fid,0,SEEK_SET); 110 111 /*Get first Enum*/ 112 if(fread(&record_enum,sizeof(int),1,this->fid)==0){ 113 _error_("Marshalled file is empty"); 114 } 115 else{ 116 if(record_enum!=MaximumNumberOfEnums){ 117 _error_("Enums in marshalled file are not compatible with compiled code, make sure you are using the same version of ISSM"); 118 } 119 } 120 } 121 } 122 /*}}}*/ 91 123 /*FUNCTION IoModel::Constant(bool* poutput,int constant_enum){{{1*/ 92 124 void IoModel::Constant(bool* poutput,int constant_enum){ -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/IoModel.h ¶
r9476 r12280 41 41 42 42 /*Input/Output*/ 43 void Constant(bool *poutput,int constant_enum); 44 void Constant(int *poutput,int constant_enum); 45 void Constant(double *poutput,int constant_enum); 46 void Constant(char **poutput,int constant_enum); 47 Param *CopyConstantObject(int constant_enum); 48 double *Data(int dataenum); 49 void DeleteData(int num,...); 50 void FetchConstants(void); 51 void FetchData(bool* pboolean,int data_enum); 52 void FetchData(int* pinteger,int data_enum); 53 void FetchData(double* pscalar,int data_enum); 54 void FetchData(char** pstring,int data_enum); 55 void FetchData(int** pmatrix,int* pM,int* pN,int data_enum); 56 void FetchData(double** pscalarmatrix,int* pM,int* pN,int data_enum); 57 void FetchData(char*** pstringarray,int* pnumstrings,int data_enum); 58 void FetchData(double*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum); 59 void FetchData(int num,...); 60 void FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,double default_value=0); 61 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 43 void CheckEnumSync(void); 44 void Constant(bool *poutput,int constant_enum); 45 void Constant(int *poutput,int constant_enum); 46 void Constant(double *poutput,int constant_enum); 47 void Constant(char **poutput,int constant_enum); 48 Param *CopyConstantObject(int constant_enum); 49 double *Data(int dataenum); 50 void DeleteData(int num,...); 51 void FetchConstants(void); 52 void FetchData(bool* pboolean,int data_enum); 53 void FetchData(int* pinteger,int data_enum); 54 void FetchData(double* pscalar,int data_enum); 55 void FetchData(char** pstring,int data_enum); 56 void FetchData(int** pmatrix,int* pM,int* pN,int data_enum); 57 void FetchData(double** pscalarmatrix,int* pM,int* pN,int data_enum); 58 void FetchData(char*** pstringarray,int* pnumstrings,int data_enum); 59 void FetchData(double*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum); 60 void FetchData(int num,...); 61 void FetchDataToInput(Elements* elements,int vector_enum,int default_vector_enum=NoneEnum,double default_value=0); 62 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 62 63 }; 63 64 -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.cpp ¶
r12229 r12280 15 15 Observation::Observation(double x_in,double y_in,int xi_in,int yi_in,int index_in,double value_in){ 16 16 17 this->x = x_in; 18 this->y = y_in; 19 this->xi = xi_in; 20 this->yi = yi_in; 21 this->index = index_in; 22 this->value = value_in; 17 this->x = x_in; 18 this->y = y_in; 19 this->xi = xi_in; 20 this->yi = yi_in; 21 this->index = index_in; 22 this->value = value_in; 23 this->weight = 1.; 23 24 24 25 } … … 42 43 printf(" xi : "); printbinary(this->xi); printf("\n"); 43 44 printf(" yi : "); printbinary(this->yi); printf("\n"); 45 printf(" weight: %g\n",this->weight); 44 46 printf(" value : %g\n",this->value); 45 47 } -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Observation.h ¶
r12229 r12280 14 14 int xi,yi; 15 15 int index; 16 double weight; 16 17 double value; 17 18 -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.cpp ¶
r12230 r12280 198 198 199 199 }/*}}}*/ 200 /*FUNCTION Quadtree::AddAndAverage{{{1*/ 201 void Quadtree::AddAndAverage(double x,double y,double value){ 202 203 QuadtreeBox **pbox = NULL; 204 QuadtreeBox *box = NULL; 205 int xi,yi; 206 int level,levelbin; 207 int index; 208 double length,length2; 209 210 /*Get integer coodinates*/ 211 this->IntergerCoordinates(&xi,&yi,x,y); 212 213 /*Initialize levels*/ 214 level = 0; 215 levelbin = (1L<<this->MaxDepth);// = 2^30 216 217 /*Get inital box (the largest)*/ 218 pbox=&root; 219 220 /*Find the smallest box where this point is located*/ 221 while((box=*pbox) && (box->nbitems<0)){ 222 223 levelbin>>=1; level+=1; 224 225 pbox = &box->box[IJ(xi,yi,levelbin)]; 226 } 227 228 /*Add obervation in this box (should be full)*/ 229 if(box && box->nbitems==4){ 230 index = 0; 231 length = pow(box->obs[0]->x - x,2.) + pow(box->obs[0]->y - y,2.); 232 for(int i=1;i<4;i++){ 233 length2 = pow(box->obs[i]->x - x,2.) + pow(box->obs[i]->y - y,2.); 234 if(length2<length){ 235 index = i; 236 length = length2; 237 } 238 } 239 240 /*We found the closest observation, now average observation (do not change xi and yi to avoid round off errors*/ 241 box->obs[index]->x = (box->obs[index]->weight*box->obs[index]->x + x)/(box->obs[index]->weight+1); 242 box->obs[index]->y = (box->obs[index]->weight*box->obs[index]->y + y)/(box->obs[index]->weight+1); 243 box->obs[index]->xi= int((box->obs[index]->weight*double(box->obs[index]->xi) + double(xi))/(box->obs[index]->weight+1)); 244 box->obs[index]->yi= int((box->obs[index]->weight*double(box->obs[index]->yi) + double(yi))/(box->obs[index]->weight+1)); 245 box->obs[index]->value = (box->obs[index]->weight*box->obs[index]->value + value)/(box->obs[index]->weight+1); 246 box->obs[index]->weight += 1; 247 } 248 else{ 249 _error_("Box is not full"); 250 } 251 }/*}}}*/ 200 252 /*FUNCTION Quadtree::Echo{{{1*/ 201 253 void Quadtree::Echo(void){ -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Kriging/Quadtree.h ¶
r12229 r12280 53 53 ~Quadtree(); 54 54 void Add(Observation *observation); 55 void AddAndAverage(double x,double y,double value); 55 56 void DeepEcho(void); 56 57 void Echo(void); -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.cpp ¶
r12004 r12280 166 166 double* localvalues=NULL; 167 167 168 /*In debugging mode, check consistency (no NaN, and values not too big)*/ 169 this->CheckConsistency(); 170 168 171 if(this->fsize){ 169 172 /*first, retrieve values that are in the f-set from the g-set values vector: */ … … 200 203 } 201 204 205 } 206 /*}}}*/ 207 /*FUNCTION ElementVector::CheckConsistency{{{1*/ 208 void ElementVector::CheckConsistency(void){ 209 /*Check element matrix values, only in debugging mode*/ 210 #ifdef _ISSM_DEBUG_ 211 for (int i=0;i<this->nrows;i++){ 212 if (isnan(this->values[i])) _error_("NaN found in Element Vector"); 213 if (fabs( this->values[i])>1.e+50) _error_("Element Vector values exceeds 1.e+50"); 214 } 215 #endif 202 216 } 203 217 /*}}}*/ -
TabularUnified issm/branches/trunk-jpl-damage/src/c/objects/Numerics/ElementVector.h ¶
r11684 r12280 43 43 void InsertIntoGlobal(Vector* pf); 44 44 void Echo(void); 45 void CheckConsistency(void); 45 46 void Init(ElementVector* pe); 46 47 void SetValue(double scalar); -
TabularUnified issm/branches/trunk-jpl-damage/src/c/solvers/solver_newton.cpp ¶
r11684 r12280 67 67 convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); 68 68 xdelete(&Kff); xdelete(&pf); 69 if(converged==true) break; 69 if(converged==true){ 70 bool max_iteration_state=false; 71 int tempStep=1; 72 double tempTime=1.0; 73 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 74 break; 75 } 70 76 if(count>=max_nonlinear_iterations){ 71 _printf_(true," maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations); 77 _printf_(true," maximum number of Newton iterations (%i) exceeded\n",max_nonlinear_iterations); 78 bool max_iteration_state=true; 79 int tempStep=1; 80 double tempTime=1.0; 81 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 72 82 break; 73 83 } -
TabularUnified issm/branches/trunk-jpl-damage/src/c/solvers/solver_nonlinear.cpp ¶
r11684 r12280 85 85 /*Increase count: */ 86 86 count++; 87 if(converged==true)break; 87 if(converged==true){ 88 bool max_iteration_state=false; 89 int tempStep=1; 90 double tempTime=1.0; 91 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 92 break; 93 } 88 94 if(count>=max_nonlinear_iterations){ 89 _printf_(true," maximum number of iterations (%i) exceeded\n",max_nonlinear_iterations);95 _printf_(true," maximum number of nonlinear iterations (%i) exceeded\n",max_nonlinear_iterations); 90 96 converged=true; 91 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum); 92 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 97 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum); 98 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 99 bool max_iteration_state=true; 100 int tempStep=1; 101 double tempTime=1.0; 102 femmodel->results->AddObject(new BoolExternalResult(femmodel->results->Size()+1, MaxIterationConvergenceFlagEnum, max_iteration_state, tempStep, tempTime)); 93 103 break; 94 104 } -
TabularUnified issm/branches/trunk-jpl-damage/src/m/enum/MaximumNumberOfEnums.m ¶
r12279 r12280 9 9 % macro=MaximumNumberOfEnums() 10 10 11 macro=4 37;11 macro=440; -
TabularUnified issm/branches/trunk-jpl-damage/src/m/model/marshall.m ¶
r12004 r12280 15 15 error(['marshall error message: could not open ' [md.miscellaneous.name '.bin'],' file for binary writing']); 16 16 end 17 18 %First, right MaximumNumberOfEnum to make sure that the Enums are synchronized 19 WriteData(fid,'enum',MaximumNumberOfEnums(),'data',true,'format','Boolean'); 17 20 18 21 %Go through all model fields: check that it is a class and call checkconsistency
Note:
See TracChangeset
for help on using the changeset viewer.