Chi-Tech
lbsrz_01a_inputchecks.cc
Go to the documentation of this file.
2
6
7#include "chi_runtime.h"
8#include "chi_log.h"
9
10namespace lbs
11{
12
14{
16 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : enter";
17
18 // --------------------------------------------------------------------------
19 // perform all verifications of Cartesian LBS
20 // --------------------------------------------------------------------------
21
23
24 // --------------------------------------------------------------------------
25 // perform additional verifications for curvilinear LBS
26 // --------------------------------------------------------------------------
27
28 // coordinate system must be curvilinear
31 {
33 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
34 << "invalid coordinate system, static_cast<int>(type) = "
35 << static_cast<int>(coord_system_type_);
36 Chi::Exit(EXIT_FAILURE);
37 }
38
39 // re-interpret geometry type to curvilinear
40 switch (options_.geometry_type)
41 {
43 {
44 switch (coord_system_type_)
45 {
46 default:
47 {
49 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
50 << "invalid geometry, static_cast<int>(type) = "
51 << static_cast<int>(options_.geometry_type) << " "
52 << "for curvilinear coordinate system, static_cast<int>(type) = "
53 << static_cast<int>(coord_system_type_);
54 Chi::Exit(EXIT_FAILURE);
55 }
56 }
57 break;
58 }
60 {
61 switch (coord_system_type_)
62 {
64 {
66 break;
67 }
68 default:
69 {
71 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
72 << "invalid geometry, static_cast<int>(type) = "
73 << static_cast<int>(options_.geometry_type) << " "
74 << "for curvilinear coordinate system, static_cast<int>(type) = "
75 << static_cast<int>(coord_system_type_);
76 Chi::Exit(EXIT_FAILURE);
77 }
78 }
79 break;
80 }
81 default:
82 {
84 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
85 << "invalid geometry, static_cast<int>(type) = "
86 << static_cast<int>(options_.geometry_type) << " "
87 << "for curvilinear coordinate system";
88 Chi::Exit(EXIT_FAILURE);
89 }
90 }
91
92 for (size_t gs = 0; gs < groupsets_.size(); ++gs)
93 {
94 // angular quadrature type must be compatible with coordinate system
95 const auto angular_quad_ptr = groupsets_[gs].quadrature_;
96 switch (coord_system_type_)
97 {
99 {
101 const auto curvilinear_angular_quad_ptr =
102 std::dynamic_pointer_cast<CylAngQuad>(angular_quad_ptr);
103 if (!curvilinear_angular_quad_ptr)
104 {
106 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
107 << "invalid angular quadrature, static_cast<int>(type) = "
108 << static_cast<int>(angular_quad_ptr->type_)
109 << ", for groupset = " << gs;
110 Chi::Exit(EXIT_FAILURE);
111 }
112 break;
113 }
115 {
116 typedef chi_math::SphericalAngularQuadrature SphAngQuad;
117 const auto curvilinear_angular_quad_ptr =
118 std::dynamic_pointer_cast<SphAngQuad>(angular_quad_ptr);
119 if (!curvilinear_angular_quad_ptr)
120 {
122 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
123 << "invalid angular quadrature, static_cast<int>(type) = "
124 << static_cast<int>(angular_quad_ptr->type_)
125 << ", for groupset = " << gs;
126 Chi::Exit(EXIT_FAILURE);
127 }
128 break;
129 }
130 default:
131 {
133 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
134 << "invalid curvilinear coordinate system, static_cast<int>(type) = "
135 << static_cast<int>(coord_system_type_);
136 Chi::Exit(EXIT_FAILURE);
137 }
138 }
139
140 // angle aggregation type must be compatible with coordinate system
141 const auto angleagg_method = groupsets_[gs].angleagg_method_;
142 switch (coord_system_type_)
143 {
145 {
146 if (angleagg_method != lbs::AngleAggregationType::AZIMUTHAL)
147 {
149 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
150 << "invalid angle aggregation type, static_cast<int>(type) = "
151 << static_cast<int>(angleagg_method) << ", for groupset = " << gs;
152 Chi::Exit(EXIT_FAILURE);
153 }
154 break;
155 }
157 {
158 if (angleagg_method != lbs::AngleAggregationType::POLAR)
159 {
161 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
162 << "invalid angle aggregation type, static_cast<int>(type) = "
163 << static_cast<int>(angleagg_method) << ", for groupset = " << gs;
164 Chi::Exit(EXIT_FAILURE);
165 }
166 break;
167 }
168 default:
169 {
171 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
172 << "invalid curvilinear coordinate system, static_cast<int>(type) = "
173 << static_cast<int>(coord_system_type_);
174 Chi::Exit(EXIT_FAILURE);
175 }
176 }
177 }
178
179 // boundary of mesh must be rectangular with origin at (0, 0, 0)
180 const std::vector<chi_mesh::Vector3> unit_normal_vectors = {
181 chi_mesh::Vector3(1.0, 0.0, 0.0),
182 chi_mesh::Vector3(0.0, 1.0, 0.0),
183 chi_mesh::Vector3(0.0, 0.0, 1.0),
184 };
185 for (const auto& cell : grid_ptr_->local_cells)
186 {
187 for (const auto& face : cell.faces_)
188 {
189 if (!face.has_neighbor_)
190 {
191 bool face_orthogonal = false;
192 for (size_t d = 0; d < unit_normal_vectors.size(); ++d)
193 {
194 const auto n_dot_e = face.normal_.Dot(unit_normal_vectors[d]);
195 if (n_dot_e > 0.999999)
196 {
197 face_orthogonal = true;
198 break;
199 }
200 else if (n_dot_e < -0.999999)
201 {
202 for (const auto& v_id : face.vertex_ids_)
203 {
204 const auto& vertex = grid_ptr_->vertices[v_id];
205 if (std::abs(vertex[d]) > 1.0e-12)
206 {
208 << "D_DO_RZ_SteadyState::SteadyStateSolver::"
209 "PerformInputChecks : "
210 << "mesh contains boundary faces with outward-oriented unit "
211 << "normal vector " << (-1 * unit_normal_vectors[d]).PrintS()
212 << "with vertices characterised by v(" << d << ") != 0.";
213 Chi::Exit(EXIT_FAILURE);
214 }
215 }
216 face_orthogonal = true;
217 break;
218 }
219 }
220 if (!face_orthogonal)
221 {
223 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : "
224 << "mesh contains boundary faces not orthogonal with respect to "
225 << "Cartesian reference frame.";
226 Chi::Exit(EXIT_FAILURE);
227 }
228 }
229 }
230 }
231
232 Chi::log.Log()
233 << "D_DO_RZ_SteadyState::SteadyStateSolver::PerformInputChecks : exit";
234}
235
236} // namespace lbs
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
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
chi_math::CoordinateSystemType coord_system_type_
virtual void PerformInputChecks()
chi_mesh::MeshContinuumPtr grid_ptr_
Definition: lbs_solver.h:75
lbs::Options options_
Definition: lbs_solver.h:61
std::vector< LBSGroupset > groupsets_
Definition: lbs_solver.h:68
VectorN< 3 > Vector3
GeometryType geometry_type
Definition: lbs_structs.h:124