9#define mk_shrd(x) std::make_shared<x>
10#define SweepVaccuumBndry \
11chi_mesh::sweep_management::BoundaryVaccuum
12#define SweepIncHomoBndry \
13chi_mesh::sweep_management::BoundaryIsotropicHomogenous
14#define SweepReflectingBndry \
15chi_mesh::sweep_management::BoundaryReflecting
16#define SweepAniHeteroBndry \
17chi_mesh::sweep_management::BoundaryIncidentHeterogeneous
19#define ExceptionLocalFaceNormalsDiffer \
20std::logic_error(fname + ": Not all face normals are," \
21" within tolerance, locally the same for the reflecting boundary" \
22" condition requested.")
24#define ExceptionGlobalFaceNormalsDiffer \
25std::logic_error(fname + ": Not all face normals are," \
26" within tolerance, globally the same for the reflecting boundary" \
27" condition requested.")
33 const std::string fname =
"lbs::LBSSolver::InitializeBoundaries";
36 std::set<uint64_t> globl_unique_bids_set;
38 std::set<uint64_t> local_unique_bids_set;
39 for (
const auto& cell :
grid_ptr_->local_cells)
40 for (
const auto& face : cell.faces_)
41 if (not face.has_neighbor_)
42 local_unique_bids_set.insert(face.neighbor_id_);
44 std::vector<uint64_t> local_unique_bids(local_unique_bids_set.begin(),
45 local_unique_bids_set.end());
46 const int local_num_unique_bids =
static_cast<int>(local_unique_bids.size());
47 std::vector<int> recvcounts(
Chi::mpi.process_count, 0);
49 MPI_Allgather(&local_num_unique_bids,
55 std::vector<int> recvdispls(
Chi::mpi.process_count, 0);
57 int running_displacement = 0;
60 recvdispls[locI] = running_displacement;
61 running_displacement += recvcounts[locI];
64 std::vector<uint64_t> recvbuf(running_displacement, 0);
66 MPI_Allgatherv(local_unique_bids.data(),
67 local_num_unique_bids,
75 globl_unique_bids_set = local_unique_bids_set;
77 for (uint64_t bid : recvbuf)
78 globl_unique_bids_set.insert(bid);
87 for (uint64_t bid : globl_unique_bids_set)
91 if (has_no_preference and has_not_been_set)
95 else if (has_not_been_set)
98 const auto& mg_q = bndry_pref.isotropic_mg_source;
107 std::make_unique<BoundaryFunctionToLua>(bndry_pref.source_function),
115 const double EPSILON = 1.0e-12;
116 std::unique_ptr<Vec3> n_ptr =
nullptr;
117 for (
const auto& cell :
grid_ptr_->local_cells)
118 for (
const auto &face: cell.faces_)
119 if (not face.has_neighbor_ and face.neighbor_id_ == bid)
121 if (not n_ptr) n_ptr = std::make_unique<Vec3>(face.normal_);
122 if (std::fabs(face.normal_.Dot(*n_ptr) - 1.0) > EPSILON)
127 const int local_has_bid = n_ptr !=
nullptr ? 1 : 0;
128 const Vec3 local_normal = local_has_bid ? *n_ptr : Vec3(0.0,0.0,0.0);
130 std::vector<int> locJ_has_bid(
Chi::mpi.process_count, 1);
131 std::vector<double> locJ_n_val(
Chi::mpi.process_count*3, 0.0);
133 MPI_Allgather(&local_has_bid,
139 MPI_Allgather(&local_normal,
151 const double* n = &locJ_n_val[offset];
152 const Vec3 locJ_normal(n[0], n[1], n[2]);
155 if (std::fabs(local_normal.Dot(locJ_normal) - 1.0) > EPSILON)
158 global_normal = locJ_normal;
static chi::MPI_Info & mpi
const MPI_Comm & comm
MPI communicator.
const int & process_count
Total number of processes.
chi_mesh::MeshContinuumPtr grid_ptr_
std::map< uint64_t, std::shared_ptr< SweepBndry > > sweep_boundaries_
std::map< uint64_t, BoundaryPreference > boundary_preferences_
void InitializeBoundaries()
#define SweepVaccuumBndry
#define SweepReflectingBndry
#define SweepIncHomoBndry
#define ExceptionLocalFaceNormalsDiffer
#define ExceptionGlobalFaceNormalsDiffer
#define SweepAniHeteroBndry
@ INCIDENT_ANISTROPIC_HETEROGENEOUS
chi_math::CoordinateSystemType MapGeometryTypeToCoordSys(const GeometryType gtype)
GeometryType geometry_type