From f8db9d7b2b72c7b1742dd33f1c022ba291b9701f Mon Sep 17 00:00:00 2001 From: Brandon Barker Date: Sun, 7 Jul 2024 23:47:43 -0400 Subject: [PATCH] Use averaged zone cycles and check if input deck exists (#26) * feat: average zone cycles and check if input deck exists, throw error if not --- src/driver.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/driver.cpp b/src/driver.cpp index 7c90d52..0f86a65 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -6,6 +6,7 @@ * Purpose : Main driver routine **/ +#include // std::exists #include #include #include @@ -31,9 +32,15 @@ int main( int argc, char *argv[] ) { // Check cmd line args if ( argc < 2 ) { - throw Error( "No input file passed! Do: ./main IN_FILE" ); + throw Error( "! No input file passed! Do: ./main IN_FILE" ); } + // ensure input deck exists + if ( !std::filesystem::exists( argv[1] ) ) { + throw Error( " ! Invalid path passed for athelas input deck!\n" ); + } + + // load input deck ProblemIn pin( argv[1] ); /* --- Problem Parameters --- */ @@ -105,7 +112,8 @@ int main( int argc, char *argv[] ) { // --- Timer --- Kokkos::Timer timer_total; Kokkos::Timer timer_zone_cycles; - Real zc_ws = 0.0; // zone cycles / wall second + Real zc_ws = 0.0; // zone cycles / wall second + Real time_cycle = 0.0; // --- Evolution loop --- int iStep = 0; @@ -148,6 +156,8 @@ int main( int argc, char *argv[] ) { #endif t += dt; + time_cycle += timer_zone_cycles.seconds( ); + timer_zone_cycles.reset( ); // Write state if ( iStep % i_write == 0 ) { @@ -155,6 +165,11 @@ int main( int argc, char *argv[] ) { i_out += 1; } + if ( iStep % i_print == 0 ) { + zc_ws = static_cast( i_print ) * nX / time_cycle; + std::printf( " ~ %d %.5e %.5e %.5e \n", iStep, t, dt, zc_ws ); + time_cycle = 0.0; + } iStep++; Real time_cycle = timer_zone_cycles.seconds( ); zc_ws = nX / time_cycle;