29 <<
"SPDS Invalid mapping encountered in MapLocJToPrelocI.";
38 for (
int i = 0; i < location_successors_.size(); i++)
40 if (location_successors_[i] == locJ) {
return i; }
44 <<
"SPDS Invalid mapping encountered in MapLocJToDeplocI.";
53 std::set<int>& location_dependencies,
54 std::set<int>& location_successors,
55 std::vector<std::set<std::pair<int, double>>>& cell_successors)
57 constexpr double tolerance = 1.0e-16;
63 cell_face_orientations_.assign(grid_.local_cells.size(), {});
64 for (
auto& cell : grid_.local_cells)
65 cell_face_orientations_[cell.local_id_].assign(cell.faces_.size(),
68 for (
auto& cell : grid_.local_cells)
71 for (
auto& face : cell.faces_)
76 const double mu = omega.
Dot(face.normal_);
78 bool owns_face =
true;
79 if (face.has_neighbor_ and cell.global_id_ > face.neighbor_id_)
85 if (mu > tolerance) orientation = FOOUTGOING;
86 else if (mu < tolerance) orientation = FOINCOMING;
88 cell_face_orientations_[cell.local_id_][f] = orientation;
90 if (face.has_neighbor_ and grid_.IsCellLocal(face.neighbor_id_))
92 const auto& adj_cell = grid_.cells[face.neighbor_id_];
93 const auto ass_face = face.GetNeighborAssociatedFace(grid_);
95 cell_face_orientations_[adj_cell.local_id_][ass_face];
99 case FOPARALLEL: adj_face_ori = FOPARALLEL;
break;
100 case FOINCOMING: adj_face_ori = FOOUTGOING;
break;
101 case FOOUTGOING: adj_face_ori = FOINCOMING;
break;
106 else if (face.has_neighbor_ and not grid_.IsCellLocal(face.neighbor_id_))
108 const auto& adj_cell = grid_.cells[face.neighbor_id_];
109 const auto ass_face = face.GetNeighborAssociatedFace(grid_);
110 const auto& adj_face = adj_cell.faces_[ass_face];
112 auto& cur_face_ori = cell_face_orientations_[cell.local_id_][f];
114 const double adj_mu = omega.
Dot(adj_face.normal_);
115 if (adj_mu > tolerance) orientation = FOOUTGOING;
116 else if (adj_mu < tolerance)
117 orientation = FOINCOMING;
122 cur_face_ori = FOPARALLEL;
125 cur_face_ori = FOOUTGOING;
128 cur_face_ori = FOINCOMING;
138 for (
auto& cell : grid_.local_cells)
140 const uint64_t c = cell.local_id_;
142 for (
auto& face : cell.faces_)
144 const double mu = omega.
Dot(face.normal_);
147 if (cell_face_orientations_[cell.local_id_][f] == FOOUTGOING)
150 if (face.has_neighbor_)
153 if (face.IsNeighborLocal(grid_))
155 double weight = mu * face.ComputeFaceArea(grid_);
156 cell_successors[c].insert(
157 std::make_pair(face.GetNeighborLocalID(grid_), weight));
160 location_successors.insert(face.GetNeighborPartitionID(grid_));
168 if (face.has_neighbor_ and not face.IsNeighborLocal(grid_))
169 location_dependencies.insert(face.GetNeighborPartitionID(grid_));
181 constexpr double tolerance = 1.0e-16;
187 std::cout <<
"// Printing directed graph for location " << p <<
":\n";
188 std::cout <<
"digraph DG {\n";
189 std::cout <<
" splines=\"FALSE\";\n";
190 std::cout <<
" rankdir=\"LR\";\n\n";
191 std::cout <<
" /* Vertices */\n";
193 for (
const auto& cell : grid_.local_cells)
195 std::cout <<
" " << cell.global_id_ <<
" [shape=\"circle\"]\n";
197 for (
const auto& face : cell.faces_)
199 if (face.has_neighbor_ and (not grid_.IsCellLocal(face.neighbor_id_)))
200 std::cout <<
" " << face.neighbor_id_
201 <<
" [shape=\"circle\", style=filled fillcolor=red "
202 "fontcolor=white] //proc="
203 << grid_.cells[face.neighbor_id_].partition_id_ <<
"\n";
209 for (
const auto& cell : grid_.local_cells)
211 for (
const auto& face : cell.faces_)
213 if (face.has_neighbor_ and (cell.global_id_ > face.neighbor_id_))
215 if (omega_.Dot(face.normal_) > tolerance)
216 std::cout <<
" " << cell.global_id_ <<
" -> "
217 << face.neighbor_id_ <<
"\n";
218 else if (omega_.Dot(face.normal_) < tolerance)
219 std::cout <<
" " << face.neighbor_id_ <<
" -> "
220 << cell.global_id_ <<
"\n";
225 const auto ghost_ids = grid_.cells.GetGhostGlobalIDs();
226 for (
const uint64_t global_id : ghost_ids)
228 const auto& cell = grid_.cells[global_id];
229 for (
const auto& face : cell.faces_)
231 if (face.has_neighbor_ and (cell.global_id_ > face.neighbor_id_) and
232 grid_.IsCellLocal(face.neighbor_id_))
234 if (omega_.Dot(face.normal_) > tolerance)
235 std::cout <<
" " << cell.global_id_ <<
" -> "
236 << face.neighbor_id_ <<
"\n";
237 else if (omega_.Dot(face.normal_) < tolerance)
238 std::cout <<
" " << face.neighbor_id_ <<
" -> "
239 << cell.global_id_ <<
"\n";
static void Exit(int error_code)
static chi::MPI_Info & mpi
const int & process_count
Total number of processes.
std::vector< int > location_dependencies_
int MapLocJToPrelocI(int locJ) const
int MapLocJToDeplocI(int locJ) const
void PrintedGhostedGraph() const
void PopulateCellRelationships(const chi_mesh::Vector3 &omega, std::set< int > &location_dependencies, std::set< int > &location_successors, std::vector< std::set< std::pair< int, double > > > &cell_successors)
std::vector< int > delayed_location_dependencies_
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const