Chi-Tech
AAH_FLUDS.cc
Go to the documentation of this file.
1#include "AAH_FLUDS.h"
2
3#include "chi_runtime.h"
4#include "chi_log.h"
5#include "math/chi_math.h"
6
8{
9
10// ######################################################### Constr
11/**This constructor initializes an auxiliary FLUDS based
12 * on a primary FLUDS. The restriction here is that the
13 * auxiliary FLUDS has the exact same sweep ordering as the
14 * primary FLUDS.*/
15AAH_FLUDS::AAH_FLUDS(size_t num_groups,
16 size_t num_angles,
17 const AAH_FLUDSCommonData& common_data)
18 : FLUDS(num_groups, num_angles, common_data.GetSPDS()),
19 common_data_(common_data)
20{
21 //============================== Adjusting for different group aggregate
24
27}
28
29// ###################################################################
30/**Given a sweep ordering index, the outgoing face counter,
31 * the outgoing face dof, this function computes the location
32 * of this position's upwind psi in the local upwind psi vector
33 * and returns a reference to it.*/
34double* AAH_FLUDS::OutgoingPsi(int cell_so_index,
35 int outb_face_counter,
36 int face_dof,
37 int n)
38{
39 // Face category
40 int fc = common_data_
41 .so_cell_outb_face_face_category[cell_so_index][outb_face_counter];
42
43 if (fc >= 0)
44 {
45 size_t index =
48 .so_cell_outb_face_slot_indices[cell_so_index][outb_face_counter] *
50 face_dof * num_groups_;
51
52 return &local_psi_[fc][index];
53 }
54 else
55 {
56 size_t index =
59 .so_cell_outb_face_slot_indices[cell_so_index][outb_face_counter] *
61 face_dof * num_groups_;
62
63 return &delayed_local_psi_[index];
64 }
65}
66
67// ###################################################################
68/**Given a outbound face counter this method returns a pointer
69 * to the location*/
70double* AAH_FLUDS::NLOutgoingPsi(int outb_face_counter, int face_dof, int n)
71{
72 if (outb_face_counter > common_data_.nonlocal_outb_face_deplocI_slot.size())
73 {
75 << "Invalid number of outb_face_counter " << outb_face_counter
76 << " max allowed " << common_data_.nonlocal_outb_face_deplocI_slot.size();
77 Chi::Exit(EXIT_FAILURE);
78 }
79
80 int depLocI =
81 common_data_.nonlocal_outb_face_deplocI_slot[outb_face_counter].first;
82 int slot =
83 common_data_.nonlocal_outb_face_deplocI_slot[outb_face_counter].second;
84 int nonlocal_psi_Gn_blockstride =
86
87 int index = nonlocal_psi_Gn_blockstride * num_groups_ * n +
88 slot * num_groups_ + face_dof * num_groups_;
89
90 if ((index < 0) || (index > deplocI_outgoing_psi_[depLocI].size()))
91 {
92 Chi::log.LogAllError() << "Invalid index " << index
93 << " encountered in non-local outgoing Psi"
94 << " max allowed "
95 << deplocI_outgoing_psi_[depLocI].size();
96 Chi::Exit(EXIT_FAILURE);
97 }
98
99 return &deplocI_outgoing_psi_[depLocI][index];
100}
101
102// ###################################################################
103/**Given a sweep ordering index, the incoming face counter,
104 * the incoming face dof, this function computes the location
105 * where to store this position's outgoing psi and returns a reference
106 * to it.*/
108 int cell_so_index, int inc_face_counter, int face_dof, int g, int n)
109{
110 // Face category
111 int fc = common_data_
112 .so_cell_inco_face_face_category[cell_so_index][inc_face_counter];
113
114 if (fc >= 0)
115 {
116 size_t index =
119 .so_cell_inco_face_dof_indices[cell_so_index][inc_face_counter]
120 .slot_address *
123 .so_cell_inco_face_dof_indices[cell_so_index][inc_face_counter]
124 .upwind_dof_mapping[face_dof] *
126 g;
127
128 return &local_psi_[fc][index];
129 }
130 else
131 {
132 size_t index =
135 .so_cell_inco_face_dof_indices[cell_so_index][inc_face_counter]
136 .slot_address *
139 .so_cell_inco_face_dof_indices[cell_so_index][inc_face_counter]
140 .upwind_dof_mapping[face_dof] *
142 g;
143
144 return &delayed_local_psi_old_[index];
145 }
146}
147
148// ###################################################################
149/**Given a sweep ordering index, the incoming face counter,
150 * the incoming face dof, this function computes the location
151 * where to obtain the position's upwind psi.*/
152double*
153AAH_FLUDS::NLUpwindPsi(int nonl_inc_face_counter, int face_dof, int g, int n)
154{
155 int prelocI =
157 .first;
158
159 if (prelocI >= 0)
160 {
161 int nonlocal_psi_Gn_blockstride =
163 int slot =
165 .second.first;
166
167 int mapped_dof =
169 .second.second[face_dof];
170
171 int index = nonlocal_psi_Gn_blockstride * num_groups_ * n +
172 slot * num_groups_ + mapped_dof * num_groups_ + g;
173
174 return &prelocI_outgoing_psi_[prelocI][index];
175 }
176 else
177 {
178 prelocI =
180 .delayed_nonlocal_inc_face_prelocI_slot_dof[nonl_inc_face_counter]
181 .first;
182
183 int nonlocal_psi_Gn_blockstride =
185 int slot =
187 .delayed_nonlocal_inc_face_prelocI_slot_dof[nonl_inc_face_counter]
188 .second.first;
189
190 int mapped_dof =
192 .delayed_nonlocal_inc_face_prelocI_slot_dof[nonl_inc_face_counter]
193 .second.second[face_dof];
194
195 int index = nonlocal_psi_Gn_blockstride * num_groups_ * n +
196 slot * num_groups_ + mapped_dof * num_groups_ + g;
197
198 return &delayed_prelocI_outgoing_psi_old_[prelocI][index];
199 }
200}
201
202size_t AAH_FLUDS::GetPrelocIFaceDOFCount(int prelocI) const
203{
204 return common_data_.prelocI_face_dof_count[prelocI];
205}
207{
209}
210size_t AAH_FLUDS::GetDeplocIFaceDOFCount(int deplocI) const
211{
212 return common_data_.deplocI_face_dof_count[deplocI];
213}
214
216{
217 auto empty_vector = std::vector<std::vector<double>>(0);
218 local_psi_.swap(empty_vector);
219
220 empty_vector = std::vector<std::vector<double>>(0);
221 prelocI_outgoing_psi_.swap(empty_vector);
222}
223
225
226void AAH_FLUDS::AllocateInternalLocalPsi(size_t num_grps, size_t num_angles)
227{
229 // fc = face category
230 for (size_t fc = 0; fc < common_data_.num_face_categories; fc++)
231 {
233 common_data_.local_psi_max_elements[fc] * num_grps *
234 num_angles,
235 0.0);
236 }
237}
238
240 size_t num_angles,
241 size_t num_loc_sucs)
242{
243 deplocI_outgoing_psi_.resize(num_loc_sucs, std::vector<double>());
244 for (size_t deplocI = 0; deplocI < num_loc_sucs; deplocI++)
245 {
246 deplocI_outgoing_psi_[deplocI].resize(
247 common_data_.deplocI_face_dof_count[deplocI] * num_grps * num_angles,
248 0.0);
249 }
250}
251
252void AAH_FLUDS::AllocateDelayedLocalPsi(size_t num_grps, size_t num_angles)
253{
256 num_grps * num_angles,
257 0.0);
258
261 num_grps * num_angles,
262 0.0);
263}
264
266 size_t num_angles,
267 size_t num_loc_deps)
268{
269 prelocI_outgoing_psi_.resize(num_loc_deps, std::vector<double>());
270 for (size_t prelocI = 0; prelocI < num_loc_deps; prelocI++)
271 {
272 prelocI_outgoing_psi_[prelocI].resize(
273 common_data_.prelocI_face_dof_count[prelocI] * num_grps * num_angles,
274 0.0);
275 }
276}
277
279 size_t num_angles,
280 size_t num_loc_deps)
281{
283 delayed_prelocI_outgoing_psi_.resize(num_loc_deps);
284
286 delayed_prelocI_outgoing_psi_old_.resize(num_loc_deps);
287
288 for (int prelocI = 0; prelocI < num_loc_deps; prelocI++)
289 {
290 const int num_nodes = common_data_.delayed_prelocI_face_dof_count[prelocI];
291
292 uint64_t buff_size = num_nodes * num_grps * num_angles;
293
294 delayed_prelocI_outgoing_psi_[prelocI].resize(buff_size, 0.0);
295 delayed_prelocI_outgoing_psi_old_[prelocI].resize(buff_size, 0.0);
296 }
297}
298
299std::vector<double>& AAH_FLUDS::DelayedLocalPsi() { return delayed_local_psi_; }
300
301std::vector<double>& AAH_FLUDS::DelayedLocalPsiOld()
302{
304}
305
306std::vector<std::vector<double>>& AAH_FLUDS::DeplocIOutgoingPsi()
307{
309}
310
311std::vector<std::vector<double>>& AAH_FLUDS::PrelocIOutgoingPsi()
312{
314}
315
316std::vector<std::vector<double>>& AAH_FLUDS::DelayedPrelocIOutgoingPsi()
317{
319}
320std::vector<std::vector<double>>& AAH_FLUDS::DelayedPrelocIOutgoingPsiOld()
321{
323}
324
325} // namespace chi_mesh::sweep_management
static void Exit(int error_code)
Definition: chi_runtime.cc:342
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream LogAllError()
Definition: chi_log.h:239
std::vector< INCOMING_FACE_INFO * > so_cell_inco_face_dof_indices
std::vector< std::pair< int, std::pair< int, std::vector< int > > > > nonlocal_inc_face_prelocI_slot_dof
std::vector< std::pair< int, int > > nonlocal_outb_face_deplocI_slot
std::vector< std::pair< int, std::pair< int, std::vector< int > > > > delayed_nonlocal_inc_face_prelocI_slot_dof
double * NLOutgoingPsi(int outb_face_count, int face_dof, int n)
Definition: AAH_FLUDS.cc:70
const AAH_FLUDSCommonData & common_data_
Definition: AAH_FLUDS.h:20
std::vector< std::vector< double > > deplocI_outgoing_psi_
Definition: AAH_FLUDS.h:32
void AllocateDelayedPrelocIOutgoingPsi(size_t num_grps, size_t num_angles, size_t num_loc_deps) override
Definition: AAH_FLUDS.cc:278
std::vector< std::vector< double > > prelocI_outgoing_psi_
Definition: AAH_FLUDS.h:33
void AllocateDelayedLocalPsi(size_t num_grps, size_t num_angles) override
Definition: AAH_FLUDS.cc:252
void AllocatePrelocIOutgoingPsi(size_t num_grps, size_t num_angles, size_t num_loc_deps) override
Definition: AAH_FLUDS.cc:265
std::vector< double > & DelayedLocalPsiOld() override
Definition: AAH_FLUDS.cc:301
std::vector< double > delayed_local_psi_
Definition: AAH_FLUDS.h:30
std::vector< std::vector< double > > delayed_prelocI_outgoing_psi_old_
Definition: AAH_FLUDS.h:37
size_t GetDelayedPrelocIFaceDOFCount(int prelocI) const
Definition: AAH_FLUDS.cc:206
std::vector< std::vector< double > > & DelayedPrelocIOutgoingPsiOld() override
Definition: AAH_FLUDS.cc:320
std::vector< std::vector< double > > & DelayedPrelocIOutgoingPsi() override
Definition: AAH_FLUDS.cc:316
double * OutgoingPsi(int cell_so_index, int outb_face_counter, int face_dof, int n)
Definition: AAH_FLUDS.cc:34
double * UpwindPsi(int cell_so_index, int inc_face_counter, int face_dof, int g, int n)
Definition: AAH_FLUDS.cc:107
std::vector< size_t > local_psi_Gn_block_strideG
Definition: AAH_FLUDS.h:25
AAH_FLUDS(size_t num_groups, size_t num_angles, const AAH_FLUDSCommonData &common_data)
Definition: AAH_FLUDS.cc:15
void AllocateOutgoingPsi(size_t num_grps, size_t num_angles, size_t num_loc_sucs) override
Definition: AAH_FLUDS.cc:239
std::vector< double > & DelayedLocalPsi() override
Definition: AAH_FLUDS.cc:299
size_t GetDeplocIFaceDOFCount(int deplocI) const
Definition: AAH_FLUDS.cc:210
std::vector< std::vector< double > > local_psi_
Definition: AAH_FLUDS.h:29
std::vector< std::vector< double > > delayed_prelocI_outgoing_psi_
Definition: AAH_FLUDS.h:36
std::vector< std::vector< double > > & PrelocIOutgoingPsi() override
Definition: AAH_FLUDS.cc:311
void AllocateInternalLocalPsi(size_t num_grps, size_t num_angles) override
Definition: AAH_FLUDS.cc:226
size_t GetPrelocIFaceDOFCount(int prelocI) const
Definition: AAH_FLUDS.cc:202
std::vector< double > delayed_local_psi_old_
Definition: AAH_FLUDS.h:31
double * NLUpwindPsi(int nonl_inc_face_counter, int face_dof, int g, int n)
Definition: AAH_FLUDS.cc:153
std::vector< std::vector< double > > & DeplocIOutgoingPsi() override
Definition: AAH_FLUDS.cc:306