-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users to change the default vector growth stategy (#3389)
This allows users to set at runtime an alternate to the default vector growth factor of 1.5. This could help save memory in simulations that use a lot of particles and are close to the capacity of the GPU device. The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [x] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate --------- Co-authored-by: Weiqun Zhang <[email protected]>
- Loading branch information
1 parent
4a4e8b3
commit 9c256b1
Showing
5 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <AMReX_PODVector.H> | ||
#include <AMReX_ParmParse.H> | ||
#include <AMReX_REAL.H> | ||
|
||
namespace amrex::VectorGrowthStrategy | ||
{ | ||
Real growth_factor = 1.5_rt; | ||
|
||
void Initialize () { | ||
ParmParse pp("amrex"); | ||
pp.queryAdd("vector_growth_factor", growth_factor); | ||
|
||
// clamp user input to reasonable values | ||
constexpr Real min_factor = 1.05_rt; | ||
constexpr Real max_factor = 4._rt; | ||
|
||
if (growth_factor < min_factor) { | ||
if (Verbose()) { | ||
amrex::Print() << "Warning: user-provided vector growth factor is too small." | ||
<< " Clamping to " << min_factor << ". \n"; | ||
} | ||
growth_factor = min_factor; | ||
} | ||
|
||
if (growth_factor > max_factor) { | ||
if (Verbose()) { | ||
amrex::Print() << "Warning: user-provided vector growth factor is too large." | ||
<< " Clamping to " << max_factor << ". \n"; | ||
} | ||
growth_factor = max_factor; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters