Skip to content

Commit 2bf2188

Browse files
committed
format
1 parent f9b80f9 commit 2bf2188

25 files changed

+299
-235
lines changed

example/diffusion/diffusion_equation.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class DiffusionEquation {
109109
if (set_flux_boundary) {
110110
flux_res = tl.AddTask(flux_res, SetFluxBoundaries, md_mat, md_in, include_flux_dx);
111111
}
112-
if (do_flux_cor && !(md_mat->grid.type() == parthenon::GridType::two_level_composite)) {
112+
if (do_flux_cor &&
113+
!(md_mat->grid.type() == parthenon::GridType::two_level_composite)) {
113114
auto start_flxcor =
114115
tl.AddTask(flux_res, parthenon::StartReceiveFluxCorrections, md_in);
115116
auto send_flxcor =

example/poisson_gmg/poisson_equation.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class PoissonEquation {
5959
if (set_flux_boundary) {
6060
flux_res = tl.AddTask(flux_res, SetFluxBoundaries, md_mat, md_in, include_flux_dx);
6161
}
62-
if (do_flux_cor && !(md_mat->grid.type() == parthenon::GridType::two_level_composite)) {
62+
if (do_flux_cor &&
63+
!(md_mat->grid.type() == parthenon::GridType::two_level_composite)) {
6364
auto start_flxcor =
6465
tl.AddTask(flux_res, parthenon::StartReceiveFluxCorrections, md_in);
6566
auto send_flxcor =

src/basic_types.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ inline constexpr BoundaryType GetAssociatedSender(BoundaryType btype) {
110110
return btype;
111111
}
112112

113-
enum class GridType : int { none, leaf, two_level_composite};
113+
enum class GridType : int { none, leaf, two_level_composite };
114114
class GridIdentifier {
115115
GridType type_ = GridType::none;
116116
int logical_level_ = 0; // Only meaningful for two_level_composite
@@ -123,15 +123,15 @@ class GridIdentifier {
123123
auto logical_level() const { return logical_level_; }
124124
auto multigrid_level() const { return multigrid_level_; }
125125
auto block_coarsenings() const { return block_coarsenings_; }
126-
auto IsMultigrid() const { return is_multigrid_; }
126+
auto IsMultigrid() const { return is_multigrid_; }
127127

128128
static GridIdentifier leaf() {
129129
auto out = GridIdentifier::leaf(-1, 0);
130130
out.is_multigrid_ = false;
131131
return out;
132132
}
133133

134-
static GridIdentifier leaf(int multigrid_level, std::size_t block_coarsenings) {
134+
static GridIdentifier leaf(int multigrid_level, std::size_t block_coarsenings) {
135135
GridIdentifier out;
136136
out.type_ = GridType::leaf;
137137
out.logical_level_ = -1111;
@@ -140,13 +140,14 @@ class GridIdentifier {
140140
out.is_multigrid_ = true;
141141
return out;
142142
}
143-
143+
144144
static GridIdentifier none() {
145145
GridIdentifier out;
146146
return out;
147147
}
148148

149-
static GridIdentifier two_level_composite(int multigrid_level, int logical_level, std::size_t block_coarsenings) {
149+
static GridIdentifier two_level_composite(int multigrid_level, int logical_level,
150+
std::size_t block_coarsenings) {
150151
GridIdentifier out;
151152
out.type_ = GridType::two_level_composite;
152153
out.logical_level_ = logical_level;
@@ -160,15 +161,17 @@ class GridIdentifier {
160161
if (type_ == GridType::leaf) {
161162
return "GridType::leaf[" + std::to_string(block_coarsenings_) + "]";
162163
} else if (type_ == GridType::two_level_composite) {
163-
return "GridType::two_level_composite[" + std::to_string(logical_level_) + ", " + std::to_string(block_coarsenings_) + "]";
164+
return "GridType::two_level_composite[" + std::to_string(logical_level_) + ", " +
165+
std::to_string(block_coarsenings_) + "]";
164166
}
165167
return "GridType::none";
166168
}
167169
};
168170
// Add a comparator so we can store in std::map
169171
inline bool operator<(const GridIdentifier &lhs, const GridIdentifier &rhs) {
170172
if (lhs.type() != rhs.type()) return lhs.type() < rhs.type();
171-
if (lhs.block_coarsenings() != rhs.block_coarsenings()) return lhs.block_coarsenings() < rhs.block_coarsenings();
173+
if (lhs.block_coarsenings() != rhs.block_coarsenings())
174+
return lhs.block_coarsenings() < rhs.block_coarsenings();
172175
return lhs.logical_level() < rhs.logical_level();
173176
}
174177

src/bvals/comms/bnd_info.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,19 @@ GetFluxCorrectionElements(const std::shared_ptr<Variable<Real>> &v,
107107
return elements;
108108
}
109109

110-
bool NeighborIsCoarser(MeshBlock *pmb, const NeighborBlock &nb) {
111-
return nb.loc.level() < pmb->loc.level() || nb.block_coarsenings > pmb->block_coarsenings;
110+
bool NeighborIsCoarser(MeshBlock *pmb, const NeighborBlock &nb) {
111+
return nb.loc.level() < pmb->loc.level() ||
112+
nb.block_coarsenings > pmb->block_coarsenings;
112113
}
113114

114-
bool NeighborIsFiner(MeshBlock *pmb, const NeighborBlock &nb) {
115-
return nb.loc.level() > pmb->loc.level() || nb.block_coarsenings < pmb->block_coarsenings;
115+
bool NeighborIsFiner(MeshBlock *pmb, const NeighborBlock &nb) {
116+
return nb.loc.level() > pmb->loc.level() ||
117+
nb.block_coarsenings < pmb->block_coarsenings;
116118
}
117119

118-
bool NeighborIsSame(MeshBlock *pmb, const NeighborBlock &nb) {
119-
return nb.loc.level() == pmb->loc.level() && nb.block_coarsenings == pmb->block_coarsenings;
120+
bool NeighborIsSame(MeshBlock *pmb, const NeighborBlock &nb) {
121+
return nb.loc.level() == pmb->loc.level() &&
122+
nb.block_coarsenings == pmb->block_coarsenings;
120123
}
121124

122125
SpatiallyMaskedIndexer6D
@@ -135,7 +138,8 @@ CalcIndices(const NeighborBlock &nb, MeshBlock *pmb,
135138
const bool nb_is_coarser = NeighborIsCoarser(pmb, nb);
136139
const bool nb_is_finer = NeighborIsFiner(pmb, nb);
137140
const bool nb_is_same = NeighborIsSame(pmb, nb);
138-
PARTHENON_REQUIRE(nb_is_coarser + nb_is_finer + nb_is_same == 1, "Only one should be set.");
141+
PARTHENON_REQUIRE(nb_is_coarser + nb_is_finer + nb_is_same == 1,
142+
"Only one should be set.");
139143
// Both prolongation and restriction always operate in the coarse
140144
// index space. Also need to use the coarse index space if the
141145
// neighbor is coarser than you, wether or not you are setting
@@ -172,8 +176,7 @@ CalcIndices(const NeighborBlock &nb, MeshBlock *pmb,
172176
std::array<int, 3> block_offset = nb.offsets;
173177

174178
int communicated_ghosts = Globals::nghost;
175-
if (!prores && nb_is_same &&
176-
v->IsSet(Metadata::CommunicateOne))
179+
if (!prores && nb_is_same && v->IsSet(Metadata::CommunicateOne))
177180
communicated_ghosts = 1;
178181
int interior_offset =
179182
ir_type == IndexRangeType::BoundaryInteriorSend ? communicated_ghosts : 0;

src/bvals/comms/bvals_utils.hpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ inline auto &GetReceiverGid(Mesh::channel_key_t &key) { return std::get<1>(key);
4242
inline auto &GetVariable(Mesh::channel_key_t &key) { return std::get<2>(key); }
4343
inline auto &GetLocIdx(Mesh::channel_key_t &key) { return std::get<3>(key); }
4444
inline auto &GetOther(Mesh::channel_key_t &key) { return std::get<4>(key); }
45-
inline std::string GetLabel(Mesh::channel_key_t &key) { return "sender: " + std::to_string(GetSenderGid(key)) + ", receiver: " +
46-
std::to_string(GetReceiverGid(key)) + ", var: " + GetVariable(key) +
47-
", location: " + std::to_string(GetLocIdx(key)) + ", other:"
48-
+ std::to_string(GetOther(key));}
45+
inline std::string GetLabel(Mesh::channel_key_t &key) {
46+
return "sender: " + std::to_string(GetSenderGid(key)) +
47+
", receiver: " + std::to_string(GetReceiverGid(key)) +
48+
", var: " + GetVariable(key) + ", location: " + std::to_string(GetLocIdx(key)) +
49+
", other:" + std::to_string(GetOther(key));
50+
}
4951
inline Mesh::channel_key_t SendKey(const MeshBlock *pmb, const NeighborBlock &nb,
5052
const std::shared_ptr<Variable<Real>> &pcv,
5153
BoundaryType btype, int id) {
@@ -105,16 +107,17 @@ void InitializeBufferCache(std::shared_ptr<MeshData<Real>> &md, COMM_MAP *comm_m
105107
std::vector<std::tuple<int, int, Mesh::channel_key_t>> key_order;
106108

107109
int boundary_idx = 0;
108-
ForEachBoundary<bound_type>(md, [&](auto pmb, sp_mbd_t rc, const nb_t &nb, const sp_cv_t v) {
109-
auto key = KeyFunc(pmb, nb, v, bound_type, md->GetBoundBufferId(bound_type));
110-
PARTHENON_DEBUG_REQUIRE(comm_map->count(key) > 0,
111-
"Boundary communicator does not exist");
112-
// Create a unique index by combining receiver gid (second element of the key
113-
// tuple) and geometric element index (fourth element of the key tuple)
114-
int recvr_idx = 27 * GetReceiverGid(key) + GetLocIdx(key);
115-
key_order.push_back({recvr_idx, boundary_idx, key});
116-
++boundary_idx;
117-
});
110+
ForEachBoundary<bound_type>(
111+
md, [&](auto pmb, sp_mbd_t rc, const nb_t &nb, const sp_cv_t v) {
112+
auto key = KeyFunc(pmb, nb, v, bound_type, md->GetBoundBufferId(bound_type));
113+
PARTHENON_DEBUG_REQUIRE(comm_map->count(key) > 0,
114+
"Boundary communicator does not exist");
115+
// Create a unique index by combining receiver gid (second element of the key
116+
// tuple) and geometric element index (fourth element of the key tuple)
117+
int recvr_idx = 27 * GetReceiverGid(key) + GetLocIdx(key);
118+
key_order.push_back({recvr_idx, boundary_idx, key});
119+
++boundary_idx;
120+
});
118121

119122
// If desired, sort the keys and boundary indices by receiver_idx
120123
// std::sort(key_order.begin(), key_order.end(),
@@ -132,8 +135,8 @@ void InitializeBufferCache(std::shared_ptr<MeshData<Real>> &md, COMM_MAP *comm_m
132135
std::for_each(std::begin(key_order), std::end(key_order), [&](auto &t) {
133136
if (comm_map->count(std::get<2>(t)) == 0) {
134137
auto key = std::get<2>(t);
135-
PARTHENON_FAIL(std::string("Asking for buffer that doesn't exist") +
136-
" (" + GetLabel(key) + ")");
138+
PARTHENON_FAIL(std::string("Asking for buffer that doesn't exist") + " (" +
139+
GetLabel(key) + ")");
137140
}
138141
pcache->buf_vec.push_back(&((*comm_map)[std::get<2>(t)]));
139142
(pcache->idx_vec)[std::get<1>(t)] = buff_idx++;

src/bvals/comms/tag_map.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ TagMap::rank_pair_t TagMap::MakeChannelPair(const MeshBlock *pmb,
3737
}
3838

3939
template <BoundaryType BOUND>
40-
void TagMap::AddMeshDataToMap(std::shared_ptr<MeshData<Real>> &md, int channels_per_pair) {
40+
void TagMap::AddMeshDataToMap(std::shared_ptr<MeshData<Real>> &md,
41+
int channels_per_pair) {
4142
for (int block = 0; block < md->NumBlocks(); ++block) {
4243
auto &rc = md->GetBlockData(block);
4344
auto pmb = rc->GetBlockPointer();
4445
// type_t var = []{...}() pattern defines and uses a lambda that
4546
// returns to reduce initializations of var
4647
const auto &neighbors = [&pmb, &md] {
4748
if constexpr (BOUND == BoundaryType::gmg_restrict_send)
48-
return pmb->loc.level() == md->grid.logical_level() ? pmb->GetGMGCoarserNeighbors()
49-
: pmb->GetGMGSelfNeighbors();
49+
return pmb->loc.level() == md->grid.logical_level()
50+
? pmb->GetGMGCoarserNeighbors()
51+
: pmb->GetGMGSelfNeighbors();
5052
if constexpr (BOUND == BoundaryType::gmg_restrict_recv)
5153
return pmb->GetGMGFinerNeighbors().size() > 0 ? pmb->GetGMGFinerNeighbors()
5254
: pmb->GetGMGSelfNeighbors();
@@ -55,8 +57,7 @@ void TagMap::AddMeshDataToMap(std::shared_ptr<MeshData<Real>> &md, int channels_
5557
if constexpr (BOUND == BoundaryType::gmg_prolongate_recv)
5658
return pmb->GetGMGCoarserNeighbors();
5759
if constexpr (BOUND == BoundaryType::gmg_same) {
58-
if (md->grid.type() == GridType::leaf)
59-
return pmb->GetNeighbors();
60+
if (md->grid.type() == GridType::leaf) return pmb->GetNeighbors();
6061
return pmb->loc.level() == md->grid.logical_level()
6162
? pmb->GetGMGSameNeighbors()
6263
: pmb->GetGMGCompositeFinerNeighbors();
@@ -76,7 +77,8 @@ void TagMap::AddMeshDataToMap(std::shared_ptr<MeshData<Real>> &md, int channels_
7677
template void
7778
TagMap::AddMeshDataToMap<BoundaryType::any>(std::shared_ptr<MeshData<Real>> &md, int);
7879
template void
79-
TagMap::AddMeshDataToMap<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &md, int);
80+
TagMap::AddMeshDataToMap<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &md,
81+
int);
8082
template void TagMap::AddMeshDataToMap<BoundaryType::gmg_prolongate_send>(
8183
std::shared_ptr<MeshData<Real>> &md, int);
8284
template void TagMap::AddMeshDataToMap<BoundaryType::gmg_restrict_send>(

src/bvals/comms/tag_map.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class NeighborBlock;
7878
class TagMap {
7979
// Unique keys defined by a two-way communication channel
8080
using rank_pair_t = UnorderedPair<BlockGeometricElementId>;
81-
// Map between a communication channel key (+ buffer id on that channel) and a unique MPI tag
81+
// Map between a communication channel key (+ buffer id on that channel) and a unique
82+
// MPI tag
8283
using rank_pair_map_t = std::map<std::pair<rank_pair_t, int>, int>;
8384
// Map of maps where the key corresponds to the MPI rank of the
8485
// other process

src/bvals/neighbor_block.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ NeighborBlock::NeighborBlock()
4343

4444
NeighborBlock::NeighborBlock(Mesh *mesh, LogicalLocation loc, LogicalLocation origin_loc,
4545
int rank, int gid, Kokkos::Array<int, 3> offsets_in, int bid,
46-
int target_id, int fi1, int fi2, std::size_t block_coarsenings)
46+
int target_id, int fi1, int fi2,
47+
std::size_t block_coarsenings)
4748
: rank{rank}, gid{gid}, bufid{bid}, targetid{target_id}, loc{loc},
48-
origin_loc{origin_loc}, fi1{fi1}, fi2{fi2}, block_size(mesh->GetBlockSize(loc, block_coarsenings)),
49-
offsets(offsets_in), ownership(true), block_coarsenings{block_coarsenings} {}
49+
origin_loc{origin_loc}, fi1{fi1}, fi2{fi2},
50+
block_size(mesh->GetBlockSize(loc, block_coarsenings)), offsets(offsets_in),
51+
ownership(true), block_coarsenings{block_coarsenings} {}
5052

5153
BufferID::BufferID(int dim, bool multilevel) {
5254
std::vector<int> x1offsets = dim > 0 ? std::vector<int>{0, -1, 1} : std::vector<int>{0};

src/interface/data_collection.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ template <>
5050
std::shared_ptr<MeshData<Real>> &
5151
DataCollection<MeshData<Real>>::GetOrAdd(const std::string &mbd_label,
5252
const int &partition_id) {
53-
return Add(mbd_label,
54-
pmy_mesh_->GetDefaultBlockPartitions()[partition_id]);
53+
return Add(mbd_label, pmy_mesh_->GetDefaultBlockPartitions()[partition_id]);
5554
}
5655

5756
template <>
5857
std::shared_ptr<MeshData<Real>> &
5958
DataCollection<MeshData<Real>>::GetOrAdd(int gmg_level, const std::string &mbd_label,
6059
const int &partition_id) {
61-
return Add(mbd_label,
62-
pmy_mesh_->GetMultigridBlockPartitions(gmg_level)[partition_id]);
60+
return Add(mbd_label, pmy_mesh_->GetMultigridBlockPartitions(gmg_level)[partition_id]);
6361
}
6462

6563
template <class T>

src/interface/mesh_data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void MeshData<T>::Initialize(BlockList_t blocks, Mesh *pmesh,
2929
if (pmesh) {
3030
grid = pmesh->GetGMGGrid(*gmg_level);
3131
} else {
32-
PARTHENON_FAIL("Cannot initialize MeshData without Mesh.");
32+
PARTHENON_FAIL("Cannot initialize MeshData without Mesh.");
3333
}
3434
} else {
3535
grid = GridIdentifier::leaf();

0 commit comments

Comments
 (0)