From 7f9f76e926901de582fae8767f861bb41d747da4 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Mon, 16 Mar 2026 15:23:51 -0400 Subject: [PATCH] add a retry_clip_species option this works like retry_swap_jacobian --- integration/BackwardEuler/be_type.H | 2 ++ integration/RKC/rkc_type.H | 3 +++ integration/VODE/vode_type.H | 3 +++ integration/_parameters | 3 +++ integration/integrator_setup_sdc.H | 7 +++++++ integration/integrator_type_sdc.H | 2 +- integration/integrator_type_strang.H | 2 +- 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/integration/BackwardEuler/be_type.H b/integration/BackwardEuler/be_type.H index 04d7d8f190..f7b5bbc67b 100644 --- a/integration/BackwardEuler/be_type.H +++ b/integration/BackwardEuler/be_type.H @@ -51,6 +51,8 @@ struct be_t { ArrayUtil::MathArray2D jac; short jacobian_type; + bool clip_species; + }; #endif diff --git a/integration/RKC/rkc_type.H b/integration/RKC/rkc_type.H index f4a20a0cd0..48cc3ec795 100644 --- a/integration/RKC/rkc_type.H +++ b/integration/RKC/rkc_type.H @@ -98,6 +98,9 @@ struct rkc_t { // not used here, but needed for compatibility with other integrators short jacobian_type; + // do we clip the species before evaluating the rates + bool clip_species; + }; #ifdef SDC diff --git a/integration/VODE/vode_type.H b/integration/VODE/vode_type.H index a1df1f9bf2..505119b1ce 100644 --- a/integration/VODE/vode_type.H +++ b/integration/VODE/vode_type.H @@ -121,6 +121,9 @@ struct dvode_t // jacobian_type = the type of Jacobian to use (1 = analytic, 2 = numerical) short jacobian_type; + // do we clip the species before evaluating the rates + bool clip_species; + // EL = Real array of integration coefficients. See DVSET amrex::Array1D el; diff --git a/integration/_parameters b/integration/_parameters index f6fb6a41f3..a4dd9a787f 100644 --- a/integration/_parameters +++ b/integration/_parameters @@ -73,6 +73,9 @@ use_burn_retry bool 0 # a retry? retry_swap_jacobian bool 1 +# when we retry, do we clip the species (or if we were, stop clipping) +retry_swap_clipping bool 0 + # Tolerances for the solver (relative and absolute), for the # species and energy equations. If set to < 0, then the same # value as the first attempt is used. diff --git a/integration/integrator_setup_sdc.H b/integration/integrator_setup_sdc.H index fe041ac7ad..00bb038ac8 100644 --- a/integration/integrator_setup_sdc.H +++ b/integration/integrator_setup_sdc.H @@ -50,6 +50,13 @@ IntegratorT integrator_setup (BurnT& state, amrex::Real dt, bool is_retry) int_state.jacobian_type = integrator_rp::jacobian; } + // set whether we clip species + if (is_retry && integrator_rp::retry_swap_clipping) { + int_state.clip_species = (integrator_rp::do_species_clip) ? false : true; + } else { + int_state.clip_species = integrator_rp::do_species_clip; + } + // Fill in the initial integration state. burn_to_int(state, int_state); diff --git a/integration/integrator_type_sdc.H b/integration/integrator_type_sdc.H index d0c699b501..6f6bbbd3bc 100644 --- a/integration/integrator_type_sdc.H +++ b/integration/integrator_type_sdc.H @@ -18,7 +18,7 @@ void clean_state(const amrex::Real time, BurnT& state, T& int_state) { // Ensure that mass fractions always stay positive. - if (integrator_rp::do_species_clip) { + if (int_state.clip_species) { for (int n = 1; n <= NumSpec; ++n) { // we use 1-based indexing, so we need to offset SFS int_state.y(SFS+n) = amrex::Clamp(int_state.y(SFS+n), diff --git a/integration/integrator_type_strang.H b/integration/integrator_type_strang.H index 7eb3c6d60f..7e71f72791 100644 --- a/integration/integrator_type_strang.H +++ b/integration/integrator_type_strang.H @@ -53,7 +53,7 @@ void clean_state (const amrex::Real time, BurnT& state, I& int_state) // Ensure that mass fractions always stay positive and less than or // equal to 1. - if (integrator_rp::do_species_clip) { + if (int_state.clip_species) { for (int n = 1; n <= NumSpec; ++n) { int_state.y(n) = amrex::Clamp(int_state.y(n), integrator_rp::SMALL_X_SAFE, 1.0_rt); }