Chi-Tech
lbsDO_sweepdata_00.cc
Go to the documentation of this file.
2
5
6#include "chi_runtime.h"
7#include "chi_log.h"
8#include "utils/chi_timer.h"
9#include "utils/chi_utils.h"
10
13
14#include "Sweepers/CBC_SPDS.h"
16
17#define ParallelParmetisNeedsCycles \
18 "When using PARMETIS type partitioning then groupset iterative method" \
19 " must be NPT_CLASSICRICHARDSON_CYCLES or NPT_GMRES_CYCLES"
20
21#define IsParallel Chi::mpi.process_count > 1
22
23#define IsPartitionTypeParmetis \
24 mesher.options.partition_type == \
25 chi_mesh::VolumeMesher::PartitionType::PARMETIS
26
27namespace lbs
28{
29/**This routine initializes basic sweep datastructures that are agnostic of
30 * the number of groups and essentially the groupsets. The routine rebuilds
31 * the data structures i) `quadrature_unq_so_grouping_map_`,
32 * ii) `quadrature_spds_map_` and iii) `quadrature_fluds_templates_map_`.
33 * i) is a mapping, per quadrature, to a collection of angle-index-sets where
34 * all the angles in a particular angleset share the same sweep ordering.
35 * ii) is a mapping, per quadrature, to a collection of SPDSs where each
36 * SPDS mirrors an angle-index-set in i)
37 * iii) is again a mapping, per quadrature, to a collection of Template FLUDS
38 * where each FLUDS mirrors a SPDS in ii).
39 *
40 * The Template FLUDS can be scaled with number of angles and groups which
41 * provides us with the angle-set-subset- and groupset-subset capability.*/
43{
45 << " Initializing sweep datastructures.\n";
46
47 //=================================== Perform checks
48 {
49 auto& mesh_handler = chi_mesh::GetCurrentHandler();
50 auto& mesher = mesh_handler.GetVolumeMesher();
51
52 for (const auto& groupset : groupsets_)
53 {
54 bool no_cycles_parmetis_partitioning =
55 (IsPartitionTypeParmetis and (not groupset.allow_cycles_));
56
57 bool is_1D_geometry = options_.geometry_type == GeometryType::ONED_SLAB;
58
59 if (no_cycles_parmetis_partitioning and not is_1D_geometry and IsParallel)
60 throw std::logic_error(ParallelParmetisNeedsCycles);
61 } // for groupset
62 }
63
64 //=================================== Define sweep ordering groups
66 std::map<AngQuadPtr, bool> quadrature_allow_cycles_map_;
67 for (auto& groupset : groupsets_)
68 {
69 if (quadrature_unq_so_grouping_map_.count(groupset.quadrature_) == 0)
70 quadrature_unq_so_grouping_map_[groupset.quadrature_] =
72 *groupset.quadrature_,
73 groupset.angleagg_method_,
75
76 if (quadrature_allow_cycles_map_.count(groupset.quadrature_) == 0)
77 quadrature_allow_cycles_map_[groupset.quadrature_] =
78 groupset.allow_cycles_;
79 }
80
81 //=================================== Build sweep orderings
83 for (const auto& [quadrature, info] : quadrature_unq_so_grouping_map_)
84 {
85 const auto& unique_so_groupings = info.first;
86
87 for (const auto& so_grouping : unique_so_groupings)
88 {
89 if (so_grouping.empty()) continue;
90
91 const size_t master_dir_id = so_grouping.front();
92 const auto& omega = quadrature->omegas_[master_dir_id];
93
94 bool verbose = false;
95 if (not verbose_sweep_angles_.empty())
96 for (const size_t dir_id : verbose_sweep_angles_)
97 if (chi::VectorListHas(so_grouping, dir_id))
98 {
99 verbose = true;
100 break;
101 }
102
103 if (sweep_type_ == "AAH")
104 {
105 using namespace chi_mesh::sweep_management;
106 const auto new_swp_order = std::make_shared<SPDS_AdamsAdamsHawkins>(
107 omega,
108 *this->grid_ptr_,
109 quadrature_allow_cycles_map_[quadrature],
110 verbose);
111 quadrature_spds_map_[quadrature].push_back(new_swp_order);
112 }
113 else if (sweep_type_ == "CBC")
114 {
115 const auto new_swp_order =
116 std::make_shared<CBC_SPDS>(omega,
117 *this->grid_ptr_,
118 quadrature_allow_cycles_map_[quadrature],
119 verbose);
120 quadrature_spds_map_[quadrature].push_back(new_swp_order);
121 }
122 else
123 ChiInvalidArgument("Unsupported sweeptype \"" + sweep_type_ + "\"");
124 }
125 } // quadrature info-pack
126
127 //=================================== Build FLUDS templates
129 for (const auto& [quadrature, spds_list] : quadrature_spds_map_)
130 {
131 using namespace chi_mesh::sweep_management;
132 for (const auto& spds : spds_list)
133 {
134 if (sweep_type_ == "AAH")
135 {
136 quadrature_fluds_commondata_map_[quadrature].push_back(
137 std::make_unique<AAH_FLUDSCommonData>(
139 }
140 else if (sweep_type_ == "CBC")
141 {
142 quadrature_fluds_commondata_map_[quadrature].push_back(
143 std::make_unique<CBC_FLUDSCommonData>(*spds, grid_nodal_mappings_));
144 }
145 else
146 ChiInvalidArgument("Unsupported sweeptype \"" + sweep_type_ + "\"");
147 }
148 } // for quadrature spds-list pair
149
151 << " Done initializing sweep datastructures.\n";
152}
153
154} // namespace lbs
#define ChiInvalidArgument(message)
static chi::Timer program_timer
Definition: chi_runtime.h:79
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
std::string GetTimeString() const
Definition: chi_timer.cc:38
std::map< AngQuadPtr, FLUDSCommonDataPtrs > quadrature_fluds_commondata_map_
static std::pair< UniqueSOGroupings, DirIDToSOMap > AssociateSOsAndDirections(const chi_mesh::MeshContinuum &grid, const chi_math::AngularQuadrature &quadrature, AngleAggregationType agg_type, lbs::GeometryType lbs_geo_type)
std::map< AngQuadPtr, SwpOrderGroupingInfo > quadrature_unq_so_grouping_map_
std::map< AngQuadPtr, SPDS_ptrs > quadrature_spds_map_
chi_mesh::MeshContinuumPtr grid_ptr_
Definition: lbs_solver.h:75
GridFaceHistogramPtr grid_face_histogram_
Definition: lbs_solver.h:79
lbs::Options options_
Definition: lbs_solver.h:61
std::vector< CellFaceNodalMapping > grid_nodal_mappings_
Definition: lbs_solver.h:77
std::vector< LBSGroupset > groupsets_
Definition: lbs_solver.h:68
#define IsParallel
#define ParallelParmetisNeedsCycles
#define IsPartitionTypeParmetis
MeshHandler & GetCurrentHandler()
bool VectorListHas(const std::vector< T > &list, const B &val)
Definition: chi_utils.h:44
GeometryType geometry_type
Definition: lbs_structs.h:124