5353
5454#include < iomanip>
5555#include < map>
56+ #include < optional>
5657#include < string>
5758#include < vector>
5859
@@ -65,7 +66,6 @@ namespace ntt {
6566 Mesh<M> mesh;
6667 Fields<D, S> fields;
6768 std::vector<Particles<D, M::CoordType>> species;
68- random_number_pool_t random_pool;
6969
7070 /* *
7171 * @brief constructor for "empty" allocation of non-local domain placeholders
@@ -81,7 +81,6 @@ namespace ntt {
8181 : mesh { ncells, extent, metric_params }
8282 , fields {}
8383 , species {}
84- , random_pool { constant::RandomSeed }
8584 , m_index { index }
8685 , m_offset_ndomains { offset_ndomains }
8786 , m_offset_ncells { offset_ncells } {}
@@ -96,10 +95,11 @@ namespace ntt {
9695 : mesh { ncells, extent, metric_params }
9796 , fields { ncells }
9897 , species { species_params.begin (), species_params.end () }
99- , random_pool { constant::RandomSeed + static_cast <std::uint64_t >(index) }
10098 , m_index { index }
10199 , m_offset_ndomains { offset_ndomains }
102- , m_offset_ncells { offset_ncells } {}
100+ , m_offset_ncells { offset_ncells }
101+ , m_random_number_pool { constant::RandomSeed +
102+ static_cast <std::uint64_t >(index) } {}
103103
104104#if defined(MPI_ENABLED)
105105 [[nodiscard]]
@@ -145,6 +145,14 @@ namespace ntt {
145145 return fields.memory_footprint () == 0 and sp_footprint == 0 ;
146146 }
147147
148+ [[nodiscard]]
149+ auto random_pool () -> random_number_pool_t& {
150+ raise::ErrorIf (not m_random_number_pool.has_value (),
151+ " random_pool() called on a placeholder domain" ,
152+ HERE);
153+ return m_random_number_pool.value ();
154+ }
155+
148156 /* setters -------------------------------------------------------------- */
149157 auto set_neighbor_idx (const dir::direction_t <D>& dir, unsigned int idx) -> void {
150158 m_neighbor_idx[dir] = idx;
@@ -161,6 +169,9 @@ namespace ntt {
161169 dir::map_t <D, unsigned int > m_neighbor_idx;
162170 // MPI rank of the domain (used only when MPI enabled)
163171 int m_mpi_rank;
172+
173+ // random number pool for the domain
174+ std::optional<random_number_pool_t > m_random_number_pool;
164175 };
165176
166177 template <SimEngine::type S, class M >
0 commit comments