[1] | 1 | /*!\file: diagnostic.cpp
|
---|
| 2 | * \brief: diagnostic solution
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifdef HAVE_CONFIG_H
|
---|
| 6 | #include "config.h"
|
---|
| 7 | #else
|
---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
[3751] | 11 | #include "../objects/objects.h"
|
---|
| 12 | #include "../shared/shared.h"
|
---|
| 13 | #include "../DataSet/DataSet.h"
|
---|
| 14 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
[3775] | 15 | #include "../include/include.h"
|
---|
[3913] | 16 | #include "../modules/modules.h"
|
---|
[3895] | 17 | #include "./solutions.h"
|
---|
[643] | 18 |
|
---|
[1] | 19 | int main(int argc,char* *argv){
|
---|
| 20 |
|
---|
| 21 | /*I/O: */
|
---|
| 22 | FILE* fid=NULL;
|
---|
| 23 | char* inputfilename=NULL;
|
---|
| 24 | char* outputfilename=NULL;
|
---|
| 25 | char* lockname=NULL;
|
---|
[3767] | 26 | bool qmu_analysis=false;
|
---|
| 27 | bool control_analysis=false;
|
---|
[1] | 28 |
|
---|
[3982] | 29 | /*FemModel: */
|
---|
| 30 | FemModel* femmodel=NULL;
|
---|
[643] | 31 |
|
---|
| 32 | /*Results: */
|
---|
[3938] | 33 | Results* results=NULL;
|
---|
[434] | 34 |
|
---|
[3767] | 35 | bool waitonlock=false;
|
---|
[210] | 36 |
|
---|
[2489] | 37 | /*time*/
|
---|
| 38 | double start, finish;
|
---|
| 39 | double start_core, finish_core;
|
---|
| 40 | double start_init, finish_init;
|
---|
| 41 |
|
---|
[4004] | 42 | int analyses[5]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,SlopecomputeAnalysisEnum};
|
---|
| 43 |
|
---|
[1] | 44 | MODULEBOOT();
|
---|
| 45 |
|
---|
| 46 | #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
|
---|
[3332] | 47 | ISSMERROR(" parallel executable was compiled without support of parallel libraries!");
|
---|
[1] | 48 | #endif
|
---|
| 49 |
|
---|
[2489] | 50 | /*Initialize Petsc and get start time*/
|
---|
[1] | 51 | PetscInitialize(&argc,&argv,(char *)0,"");
|
---|
[2489] | 52 | MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
|
---|
[1] | 53 |
|
---|
| 54 | /*Size and rank: */
|
---|
| 55 | MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
|
---|
| 56 | MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
|
---|
| 57 |
|
---|
| 58 | _printf_("recover , input file name and output file name:\n");
|
---|
| 59 | inputfilename=argv[2];
|
---|
| 60 | outputfilename=argv[3];
|
---|
| 61 | lockname=argv[4];
|
---|
| 62 |
|
---|
[3982] | 63 | /*Initialize femmodel structure: */
|
---|
[2489] | 64 | MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
|
---|
[1826] | 65 |
|
---|
[1] | 66 | /*Open handle to data on disk: */
|
---|
[472] | 67 | fid=pfopen(inputfilename,"rb");
|
---|
[358] | 68 |
|
---|
[4004] | 69 | _printf_("create finite element model, using analyses types statically defined above:\n");
|
---|
| 70 | femmodel=new FemModel(iomodel,analyses,5);
|
---|
[1881] | 71 |
|
---|
[1887] | 72 | /*get parameters: */
|
---|
[3982] | 73 | femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
|
---|
| 74 | femmodel->parameters->FindParam(&control_analysis,ControlAnalysisEnum);
|
---|
| 75 | femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
|
---|
[1] | 76 |
|
---|
[2489] | 77 | MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
|
---|
| 78 |
|
---|
[732] | 79 | /*are we running the solution sequence, or a qmu wrapper around it? : */
|
---|
[586] | 80 | if(!qmu_analysis){
|
---|
[1911] | 81 | if(!control_analysis){
|
---|
[3887] | 82 |
|
---|
[1911] | 83 | _printf_("call computational core:\n");
|
---|
[2489] | 84 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[3982] | 85 | results=diagnostic_core(femmodel);
|
---|
[2489] | 86 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
[2234] | 87 |
|
---|
[2048] | 88 | }
|
---|
| 89 | else{
|
---|
[2234] | 90 | /*run control analysis: */
|
---|
| 91 | _printf_("call computational core:\n");
|
---|
[2489] | 92 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[3982] | 93 | results=control_core(femmodel);
|
---|
[2489] | 94 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
[2234] | 95 |
|
---|
[2048] | 96 | }
|
---|
| 97 |
|
---|
| 98 | _printf_("write results to disk:\n");
|
---|
[3938] | 99 | OutputResults(results,outputfilename);
|
---|
[586] | 100 | }
|
---|
| 101 | else{
|
---|
| 102 | /*run qmu analysis: */
|
---|
| 103 | _printf_("calling qmu analysis on diagnostic core:\n");
|
---|
[804] | 104 |
|
---|
[662] | 105 | #ifdef _HAVE_DAKOTA_
|
---|
[2489] | 106 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[3982] | 107 | Qmux(femmodel,DiagnosticAnalysisEnum,NoneAnalysisEnum);
|
---|
[2489] | 108 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
[662] | 109 | #else
|
---|
[3332] | 110 | ISSMERROR(" Dakota not present, cannot do qmu!");
|
---|
[662] | 111 | #endif
|
---|
[586] | 112 | }
|
---|
[1] | 113 |
|
---|
[2629] | 114 | if (waitonlock>0){
|
---|
| 115 | _printf_("write lock file:\n");
|
---|
[1] | 116 | WriteLockFile(lockname);
|
---|
| 117 | }
|
---|
[2048] | 118 |
|
---|
[1911] | 119 | /*Free ressources */
|
---|
[3982] | 120 | delete femmodel;
|
---|
[1942] | 121 | delete results;
|
---|
[1911] | 122 |
|
---|
[2489] | 123 | /*Get finish time and close*/
|
---|
| 124 | MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
|
---|
[3982] | 125 | _printf_("\n %-34s %f seconds \n","FemModel initialization elapsed time:",finish_init-start_init);
|
---|
[2489] | 126 | _printf_(" %-34s %f seconds \n","Core solution elapsed time:",finish_core-start_core);
|
---|
[3097] | 127 | _printf_("\n %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
|
---|
[2397] | 128 | _printf_("closing MPI and Petsc\n");
|
---|
| 129 | PetscFinalize();
|
---|
| 130 |
|
---|
| 131 | /*end module: */
|
---|
| 132 | MODULEEND();
|
---|
| 133 |
|
---|
[1] | 134 | return 0; //unix success return;
|
---|
| 135 | }
|
---|