Chi-Tech
AAH_AngleSet.cc
Go to the documentation of this file.
1#include "AAH_AngleSet.h"
2
4
5#include "chi_runtime.h"
6#include "chi_log.h"
7
9{
10
11// ###################################################################
12/**AngleSet constructor.*/
14 size_t id,
15 size_t in_numgrps,
16 size_t in_ref_subset,
17 const SPDS& in_spds,
18 std::shared_ptr<FLUDS>& in_fluds,
19 std::vector<size_t>& angle_indices,
20 std::map<uint64_t, std::shared_ptr<SweepBndry>>& sim_boundaries,
21 int sweep_eager_limit,
22 const chi::ChiMPICommunicatorSet& in_comm_set)
23 : AngleSet(id,
24 in_numgrps,
25 in_spds,
26 in_fluds,
27 angle_indices,
28 sim_boundaries,
29 in_ref_subset),
30 async_comm_(
31 *in_fluds, num_grps, angle_indices.size(), sweep_eager_limit, in_comm_set)
32{
33}
34
35// ###################################################################
36/**Initializes delayed upstream data. This method gets called
37 * when a sweep scheduler is constructed.*/
39{
41}
42
43// ###################################################################
44/**This function advances the work stages of an angleset.*/
47 const std::vector<size_t>& timing_tags,
48 ExecutionPermission permission)
49{
50 typedef AngleSetStatus Status;
51
52 if (executed_)
53 {
56 }
57
58 // Check upstream data available
59 Status status =
60 async_comm_.ReceiveUpstreamPsi(static_cast<int>(this->GetID()));
61
62 // Also check boundaries
63 for (auto& [bid, bndry] : ref_boundaries_)
64 if (not bndry->CheckAnglesReadyStatus(angles_, ref_group_subset_))
65 {
66 status = Status::RECEIVING;
67 break;
68 }
69
70 if (status == Status::RECEIVING) return status;
71 else if (status == Status::READY_TO_EXECUTE and
72 permission == ExecutionPermission::EXECUTE)
73 {
75
77 sweep_chunk.Sweep(*this); // Execute chunk
79
80 // Send outgoing psi and clear local and receive buffers
81 async_comm_.SendDownstreamPsi(static_cast<int>(this->GetID()));
83
84 // Update boundary readiness
85 for (auto& [bid, bndry] : ref_boundaries_)
86 bndry->UpdateAnglesReadyStatus(angles_, ref_group_subset_);
87
88 executed_ = true;
90 }
91 else
93}
94
95// ###################################################################
96/***/
98{
100
102
104}
105
106// ###################################################################
107/**Returns the maximum buffer size from the sweepbuffer.*/
109{
111}
112
113// ###################################################################
114/**Sets the maximum buffer size for the sweepbuffer.*/
116{
117 async_comm_.max_num_mess = new_max;
118}
119
120// ###################################################################
121/**Resets the sweep buffer.*/
123{
125 executed_ = false;
126}
127
128// ###################################################################
129/**Instructs the sweep buffer to receive delayed data.*/
131{
132 return async_comm_.ReceiveDelayedData(static_cast<int>(this->GetID()));
133}
134
135// ###################################################################
136/**Returns a pointer to a boundary flux data.*/
137const double* AAH_AngleSet::PsiBndry(uint64_t bndry_map,
138 unsigned int angle_num,
139 uint64_t cell_local_id,
140 unsigned int face_num,
141 unsigned int fi,
142 int g,
143 size_t gs_ss_begin,
144 bool surface_source_active)
145{
146 if (ref_boundaries_[bndry_map]->IsReflecting())
147 return ref_boundaries_[bndry_map]->HeterogeneousPsiIncoming(
148 cell_local_id, face_num, fi, angle_num, g, gs_ss_begin);
149
150 if (not surface_source_active) return ref_boundaries_[bndry_map]->ZeroFlux(g);
151
152 return ref_boundaries_[bndry_map]->HeterogeneousPsiIncoming(
153 cell_local_id, face_num, fi, angle_num, g, gs_ss_begin);
154}
155
156// ###################################################################
157/**Returns a pointer to outbound boundary flux data.*/
159 unsigned int angle_num,
160 uint64_t cell_local_id,
161 unsigned int face_num,
162 unsigned int fi,
163 size_t gs_ss_begin)
164{
165 return ref_boundaries_[bndry_map]->HeterogeneousPsiOutgoing(
166 cell_local_id, face_num, fi, angle_num, gs_ss_begin);
167}
168
169} // namespace chi_mesh::sweep_management
static chi::ChiLog & log
Definition: chi_runtime.h:81
@ EVENT_BEGIN
Signals the begin of an event.
@ EVENT_END
Signals the end of an event.
void LogEvent(size_t ev_tag, EventType ev_type, const std::shared_ptr< EventInfo > &ev_info)
Definition: chi_log.cc:204
AngleSetStatus AngleSetAdvance(SweepChunk &sweep_chunk, const std::vector< size_t > &timing_tags, ExecutionPermission permission) override
Definition: AAH_AngleSet.cc:46
void SetMaxBufferMessages(int new_max) override
chi_mesh::sweep_management::AAH_ASynchronousCommunicator async_comm_
Definition: AAH_AngleSet.h:54
const double * PsiBndry(uint64_t bndry_map, unsigned int angle_num, uint64_t cell_local_id, unsigned int face_num, unsigned int fi, int g, size_t gs_ss_begin, bool surface_source_active) override
double * ReflectingPsiOutBoundBndry(uint64_t bndry_map, unsigned int angle_num, uint64_t cell_local_id, unsigned int face_num, unsigned int fi, size_t gs_ss_begin) override
AngleSetStatus FlushSendBuffers() override
Definition: AAH_AngleSet.cc:97
AAH_AngleSet(size_t id, size_t in_numgrps, size_t in_ref_subset, const SPDS &in_spds, std::shared_ptr< FLUDS > &in_fluds, std::vector< size_t > &angle_indices, std::map< uint64_t, std::shared_ptr< SweepBndry > > &sim_boundaries, int sweep_eager_limit, const chi::ChiMPICommunicatorSet &in_comm_set)
Definition: AAH_AngleSet.cc:13
std::map< uint64_t, SweepBndryPtr > & ref_boundaries_
Definition: AngleSet.h:80
const std::vector< size_t > angles_
Definition: AngleSet.h:79
virtual void Sweep(AngleSet &angle_set)