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