Skip to content

Commit 92addab

Browse files
authored
Merge branch 'master' into add-modular-precision-update
2 parents c395868 + ffce00e commit 92addab

File tree

26 files changed

+166
-1066
lines changed

26 files changed

+166
-1066
lines changed

docs/documentation/testing.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Testing
2-
2+
33
To run MFC's test suite, run
44
```shell
55
./mfc.sh test -j <thread count>
@@ -8,15 +8,15 @@ To run MFC's test suite, run
88
It will generate and run test cases, comparing their output to previous runs from versions of MFC considered accurate.
99
*golden files*, stored in the `tests/` directory contain this data, aggregating `.dat` files generated when running MFC.
1010
A test is considered passing when our error tolerances are met in order to maintain a high level of stability and accuracy.
11-
Run `./mfc.sh test -h` for a full list of accepted arguments.
12-
13-
Most notably, you can consult the full list of tests by running
14-
```shell
15-
./mfc.sh test -l
16-
```
11+
`./mfc.sh test` has the following unique options:
12+
- `-l` outputs the full list of tests
13+
- `--from` (`-f)` and `--to` (`t`) restrict testing to a range of contiguous slugs
14+
- `--only` (`-o`) restricts testing to a non-contiguous range of tests based on if their trace contains a certain feature
15+
- `--test-all` (`a`) test post process and ensure the Silo database files are correct
16+
- `--percent` (`%`) to specify a percentage of the test suite to select at random and test
17+
- `--max-attempts` (`-m`) the maximum number of attempts to make on a test before considering it failed
18+
- `--no-examples` skips the testing of cases in the examples folder
1719

18-
To restrict to a given range, use the `--from` (`-f`) and `--to` (`-t`) options.
19-
To run a (non-contiguous) subset of tests, use the `--only` (`-o`) option instead.
2020
To specify a computer, pass the `-c` flag to `./mfc.sh run` like so:
2121
```shell
2222
./mfc.sh test -j <thread count> -- -c <computer name>
@@ -27,15 +27,13 @@ The use of `--` in the above command passes options to the `./mfc.sh run` comman
2727

2828
### Creating Tests
2929

30-
To (re)generate *golden files*, append the `--generate` option:
31-
```shell
32-
./mfc.sh test --generate -j 8
33-
```
30+
Creating and updating test cases can be done with the following command line arguments:
31+
- `--generate` to generate golden files for a new test case
32+
- `--add-new-variables` to similar to `--generate`, but rather than generating a golden file from scratch, it generates a gold file with new variables for an updated test without changing the original golden file values.
33+
- `--remove-old-tests` to remove the directories of tests that no longer exist
3434

3535
It is recommended that a range be specified when generating golden files for new test cases, as described in the previous section, in an effort not to regenerate the golden files of existing test cases.
3636

