[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;
|
---|
[4037] | 28 | bool waitonlock=false;
|
---|
[1] | 29 |
|
---|
[3982] | 30 | /*FemModel: */
|
---|
| 31 | FemModel* femmodel=NULL;
|
---|
[643] | 32 |
|
---|
[2489] | 33 | /*time*/
|
---|
| 34 | double start, finish;
|
---|
| 35 | double start_core, finish_core;
|
---|
| 36 | double start_init, finish_init;
|
---|
| 37 |
|
---|
[4055] | 38 | int analyses[5]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,SlopeAnalysisEnum};
|
---|
[4028] | 39 | int solution_type=DiagnosticAnalysisEnum;
|
---|
[4004] | 40 |
|
---|
[1] | 41 | MODULEBOOT();
|
---|
| 42 |
|
---|
| 43 | #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
|
---|
[3332] | 44 | ISSMERROR(" parallel executable was compiled without support of parallel libraries!");
|
---|
[1] | 45 | #endif
|
---|
| 46 |
|
---|
[2489] | 47 | /*Initialize Petsc and get start time*/
|
---|
[1] | 48 | PetscInitialize(&argc,&argv,(char *)0,"");
|
---|
[2489] | 49 | MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
|
---|
[1] | 50 |
|
---|
| 51 | /*Size and rank: */
|
---|
| 52 | MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
|
---|
| 53 | MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
|
---|
| 54 |
|
---|
| 55 | _printf_("recover , input file name and output file name:\n");
|
---|
| 56 | inputfilename=argv[2];
|
---|
| 57 | outputfilename=argv[3];
|
---|
| 58 | lockname=argv[4];
|
---|
| 59 |
|
---|
[2489] | 60 | MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
|
---|
[1826] | 61 |
|
---|
[1] | 62 | /*Open handle to data on disk: */
|
---|
[472] | 63 | fid=pfopen(inputfilename,"rb");
|
---|
[358] | 64 |
|
---|
[4037] | 65 | _printf_("create finite element model:\n");
|
---|
[4028] | 66 | femmodel=new FemModel(fid,solution_type,analyses,5);
|
---|
[4055] | 67 |
|
---|
| 68 | /*add outputfilename in parameters: */
|
---|
| 69 | femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
|
---|
[1881] | 70 |
|
---|
[1887] | 71 | /*get parameters: */
|
---|
[3982] | 72 | femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
|
---|
| 73 | femmodel->parameters->FindParam(&control_analysis,ControlAnalysisEnum);
|
---|
| 74 | femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
|
---|
[1] | 75 |
|
---|
[2489] | 76 | MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
|
---|
| 77 |
|
---|
[732] | 78 | /*are we running the solution sequence, or a qmu wrapper around it? : */
|
---|
[586] | 79 | if(!qmu_analysis){
|
---|
[1911] | 80 | if(!control_analysis){
|
---|
[3887] | 81 |
|
---|
[1911] | 82 | _printf_("call computational core:\n");
|
---|
[2489] | 83 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[4014] | 84 | diagnostic_core(femmodel);
|
---|
[2489] | 85 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
[2234] | 86 |
|
---|
[2048] | 87 | }
|
---|
| 88 | else{
|
---|
[2234] | 89 | /*run control analysis: */
|
---|
| 90 | _printf_("call computational core:\n");
|
---|
[2489] | 91 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[4014] | 92 | control_core(femmodel);
|
---|
[2489] | 93 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
[2234] | 94 |
|
---|
[2048] | 95 | }
|
---|
| 96 |
|
---|
| 97 | _printf_("write results to disk:\n");
|
---|
[4055] | 98 | OutputResults(femmodel->elements, femmodel->loads, femmodel->nodes, femmodel->vertices, femmodel->materials, femmodel->parameters);
|
---|
[586] | 99 | }
|
---|
| 100 | else{
|
---|
| 101 | /*run qmu analysis: */
|
---|
| 102 | _printf_("calling qmu analysis on diagnostic core:\n");
|
---|
[804] | 103 |
|
---|
[662] | 104 | #ifdef _HAVE_DAKOTA_
|
---|
[2489] | 105 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[3982] | 106 | Qmux(femmodel,DiagnosticAnalysisEnum,NoneAnalysisEnum);
|
---|
[2489] | 107 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
[662] | 108 | #else
|
---|
[3332] | 109 | ISSMERROR(" Dakota not present, cannot do qmu!");
|
---|
[662] | 110 | #endif
|
---|
[586] | 111 | }
|
---|
[1] | 112 |
|
---|
[2629] | 113 | if (waitonlock>0){
|
---|
| 114 | _printf_("write lock file:\n");
|
---|
[1] | 115 | WriteLockFile(lockname);
|
---|
| 116 | }
|
---|
[2048] | 117 |
|
---|
[1911] | 118 | /*Free ressources */
|
---|
[3982] | 119 | delete femmodel;
|
---|
[1911] | 120 |
|
---|
[2489] | 121 | /*Get finish time and close*/
|
---|
| 122 | MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
|
---|
[3982] | 123 | _printf_("\n %-34s %f seconds \n","FemModel initialization elapsed time:",finish_init-start_init);
|
---|
[2489] | 124 | _printf_(" %-34s %f seconds \n","Core solution elapsed time:",finish_core-start_core);
|
---|
[3097] | 125 | _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] | 126 | _printf_("closing MPI and Petsc\n");
|
---|
| 127 | PetscFinalize();
|
---|
| 128 |
|
---|
| 129 | /*end module: */
|
---|
| 130 | MODULEEND();
|
---|
| 131 |
|
---|
[1] | 132 | return 0; //unix success return;
|
---|
| 133 | }
|
---|