Changeset 659
- Timestamp:
- 05/31/09 00:20:31 (16 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/DataSet/DataSet.cpp
r586 r659 317 317 } 318 318 319 int DataSet::FindResult(void* pvalue, char* name){ 320 321 /*Go through a dataset, and find a Result* object 322 *which field name is "name" : */ 323 324 vector<Object*>::iterator object; 325 Result* result=NULL; 326 327 int found=0; 328 329 for ( object=objects.begin() ; object < objects.end(); object++ ){ 330 331 /*Find param type objects: */ 332 if((*object)->Enum()==ResultEnum()){ 333 334 /*Ok, this object is a result, recover it and ask which name it has: */ 335 result=(Result*)(*object); 336 337 if (strcmp(result->GetFieldName(),name)==0){ 338 /*Ok, this is the one! Recover the value of this result: */ 339 double** field=NULL; 340 field=(double**)pvalue; //not very safe, but hey! 341 result->GetField(field); 342 found=1; 343 break; 344 } 345 } 346 } 347 return found; 348 } 349 350 319 351 Object* DataSet::FindParamObject(char* name){ 320 352 -
issm/trunk/src/c/DataSet/DataSet.h
r586 r659 81 81 int DeleteObject(Object* object); 82 82 void ComputePressure(Vec p_g); 83 int FindResult(void* pvalue, char* name); 83 84 84 85 }; -
issm/trunk/src/c/parallel/DakotaResponses.cpp
r643 r659 14 14 #undef __FUNCT__ 15 15 #define __FUNCT__ "DakotaResponses" 16 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses, DataSet* results,int analysis_type,int sub_analysis_type){16 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodels,DataSet* results,int analysis_type,int sub_analysis_type){ 17 17 18 int i; 18 int i,j; 19 int found=0; 19 20 char* response_descriptor=NULL; 21 int numberofnodes; 22 FemModel* fem=NULL; 23 extern int my_rank; 24 25 /*recover first model: */ 26 fem=femmodels; 27 28 /*some data needed across the responses: */ 29 found=fem->parameters->FindParam((void*)&numberofnodes,"numberofnodes"); 30 if(!found)throw ErrorException(__FUNCT__," could not find numberofnodes in fem model"); 31 20 32 21 33 for(i=0;i<numresponses;i++){ … … 25 37 //'min_vx' 'max_vx' 'max_abs_vx' 'min_vy' 'max_vy' 'max_abs_vy' 'min_vel' 'max_vel' 26 38 27 if(strcmp(response_descriptor,"min_vel")){ 39 if(strcmp(response_descriptor,"min_vel")==0){ 40 double* vel=NULL; 41 double min_vel=0; 42 43 found=results->FindResult((void*)&vel,"vel"); 44 if(!found)throw ErrorException(__FUNCT__," could not find vel to compute min_vel"); 28 45 46 min_vel=vel[0]; 47 for(j=1;j<numberofnodes;j++){ 48 if (vel[j]<min_vel)min_vel=vel[j]; 49 } 29 50 51 if(my_rank==0)responses[i]=min_vel; 52 53 } 54 else if(strcmp(response_descriptor,"max_vel")==0){ 55 double* vel=NULL; 56 double max_vel=0; 57 58 found=results->FindResult((void*)&vel,"vel"); 59 if(!found)throw ErrorException(__FUNCT__," could not find vel to compute max_vel"); 60 61 max_vel=vel[0]; 62 for(j=1;j<numberofnodes;j++){ 63 if (vel[j]>max_vel)max_vel=vel[j]; 64 } 65 if(my_rank==0)responses[i]=max_vel; 66 } 67 else if(strcmp(response_descriptor,"min_vx")==0){ 68 double* vx=NULL; 69 double min_vx=0; 70 71 found=results->FindResult((void*)&vx,"vx"); 72 if(!found)throw ErrorException(__FUNCT__," could not find vx to compute min_vx"); 73 74 min_vx=vx[0]; 75 for(j=1;j<numberofnodes;j++){ 76 if (vx[j]<min_vx)min_vx=vx[j]; 77 } 78 if(my_rank==0)responses[i]=min_vx; 79 } 80 else if(strcmp(response_descriptor,"max_vx")==0){ 81 double* vx=NULL; 82 double max_vx=0; 83 84 found=results->FindResult((void*)&vx,"vx"); 85 if(!found)throw ErrorException(__FUNCT__," could not find vx to compute max_vx"); 86 87 max_vx=vx[0]; 88 for(j=1;j<numberofnodes;j++){ 89 if (vx[j]>max_vx)max_vx=vx[j]; 90 } 91 if(my_rank==0)responses[i]=max_vx; 92 } 93 else if(strcmp(response_descriptor,"max_abs_vx")==0){ 94 double* vx=NULL; 95 double max_abs_vx=0; 96 97 found=results->FindResult((void*)&vx,"vx"); 98 if(!found)throw ErrorException(__FUNCT__," could not find vx to compute max_abs_vx"); 99 100 max_abs_vx=fabs(vx[0]); 101 for(j=1;j<numberofnodes;j++){ 102 if (fabs(vx[j])>max_abs_vx)max_abs_vx=fabs(vx[j]); 103 } 104 if(my_rank==0)responses[i]=max_abs_vx; 105 } 106 else if(strcmp(response_descriptor,"min_vy")==0){ 107 double* vy=NULL; 108 double min_vy=0; 109 110 found=results->FindResult((void*)&vy,"vy"); 111 if(!found)throw ErrorException(__FUNCT__," could not find vy to compute min_vy"); 112 113 min_vy=vy[0]; 114 for(j=1;j<numberofnodes;j++){ 115 if (vy[j]<min_vy)min_vy=vy[j]; 116 } 117 if(my_rank==0)responses[i]=min_vy; 118 } 119 else if(strcmp(response_descriptor,"max_vy")==0){ 120 double* vy=NULL; 121 double max_vy=0; 122 123 found=results->FindResult((void*)&vy,"vy"); 124 if(!found)throw ErrorException(__FUNCT__," could not find vy to compute max_vy"); 125 126 max_vy=vy[0]; 127 for(j=1;j<numberofnodes;j++){ 128 if (vy[j]>max_vy)max_vy=vy[j]; 129 } 130 if(my_rank==0)responses[i]=max_vy; 131 } 132 else if(strcmp(response_descriptor,"max_abs_vy")==0){ 133 double* vy=NULL; 134 double max_abs_vy=0; 135 136 found=results->FindResult((void*)&vy,"vy"); 137 if(!found)throw ErrorException(__FUNCT__," could not find vy to compute max_abs_vy"); 138 139 max_abs_vy=fabs(vy[0]); 140 for(j=1;j<numberofnodes;j++){ 141 if (fabs(vy[j])>max_abs_vy)max_abs_vy=fabs(vy[j]); 142 } 143 if(my_rank==0)responses[i]=max_abs_vy; 144 } 145 else if(strcmp(response_descriptor,"min_vz")==0){ 146 double* vz=NULL; 147 double min_vz=0; 148 149 found=results->FindResult((void*)&vz,"vz"); 150 if(!found)throw ErrorException(__FUNCT__," could not find vz to compute min_vz"); 151 152 min_vz=vz[0]; 153 for(j=1;j<numberofnodes;j++){ 154 if (vz[j]<min_vz)min_vz=vz[j]; 155 } 156 if(my_rank==0)responses[i]=min_vz; 157 } 158 else if(strcmp(response_descriptor,"max_vz")==0){ 159 double* vz=NULL; 160 double max_vz=0; 161 162 found=results->FindResult((void*)&vz,"vz"); 163 if(!found)throw ErrorException(__FUNCT__," could not find vz to compute max_vz"); 164 165 max_vz=vz[0]; 166 for(j=1;j<numberofnodes;j++){ 167 if (vz[j]>max_vz)max_vz=vz[j]; 168 } 169 if(my_rank==0)responses[i]=max_vz; 170 } 171 else if(strcmp(response_descriptor,"max_abs_vz")==0){ 172 double* vz=NULL; 173 double max_abs_vz=0; 174 175 found=results->FindResult((void*)&vz,"vz"); 176 if(!found)throw ErrorException(__FUNCT__," could not find vz to compute max_abs_vz"); 177 178 max_abs_vz=fabs(vz[0]); 179 for(j=1;j<numberofnodes;j++){ 180 if (fabs(vz[j])>max_abs_vz)max_abs_vz=fabs(vz[j]); 181 } 182 if(my_rank==0)responses[i]=max_abs_vz; 30 183 } 31 184 else throw ErrorException(__FUNCT__,exprintf("%s%s%s"," response descriptor : ",response_descriptor," not supported yet!")); -
issm/trunk/src/c/parallel/ProcessResults.cpp
r643 r659 21 21 #include "../shared/shared.h" 22 22 23 void ProcessResults(DataSet** p newresults,DataSet*results,FemModel* fems,int analysis_type){23 void ProcessResults(DataSet** presults,FemModel* fems,int analysis_type){ 24 24 25 25 int i,n; 26 26 Result* result=NULL; 27 27 Result* newresult=NULL; 28 29 /*input: */ 30 DataSet* results=NULL; 28 31 29 32 /*output: */ … … 47 50 double* vy=NULL; 48 51 double* vz=NULL; 52 double* vel=NULL; 49 53 Vec p_g=NULL; 50 54 double* p_g_serial=NULL; … … 55 59 int numberofnodes; 56 60 61 /*recover input results: */ 62 results=*presults; 63 57 64 /*Initialize new results: */ 58 65 newresults=new DataSet(ResultsEnum()); 59 66 60 61 67 /*Recover femmodels first: */ 62 68 if(analysis_type==DiagnosticAnalysisEnum()){ … … 101 107 vy=(double*)xmalloc(numberofnodes*sizeof(double)); 102 108 vz=(double*)xmalloc(numberofnodes*sizeof(double)); 109 vel=(double*)xmalloc(numberofnodes*sizeof(double)); 103 110 104 111 for(i=0;i<numberofnodes;i++){ … … 106 113 vy[i]=u_g_serial[2*(int)partition[i]+1]*yts; 107 114 vz[i]=0; 115 vel[i]=sqrt(pow(vx[i],2)+pow(vy[i],2)+pow(vz[i],2)); 108 116 } 117 109 118 } 110 119 else{ … … 116 125 vy=(double*)xmalloc(numberofnodes*sizeof(double)); 117 126 vz=(double*)xmalloc(numberofnodes*sizeof(double)); 127 vel=(double*)xmalloc(numberofnodes*sizeof(double)); 118 128 for(i=0;i<numberofnodes;i++){ 119 129 vx[i]=u_g_serial[4*(int)partition[i]+0]*yts; 120 130 vy[i]=u_g_serial[4*(int)partition[i]+1]*yts; 121 131 vz[i]=u_g_serial[4*(int)partition[i]+2]*yts; 132 vel[i]=sqrt(pow(vx[i],2)+pow(vy[i],2)+pow(vz[i],2)); 122 133 } 123 134 } … … 133 144 newresults->AddObject(newresult); 134 145 146 newresult=new Result(newresults->Size()+1,result->GetTime(),result->GetStep(),"vel",vel,numberofnodes); 147 newresults->AddObject(newresult); 148 135 149 /*do some cleanup: */ 136 150 xfree((void**)&u_g_serial); … … 138 152 } 139 153 else if(strcmp(result->GetFieldName(),"p_g")==0){ 140 141 154 /*easy, p_g is of size numberofnodes, on 1 dof, just repartition: */ 142 155 result->GetField(&p_g); … … 174 187 } 175 188 189 /*Delete results: */ 190 delete results; 191 192 176 193 /*Assign output pointers:*/ 177 *pnewresults=newresults; 178 194 *presults=newresults; 179 195 } 180 196 -
issm/trunk/src/c/parallel/SpawnCore.cpp
r643 r659 24 24 25 25 /*output from core solutions: */ 26 Vec u_g=NULL; 27 Vec p_g=NULL; 26 DataSet* results=NULL; 28 27 29 28 char** responses_descriptors=NULL; … … 34 33 double* qmu_part=NULL; 35 34 int qmu_npart; 36 DataSet* results=NULL;37 35 38 36 extern int my_rank; … … 91 89 #endif 92 90 91 _printf_("initialize results:\n"); 92 results=new DataSet(ResultsEnum()); 93 93 94 /*Modify core inputs to reflect the dakota variables inputs: */ 94 95 //inputs->UpdateFromDakota(variables,variables_descriptors,numvariables,qmu_part,qmu_npart); … … 105 106 } 106 107 108 /*Now process the outputs, before computing the dakota responses: */ 109 _printf_("process results:\n"); 110 ProcessResults(&results,femmodels,analysis_type); 111 107 112 /*compute responses on cpu 0: dummy for now! */ 108 DakotaResponses(responses,responses_descriptors,numresponses,results,analysis_type,sub_analysis_type); 113 _printf_("compute dakota responses:\n"); 114 DakotaResponses(responses,responses_descriptors,numresponses,femmodels,results,analysis_type,sub_analysis_type); 109 115 110 116 /*Free ressources:*/ 111 112 //vectors 113 VecFree(&u_g); 114 VecFree(&p_g); 115 117 delete results; 118 116 119 //variables only on cpu != 0 117 120 if(my_rank!=0){ -
issm/trunk/src/c/parallel/diagnostic.cpp
r651 r659 23 23 char* outputfilename=NULL; 24 24 char* lockname=NULL; 25 char* qmuname=NULL; 25 char* qmuinname=NULL; 26 char* qmuoutname=NULL; 27 char* qmuerrname=NULL; 26 28 int numberofnodes; 27 29 int qmu_analysis=0; … … 32 34 /*Results: */ 33 35 DataSet* results=NULL; 34 DataSet* newresults=NULL;35 36 36 37 ParameterInputs* inputs=NULL; … … 56 57 outputfilename=argv[3]; 57 58 lockname=argv[4]; 58 qmuname=argv[5]; 59 qmuinname=argv[5]; 60 qmuoutname=argv[6]; 61 qmuerrname=argv[7]; 59 62 60 63 /*Open handle to data on disk: */ … … 101 104 _printf_("calling qmu analysis on diagnostic core:\n"); 102 105 103 //qmu(qmuname,&femmodels[0],inputs,DiagnosticAnalysisEnum(),NoneAnalysisEnum());106 qmu(qmuinname,qmuoutname,qmuerrname,&femmodels[0],inputs,DiagnosticAnalysisEnum(),NoneAnalysisEnum()); 104 107 } 105 108 106 109 _printf_("process results:\n"); 107 ProcessResults(& newresults,results,&femmodels[0],DiagnosticAnalysisEnum()); delete results;110 ProcessResults(&results,&femmodels[0],DiagnosticAnalysisEnum()); 108 111 109 112 _printf_("write results to disk:\n"); 110 OutputResults( newresults,outputfilename);113 OutputResults(results,outputfilename); 111 114 112 115 _printf_("write lock file:\n"); … … 117 120 118 121 _printf_("closing MPI and Petsc\n"); 119 MPI_Barrier(MPI_COMM_WORLD);120 121 /*Close MPI libraries: */122 122 PetscFinalize(); 123 123 124 124 125 /*end module: */ -
issm/trunk/src/c/parallel/parallel.h
r643 r659 36 36 void CreateFemModel(FemModel* femmodel,ConstDataHandle MODEL,char* analysis_type,char* sub_analysis_type); 37 37 //int BatchDebug(Mat* Kgg,Vec* pg,FemModel* femmodel,char* filename); 38 void qmu(const char* dakota_input_file, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type);38 void qmu(const char* dakota_input_file,const char* dakota_output_file,const char* dakota_error_file,FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 39 39 void SpawnCore(double* responses,double* variables,char** variable_descriptors,int numvariables, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 40 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses, DataSet* results,int analysis_type,int sub_analysis_type);41 void ProcessResults(DataSet** p newresults,DataSet*results,FemModel* fems,int analysis_type);40 void DakotaResponses(double* responses,char** responses_descriptors,int numresponses,FemModel* femmodels, DataSet* results,int analysis_type,int sub_analysis_type); 41 void ProcessResults(DataSet** presults,FemModel* fems,int analysis_type); 42 42 43 43 #endif -
issm/trunk/src/c/parallel/qmu.cpp
r586 r659 23 23 #include "parallel.h" 24 24 25 void qmu(const char* dakota_input_file,FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type){ 25 void qmu(const char* dakota_input_file,const char* dakota_output_file,const char* dakota_error_file, FemModel* femmodels,ParameterInputs* inputs,int analysis_type,int sub_analysis_type){ 26 26 27 27 28 extern int my_rank; … … 30 31 31 32 if(my_rank==0){ 32 33 33 34 // Instantiate/initialize the parallel library and problem description 34 35 // database objects. … … 41 42 problem_db.manage_inputs(dakota_input_file); 42 43 // specify_outputs_restart() is only necessary if specifying non-defaults 43 //parallel_lib.specify_outputs_restart(NULL, NULL,NULL, NULL);44 parallel_lib.specify_outputs_restart(dakota_output_file,dakota_error_file,NULL, NULL); 44 45 45 46 // Instantiate the Strategy object (which instantiates all Model and -
issm/trunk/src/c/parallel/thermal.cpp
r654 r659 35 35 /*Results: */ 36 36 DataSet* results=NULL; 37 DataSet* newresults=NULL;38 37 39 38 ParameterInputs* inputs=NULL; … … 89 88 param=(Param*)femmodels[1].parameters->FindParamObject("p_g"); 90 89 femmodels[1].parameters->DeleteObject((Object*)param); 90 91 91 92 92 _printf_("call computational core:\n"); … … 94 94 95 95 _printf_("process results:\n"); 96 ProcessResults(& newresults,results,&femmodels[0],ThermalAnalysisEnum()); delete results;96 ProcessResults(&results,&femmodels[0],ThermalAnalysisEnum()); 97 97 98 98 _printf_("write results to disk:\n"); 99 OutputResults( newresults,outputfilename);99 OutputResults(results,outputfilename); 100 100 101 101 _printf_("write lock file:\n"); -
issm/trunk/src/m/classes/public/BuildQueueingScriptGeneric.m
r612 r659 29 29 end 30 30 31 fprintf(fid,' %s %s.bin %s.outbin %s.lock qmu.in 2> %s.errlog >%s.outlog & ',executionpath,md.name,md.name,md.name,md.name,md.name);31 fprintf(fid,' %s %s.bin %s.outbin %s.lock %s.qmu.in %s.qmu.out %s.qmu.err 2> %s.errlog >%s.outlog & ',executionpath,md.name,md.name,md.name,md.name,md.name,md.name,md.name,md.name); 32 32 fclose(fid); -
issm/trunk/src/m/classes/public/LaunchQueueJobGeneric.m
r586 r659 21 21 if strcmpi(hostname,md.cluster), 22 22 if md.qmu_analysis, 23 system(['cp ' md.name '.bin' ' ' md.name '.queue qmu/ qmu.in ' ' ' executionpath]);23 system(['cp ' md.name '.bin' ' ' md.name '.queue qmu/' md.name '.qmu.in ' ' ' executionpath]); 24 24 else 25 25 system(['cp ' md.name '.bin' ' ' md.name '.queue' ' ' executionpath]); … … 27 27 else 28 28 if md.qmu_analysis, 29 system(['scp ' md.name '.bin' ' ' md.name '.queue qmu/ qmu.in ' ' ' md.cluster ':' executionpath]);29 system(['scp ' md.name '.bin' ' ' md.name '.queue qmu/' md.name '.qmu.in ' ' ' md.cluster ':' executionpath]); 30 30 else 31 31 system(['scp ' md.name '.bin' ' ' md.name '.queue' ' ' md.cluster ':' executionpath]); -
issm/trunk/src/m/classes/public/marshall.m
r649 r659 164 164 WriteData(fid,responses(i).descriptor,'String',['descriptor' num2str(i-1)]); 165 165 end 166 WriteData(fid,md.npart,'Integer','npart'); 166 167 end 167 168 -
issm/trunk/src/m/solutions/dakota/dakota_in_write.m
r452 r659 26 26 [pathstr,name,ext,versn] = fileparts(filei); 27 27 if isempty(ext) 28 ext='. in';28 ext='.qmu.in'; 29 29 end 30 30 filei2=fullfile(pathstr,[name ext versn]); -
issm/trunk/src/m/solutions/dakota/qmuin.m
r586 r659 8 8 qmudir ='qmu'; 9 9 % qmufile can not be changed unless cielo_ice_script.sh is also changed 10 qmufile= 'qmu';10 qmufile=md.name; 11 11 ivar =1; 12 12 iresp =1; … … 75 75 md.qmu_params(iparams).analysis_driver=[ISSM_DIR '/src/m/solutions/dakota/cielo_ice_script.sh']; 76 76 end 77 77 78 dakota_in_data(md.qmu_method(imethod),md.variables(ivar),md.responses(iresp),md.qmu_params(iparams),qmufile,package,md); 78 79 79 system(['rm -rf qmu.m']); 80 81 system(['rm -rf ' md.name '.m']); 80 82 cd ../ 81 83
Note:
See TracChangeset
for help on using the changeset viewer.