Changeset 472
- Timestamp:
- 05/18/09 11:53:23 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 11 added
- 7 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/EnumDefinitions/AnalysisTypeAsEnum.cpp
r465 r472 57 57 return VertAnalysisEnum(); 58 58 } 59 else if (strcmp(analysis_type,"steady")==0){ 60 return SteadyAnalysisEnum(); 61 } 62 else if (strcmp(analysis_type,"transient")==0){ 63 return TransientAnalysisEnum(); 64 } 59 65 else if (strcmp(analysis_type,"")==0){ 60 66 return NoneAnalysisEnum(); -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.cpp
r465 r472 30 30 int VertAnalysisEnum(void){ return 33; } 31 31 int NoneAnalysisEnum(void){ return 34; } 32 int SteadyAnalysisEnum(void){ return 35; } 33 int TransientAnalysisEnum(void){ return 36; } 32 34 33 35 /*datasets: */ -
issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
r465 r472 49 49 int VertAnalysisEnum(void); 50 50 int NoneAnalysisEnum(void); 51 int SteadyAnalysisEnum(void); 52 int TransientAnalysisEnum(void); 51 53 52 54 -
issm/trunk/src/c/Makefile.am
r465 r472 162 162 ./io/FetchRifts.cpp\ 163 163 ./io/ParameterInputsInit.cpp\ 164 ./io/pfopen.cpp\ 165 ./io/pfclose.cpp\ 164 166 ./EnumDefinitions/EnumDefinitions.h\ 165 167 ./EnumDefinitions/EnumDefinitions.cpp\ … … 406 408 ./io/FetchRifts.cpp\ 407 409 ./io/ParameterInputsInit.cpp\ 410 ./io/pfopen.cpp\ 411 ./io/pfclose.cpp\ 408 412 ./EnumDefinitions/EnumDefinitions.h\ 409 413 ./EnumDefinitions/EnumDefinitions.cpp\ … … 493 497 ./parallel/diagnostic_core_linear.cpp\ 494 498 ./parallel/diagnostic_core_nonlinear.cpp\ 499 ./parallel/thermal_core.cpp\ 495 500 ./parallel/CreateFemModel.cpp\ 496 501 ./parallel/OutputDiagnostic.cpp\ … … 498 503 ./parallel/control.cpp\ 499 504 ./parallel/OutputControl.cpp\ 505 ./parallel/OutputThermal.cpp\ 500 506 ./parallel/objectivefunctionC.cpp\ 501 507 ./parallel/GradJCompute.cpp -
issm/trunk/src/c/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp
r465 r472 13 13 #include "../EnumDefinitions/EnumDefinitions.h" 14 14 15 void PenaltySystemMatricesx(Mat Kgg, Vec pg, DataSet* elements,DataSet* nodes,DataSet* loads,DataSet* materials,15 void PenaltySystemMatricesx(Mat Kgg, Vec pg,double* pkmax,DataSet* elements,DataSet* nodes,DataSet* loads,DataSet* materials, 16 16 int kflag,int pflag,ParameterInputs* inputs,int analysis_type,int sub_analysis_type){ 17 17 … … 52 52 #endif 53 53 54 54 /*Assign output pointers:*/ 55 if(pkmax)*pkmax=kmax; 55 56 56 57 } -
issm/trunk/src/c/PenaltySystemMatricesx/PenaltySystemMatricesx.h
r465 r472 10 10 11 11 /* local prototypes: */ 12 void PenaltySystemMatricesx(Mat Kgg, Vec pg, DataSet* elements,DataSet* nodes,DataSet* loads,DataSet* materials,12 void PenaltySystemMatricesx(Mat Kgg, Vec pg,double* pkmax, DataSet* elements,DataSet* nodes,DataSet* loads,DataSet* materials, 13 13 int kflag,int pflag,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 14 14 -
issm/trunk/src/c/io/io.h
r117 r472 45 45 int FetchRifts(int** priftsnumpenaltypairs,double*** priftspenaltypairs,int** priftsfill,double** priftsfriction,ConstDataHandle model_handle,int numrifts); 46 46 47 /*File I/O: */ 48 FILE* pfopen(char* filename,char* format); 49 void* pfclose(FILE* fid,char* filename); 50 47 51 #endif /* _IMDB_H */ 48 52 -
issm/trunk/src/c/parallel/OutputControl.cpp
r317 r472 38 38 /* Open output file to write raw binary data: */ 39 39 if(my_rank==0){ 40 fid=fopen(filename,"wb"); 41 if(fid==NULL)throw ErrorException(__FUNCT__,exprintf("%s%s%s","could not open file ",filename," for binary writing.")); 40 fid=pfopen(filename,"wb"); 42 41 43 42 /*Write solution type: */ … … 62 61 63 62 /*Close file: */ 64 if(fclose(fid)!=0)throw ErrorException(__FUNCT__,exprintf("%s%s","could not close file ",filename));63 pfclose(fid,filename); 65 64 } 66 65 -
issm/trunk/src/c/parallel/OutputDiagnostic.cpp
r434 r472 50 50 /* Open output file to write raw binary data: */ 51 51 if(my_rank==0){ 52 fid=fopen(filename,"wb"); 53 if(fid==NULL)throw ErrorException(__FUNCT__,exprintf("%s%s%s","could not open file ",filename," for binary writing.")); 52 fid=pfopen(filename,"wb"); 54 53 55 54 /*Write solution type: */ … … 67 66 68 67 /*Close file: */ 69 if(fclose(fid)!=0)throw ErrorException(__FUNCT__,exprintf("%s%s","could not close file ",filename));68 pfclose(fid,filename); 70 69 } 71 70 -
issm/trunk/src/c/parallel/control.cpp
r465 r472 75 75 76 76 /*Open handle to data on disk: */ 77 fid=fopen(inputfilename,"rb"); 78 if(fid==NULL) throw ErrorException(__FUNCT__,exprintf("%s%s%s","could not open file ",inputfilename," for binary reading")); 77 fid=pfopen(inputfilename,"rb"); 79 78 80 79 _printf_("read and create finite element model:\n"); -
issm/trunk/src/c/parallel/diagnostic.cpp
r465 r472 54 54 55 55 /*Open handle to data on disk: */ 56 fid=fopen(inputfilename,"rb"); 57 if(fid==NULL) throw ErrorException(__FUNCT__,exprintf("%s%s%s","could not open file ",inputfilename," for binary reading")); 56 fid=pfopen(inputfilename,"rb"); 58 57 59 58 _printf_("read and create finite element model:\n"); -
issm/trunk/src/c/parallel/diagnostic_core_nonlinear.cpp
r465 r472 88 88 if (debug) _printf_(" Generating penalty matrices\n"); 89 89 //*Generate penalty system matrices 90 PenaltySystemMatricesx(Kgg, pg, fem->elements,fem->nodes,loads,fem->materials,kflag,pflag,inputs,analysis_type,sub_analysis_type);90 PenaltySystemMatricesx(Kgg, pg,NULL,fem->elements,fem->nodes,loads,fem->materials,kflag,pflag,inputs,analysis_type,sub_analysis_type); 91 91 92 92 if (debug) _printf_(" reducing matrix from g to f set\n"); -
issm/trunk/src/c/parallel/parallel.h
r465 r472 14 14 void diagnostic_core_nonlinear(Vec* pug,Mat* pK_ff0,Mat* pK_fs0, FemModel* fem,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 15 15 void diagnostic_core_linear(Vec* ppg,FemModel* fem,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 16 int cielothermal_core(Vec** pt_g,ParameterInputs* inputs,FemModel* femmodel);16 void thermal_core(Vec* pt_g,double* pmelting_offset,FemModel* femmodel,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 17 17 18 18 //int GradJOrth(WorkspaceParams* workspaceparams); … … 29 29 //int ParameterUpdate(double* search_vector,int step, WorkspaceParams* workspaceparams,BatchParams* batchparams); 30 30 void OutputDiagnostic(Vec u_g,Vec p_g, FemModel* femmodels,char* filename); 31 int OutputThermal(Vec* t_g,Vec* tpartition,char* filename,char* analysis_type,int sub_analysis_type);31 void OutputThermal(Vec* t_g,Vec* m_g, FemModel* femmodels,char* filename); 32 32 void OutputControl(Vec u_g,double* p_g, double* J, int nsteps, Vec partition,char* filename,NodeSets* nodesets); 33 33 void WriteLockFile(char* filename); -
issm/trunk/src/c/parallel/thermal.cpp
r465 r472 17 17 int main(int argc,char* *argv){ 18 18 19 int i,n; 20 19 21 /*I/O: */ 20 22 FILE* fid=NULL; … … 30 32 Vec u_g=NULL; 31 33 Vec p_g=NULL; 34 double dt; 35 double ndt; 36 int nsteps; 37 int debug=0; 32 38 33 34 39 /*solution vectors: */ 35 Vec t_g=NULL;36 Vec m_g=NULL;40 Vec* t_g=NULL; 41 Vec* m_g=NULL; 37 42 38 43 ParameterInputs* inputs=NULL; 44 Param* param=NULL; 45 39 46 int waitonlock=0; 47 int sub_analysis_type; 48 double melting_offset; 40 49 41 50 MODULEBOOT(); … … 51 60 MPI_Comm_size(MPI_COMM_WORLD,&num_procs); 52 61 53 _printf_("recover , input file name and output file name:\n");54 62 inputfilename=argv[2]; 55 63 outputfilename=argv[3]; … … 57 65 58 66 /*Open handle to data on disk: */ 59 fid=fopen(inputfilename,"rb"); 60 if(fid==NULL) throw ErrorException(__FUNCT__,exprintf("%s%s%s","could not open file ",inputfilename," for binary reading")); 67 fid=pfopen(inputfilename,"rb"); 61 68 62 _printf_("read and create finite element model:\n");69 _printf_("read and create thermal finite element model:\n"); 63 70 CreateFemModel(&femmodels[0],fid,"thermal",""); 71 _printf_("read and create melting finite element model:\n"); 64 72 CreateFemModel(&femmodels[1],fid,"melting",""); 65 73 … … 68 76 femmodels[0].parameters->FindParam((void*)&p_g,"p_g"); 69 77 femmodels[0].parameters->FindParam((void*)&numberofnodes,"numberofnodes"); 78 femmodels[0].parameters->FindParam((void*)&dt,"dt"); 79 femmodels[0].parameters->FindParam((void*)&ndt,"ndt"); 80 femmodels[0].parameters->FindParam((void*)&waitonlock,"waitonlock"); 81 femmodels[0].parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type"); 82 femmodels[0].parameters->FindParam((void*)&debug,"debug"); 70 83 71 84 inputs=new ParameterInputs; 72 //inputs->Add("velocity",u_g_initial,3,numberofnodes); 85 inputs->Add("velocity",u_g,3,numberofnodes); 86 inputs->Add("pressure",p_g,1,numberofnodes); 87 inputs->Add("dt",dt); 73 88 74 //erase velocities: 75 //param=(Param*)femmodels[0].parameters->FindParamObject("u_g"); 76 //femmodels[0].parameters->DeleteObject((Object*)param); 89 //erase velocities and pressure embedded in parameters 90 param=(Param*)femmodels[0].parameters->FindParamObject("u_g"); 91 femmodels[0].parameters->DeleteObject((Object*)param); 92 param=(Param*)femmodels[0].parameters->FindParamObject("p_g"); 93 femmodels[0].parameters->DeleteObject((Object*)param); 94 param=(Param*)femmodels[1].parameters->FindParamObject("u_g"); 95 femmodels[1].parameters->DeleteObject((Object*)param); 96 param=(Param*)femmodels[1].parameters->FindParamObject("p_g"); 97 femmodels[1].parameters->DeleteObject((Object*)param); 77 98 78 _printf_("call computational core:\n"); 79 diagnostic_core(&u_g,&p_g,femmodels,inputs); 99 if(sub_analysis_type==SteadyAnalysisEnum()){ 100 if(debug)_printf_("computing temperatures:\n"); 101 thermal_core(&t_g[0],&melting_offset,&femmodels[0],inputs,ThermalAnalysisEnum(),SteadyAnalysisEnum()); 102 103 inputs->Add("temperature",t_g[0],1,numberofnodes); 104 inputs->Add("melting_offset",melting_offset); 105 106 if(debug)_printf_("computing melting:\n"); 107 diagnostic_core_linear(&m_g[0],&femmodels[1],inputs,MeltingAnalysisEnum(),SteadyAnalysisEnum()); 108 } 109 else{ 110 111 nsteps=(int)(ndt/dt); 112 113 /*allocate t_g and m_g arrays: */ 114 t_g=(Vec*)xmalloc((nsteps+1)*sizeof(Vec)); 115 m_g=(Vec*)xmalloc((nsteps+1)*sizeof(Vec)); 116 117 //initialize temperature and melting 118 femmodels[0].parameters->FindParam((void*)&t_g[0],"t_g"); 119 femmodels[1].parameters->FindParam((void*)&m_g[0],"m_g"); 120 121 //erase temperature and melting embedded in parameters 122 param=(Param*)femmodels[0].parameters->FindParamObject("t_g"); 123 femmodels[0].parameters->DeleteObject((Object*)param); 124 param=(Param*)femmodels[1].parameters->FindParamObject("m_g"); 125 femmodels[1].parameters->DeleteObject((Object*)param); 126 127 for(i=0;i<nsteps;i++){ 128 if(debug)_printf_("time step: %i/%i\n",n,nsteps); 129 130 if(debug)_printf_("computing temperatures:\n"); 131 inputs->Add("temperature",t_g[i],1,numberofnodes); 132 thermal_core(&t_g[i+1],&melting_offset,&femmodels[0],inputs,ThermalAnalysisEnum(),TransientAnalysisEnum()); 133 134 if(debug)_printf_("computing melting:\n"); 135 inputs->Add("temperature",t_g[i+1],1,numberofnodes); 136 inputs->Add("melting_offset",melting_offset); 137 diagnostic_core_linear(&m_g[0],&femmodels[1],inputs,MeltingAnalysisEnum(),TransientAnalysisEnum()); 138 } 139 } 80 140 81 141 _printf_("write results to disk:\n"); 82 Output Diagnostic(u_g,p_g,&femmodels[0],outputfilename);142 OutputThermal(t_g,m_g,&femmodels[0],outputfilename); 83 143 84 144 _printf_("write lock file:\n"); -
issm/trunk/src/m/classes/public/loadresultsfromdisk.m
r471 r472 1 function md=loadresultsfromdisk(md,filename ,analysis_type)1 function md=loadresultsfromdisk(md,filename) 2 2 %LOADRESULTSFROMDISK - load results of solution sequence from disk file "filename" 3 3 % -
issm/trunk/src/m/classes/public/solve.m
r471 r472 3 3 % 4 4 % Usage: 5 % md=solve(md,varargin)6 % where varargin is a lit of paired arguments.7 % arguments can be: 'analysis_type': 'diagnostic','thermal','prognostic','transient'8 % arguments can be: 'sub_analysis_type': 'transient',''9 % arguments can be: 'package': 'macayeal','ice','cielo'5 % md=solve(md,varargin) 6 % where varargin is a lit of paired arguments. 7 % arguments can be: 'analysis_type': 'diagnostic','thermal','prognostic','transient' 8 % arguments can be: 'sub_analysis_type': 'transient','' 9 % arguments can be: 'package': 'macayeal','ice','cielo' 10 10 % 11 11 % Examples: … … 87 87 addpath(genpath_ice([ISSM_DIR '/src/m/solutions/cielo'])); 88 88 addpath(genpath_ice([ISSM_DIR '/bin'])); 89 90 function solveusage(); 91 disp(' '); 92 disp(' Solve usage: md=solve(md,md.analysis_type,package)'); 93 disp(' md.analysis_type can be ''diagnostic'',''transient'', ''thermal'',''thermaltransient'',''parameters'',''mesh2grid'' or ''control'''); 94 disp(' package is either ''cielo'' or ''ice'''); -
issm/trunk/src/m/solutions/cielo/diagnostic_core_linear.m
r469 r472 13 13 %system matrices 14 14 [K_gg, p_g]=SystemMatrices(m.elements,m.nodes,m.loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 15 [K_gg, p_g,kmax]=PenaltySystemMatrices(K_gg,p_g,m.elements,m.nodes,m.loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 15 16 16 17 %Reduce tangent matrix from g size to f size -
issm/trunk/src/m/solutions/cielo/diagnostic_core_nonlinear.m
r465 r472 33 33 34 34 %penalties 35 [K_gg , p_g ]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);35 [K_gg , p_g, kmax]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 36 36 37 37 -
issm/trunk/src/m/solutions/cielo/thermal.m
r465 r472 28 28 29 29 displaystring(debug,'\n%s',['computing temperatures...']); 30 [t_g loads_tmelting_offset]=thermal_core(m_t,inputs,'thermal','steady');30 [t_g m_t.loads melting_offset]=thermal_core(m_t,inputs,'thermal','steady'); 31 31 32 32 displaystring(debug,'\n%s',['computing melting...']); 33 33 inputs=add(inputs,'melting_offset',melting_offset,'double'); 34 melting_g=melting_core(m_m,inputs,'melting','steady'); 34 inputs=add(inputs,'temperature',t_g,'doublevec',1,m_t.parameters.numberofnodes); 35 melting_g=diagnostic_core_linear(m_m,inputs,'melting','steady'); 35 36 36 37 displaystring(debug,'\n%s',['load results...']); … … 40 41 else 41 42 42 %initialize velocity, pressure, temperature and melting 43 u_g=m_t.parameters.u_g; 44 p_g=m_t.parameters.p_g; 43 %initialize temperature and melting 45 44 t_g=m_t.parameters.t_g; 46 45 melting_g=m_t.parameters.melting_g; … … 58 57 displaystring(debug,'\n%s',[' computing temperatures...']); 59 58 inputs=add(inputs,'temperature',soln(n).t_g,'doublevec',1,m_t.parameters.numberofnodes); 60 [soln(n+1).t_g loads_tmelting_offset]=thermal_core(m_t,inputs);59 [soln(n+1).t_g m_t.loads melting_offset]=thermal_core(m_t,inputs); 61 60 62 61 disp(' computing melting...'); 63 inputs=struct('pressure',p_g,'temperature',soln(n).t_g,'dt',m_t.parameters.dt); 64 soln(n+1).melting_g=melting_core(m_m,inputs); 62 inputs=add(inputs,'temperature',soln(n).t_g,'doublevec',1,m_t.parameters.numberofnodes); 63 inputs=add(inputs,'melting_offset',melting_offset,'double'); 64 soln(n+1).melting_g=diagnostic_core_linear(m_m,inputs); 65 65 66 66 end -
issm/trunk/src/m/solutions/cielo/thermal_core.m
r163 r472 1 function [t_g , m]=thermal_core(m,inputs)1 function [t_g ,loads, melting_offset]=thermal_core(m,inputs,analysis_type,sub_analysis_type) 2 2 %THERMAL_CORE - core of thermal solution sequence. 3 3 % model is return together with temperature … … 5 5 % 6 6 % Usage: 7 % [t_g ,m]=thermal_core(m,inputs)7 % [t_g ,loads, melting_offset]=thermal_core(m,inputs,analysis_type,sub_analysis_type); 8 8 % 9 9 % … … 12 12 converged=0; 13 13 14 % we are going to return the loads, make them a variable of this routine 15 loads=m.loads; 16 14 17 %stiffness and load generation only: 15 18 m.parameters.kflag=1; m.parameters.pflag=1; 16 19 17 disp(sprintf('%s',' starting direct shooting method')); 20 displaystring(m.parameters.debug,'\n%s',[' starting direct shooting method']); 21 18 22 while(~converged), 19 23 … … 23 27 %system matrices 24 28 [K_gg_ , p_g_]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs); 29 [K_gg_ , p_g_]=SystemMatrices(K_gg,p_g,m.elements,m.nodes,loads,m.materials,m.parameters,inputs); 25 30 26 31 %Reduce tangent matrix from g size to f size … … 31 36 32 37 %Solve 33 if m.parameters.debug, 34 disp(sprintf('%s%g',' condition number of stiffness matrix: ',condest(K_ff))); 35 end 38 displaystring(m.parameters.debug,'\n%s',[' condition number of stiffness matrix: ',condest(K_ff)]); 36 39 [t_f]=Solver(K_ff,p_f,[],m.parameters); 37 40 … … 40 43 41 44 %Update inputs in datasets 42 inputs .temperature=t_g;45 inputs=add(inputs,'temperature',t_g,'doublevec',m.parameters.numberofdofspernode,m.parameters.numberofnodes); 43 46 [m.elements,m.nodes, loads,m.materials]=UpdateFromInputs(m.elements,m.nodes, loads,m.materials,inputs); 44 47 … … 47 50 48 51 if ~converged, 49 if m.parameters.debug, disp(sprintf(' %s %i','#unstable constraints ',num_unstable_constraints));end;52 displaystring(m.parameters.debug,'\n%s%i','#unstable constraints ',num_unstable_constraints); 50 53 51 if num_unstable_constraints< thermalparams.min_thermal_constraints,54 if num_unstable_constraints<m.parameters.min_thermal_constraints, 52 55 converged=1; 53 56 end -
issm/trunk/src/m/solutions/ice/thermal.m
r34 r472 33 33 gridset=m_t.gridset; 34 34 inputs=struct('pressure',pressure,'velocity',velocity,'dt',md.dt); 35 [t_g loads_t melting_offset]=thermal_core(m_t,analysis_type,inputs);35 [t_g m_t.loads_t melting_offset]=thermal_core(m_t,analysis_type,inputs); 36 36 37 37 %Call core melting computation … … 69 69 gridset=m_t.gridset; 70 70 inputs=struct('pressure',pressure,'temperature',soln(n).t_g,'velocity',velocity,'dt',md.dt); 71 [soln(n+1).t_g loads_t melting_offset]=thermal_core(m_t,analysis_type,inputs);71 [soln(n+1).t_g m_t.loads_t melting_offset]=thermal_core(m_t,analysis_type,inputs); 72 72 73 73 %Call core melting computation -
issm/trunk/src/mex/PenaltySystemMatrices/PenaltySystemMatrices.cpp
r465 r472 9 9 /*diverse: */ 10 10 int noerr=1; 11 12 /*output: */ 13 double kmax; 11 14 12 15 /*input datasets: */ … … 53 56 54 57 /*!Generate stiffnesses from penalties: */ 55 PenaltySystemMatricesx(Kgg, pg, elements,nodes,loads,materials,kflag,pflag,inputs,analysis_type,sub_analysis_type);58 PenaltySystemMatricesx(Kgg, pg,&kmax,elements,nodes,loads,materials,kflag,pflag,inputs,analysis_type,sub_analysis_type); 56 59 57 60 /*write output datasets: */ 58 61 WriteData(KGG,Kgg,0,0,"Matrix",NULL); 59 62 WriteData(PG,pg,0,0,"Vector",NULL); 63 WriteData(KMAX,&kmax,0,0,"Scalar",NULL); 60 64 61 65 /*Free ressources: */ -
issm/trunk/src/mex/PenaltySystemMatrices/PenaltySystemMatrices.h
r465 r472 31 31 #define KGG (mxArray**)&plhs[0] 32 32 #define PG (mxArray**)&plhs[1] 33 #define KMAX (mxArray**)&plhs[2] 33 34 34 35 /* serial arg counts: */ 35 36 #undef NLHS 36 #define NLHS 237 #define NLHS 3 37 38 #undef NRHS 38 39 #define NRHS 10
Note:
See TracChangeset
for help on using the changeset viewer.