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