diff options
author | 2023-02-22 11:27:31 -0800 | |
---|---|---|
committer | 2023-02-22 11:27:31 -0800 | |
commit | e90af8435b64228c4f1d8c83c971a266b668304c (patch) | |
tree | eeb3a0e8074399e78a54519a8014d9aef66e3263 /Source/Diagnostics/BTDiagnostics.cpp | |
parent | c510ded86e5eef9bdb8a3c952a5e08b4f50c3692 (diff) | |
download | WarpX-e90af8435b64228c4f1d8c83c971a266b668304c.tar.gz WarpX-e90af8435b64228c4f1d8c83c971a266b668304c.tar.zst WarpX-e90af8435b64228c4f1d8c83c971a266b668304c.zip |
Add option to increase `max_step` or `stop_time` to fill BTD (#3693)
* add option to increase max_step to fill BTD
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* make sure code compiles locally
* allow for unspecified max step if setting by BTD
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* clarify docs, match default max_step value
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Apply suggestions from code review
shortening flag name
* add example input script, fix bugf
* check stop_time and max_step
* account for stop time
* Fix logic, improve documentation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'Source/Diagnostics/BTDiagnostics.cpp')
-rw-r--r-- | Source/Diagnostics/BTDiagnostics.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/Source/Diagnostics/BTDiagnostics.cpp b/Source/Diagnostics/BTDiagnostics.cpp index 84a0501b5..ab538efb5 100644 --- a/Source/Diagnostics/BTDiagnostics.cpp +++ b/Source/Diagnostics/BTDiagnostics.cpp @@ -42,7 +42,7 @@ #include <cmath> #include <cstdio> #include <memory> -#include <string> +#include <sstream> #include <vector> using namespace amrex::literals; @@ -158,15 +158,38 @@ void BTDiagnostics::DerivedInitData () // j >= i / gamma / (1+beta) * dt_snapshot / dt_boosted_frame const int final_snapshot_starting_step = static_cast<int>(std::ceil(final_snapshot_iteration / warpx.gamma_boost / (1._rt+warpx.beta_boost) * m_dt_snapshots_lab / dt_boosted_frame)); const int final_snapshot_fill_iteration = final_snapshot_starting_step + num_buffers * m_buffer_size - 1; - if (final_snapshot_fill_iteration > warpx.maxStep()) { - std::string warn_string = - "\nSimulation might not run long enough to fill all BTD snapshots.\n" - "Final step: " + std::to_string(warpx.maxStep()) + "\n" - "Last BTD snapshot fills around step: " + std::to_string(final_snapshot_fill_iteration); + const amrex::Real final_snapshot_fill_time = final_snapshot_fill_iteration * dt_boosted_frame; + if (warpx.compute_max_step_from_btd) { + if (final_snapshot_fill_iteration > warpx.maxStep()) { + warpx.updateMaxStep(final_snapshot_fill_iteration); + amrex::Print()<<"max_step insufficient to fill all BTD snapshots. Automatically increased to: " + << final_snapshot_fill_iteration << std::endl; + + } + if (final_snapshot_fill_time > warpx.stopTime()) { + warpx.updateStopTime(final_snapshot_fill_time); + amrex::Print()<<"stop_time insufficient to fill all BTD snapshots. Automatically increased to: " + << final_snapshot_fill_time << std::endl; + + } + if (warpx.maxStep() == std::numeric_limits<int>::max() && warpx.stopTime() == std::numeric_limits<amrex::Real>::max()) { + amrex::Print()<<"max_step unspecified and stop time unspecified. Setting max step to " + <<final_snapshot_fill_iteration<< " to fill all BTD snapshots." << std::endl; + warpx.updateMaxStep(final_snapshot_fill_iteration); + } + + } else if (final_snapshot_fill_iteration > warpx.maxStep() || final_snapshot_fill_time > warpx.stopTime()) { + std::stringstream warn_string; + warn_string << "\nSimulation might not run long enough to fill all BTD snapshots.\n" + << "Final step: " << warpx.maxStep() << "\n" + <<"Stop time: " << warpx.stopTime() << "\n" + <<"Last BTD snapshot fills around step: " << final_snapshot_fill_iteration << "\n" + <<" or time: " << final_snapshot_fill_time << "\n"; ablastr::warn_manager::WMRecordWarning( - "BTD", warn_string, + "BTD", warn_string.str(), ablastr::warn_manager::WarnPriority::low); } + #ifdef WARPX_DIM_RZ UpdateVarnamesForRZopenPMD(); #endif |