Skip to content

Commit 014f888

Browse files
committed
Merge remote-tracking branch 'origin' into 1.4.0rc
2 parents 2d9a5ae + 5bf97fd commit 014f888

7 files changed

Lines changed: 25 additions & 14 deletions

File tree

pgens/accretion/pgen.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ namespace user {
239239

240240
inline void InitPrtls(Domain<S, M>& local_domain) {
241241
const auto energy_dist = arch::Maxwellian<S, M>(local_domain.mesh.metric,
242-
local_domain.random_pool,
242+
local_domain.random_pool(),
243243
temperature);
244244
const auto spatial_dist = PointDistribution<S, M>(xi_min,
245245
xi_max,
@@ -260,7 +260,7 @@ namespace user {
260260

261261
void CustomPostStep(std::size_t, long double time, Domain<S, M>& local_domain) {
262262
const auto energy_dist = arch::Maxwellian<S, M>(local_domain.mesh.metric,
263-
local_domain.random_pool,
263+
local_domain.random_pool(),
264264
temperature);
265265
const auto spatial_dist = PointDistribution<S, M>(xi_min,
266266
xi_max,

pgens/reconnection/pgen.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ namespace user {
216216

217217
// current layer
218218
auto edist_cs = arch::Maxwellian<S, M>(local_domain.mesh.metric,
219-
local_domain.random_pool,
219+
local_domain.random_pool(),
220220
cs_temperature,
221221
{ ZERO, ZERO, cs_drift_u });
222222
const auto sdist_cs = CurrentLayer<S, M>(local_domain.mesh.metric,
@@ -243,7 +243,7 @@ namespace user {
243243
}
244244

245245
const auto energy_dist = arch::Maxwellian<S, M>(domain.mesh.metric,
246-
domain.random_pool,
246+
domain.random_pool(),
247247
bg_temperature);
248248

249249
const auto dx = domain.mesh.metric.template sqrt_h_<1, 1>({});

pgens/turbulence/pgen.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ namespace user {
401401

402402
// particle escape (resample velocities)
403403
const auto energy_dist = arch::Maxwellian<S, M>(domain.mesh.metric,
404-
domain.random_pool,
404+
domain.random_pool(),
405405
temperature);
406406
for (const auto& sp : { 0, 1 }) {
407407
if (domain.species[sp].npld_r() > 1) {

src/archetypes/particle_injector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ namespace arch {
257257
energy_dists.first,
258258
energy_dists.second,
259259
ONE / params.template get<real_t>("scales.V0"),
260-
domain.random_pool));
260+
domain.random_pool()));
261261
domain.species[species.first - 1].set_npart(
262262
domain.species[species.first - 1].npart() + nparticles);
263263
domain.species[species.second - 1].set_npart(
@@ -372,7 +372,7 @@ namespace arch {
372372
energy_dists.second,
373373
spatial_dist,
374374
ONE / params.template get<real_t>("scales.V0"),
375-
domain.random_pool);
375+
domain.random_pool());
376376
Kokkos::parallel_for("InjectNonUniformNumberDensity",
377377
cell_range,
378378
injector_kernel);

src/archetypes/utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ namespace arch {
5252
const auto temperature_2 = temperatures.second / mass_2;
5353

5454
const auto maxwellian_1 = arch::Maxwellian<S, M>(domain.mesh.metric,
55-
domain.random_pool,
55+
domain.random_pool(),
5656
temperature_1,
5757
drift_four_vels.first);
5858
const auto maxwellian_2 = arch::Maxwellian<S, M>(domain.mesh.metric,
59-
domain.random_pool,
59+
domain.random_pool(),
6060
temperature_2,
6161
drift_four_vels.second);
6262

src/engines/srpic.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ namespace ntt {
12211221
}
12221222

12231223
const auto maxwellian = arch::Maxwellian<S, M> { domain.mesh.metric,
1224-
domain.random_pool,
1224+
domain.random_pool(),
12251225
temp };
12261226

12271227
if (dim == in::x1) {

src/framework/domain/domain.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757
#include <iomanip>
5858
#include <map>
59+
#include <optional>
5960
#include <string>
6061
#include <vector>
6162

@@ -69,7 +70,6 @@ namespace ntt {
6970
Mesh<M> mesh;
7071
Fields<D, S> fields;
7172
std::vector<Particles<D, M::CoordType>> species;
72-
random_number_pool_t random_pool;
7373

7474
/**
7575
* @brief constructor for "empty" allocation of non-local domain placeholders
@@ -85,7 +85,6 @@ namespace ntt {
8585
: mesh { ncells, extent, metric_params }
8686
, fields {}
8787
, species {}
88-
, random_pool { constant::RandomSeed }
8988
, m_index { index }
9089
, m_offset_ndomains { offset_ndomains }
9190
, m_offset_ncells { offset_ncells } {}
@@ -100,10 +99,11 @@ namespace ntt {
10099
: mesh { ncells, extent, metric_params }
101100
, fields { ncells }
102101
, species { species_params.begin(), species_params.end() }
103-
, random_pool { constant::RandomSeed + static_cast<std::uint64_t>(index) }
104102
, m_index { index }
105103
, m_offset_ndomains { offset_ndomains }
106-
, m_offset_ncells { offset_ncells } {}
104+
, m_offset_ncells { offset_ncells }
105+
, m_random_number_pool { constant::RandomSeed +
106+
static_cast<std::uint64_t>(index) } {}
107107

108108
#if defined(MPI_ENABLED)
109109
[[nodiscard]]
@@ -149,6 +149,14 @@ namespace ntt {
149149
return fields.memory_footprint() == 0 and sp_footprint == 0;
150150
}
151151

152+
[[nodiscard]]
153+
auto random_pool() -> random_number_pool_t& {
154+
raise::ErrorIf(not m_random_number_pool.has_value(),
155+
"random_pool() called on a placeholder domain",
156+
HERE);
157+
return m_random_number_pool.value();
158+
}
159+
152160
/* setters -------------------------------------------------------------- */
153161
auto set_neighbor_idx(const dir::direction_t<D>& dir, unsigned int idx)
154162
-> void {
@@ -227,6 +235,9 @@ namespace ntt {
227235
dir::map_t<D, unsigned int> m_neighbor_idx;
228236
// MPI rank of the domain (used only when MPI enabled)
229237
int m_mpi_rank;
238+
239+
// random number pool for the domain
240+
std::optional<random_number_pool_t> m_random_number_pool;
230241
};
231242

232243
template <SimEngine::type S, class M>

0 commit comments

Comments
 (0)