37-
**Note:** If you output new variables and want to update the golden files to include these without modifying the original data, use the `--add-new-variables` option instead.
38-
3937
Adding a new test case can be done by modifying [cases.py](https://github.com/MFlowCode/MFC/tree/master/toolchain/mfc/test/cases.py).
4038
The function `list_cases` is responsible for generating the list of test cases.
4139
Loops and conditionals are used to vary parameters, whose defaults can be found in the `BASE_CFG` case object within [case.py](https://github.com/MFlowCode/MFC/tree/master/toolchain/mfc/test/case.py).
@@ -44,7 +42,7 @@ The function operates on two variables:
4442
- `stack`: A stack that holds the variations to the default case parameters.
4543
By pushing and popping the stack inside loops and conditionals, it is easier to nest test case descriptions, as it holds the variations that are common to all future test cases within the same indentation level (in most scenarios).
4644

47-
- `cases`: A list that holds fully-formed `Case` objects, that will be returned at the end of the function.
45+
- `cases`: A list that holds fully-formed `Case` objects, that will be returned at the end of the function.
4846

4947
Internally a test case is described as:
5048
```python
@@ -93,13 +91,13 @@ Finally, the case is appended to the `cases` list, which will be returned by the
9391

9492
### Testing Post Process
9593

96-
To test the post-processing code, append the `-a` or `--test-all` option:
94+
To test the post-processing code, append the `-a` or `--test-all` option:
9795
```shell
9896
./mfc.sh test -a -j 8
9997
```
10098

10199
This argument will re-run the test stack with `parallel_io='T'`, which generates silo_hdf5 files.
102100
It will also turn most write parameters (`*_wrt`) on.
103101
Then, it searches through the silo files using `h5dump` to ensure that there are no `NaN`s or `Infinity`s.
104-
Although adding this option does not guarantee that accurate `.silo` files are generated, it does ensure that the post-process code does not fail or produce malformed data.
102+
Although adding this option does not guarantee that accurate `.silo` files are generated, it does ensure that the post-process code does not fail or produce malformed data.
105103

examples/nD_perfect_reactor/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
sol.TPX = 1_600, ct.one_atm, 'H2:0.04, O2:0.02, AR:0.94'
2828

29-
Nx = 25 * args.scale
29+
Nx = int(25 * args.scale)
3030
Tend = 1e-4
3131
s = 1e-2
3232
dt = 1e-7

src/common/m_variables_conversion.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module m_variables_conversion
2323
use m_helper
2424

2525
use m_thermochem, only: &
26-
num_species, get_temperature, get_pressure, &
26+
num_species, get_temperature, get_pressure, gas_constant, &
2727
get_mixture_molecular_weight, get_mixture_energy_mass
2828

2929
! ==========================================================================
@@ -1116,7 +1116,7 @@ contains
11161116
end do
11171117

11181118
call get_mixture_molecular_weight(Ys, mix_mol_weight)
1119-
T = q_prim_vf(T_idx)%sf(j, k, l)
1119+
T = q_prim_vf(E_idx)%sf(j, k, l)*mix_mol_weight/(gas_constant*rho)
11201120
call get_mixture_energy_mass(T, Ys, e_mix)
11211121

11221122
q_cons_vf(E_idx)%sf(j, k, l) = &

src/post_process/p_main.fpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ program p_main
4444

4545
! Time-Marching Loop =======================================================
4646
do
47+
! If all time-steps are not ready to be post-processed and one rank is
48+
! faster than another, the slower rank processing the last available
49+
! step might be killed when the faster rank attempts to process the
50+
! first missing step, before the slower rank finishes writing the last
51+
! available step. To avoid this, we force synchronization here.
52+
call s_mpi_barrier()
53+
4754
call s_perform_time_step(t_step)
4855

4956
call s_save_data(t_step, varname, pres, c, H)

src/simulation/m_chemistry.fpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -51,53 +51,6 @@ contains
5151

5252
end subroutine s_finalize_chemistry_module
5353

54-
subroutine s_compute_chemistry_advection_flux(flux_n, rhs_vf)
55-
56-
type(vector_field), dimension(:), intent(IN) :: flux_n
57-
type(scalar_field), dimension(sys_size), intent(INOUT) :: rhs_vf
58-
integer :: x, y, z
59-
integer :: eqn
60-
61-
real(wp) :: flux_x, flux_y, flux_z
62-
63-
#:for num_dims in range(1, 4)
64-
if (num_dims == ${num_dims}$) then
65-
!$acc parallel loop collapse(4) gang vector default(present) &
66-
!$acc private(flux_x, flux_y, flux_z)
67-
do z = idwint(3)%beg, idwint(3)%end
68-
do y = idwint(2)%beg, idwint(2)%end
69-
do x = idwint(1)%beg, idwint(1)%end
70-
do eqn = chemxb, chemxe
71-
! \nabla \cdot (F)
72-
flux_x = (flux_n(1)%vf(eqn)%sf(x - 1, y, z) - &
73-
flux_n(1)%vf(eqn)%sf(x, y, z))/dx(x)
74-
75-
#:if num_dims >= 2
76-
flux_y = (flux_n(2)%vf(eqn)%sf(x, y - 1, z) - &
77-
flux_n(2)%vf(eqn)%sf(x, y, z))/dy(y)
78-
#:else
79-
flux_y = 0._wp
80-
#:endif
81-
82-
#:if num_dims == 3
83-
flux_z = (flux_n(3)%vf(eqn)%sf(x, y, z - 1) - &
84-
flux_n(3)%vf(eqn)%sf(x, y, z))/dz(z)
85-
#:else
86-
flux_z = 0._wp
87-
#:endif
88-
89-
rhs_vf(eqn)%sf(x, y, z) = flux_x + flux_y + flux_z
90-
end do
91-
92-
rhs_vf(T_idx)%sf(x, y, z) = 0._wp
93-
end do
94-
end do
95-
end do
96-
end if
97-
#:endfor
98-
99-
end subroutine s_compute_chemistry_advection_flux
100-
10154
subroutine s_compute_chemistry_reaction_flux(rhs_vf, q_cons_qp, q_prim_qp)
10255

10356
type(scalar_field), dimension(sys_size), intent(INOUT) :: rhs_vf, q_cons_qp, q_prim_qp

src/simulation/m_rhs.fpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,12 +860,6 @@ contains
860860
end do
861861
! END: Dimensional Splitting Loop =================================
862862

863-
if (chemistry) then
864-
call nvtxStartRange("RHS-CHEM-ADVECTION")
865-
call s_compute_chemistry_advection_flux(flux_n, rhs_vf)
866-
call nvtxEndRange
867-
end if
868-
869863
if (ib) then
870864
!$acc parallel loop collapse(3) gang vector default(present)
871865
do l = 0, p
@@ -904,6 +898,10 @@ contains
904898
end if
905899

906900
if (chemistry) then
901+
!$acc kernels
902+
rhs_vf(T_idx)%sf(:, :, :) = 0d0
903+
!$acc end kernels
904+
907905
if (chem_params%reactions) then
908906
call nvtxStartRange("RHS-CHEM-REACTIONS")
909907
call s_compute_chemistry_reaction_flux(rhs_vf, q_cons_qp%vf, q_prim_qp%vf)

src/simulation/m_riemann_solvers.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,8 +800,8 @@ contains
800800
Y_L = qL_prim_rs${XYZ}$_vf(j, k, l, i)
801801
Y_R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)
802802
803-
flux_rs${XYZ}$_vf(j, k, l, i) = (s_M*Y_R*rho_R*vel_R(dir_idx(norm_dir)) &
804-
- s_P*Y_L*rho_L*vel_L(dir_idx(norm_dir)) &
803+
flux_rs${XYZ}$_vf(j, k, l, i) = (s_M*Y_R*rho_R*vel_R(dir_idx(1)) &
804+
- s_P*Y_L*rho_L*vel_L(dir_idx(1)) &
805805
+ s_M*s_P*(Y_L*rho_L - Y_R*rho_R)) &
806806
/(s_M - s_P)
807807
flux_src_rs${XYZ}$_vf(j, k, l, i) = 0._wp

tests/1550B67E/golden-metadata.txt

Lines changed: 2 additions & 134 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)