[823] | 1 | /*!\file: transient.cpp
|
---|
| 2 | * \brief: transient solution
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #include "../issm.h"
|
---|
| 6 | #include "./parallel.h"
|
---|
| 7 |
|
---|
| 8 | #undef __FUNCT__
|
---|
| 9 | #define __FUNCT__ "transient"
|
---|
| 10 |
|
---|
| 11 | #ifdef HAVE_CONFIG_H
|
---|
| 12 | #include "config.h"
|
---|
| 13 | #else
|
---|
| 14 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 15 | #endif
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | int main(int argc,char* *argv){
|
---|
| 19 |
|
---|
| 20 | /*I/O: */
|
---|
| 21 | FILE* fid=NULL;
|
---|
| 22 | char* inputfilename=NULL;
|
---|
| 23 | char* outputfilename=NULL;
|
---|
| 24 | char* lockname=NULL;
|
---|
| 25 | int numberofnodes;
|
---|
| 26 | int qmu_analysis=0;
|
---|
| 27 |
|
---|
[1820] | 28 | /*Model: */
|
---|
| 29 | Model* model=NULL;
|
---|
[823] | 30 | int dim=-1;
|
---|
| 31 |
|
---|
| 32 | /*Results: */
|
---|
| 33 | DataSet* results=NULL;
|
---|
[2112] | 34 | DataSet* processed_results=NULL;
|
---|
[1271] | 35 | Result* result=NULL;
|
---|
[823] | 36 |
|
---|
| 37 | ParameterInputs* inputs=NULL;
|
---|
| 38 | int waitonlock=0;
|
---|
| 39 |
|
---|
| 40 | /*inputs: */
|
---|
| 41 | double* u_g=NULL;
|
---|
| 42 | double* m_g=NULL;
|
---|
| 43 | double* a_g=NULL;
|
---|
| 44 | double dt;
|
---|
[1719] | 45 | double yts;
|
---|
[823] | 46 | Param* param=NULL;
|
---|
| 47 |
|
---|
| 48 | MODULEBOOT();
|
---|
| 49 |
|
---|
| 50 | #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
|
---|
| 51 | throw ErrorException(__FUNCT__," parallel executable was compiled without support of parallel libraries!");
|
---|
| 52 | #endif
|
---|
| 53 |
|
---|
| 54 | PetscInitialize(&argc,&argv,(char *)0,"");
|
---|
| 55 |
|
---|
| 56 | /*Size and rank: */
|
---|
| 57 | MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
|
---|
| 58 | MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
|
---|
| 59 |
|
---|
| 60 | _printf_("recover , input file name and output file name:\n");
|
---|
| 61 | inputfilename=argv[2];
|
---|
| 62 | outputfilename=argv[3];
|
---|
| 63 | lockname=argv[4];
|
---|
| 64 |
|
---|
| 65 | /*Open handle to data on disk: */
|
---|
| 66 | fid=pfopen(inputfilename,"rb");
|
---|
| 67 |
|
---|
[1820] | 68 | /*Initialize model structure: */
|
---|
| 69 | model=new Model();
|
---|
| 70 |
|
---|
[823] | 71 | _printf_("read and create finite element model:\n");
|
---|
| 72 | _printf_("\n reading diagnostic horiz model data:\n");
|
---|
[1881] | 73 | model->AddFormulation(fid,DiagnosticAnalysisEnum(),HorizAnalysisEnum());
|
---|
| 74 |
|
---|
[823] | 75 | _printf_("\n reading diagnostic vert model data:\n");
|
---|
[1881] | 76 | model->AddFormulation(fid,DiagnosticAnalysisEnum(),VertAnalysisEnum());
|
---|
| 77 |
|
---|
[823] | 78 | _printf_("\n reading diagnostic stokes model data:\n");
|
---|
[1881] | 79 | model->AddFormulation(fid,DiagnosticAnalysisEnum(),StokesAnalysisEnum());
|
---|
| 80 |
|
---|
[823] | 81 | _printf_("\n reading diagnostic hutter model data:\n");
|
---|
[1881] | 82 | model->AddFormulation(fid,DiagnosticAnalysisEnum(),HutterAnalysisEnum());
|
---|
| 83 |
|
---|
[823] | 84 | _printf_("\n reading surface and bed slope computation model data:\n");
|
---|
[1886] | 85 | model->AddFormulation(fid,SlopeComputeAnalysisEnum());
|
---|
[1881] | 86 |
|
---|
[823] | 87 | _printf_("\n reading prognositc model data:\n");
|
---|
[1886] | 88 | model->AddFormulation(fid,PrognosticAnalysisEnum());
|
---|
[823] | 89 |
|
---|
| 90 | /*Do we run in 3d?, in which case we need thermal and melting also:*/
|
---|
[1881] | 91 | model->FindParam(&dim,"dim");
|
---|
[823] | 92 | if(dim==3){
|
---|
| 93 | _printf_("read and create thermal finite element model:\n");
|
---|
[1881] | 94 | model->AddFormulation(fid,ThermalAnalysisEnum(),TransientAnalysisEnum());
|
---|
[823] | 95 | _printf_("read and create melting finite element model:\n");
|
---|
[1881] | 96 | model->AddFormulation(fid,MeltingAnalysisEnum(),TransientAnalysisEnum());
|
---|
[823] | 97 | }
|
---|
| 98 |
|
---|
[1887] | 99 | /*recover parameters: */
|
---|
| 100 | model->FindParam(&waitonlock,"waitonlock");
|
---|
| 101 | model->FindParam(&qmu_analysis,"qmu_analysis");
|
---|
| 102 |
|
---|
[823] | 103 | _printf_("initialize inputs:\n");
|
---|
[1888] | 104 | model->FindParam(&u_g,"u_g",PrognosticAnalysisEnum());
|
---|
| 105 | model->FindParam(&m_g,"m_g",PrognosticAnalysisEnum());
|
---|
| 106 | model->FindParam(&a_g,"a_g",PrognosticAnalysisEnum());
|
---|
[1881] | 107 | model->FindParam(&numberofnodes,"numberofnodes");
|
---|
| 108 | model->FindParam(&dt,"dt");
|
---|
| 109 | model->FindParam(&yts,"yts");
|
---|
[1887] | 110 |
|
---|
[1881] | 111 |
|
---|
[828] | 112 | inputs=new ParameterInputs;
|
---|
[859] | 113 | inputs->Add("velocity",u_g,3,numberofnodes);
|
---|
[828] | 114 | inputs->Add("melting",m_g,1,numberofnodes);
|
---|
| 115 | inputs->Add("accumulation",a_g,1,numberofnodes);
|
---|
[1719] | 116 | inputs->Add("dt",dt*yts);
|
---|
[823] | 117 |
|
---|
| 118 | _printf_("initialize results:\n");
|
---|
| 119 | results=new DataSet(ResultsEnum());
|
---|
| 120 |
|
---|
| 121 | /*are we running the solution sequence, or a qmu wrapper around it? : */
|
---|
| 122 | if(!qmu_analysis){
|
---|
| 123 |
|
---|
| 124 | /*run diagnostic analysis: */
|
---|
| 125 | _printf_("call computational core:\n");
|
---|
[1820] | 126 | transient_core(results,model,inputs);
|
---|
[2048] | 127 |
|
---|
| 128 | /*Add analysis_type to results: */
|
---|
| 129 | result=new Result(results->Size()+1,0,1,"analysis_type","transient");
|
---|
| 130 | results->AddObject(result);
|
---|
| 131 |
|
---|
| 132 | _printf_("process results:\n");
|
---|
[2112] | 133 | ProcessResults(&processed_results,results,model,TransientAnalysisEnum());
|
---|
[2048] | 134 |
|
---|
| 135 | _printf_("write results to disk:\n");
|
---|
| 136 | OutputResults(results,outputfilename);
|
---|
[823] | 137 | }
|
---|
| 138 | else{
|
---|
| 139 | /*run qmu analysis: */
|
---|
| 140 | _printf_("calling qmu analysis on transient core:\n");
|
---|
| 141 |
|
---|
| 142 | #ifdef _HAVE_DAKOTA_
|
---|
[1820] | 143 | Qmux(model,inputs,TransientAnalysisEnum(),NoneAnalysisEnum());
|
---|
[823] | 144 | #else
|
---|
| 145 | throw ErrorException(__FUNCT__," Dakota not present, cannot do qmu!");
|
---|
| 146 | #endif
|
---|
| 147 | }
|
---|
| 148 | _printf_("write lock file:\n");
|
---|
| 149 | if (waitonlock){
|
---|
| 150 | WriteLockFile(lockname);
|
---|
| 151 | }
|
---|
[2013] | 152 | /*Free ressources:*/
|
---|
| 153 | delete results;
|
---|
[2112] | 154 | delete processed_results;
|
---|
[2013] | 155 | delete model;
|
---|
| 156 | delete inputs;
|
---|
| 157 | xfree((void**)&u_g);
|
---|
| 158 | xfree((void**)&m_g);
|
---|
| 159 | xfree((void**)&a_g);
|
---|
[823] | 160 |
|
---|
| 161 | _printf_("closing MPI and Petsc\n");
|
---|
| 162 | PetscFinalize();
|
---|
| 163 |
|
---|
| 164 | /*end module: */
|
---|
| 165 | MODULEEND();
|
---|
| 166 |
|
---|
| 167 | return 0; //unix success return;
|
---|
| 168 | }
|
---|