From 4f66639c3878f422bd94f855818b0a161c1a26fc Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Tue, 4 Jun 2024 13:49:08 -0700 Subject: [PATCH] update options --- .../SUNDIALS/Exec/inputs_forward_euler | 4 ++-- ExampleCodes/SUNDIALS/Exec/inputs_rk3 | 4 ++-- .../SUNDIALS/Exec/inputs_sundials_erk | 11 +++++----- ExampleCodes/SUNDIALS/Source/main.cpp | 22 ++++++++++--------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ExampleCodes/SUNDIALS/Exec/inputs_forward_euler b/ExampleCodes/SUNDIALS/Exec/inputs_forward_euler index eeec44c6..746c08b9 100644 --- a/ExampleCodes/SUNDIALS/Exec/inputs_forward_euler +++ b/ExampleCodes/SUNDIALS/Exec/inputs_forward_euler @@ -1,8 +1,8 @@ n_cell = 32 max_grid_size = 16 -nsteps = 1000 -plot_int = 100 +nsteps = 10 +plot_int = 1 dt = 1.e-5 diff --git a/ExampleCodes/SUNDIALS/Exec/inputs_rk3 b/ExampleCodes/SUNDIALS/Exec/inputs_rk3 index dded52b9..b363c7cb 100644 --- a/ExampleCodes/SUNDIALS/Exec/inputs_rk3 +++ b/ExampleCodes/SUNDIALS/Exec/inputs_rk3 @@ -1,8 +1,8 @@ n_cell = 32 max_grid_size = 16 -nsteps = 1000 -plot_int = 100 +nsteps = 10 +plot_int = 1 dt = 1.e-5 diff --git a/ExampleCodes/SUNDIALS/Exec/inputs_sundials_erk b/ExampleCodes/SUNDIALS/Exec/inputs_sundials_erk index c03a8e0a..5eb6ab52 100644 --- a/ExampleCodes/SUNDIALS/Exec/inputs_sundials_erk +++ b/ExampleCodes/SUNDIALS/Exec/inputs_sundials_erk @@ -1,15 +1,14 @@ n_cell = 32 max_grid_size = 16 -# time between outputs -dt_out = 1.e-3 - # number of output steps nsteps = 10 -plot_int = 10 +plot_int = 1 + +dt = 1.e-5 -# final time -t_final = 1.e-2 +# use adaptive time stepping -- should also set integrator tolerances +# adapt_dt = true # INTEGRATION # integration.type can take on the following values: diff --git a/ExampleCodes/SUNDIALS/Source/main.cpp b/ExampleCodes/SUNDIALS/Source/main.cpp index 60c543e1..a04c62ff 100644 --- a/ExampleCodes/SUNDIALS/Source/main.cpp +++ b/ExampleCodes/SUNDIALS/Source/main.cpp @@ -35,10 +35,10 @@ void main_main () int plot_int; // time step - Real dt_out; + Real dt; - // final time - Real t_final; + // use adaptive time step (dt used for output time) + bool adapt_dt = false; // inputs parameters { @@ -64,10 +64,10 @@ void main_main () pp.query("plot_int",plot_int); // time step - pp.get("dt_out",dt_out); + pp.get("dt",dt); - // time step - pp.get("t_final",t_final); + // use adaptive step sizes + pp.query("adapt_dt",adapt_dt); } // ********************************** @@ -188,11 +188,15 @@ void main_main () TimeIntegrator integrator(phi, time); integrator.set_pre_rhs_action(pre_rhs_function); integrator.set_rhs(rhs_function); + integrator.set_time_step(dt); + if (adapt_dt) { + integrator.set_adaptive_step(); + } for (int step = 1; step <= nsteps; ++step) { - // Set output time - time += dt_out; + // Set time to evolve to + time += dt; // Advance to output time integrator.evolve(phi, time); @@ -206,7 +210,5 @@ void main_main () const std::string& pltfile = amrex::Concatenate("plt",step,5); WriteSingleLevelPlotfile(pltfile, phi, {"phi"}, geom, time, step); } - - if (time > t_final) break; } }