Chi-Tech
boundary_aniso_hetero.cc
Go to the documentation of this file.
1#include "sweep_boundaries.h"
2
5
6#include "chi_runtime.h"
7#include "chi_log.h"
8
9//###################################################################
10/**Returns a pointer to a heterogeneous flux storage location.*/
12HeterogeneousPsiIncoming(uint64_t cell_local_id,
13 unsigned int face_num,
14 unsigned int fi,
15 unsigned int angle_num,
16 int group_num,
17 size_t gs_ss_begin)
18{
19 if (local_cell_data_.empty())
20 {
22 << "HeterogeneousPsiIncoming call made to a heterogeneous boundary "
23 "with that information not yet set up.";
24 exit(EXIT_FAILURE);
25 }
26
27 const size_t dof_offset = num_groups_ * angle_num + group_num;
28
29 return &local_cell_data_[cell_local_id][face_num][fi][dof_offset];
30}
31
32//###################################################################
33/**Performs the setup for a particular quadrature.*/
36 const chi_math::AngularQuadrature &quadrature)
37{
38 const size_t num_local_cells = grid.local_cells.size();
39 local_cell_data_.clear();
40 local_cell_data_.reserve(num_local_cells);
41
42 std::vector<bool> cell_bndry_flags(num_local_cells,false);
43 for (const auto& cell : grid.local_cells)
44 for (const auto& face : cell.faces_)
45 if (not face.has_neighbor_)
46 {
47 cell_bndry_flags[cell.local_id_] = true;
48 break;
49 }
50
51 size_t num_angles = quadrature.omegas_.size();
52
53 typedef std::pair<double, double> PhiTheta;
54
55 std::vector<int> angle_indices;
56 std::vector<chi_mesh::Vector3> angle_vectors;
57 std::vector<PhiTheta> phi_theta_angles;
58 std::vector<int> group_indices;
59
60 angle_indices.reserve(num_angles);
61 angle_vectors.reserve(num_angles);
62 phi_theta_angles.reserve(num_angles);
63 group_indices.reserve(num_groups_);
64
65 int num_angles_int = static_cast<int>(num_angles);
66 for (int n=0; n<num_angles_int; ++n)
67 angle_indices.emplace_back(n);
68 for (int n=0; n<num_angles_int; ++n)
69 angle_vectors.emplace_back(quadrature.omegas_[n]);
70 for (int n=0; n<num_angles_int; ++n)
71 {
72 auto& abscissae = quadrature.abscissae_[n];
73 double phi = abscissae.phi;
74 double theta = abscissae.theta;
75 phi_theta_angles.emplace_back(std::make_pair(phi, theta));
76 }
77 for (int g=0; g<static_cast<int>(num_groups_); ++g)
78 group_indices.emplace_back(g);
79
80 const double eval_time = GetEvaluationTime();
81
82 for (const auto& cell : grid.local_cells)
83 {
84 if (cell_bndry_flags[cell.local_id_])
85 {
86 CellData cell_data(cell.faces_.size());
87
88 for (size_t f=0; f<cell.faces_.size(); ++f)
89 {
90 auto& face = cell.faces_[f];
91 size_t face_num_nodes = face.vertex_ids_.size();
92 FaceData face_data;
93
94 if (not face.has_neighbor_ and face.neighbor_id_ == ref_boundary_id_)
95 {
96 face_data.reserve(face_num_nodes);
97 for (size_t i=0; i<face_num_nodes; ++i)
98 {
99 std::vector<double> face_node_data =
100 boundary_function_->Evaluate(cell.global_id_,
101 cell.material_id_,
102 f, i,
103 grid.vertices[face.vertex_ids_[i]],
104 face.normal_,
105 angle_indices,
106 angle_vectors,
107 phi_theta_angles,
108 group_indices,
109 eval_time);
110
111 face_data.push_back(std::move(face_node_data));
112 }//for face node-i
113 }//bndry face
114
115 cell_data[f] = std::move(face_data);
116 }//for face f
117
118 local_cell_data_.push_back(std::move(cell_data));
119 }//if bndry cell
120 else
121 local_cell_data_.emplace_back();
122
123 }//for cell
124}
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream LogAllError()
Definition: chi_log.h:239
std::vector< chi_math::QuadraturePointPhiTheta > abscissae_
std::vector< chi_mesh::Vector3 > omegas_
LocalCellHandler local_cells
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
void Setup(const chi_mesh::MeshContinuum &grid, const chi_math::AngularQuadrature &quadrature) override