Skip to content

Commit

Permalink
remove duplicate init_species_all_equal in favor of uniform_xn
Browse files Browse the repository at this point in the history
test_react had already implemented uniform_xn, so now we bump
that runtime parameter up a level so all unit tests can use it.
  • Loading branch information
zingale committed Feb 6, 2025
1 parent b0839d1 commit 27b71fc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Docs/source/burn_cell.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ by setting:

::

unit_test.init_species_all_equal = 1
unit_test.uniform_xn = 1


Controlling time
Expand Down
3 changes: 3 additions & 0 deletions unit_test/_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ X32 real 0.0e0
X33 real 0.0e0
X34 real 0.0e0
X35 real 0.0e0

uniform_xn bool 0

2 changes: 0 additions & 2 deletions unit_test/burn_cell/_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ density real 1.e7
temperature real 3.e9

skip_initial_normalization bool 0

init_species_all_equal bool 0
10 changes: 3 additions & 7 deletions unit_test/burn_cell/burn_cell.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ void burn_cell_c()
// Make sure user set all the mass fractions to values in the interval [0, 1]
for (int n = 1; n <= NumSpec; ++n) {

if (unit_test_rp::init_species_all_equal) {
massfractions[n-1] = 1.0_rt / static_cast<amrex::Real>(NumSpec);
} else {
massfractions[n-1] = get_xn(n);
massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn);

if (massfractions[n-1] < 0 || massfractions[n-1] > 1) {
amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!");
}
if (massfractions[n-1] < 0 || massfractions[n-1] > 1) {
amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!");
}
}

Expand Down
9 changes: 7 additions & 2 deletions unit_test/react_util.H
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ init_t setup_composition(const int nz) {


AMREX_INLINE AMREX_GPU_HOST_DEVICE
void get_xn(const int k, const init_t cd, amrex::Real *xn_zone, int uniform_composition = 0) {
void get_xn(const int k, const init_t cd, amrex::Real *xn_zone, bool uniform_composition=false) {

for (int n = 0; n < NumSpec; n++) {
xn_zone[n] = 0.0_rt;
Expand Down Expand Up @@ -167,10 +167,15 @@ void get_xn(const int k, const init_t cd, amrex::Real *xn_zone, int uniform_comp
///

AMREX_INLINE AMREX_GPU_HOST_DEVICE
amrex::Real get_xn(const int index) {
amrex::Real get_xn(const int index, bool uniform_composition=false) {

amrex::Real mass_fraction{};

if (uniform_composition) {
mass_fraction = 1.0_rt / NumSpec;
return mass_fraction;
}

switch (index) {

case 1:
Expand Down
2 changes: 0 additions & 2 deletions unit_test/test_react/_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ dens_max real 1.e9
temp_min real 1.e6
temp_max real 1.e15

uniform_xn int 0

tmax real 0.1e0

small_temp real 1.e5
Expand Down

0 comments on commit 27b71fc

Please sign in to comment.