@@ -27,8 +27,9 @@ class FlatSourceDomain {
2727
2828 // ----------------------------------------------------------------------------
2929 // Methods
30- virtual void update_neutron_source (double k_eff);
31- double compute_k_eff (double k_eff_old) const ;
30+ virtual void update_single_neutron_source (SourceRegionHandle& srh);
31+ virtual void update_all_neutron_sources ();
32+ void compute_k_eff ();
3233 virtual void normalize_scalar_flux_and_volumes (
3334 double total_active_distance_per_iteration);
3435
@@ -41,7 +42,7 @@ class FlatSourceDomain {
4142 void output_to_vtk () const ;
4243 void convert_external_sources ();
4344 void count_external_source_regions ();
44- void set_adjoint_sources (const vector< double >& forward_flux );
45+ void set_adjoint_sources ();
4546 void flux_swap ();
4647 virtual double evaluate_flux_at_point (Position r, int64_t sr, int g) const ;
4748 double compute_fixed_source_normalization_factor () const ;
@@ -54,9 +55,8 @@ class FlatSourceDomain {
5455 bool is_target_void);
5556 void apply_mesh_to_cell_and_children (int32_t i_cell, int32_t mesh_idx,
5657 int32_t target_material_id, bool is_target_void);
57- void prepare_base_source_regions ();
5858 SourceRegionHandle get_subdivided_source_region_handle (
59- int64_t sr, int mesh_bin, Position r, double dist , Direction u);
59+ SourceRegionKey sr_key, Position r, Direction u);
6060 void finalize_discovered_source_regions ();
6161 void apply_transport_stabilization ();
6262 int64_t n_source_regions () const
@@ -67,6 +67,10 @@ class FlatSourceDomain {
6767 {
6868 return source_regions_.n_source_regions () * negroups_;
6969 }
70+ int64_t lookup_base_source_region_idx (const GeometryState& p) const ;
71+ SourceRegionKey lookup_source_region_key (const GeometryState& p) const ;
72+ int64_t lookup_mesh_bin (int64_t sr, Position r) const ;
73+ int lookup_mesh_idx (int64_t sr) const ;
7074
7175 // ----------------------------------------------------------------------------
7276 // Static Data members
@@ -86,6 +90,7 @@ class FlatSourceDomain {
8690
8791 // ----------------------------------------------------------------------------
8892 // Public Data members
93+ double k_eff_ {1.0 }; // Eigenvalue
8994 bool mapped_all_tallies_ {false }; // If all source regions have been visited
9095
9196 int64_t n_external_source_regions_ {0 }; // Total number of source regions with
@@ -110,14 +115,6 @@ class FlatSourceDomain {
110115 // The abstract container holding all source region-specific data
111116 SourceRegionContainer source_regions_;
112117
113- // Base source region container. When source region subdivision via mesh
114- // is in use, this container holds the original (non-subdivided) material
115- // filled cell instance source regions. These are useful as they can be
116- // initialized with external source and mesh domain information ahead of time.
117- // Then, dynamically discovered source regions can be initialized by cloning
118- // their base region.
119- SourceRegionContainer base_source_regions_;
120-
121118 // Parallel hash map holding all source regions discovered during
122119 // a single iteration. This is a threadsafe data structure that is cleaned
123120 // out after each iteration and stored in the "source_regions_" container.
@@ -134,8 +131,17 @@ class FlatSourceDomain {
134131 // Map that relates a SourceRegionKey to the external source index. This map
135132 // is used to check if there are any point sources within a subdivided source
136133 // region at the time it is discovered.
137- std::unordered_map<SourceRegionKey, int64_t , SourceRegionKey::HashFunctor>
138- point_source_map_;
134+ std::unordered_map<SourceRegionKey, vector<int >, SourceRegionKey::HashFunctor>
135+ external_point_source_map_;
136+
137+ // Map that relates a base source region index to the external source index.
138+ // This map is used to check if there are any volumetric sources within a
139+ // subdivided source region at the time it is discovered.
140+ std::unordered_map<int64_t , vector<int >> external_volumetric_source_map_;
141+
142+ // Map that relates a base source region index to a mesh index. This map
143+ // is used to check which subdivision mesh is present in a source region.
144+ std::unordered_map<int64_t , int > mesh_map_;
139145
140146 // If transport corrected MGXS data is being used, there may be negative
141147 // in-group scattering cross sections that can result in instability in MOC
@@ -147,12 +153,11 @@ class FlatSourceDomain {
147153 // ----------------------------------------------------------------------------
148154 // Methods
149155 void apply_external_source_to_source_region (
150- Discrete* discrete, double strength_factor, SourceRegionHandle& srh);
151- void apply_external_source_to_cell_instances (int32_t i_cell,
152- Discrete* discrete, double strength_factor, int target_material_id,
153- const vector<int32_t >& instances);
154- void apply_external_source_to_cell_and_children (int32_t i_cell,
155- Discrete* discrete, double strength_factor, int32_t target_material_id);
156+ int src_idx, SourceRegionHandle& srh);
157+ void apply_external_source_to_cell_instances (int32_t i_cell, int src_idx,
158+ int target_material_id, const vector<int32_t >& instances);
159+ void apply_external_source_to_cell_and_children (
160+ int32_t i_cell, int src_idx, int32_t target_material_id);
156161 virtual void set_flux_to_flux_plus_source (int64_t sr, double volume, int g);
157162 void set_flux_to_source (int64_t sr, int g);
158163 virtual void set_flux_to_old_flux (int64_t sr, int g);
0 commit comments