[4030] | 1 | /*!\file: bedslope.cpp
|
---|
| 2 | * \brief: bedslope computation 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 |
|
---|
| 11 | #include "../objects/objects.h"
|
---|
| 12 | #include "../shared/shared.h"
|
---|
[4236] | 13 | #include "../Container/Container.h"
|
---|
[4030] | 14 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 15 | #include "../include/include.h"
|
---|
| 16 | #include "../modules/modules.h"
|
---|
| 17 | #include "./solutions.h"
|
---|
| 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;
|
---|
| 26 | bool qmu_analysis=false;
|
---|
| 27 |
|
---|
| 28 | /*FemModel: */
|
---|
| 29 | FemModel* femmodel=NULL;
|
---|
| 30 |
|
---|
| 31 | /*Results: */
|
---|
| 32 | bool waitonlock=false;
|
---|
| 33 |
|
---|
| 34 | /*time*/
|
---|
| 35 | double start, finish;
|
---|
| 36 | double start_core, finish_core;
|
---|
| 37 | double start_init, finish_init;
|
---|
| 38 |
|
---|
[4295] | 39 | const int numanalyses=1;
|
---|
| 40 | const int analyses[numanalyses]={BedSlopeAnalysisEnum};
|
---|
| 41 | const int solution_type=BedSlopeSolutionEnum;
|
---|
[4030] | 42 |
|
---|
| 43 | MODULEBOOT();
|
---|
| 44 |
|
---|
| 45 | #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
|
---|
| 46 | ISSMERROR(" parallel executable was compiled without support of parallel libraries!");
|
---|
| 47 | #endif
|
---|
| 48 |
|
---|
| 49 | /*Initialize Petsc and get start time*/
|
---|
| 50 | PetscInitialize(&argc,&argv,(char *)0,"");
|
---|
| 51 | MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
|
---|
| 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 | /*Initialize femmodel structure: */
|
---|
| 63 | MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
|
---|
| 64 |
|
---|
| 65 | /*Open handle to data on disk: */
|
---|
| 66 | fid=pfopen(inputfilename,"rb");
|
---|
| 67 |
|
---|
| 68 | _printf_("create finite element model, using analyses types statically defined above:\n");
|
---|
[4295] | 69 | femmodel=new FemModel(fid,solution_type,analyses,numanalyses);
|
---|
[4055] | 70 |
|
---|
| 71 | /*add outputfilename in parameters: */
|
---|
| 72 | femmodel->parameters->AddObject(new StringParam(OutputFileNameEnum,outputfilename));
|
---|
[4030] | 73 |
|
---|
| 74 | /*get parameters: */
|
---|
| 75 | femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
|
---|
| 76 | femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
|
---|
| 77 |
|
---|
| 78 | MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
|
---|
| 79 |
|
---|
| 80 | /*are we running the solution sequence, or a qmu wrapper around it? : */
|
---|
| 81 | if(!qmu_analysis){
|
---|
| 82 |
|
---|
| 83 | _printf_("call computational core:\n");
|
---|
| 84 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
| 85 | bedslope_core(femmodel);
|
---|
| 86 | MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
|
---|
| 87 |
|
---|
| 88 | _printf_("write results to disk:\n");
|
---|
[4211] | 89 | OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results);
|
---|
[4030] | 90 | }
|
---|
| 91 | else{
|
---|
| 92 |
|
---|
| 93 | /*run qmu analysis: */
|
---|
| 94 | _printf_("calling qmu analysis on bed slope core:\n");
|
---|
| 95 |
|
---|
| 96 | #ifdef _HAVE_DAKOTA_
|
---|
| 97 | MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
|
---|
[4055] | 98 | Qmux(femmodel,BedSlopeAnalysisEnum,NoneAnalysisEnum);
|
---|
[4030] | 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 */
|
---|
| 111 | delete femmodel;
|
---|
| 112 |
|
---|
| 113 | /*Get finish time and close*/
|
---|
| 114 | MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
|
---|
| 115 | _printf_("\n %-34s %f seconds \n","FemModel 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 | }
|
---|