From 7cdc358af23663afa688c04f0449394937ded424 Mon Sep 17 00:00:00 2001 From: Rex Zhe Li Date: Mon, 1 Feb 2021 00:39:21 -0500 Subject: [PATCH] code clean up --- tests/lbpm_freelee_simulator.cpp | 113 ++++++++++++++----------------- 1 file changed, 51 insertions(+), 62 deletions(-) diff --git a/tests/lbpm_freelee_simulator.cpp b/tests/lbpm_freelee_simulator.cpp index 61de8c28..3e9c372a 100644 --- a/tests/lbpm_freelee_simulator.cpp +++ b/tests/lbpm_freelee_simulator.cpp @@ -1,81 +1,70 @@ +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include "models/FreeLeeModel.h" #include "common/Utilities.h" +#include "models/FreeLeeModel.h" -//#define WRE_SURFACES +//******************************************************************* +// Implementation of Free-Energy Two-Phase LBM (Lee model) +//******************************************************************* -/* - * Simulator for two-phase flow in porous media - * James E. McClure 2013-2014 - */ - - -//************************************************************************* -// Implementation of Two-Phase Immiscible LBM using CUDA -//************************************************************************* - -int main(int argc, char **argv) +int main( int argc, char **argv ) { - // Initialize MPI - Utilities::startup( argc, argv ); - Utilities::MPI comm( MPI_COMM_WORLD ); - int rank = comm.getRank(); - int nprocs = comm.getSize(); + // Initialize + Utilities::startup( argc, argv ); + + // Load the input database + auto db = std::make_shared( argv[1] ); - // Load the input database - auto db = std::make_shared( argv[1] ); + { // Limit scope so variables that contain communicators will free before MPI_Finialize - // Initialize MPI and error handlers - auto multiple = db->getWithDefault( "MPI_THREAD_MULTIPLE", true ); - //Utilities::startup( argc, argv, multiple ); - //Utilities::MPI::changeProfileLevel( 1 ); + Utilities::MPI comm( MPI_COMM_WORLD ); + int rank = comm.getRank(); + int nprocs = comm.getSize(); - { // Limit scope so variables that contain communicators will free before MPI_Finialize + if (rank == 0){ + printf("********************************************************\n"); + printf("Running Free Energy Lee LBM \n"); + printf("********************************************************\n"); + } + // Initialize compute device + int device=ScaLBL_SetDevice(rank); + NULL_USE( device ); + ScaLBL_DeviceBarrier(); + comm.barrier(); - if (rank == 0){ - printf("********************************************************\n"); - printf("Running Free Energy Lee LBM \n"); - printf("********************************************************\n"); - } - // Initialize compute device - int device=ScaLBL_SetDevice(rank); - NULL_USE( device ); - ScaLBL_DeviceBarrier(); - comm.barrier(); + PROFILE_ENABLE(1); + //PROFILE_ENABLE_TRACE(); + //PROFILE_ENABLE_MEMORY(); + PROFILE_SYNCHRONIZE(); + PROFILE_START("Main"); + Utilities::setErrorHandlers(); - PROFILE_ENABLE(1); - //PROFILE_ENABLE_TRACE(); - //PROFILE_ENABLE_MEMORY(); - PROFILE_SYNCHRONIZE(); - PROFILE_START("Main"); - Utilities::setErrorHandlers(); + auto filename = argv[1]; + ScaLBL_FreeLeeModel LeeModel( rank,nprocs,comm ); + LeeModel.ReadParams( filename ); + LeeModel.SetDomain(); + LeeModel.ReadInput(); + LeeModel.Create(); + LeeModel.Initialize(); + LeeModel.Run(); + LeeModel.WriteDebug(); - auto filename = argv[1]; - ScaLBL_FreeLeeModel LeeModel(rank,nprocs,comm); - LeeModel.ReadParams(filename); - LeeModel.SetDomain(); - LeeModel.ReadInput(); - LeeModel.Create(); // creating the model will create data structure to match the pore structure and allocate variables - LeeModel.Initialize(); // initializing the model will set initial conditions for variables - LeeModel.Run(); - LeeModel.WriteDebug(); - - PROFILE_STOP("Main"); - auto file = db->getWithDefault( "TimerFile", "lbpm_freelee_simulator" ); - auto level = db->getWithDefault( "TimerLevel", 1 ); - PROFILE_SAVE(file,level); - // **************************************************** + PROFILE_STOP("Main"); + auto file = db->getWithDefault( "TimerFile", "lbpm_freelee_simulator" ); + auto level = db->getWithDefault( "TimerLevel", 1 ); + PROFILE_SAVE( file,level ); + // **************************************************** - } // Limit scope so variables that contain communicators will free before MPI_Finialize + } // Limit scope so variables that contain communicators will free before MPI_Finialize - Utilities::shutdown(); + Utilities::shutdown(); + return 0; }