@@ -139,6 +139,9 @@ class IndependentSource : public Source {
139139 DomainType domain_type () const { return domain_type_; }
140140 const std::unordered_set<int32_t >& domain_ids () const { return domain_ids_; }
141141
142+ // Setter for spatial distribution
143+ void set_space (UPtrSpace space) { space_ = std::move (space); }
144+
142145protected:
143146 // Indicates whether derived class already handles constraints
144147 bool constraints_applied () const override { return true ; }
@@ -205,6 +208,23 @@ typedef unique_ptr<Source> create_compiled_source_t(std::string parameters);
205208// ! Mesh-based source with different distributions for each element
206209// ==============================================================================
207210
211+ // Helper class to sample spatial position on a single mesh element
212+ class MeshElementSpatial : public SpatialDistribution {
213+ public:
214+ MeshElementSpatial (int32_t mesh_index, int elem_index)
215+ : mesh_index_(mesh_index), elem_index_(elem_index)
216+ {}
217+
218+ // ! Sample a position from the distribution
219+ // ! \param seed Pseudorandom number seed pointer
220+ // ! \return Sampled position
221+ Position sample (uint64_t * seed) const override ;
222+
223+ private:
224+ int32_t mesh_index_ {C_NONE}; // !< Index in global meshes array
225+ int elem_index_; // ! Index of mesh element
226+ };
227+
208228class MeshSource : public Source {
209229public:
210230 // Constructors
@@ -219,18 +239,15 @@ class MeshSource : public Source {
219239 double strength () const override { return space_->total_strength (); }
220240
221241 // Accessors
222- const std:: unique_ptr<Source >& source (int32_t i) const
242+ const unique_ptr<IndependentSource >& source (int32_t i) const
223243 {
224244 return sources_.size () == 1 ? sources_[0 ] : sources_[i];
225245 }
226246
227- protected:
228- bool constraints_applied () const override { return true ; }
229-
230247private:
231248 // Data members
232- unique_ptr<MeshSpatial> space_; // !< Mesh spatial
233- vector<std:: unique_ptr<Source >> sources_; // !< Source distributions
249+ unique_ptr<MeshSpatial> space_; // !< Mesh spatial
250+ vector<unique_ptr<IndependentSource >> sources_; // !< Source distributions
234251};
235252
236253// ==============================================================================
0 commit comments