Chi-Tech
sweepchunk_base.h
Go to the documentation of this file.
1#ifndef CHI_SWEEPCHUNK_BASE_H
2#define CHI_SWEEPCHUNK_BASE_H
3
5
6#include <functional>
7
8// ###################################################################
9/**Sweep work function*/
11{
12public:
13 /**
14 * Convenient typdef for the moment call back function. See moment_callbacks.
15 * Arguments are:
16 * chi_mesh::sweep_management::SweepChunk *
17 * chi_mesh::sweep_management::AngleSet *
18 */
19 typedef std::function<void(chi_mesh::sweep_management::SweepChunk* sweeper,
22
23 /**
24 * Functions of type MomentCallbackF can be added to the moment_callbacks
25 * vector and these can be called from within functions taking a
26 * LBSGroupset instance. The intention is that this function can
27 * be used as a general interface to retrieve angular flux values
28 */
29 std::vector<MomentCallbackF> moment_callbacks;
30
31 SweepChunk(std::vector<double>& in_destination_phi,
32 std::vector<double>& in_destination_psi)
33 : destination_phi(&in_destination_phi), destination_psi(&in_destination_psi)
34 {
35 }
36
37 /**Sweep chunks should override this.*/
38 virtual void Sweep(AngleSet& angle_set) {}
39
40 /**Sets the currently active FLUx Data Structure*/
41 virtual void SetAngleSet(AngleSet& angle_set) {}
42
43 /**For cell-by-cell methods or computing the residual on a
44 * single cell.*/
45 virtual void SetCell(chi_mesh::Cell const* cell_ptr,
47 {
48 }
49
50 virtual void SetCells(const std::vector<const chi_mesh::Cell*>& cell_ptrs) {}
51
52 virtual ~SweepChunk() = default;
53
54protected:
55 friend class SweepScheduler;
56 /**Sets the location where flux moments are to be written.*/
57 void SetDestinationPhi(std::vector<double>& in_destination_phi)
58 {
59 destination_phi = (&in_destination_phi);
60 }
61
62 /**Sets all elements of the output vector to zero.*/
64 {
65 (*destination_phi).assign((*destination_phi).size(), 0.0);
66 }
67
68 /**Returns a reference to the output flux moments vector.*/
69 std::vector<double>& GetDestinationPhi() { return *destination_phi; }
70
71 /**Sets the location where angular fluxes are to be written.*/
72 void SetDestinationPsi(std::vector<double>& in_destination_psi)
73 {
74 destination_psi = (&in_destination_psi);
75 }
76
77 /**Sets all elements of the output angular flux vector to zero.*/
79 {
80 (*destination_psi).assign((*destination_psi).size(), 0.0);
81 }
82
83 /**Returns a reference to the output angular flux vector.*/
84 std::vector<double>& GetDestinationPsi() { return *destination_psi; }
85
86 /**Activates or deactives the surface src flag.*/
87 void SetBoundarySourceActiveFlag(bool flag_value) // Done
88 {
89 surface_source_active = flag_value;
90 }
91
92protected:
93 /**Returns the surface src-active flag.*/
95
96private:
97 std::vector<double>* destination_phi;
98 std::vector<double>* destination_psi;
100};
101
102#endif // CHI_SWEEPCHUNK_BASE_H
virtual void SetCell(chi_mesh::Cell const *cell_ptr, chi_mesh::sweep_management::AngleSet &angle_set)
virtual void SetAngleSet(AngleSet &angle_set)
std::vector< double > & GetDestinationPsi()
std::vector< double > & GetDestinationPhi()
std::vector< double > * destination_psi
void SetDestinationPsi(std::vector< double > &in_destination_psi)
SweepChunk(std::vector< double > &in_destination_phi, std::vector< double > &in_destination_psi)
std::function< void(chi_mesh::sweep_management::SweepChunk *sweeper, chi_mesh::sweep_management::AngleSet *angle_set)> MomentCallbackF
virtual void Sweep(AngleSet &angle_set)
void SetDestinationPhi(std::vector< double > &in_destination_phi)
virtual void SetCells(const std::vector< const chi_mesh::Cell * > &cell_ptrs)
void SetBoundarySourceActiveFlag(bool flag_value)
std::vector< MomentCallbackF > moment_callbacks
std::vector< double > * destination_phi