Skip to content

Commit

Permalink
Use averaged zone cycles and check if input deck exists (#26)
Browse files Browse the repository at this point in the history
* feat: average zone cycles and check if input deck exists, throw error if not
  • Loading branch information
AstroBarker authored Jul 8, 2024
1 parent 436a67c commit f8db9d7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Purpose : Main driver routine
**/

#include <filesystem> // std::exists
#include <iostream>
#include <string>
#include <vector>
Expand All @@ -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 --- */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -148,13 +156,20 @@ 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 ) {
WriteState( &state, Grid, &S_Limiter, ProblemName, t, order, i_out );
i_out += 1;
}

if ( iStep % i_print == 0 ) {
zc_ws = static_cast<Real>( 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;
Expand Down

0 comments on commit f8db9d7

Please sign in to comment.