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 |
|
---|
28 | /*Fem models : */
|
---|
29 | FemModel femmodels[8];
|
---|
30 | int dim=-1;
|
---|
31 |
|
---|
32 | /*Results: */
|
---|
33 | DataSet* results=NULL;
|
---|
34 |
|
---|
35 | ParameterInputs* inputs=NULL;
|
---|
36 | int waitonlock=0;
|
---|
37 |
|
---|
38 | /*inputs: */
|
---|
39 | double* u_g=NULL;
|
---|
40 | double* m_g=NULL;
|
---|
41 | double* a_g=NULL;
|
---|
42 | double dt;
|
---|
43 | Param* param=NULL;
|
---|
44 |
|
---|
45 | MODULEBOOT();
|
---|
46 |
|
---|
47 | #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
|
---|
48 | throw ErrorException(__FUNCT__," parallel executable was compiled without support of parallel libraries!");
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | PetscInitialize(&argc,&argv,(char *)0,"");
|
---|
52 |
|
---|
53 | /*Size and rank: */
|
---|
54 | MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
|
---|
55 | MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
|
---|
56 |
|
---|
57 | _printf_("recover , input file name and output file name:\n");
|
---|
58 | inputfilename=argv[2];
|
---|
59 | outputfilename=argv[3];
|
---|
60 | lockname=argv[4];
|
---|
61 |
|
---|
62 | /*Open handle to data on disk: */
|
---|
63 | fid=pfopen(inputfilename,"rb");
|
---|
64 |
|
---|
65 | _printf_("read and create finite element model:\n");
|
---|
66 | _printf_("\n reading diagnostic horiz model data:\n");
|
---|
67 | CreateFemModel(&femmodels[0],fid,"diagnostic","horiz");
|
---|
68 | _printf_("\n reading diagnostic vert model data:\n");
|
---|
69 | CreateFemModel(&femmodels[1],fid,"diagnostic","vert");
|
---|
70 | _printf_("\n reading diagnostic stokes model data:\n");
|
---|
71 | CreateFemModel(&femmodels[2],fid,"diagnostic","stokes");
|
---|
72 | _printf_("\n reading diagnostic hutter model data:\n");
|
---|
73 | CreateFemModel(&femmodels[3],fid,"diagnostic","hutter");
|
---|
74 | _printf_("\n reading surface and bed slope computation model data:\n");
|
---|
75 | CreateFemModel(&femmodels[4],fid,"slope_compute","");
|
---|
76 | _printf_("\n reading prognositc model data:\n");
|
---|
77 | CreateFemModel(&femmodels[5],fid,"prognostic","");
|
---|
78 |
|
---|
79 | /*Do we run in 3d?, in which case we need thermal and melting also:*/
|
---|
80 | femmodels[0].parameters->FindParam((void*)&dim,"dim");
|
---|
81 | if(dim==3){
|
---|
82 | _printf_("read and create thermal finite element model:\n");
|
---|
83 | CreateFemModel(&femmodels[6],fid,"thermal","transient");
|
---|
84 | _printf_("read and create melting finite element model:\n");
|
---|
85 | CreateFemModel(&femmodels[7],fid,"melting","transient");
|
---|
86 | }
|
---|
87 |
|
---|
88 | _printf_("initialize inputs:\n");
|
---|
89 | inputs=new ParameterInputs;
|
---|
90 | femmodels[5].parameters->FindParam((void*)&numberofnodes,"numberofnodes");
|
---|
91 |
|
---|
92 | femmodels[5].parameters->FindParam((void*)&u_g,"u_g");
|
---|
93 | inputs->Add("velocity",u_g,3,numberofnodes);
|
---|
94 |
|
---|
95 | femmodels[5].parameters->FindParam((void*)&m_g,"m_g");
|
---|
96 | inputs->Add("melting",m_g,1,numberofnodes);
|
---|
97 |
|
---|
98 | femmodels[5].parameters->FindParam((void*)&a_g,"a_g");
|
---|
99 | inputs->Add("accumulation",a_g,1,numberofnodes);
|
---|
100 |
|
---|
101 | femmodels[5].parameters->FindParam((void*)&dt,"dt");
|
---|
102 | inputs->Add("dt",dt);
|
---|
103 |
|
---|
104 | _printf_("initialize results:\n");
|
---|
105 | results=new DataSet(ResultsEnum());
|
---|
106 |
|
---|
107 | /*are we running the solution sequence, or a qmu wrapper around it? : */
|
---|
108 | femmodels[5].parameters->FindParam((void*)&qmu_analysis,"qmu_analysis");
|
---|
109 | if(!qmu_analysis){
|
---|
110 |
|
---|
111 | /*run diagnostic analysis: */
|
---|
112 | _printf_("call computational core:\n");
|
---|
113 | transient_core(results,femmodels,inputs);
|
---|
114 | }
|
---|
115 | else{
|
---|
116 | /*run qmu analysis: */
|
---|
117 | _printf_("calling qmu analysis on transient core:\n");
|
---|
118 |
|
---|
119 | #ifdef _HAVE_DAKOTA_
|
---|
120 | Qmux(&femmodels[0],inputs,TransientAnalysisEnum(),NoneAnalysisEnum());
|
---|
121 | #else
|
---|
122 | throw ErrorException(__FUNCT__," Dakota not present, cannot do qmu!");
|
---|
123 | #endif
|
---|
124 | }
|
---|
125 |
|
---|
126 | _printf_("process results:\n");
|
---|
127 | ProcessResults(&results,&femmodels[0],TransientAnalysisEnum());
|
---|
128 |
|
---|
129 | _printf_("write results to disk:\n");
|
---|
130 | OutputResults(results,outputfilename);
|
---|
131 |
|
---|
132 | _printf_("write lock file:\n");
|
---|
133 | femmodels[0].parameters->FindParam((void*)&waitonlock,"waitonlock");
|
---|
134 | if (waitonlock){
|
---|
135 | WriteLockFile(lockname);
|
---|
136 | }
|
---|
137 |
|
---|
138 | _printf_("closing MPI and Petsc\n");
|
---|
139 | PetscFinalize();
|
---|
140 |
|
---|
141 | /*end module: */
|
---|
142 | MODULEEND();
|
---|
143 |
|
---|
144 | return 0; //unix success return;
|
---|
145 | }
|
---|