|
34 | 34 | * @param[in] scattering processes an array of scattering processes included for consideration.
|
35 | 35 | * @param[in] engine the random engine.
|
36 | 36 | */
|
37 |
| -template <typename index_type> |
| 37 | +template <int max_process_count, typename index_type> |
38 | 38 | AMREX_GPU_HOST_DEVICE AMREX_INLINE
|
39 | 39 | void CollisionPairFilter (const amrex::ParticleReal u1x, const amrex::ParticleReal u1y,
|
40 | 40 | const amrex::ParticleReal u1z, const amrex::ParticleReal u2x,
|
@@ -65,11 +65,11 @@ void CollisionPairFilter (const amrex::ParticleReal u1x, const amrex::ParticleRe
|
65 | 65 |
|
66 | 66 | // Evaluate the cross-section for each scattering process to determine
|
67 | 67 | // the total collision probability.
|
68 |
| - AMREX_ASSERT_WITH_MESSAGE( |
69 |
| - (process_count < 4), "Too many scattering processes in DSMC routine." |
70 |
| - ); |
71 |
| - int coll_type[4] = {0, 0, 0, 0}; |
72 |
| - amrex::ParticleReal sigma_sums[4] = {0._prt, 0._prt, 0._prt, 0._prt}; |
| 68 | + |
| 69 | + // The size of the arrays below is a compile-time constant (template parameter) |
| 70 | + // for performance reasons: it avoids dynamic memory allocation on the GPU. |
| 71 | + int coll_type[max_process_count] = {0}; |
| 72 | + amrex::ParticleReal sigma_sums[max_process_count] = {0._prt}; |
73 | 73 | for (int ii = 0; ii < process_count; ii++) {
|
74 | 74 | auto const& scattering_process = scattering_processes[ii];
|
75 | 75 | coll_type[ii] = int(scattering_process.m_type);
|
|
0 commit comments