Skip to content

Commit 3130448

Browse files
authored
remove duplicate init_species_all_equal in favor of uniform_xn (#1736)
test_react had already implemented uniform_xn, so now we bump that runtime parameter up a level so all unit tests can use it.
1 parent dad2c49 commit 3130448

File tree

9 files changed

+20
-18
lines changed

9 files changed

+20
-18
lines changed

Docs/source/burn_cell.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ by setting:
8282

8383
::
8484

85-
unit_test.init_species_all_equal = 1
85+
unit_test.uniform_xn = 1
8686

8787

8888
Controlling time

unit_test/_parameters

+3
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ X32 real 0.0e0
3939
X33 real 0.0e0
4040
X34 real 0.0e0
4141
X35 real 0.0e0
42+
43+
uniform_xn bool 0
44+

unit_test/burn_cell/_parameters

-2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@ density real 1.e7
1717
temperature real 3.e9
1818

1919
skip_initial_normalization bool 0
20-
21-
init_species_all_equal bool 0

unit_test/burn_cell/burn_cell.H

+3-7
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ void burn_cell_c()
2121
// Make sure user set all the mass fractions to values in the interval [0, 1]
2222
for (int n = 1; n <= NumSpec; ++n) {
2323

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

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

unit_test/burn_cell_sdc/burn_cell.H

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void burn_cell_c()
2020
// Make sure user set all the mass fractions to values in the interval [0, 1]
2121
for (int n = 1; n <= NumSpec; ++n) {
2222

23-
massfractions[n-1] = get_xn(n);
23+
massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn);
2424

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

unit_test/eos_cell/eos_cell.H

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void eos_cell_c()
2424
// Make sure user set all the mass fractions to values in the interval [0, 1]
2525
for (int n = 1; n <= NumSpec; ++n) {
2626

27-
massfractions[n-1] = get_xn(n);
27+
massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn);
2828

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

unit_test/jac_cell/jac_cell.H

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void jac_cell_c()
2222
// Make sure user set all the mass fractions to values in the interval [0, 1]
2323
for (int n = 1; n <= NumSpec; ++n) {
2424

25-
massfractions[n-1] = get_xn(n);
25+
massfractions[n-1] = get_xn(n, unit_test_rp::uniform_xn);
2626

2727
if (massfractions[n-1] < 0 || massfractions[n-1] > 1) {
2828
amrex::Error("mass fraction for " + short_spec_names_cxx[n-1] + " not initialized in the interval [0,1]!");
@@ -38,7 +38,9 @@ void jac_cell_c()
3838
burn_state.xn[n] = massfractions[n];
3939
}
4040

41-
normalize_abundances_burn(burn_state);
41+
if (! unit_test_rp::skip_initial_normalization) {
42+
normalize_abundances_burn(burn_state);
43+
}
4244

4345
// get the energy
4446

unit_test/react_util.H

+7-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ init_t setup_composition(const int nz) {
8888

8989

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

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

169169
AMREX_INLINE AMREX_GPU_HOST_DEVICE
170-
amrex::Real get_xn(const int index) {
170+
amrex::Real get_xn(const int index, bool uniform_composition=false) {
171171

172172
amrex::Real mass_fraction{};
173173

174+
if (uniform_composition) {
175+
mass_fraction = 1.0_rt / NumSpec;
176+
return mass_fraction;
177+
}
178+
174179
switch (index) {
175180

176181
case 1:

unit_test/test_react/_parameters

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ dens_max real 1.e9
55
temp_min real 1.e6
66
temp_max real 1.e15
77

8-
uniform_xn int 0
9-
108
tmax real 0.1e0
119

1210
small_temp real 1.e5

0 commit comments

Comments
 (0)