Chi-Tech
sweep_boundaries.h
Go to the documentation of this file.
1#ifndef CHI_SWEEP_BOUNDARY_BASE_H
2#define CHI_SWEEP_BOUNDARY_BASE_H
3
4#include "mesh/chi_mesh.h"
5#include "math/chi_math.h"
6
7#include <vector>
8#include <limits>
9
11{
12
13enum class BoundaryType
14{
15 INCIDENT_VACCUUM = 0, ///< Zero for all angles, space
16 INCIDENT_ISOTROPIC_HOMOGENOUS = 1, ///< One value for all angles, homogenous in space
17 REFLECTING = 2, ///< Reflecting boundary condition about a normal
18 INCIDENT_ANISOTROPIC_HETEROGENEOUS = 3 ///< Complex different for each angle and face node
19};
20
21//###################################################################
22/**Base class for sweep related boundaries.*/
24{
25private:
28 double evaluation_time_ = 0.0; ///< Time value passed to boundary functions
29protected:
30 std::vector<double> zero_boundary_flux_;
32
33public:
34 explicit SweepBoundary(BoundaryType bndry_type,
35 size_t in_num_groups,
37 type_(bndry_type),
38 coord_type_(coord_type),
39 num_groups_(in_num_groups)
40 {
42 }
43
44 virtual ~SweepBoundary() = default;
45 BoundaryType Type() const {return type_;}
47 bool IsReflecting() const
48 { return type_ == BoundaryType::REFLECTING; }
49
50 double GetEvaluationTime() const {return evaluation_time_;}
51 void SetEvaluationTime(double time) { evaluation_time_ = time;}
52
53
54 virtual double* HeterogeneousPsiIncoming(uint64_t cell_local_id,
55 unsigned int face_num,
56 unsigned int fi,
57 unsigned int angle_num,
58 int group_num,
59 size_t gs_ss_begin);
60
61 virtual double* HeterogeneousPsiOutgoing(uint64_t cell_local_id,
62 unsigned int face_num,
63 unsigned int fi,
64 unsigned int angle_num,
65 size_t gs_ss_begin);
66
67 virtual void UpdateAnglesReadyStatus(const std::vector<size_t>& angles,
68 size_t gs_ss)
69 {}
70 virtual bool CheckAnglesReadyStatus(const std::vector<size_t>& angles,
71 size_t gs_ss)
72 {return true;}
73 virtual void Setup(const chi_mesh::MeshContinuum& grid,
74 const chi_math::AngularQuadrature& quadrature) {}
75
76 double* ZeroFlux(int group_num) {return &zero_boundary_flux_[group_num];}
77};
78
79//###################################################################
80/** Zero fluxes homogenous on a boundary and in angle.*/
82{
83private:
84 std::vector<double> boundary_flux_;
85public:
86 explicit
87 BoundaryVaccuum(size_t in_num_groups,
90 SweepBoundary(BoundaryType::INCIDENT_VACCUUM, in_num_groups, coord_type),
91 boundary_flux_(in_num_groups, 0.0)
92 {}
93
95 uint64_t cell_local_id,
96 unsigned int face_num,
97 unsigned int fi,
98 unsigned int angle_num,
99 int group_num,
100 size_t gs_ss_begin) override;
101};
102
103
104//###################################################################
105/** Specified incident fluxes homogenous on a boundary.*/
107{
108private:
109 std::vector<double> boundary_flux;
110public:
111 explicit
112 BoundaryIsotropicHomogenous(size_t in_num_groups,
113 std::vector<double> ref_boundary_flux,
117 coord_type),
118 boundary_flux(std::move(ref_boundary_flux))
119 {}
120
122 uint64_t cell_local_id,
123 unsigned int face_num,
124 unsigned int fi,
125 unsigned int angle_num,
126 int group_num,
127 size_t gs_ss_begin) override;
128};
129
130//###################################################################
131/** Reflective boundary condition.*/
133{
134protected:
137
138 typedef std::vector<double> DOFVec; //Groups per DOF
139 typedef std::vector<DOFVec> FaceVec; //DOFs per face
140 typedef std::vector<FaceVec> CellVec; //Faces per cell
141 typedef std::vector<CellVec> AngVec; //Cell per angle
142
143 //angle,cell,face,dof,group
144 //Populated by angle aggregation
145 std::vector<AngVec> hetero_boundary_flux_;
146 std::vector<AngVec> hetero_boundary_flux_old_;
147
148 std::vector<int> reflected_anglenum_;
149 std::vector<std::vector<bool>> angle_readyflags_;
150
151public:
152 BoundaryReflecting(size_t in_num_groups,
153 const chi_mesh::Normal& in_normal,
156 SweepBoundary(BoundaryType::REFLECTING, in_num_groups, coord_type),
157 normal_(in_normal)
158 {}
159
160 const chi_mesh::Vector3& Normal() const {return normal_;}
162 void SetOpposingReflected(bool value) { opposing_reflected_ = value;}
163
164 std::vector<AngVec>& GetHeteroBoundaryFluxNew() {return hetero_boundary_flux_;}
166
167 std::vector<int>& GetReflectedAngleIndexMap() {return reflected_anglenum_;}
168 std::vector<std::vector<bool>>&
170
171 double* HeterogeneousPsiIncoming(uint64_t cell_local_id,
172 unsigned int face_num,
173 unsigned int fi,
174 unsigned int angle_num,
175 int group_num,
176 size_t gs_ss_begin) override;
177 double* HeterogeneousPsiOutgoing(uint64_t cell_local_id,
178 unsigned int face_num,
179 unsigned int fi,
180 unsigned int angle_num,
181 size_t gs_ss_begin) override;
182
183 void UpdateAnglesReadyStatus(const std::vector<size_t>& angles,
184 size_t gs_ss) override;
185 bool CheckAnglesReadyStatus(const std::vector<size_t>& angles,
186 size_t gs_ss) override;
188};
189
190/**This boundary function class can be derived from to
191 * provide a much more custom experience. This function
192 * is called during Setup. */
194{
195public:
196 virtual std::vector<double> Evaluate(
197 size_t cell_global_id,
198 int cell_material_id,
199 unsigned int face_index,
200 unsigned int face_node_index,
201 const chi_mesh::Vector3& face_node_location,
202 const chi_mesh::Vector3& face_node_normal,
203 const std::vector<int>& quadrature_angle_indices,
204 const std::vector<chi_mesh::Vector3>& quadrature_angle_vectors,
205 const std::vector<std::pair<double,double>>& quadrature_phi_theta_angles,
206 const std::vector<int>& group_indices,
207 double time) = 0;
208
209 virtual ~BoundaryFunction() = default;
210};
211
212//###################################################################
213/** Specified incident fluxes homogenous on a boundary.*/
215{
216private:
217 std::unique_ptr<BoundaryFunction> boundary_function_;
218 const uint64_t ref_boundary_id_;
219
220 typedef std::vector<double> FaceNodeData;
221 typedef std::vector<FaceNodeData> FaceData;
222 typedef std::vector<FaceData> CellData;
223
224 std::vector<CellData> local_cell_data_;
225public:
226 explicit
227 BoundaryIncidentHeterogeneous(size_t in_num_groups,
228 std::unique_ptr<BoundaryFunction> in_bndry_function,
229 uint64_t in_ref_boundary_id,
233 coord_type),
234 boundary_function_(std::move(in_bndry_function)),
235 ref_boundary_id_(in_ref_boundary_id)
236 {}
237
238 double* HeterogeneousPsiIncoming(uint64_t cell_local_id,
239 unsigned int face_num,
240 unsigned int fi,
241 unsigned int angle_num,
242 int group_num,
243 size_t gs_ss_begin) override;
244
245 void Setup(const chi_mesh::MeshContinuum &grid,
246 const chi_math::AngularQuadrature &quadrature) override;
247};
248
249}//namespace sweep_management
250
251#endif //CHI_SWEEP_BOUNDARY_BASE_H
virtual std::vector< double > Evaluate(size_t cell_global_id, int cell_material_id, unsigned int face_index, unsigned int face_node_index, const chi_mesh::Vector3 &face_node_location, const chi_mesh::Vector3 &face_node_normal, const std::vector< int > &quadrature_angle_indices, const std::vector< chi_mesh::Vector3 > &quadrature_angle_vectors, const std::vector< std::pair< double, double > > &quadrature_phi_theta_angles, const std::vector< int > &group_indices, double time)=0
std::unique_ptr< BoundaryFunction > boundary_function_
double * HeterogeneousPsiIncoming(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, int group_num, size_t gs_ss_begin) override
BoundaryIncidentHeterogeneous(size_t in_num_groups, std::unique_ptr< BoundaryFunction > in_bndry_function, uint64_t in_ref_boundary_id, chi_math::CoordinateSystemType coord_type=chi_math::CoordinateSystemType::CARTESIAN)
void Setup(const chi_mesh::MeshContinuum &grid, const chi_math::AngularQuadrature &quadrature) override
BoundaryIsotropicHomogenous(size_t in_num_groups, std::vector< double > ref_boundary_flux, chi_math::CoordinateSystemType coord_type=chi_math::CoordinateSystemType::CARTESIAN)
double * HeterogeneousPsiIncoming(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, int group_num, size_t gs_ss_begin) override
double * HeterogeneousPsiIncoming(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, int group_num, size_t gs_ss_begin) override
std::vector< std::vector< bool > > angle_readyflags_
bool CheckAnglesReadyStatus(const std::vector< size_t > &angles, size_t gs_ss) override
double * HeterogeneousPsiOutgoing(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, size_t gs_ss_begin) override
BoundaryReflecting(size_t in_num_groups, const chi_mesh::Normal &in_normal, chi_math::CoordinateSystemType coord_type=chi_math::CoordinateSystemType::CARTESIAN)
void UpdateAnglesReadyStatus(const std::vector< size_t > &angles, size_t gs_ss) override
const chi_mesh::Vector3 & Normal() const
std::vector< std::vector< bool > > & GetAngleReadyFlags()
BoundaryVaccuum(size_t in_num_groups, chi_math::CoordinateSystemType coord_type=chi_math::CoordinateSystemType::CARTESIAN)
double * HeterogeneousPsiIncoming(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, int group_num, size_t gs_ss_begin) override
chi_math::CoordinateSystemType CoordType() const
SweepBoundary(BoundaryType bndry_type, size_t in_num_groups, chi_math::CoordinateSystemType coord_type)
const chi_math::CoordinateSystemType coord_type_
virtual void UpdateAnglesReadyStatus(const std::vector< size_t > &angles, size_t gs_ss)
virtual double * HeterogeneousPsiOutgoing(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, size_t gs_ss_begin)
const chi_mesh::sweep_management::BoundaryType type_
virtual bool CheckAnglesReadyStatus(const std::vector< size_t > &angles, size_t gs_ss)
double evaluation_time_
Time value passed to boundary functions.
virtual void Setup(const chi_mesh::MeshContinuum &grid, const chi_math::AngularQuadrature &quadrature)
virtual double * HeterogeneousPsiIncoming(uint64_t cell_local_id, unsigned int face_num, unsigned int fi, unsigned int angle_num, int group_num, size_t gs_ss_begin)
CoordinateSystemType
Definition: chi_math.h:29
@ INCIDENT_ANISOTROPIC_HETEROGENEOUS
Complex different for each angle and face node.
@ INCIDENT_ISOTROPIC_HOMOGENOUS
One value for all angles, homogenous in space.
@ REFLECTING
Reflecting boundary condition about a normal.
@ INCIDENT_VACCUUM
Zero for all angles, space.