Skip to content

Commit

Permalink
formatting and style
Browse files Browse the repository at this point in the history
  • Loading branch information
jdolence committed Aug 15, 2023
1 parent 0d286a3 commit c153a90
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
3 changes: 2 additions & 1 deletion src/amr_criteria/amr_criteria.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
namespace parthenon {

class ParameterInput;
template <class> class MeshBlockData;
template <class>
class MeshBlockData;

struct AMRBounds {
AMRBounds(const IndexRange &ib, const IndexRange &jb, const IndexRange &kb)
Expand Down
2 changes: 1 addition & 1 deletion src/interface/mesh_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class MeshData {
};

template <typename T, typename... Args>
std::vector<Uid_t> UidIntersection(MeshData<T> *md1, MeshData<T> *md2, Args &&... args) {
std::vector<Uid_t> UidIntersection(MeshData<T> *md1, MeshData<T> *md2, Args &&...args) {
auto u1 = md1->GetBlockData(0)->GetVariableUIDs(std::forward<Args>(args)...);
auto u2 = md2->GetBlockData(0)->GetVariableUIDs(std::forward<Args>(args)...);
return UidIntersection(u1, u2);
Expand Down
6 changes: 3 additions & 3 deletions src/interface/meshblock_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ class MeshBlockData {
}

std::vector<Uid_t> GetVariableUIDs(const std::vector<std::string> &names,
const std::vector<int> &sparse_ids = {}) {
const std::vector<int> &sparse_ids = {}) {
return GetVariablesByName(names, sparse_ids).unique_ids();
}
std::vector<Uid_t> GetVariableUIDs(const Metadata::FlagCollection &flags,
const std::vector<int> &sparse_ids = {}) {
const std::vector<int> &sparse_ids = {}) {
return GetVariablesByFlag(flags, sparse_ids).unique_ids();
}
std::vector<Uid_t> GetVariableUIDs(const std::vector<int> &sparse_ids = {}) {
Expand Down Expand Up @@ -661,7 +661,7 @@ class MeshBlockData {

template <typename T, typename... Args>
std::vector<Uid_t> UidIntersection(MeshBlockData<T> *mbd1, MeshBlockData<T> *mbd2,
Args &&... args) {
Args &&...args) {
auto u1 = mbd1->GetVariableUIDs(std::forward<Args>(args)...);
auto u2 = mbd2->GetVariableUIDs(std::forward<Args>(args)...);
return UidIntersection(u1, u2);
Expand Down
43 changes: 19 additions & 24 deletions src/interface/sparse_pack_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace parthenon {
class SparsePackCache;
namespace impl {
class PackDescriptor;
class PackDescriptor;
}

// Map for going from variable names to sparse pack variable indices
Expand All @@ -45,8 +45,6 @@ class StateDescriptor;

enum class PDOpt { WithFluxes, Coarse, Flatten };



class SparsePackBase {
public:
SparsePackBase() = default;
Expand Down Expand Up @@ -126,18 +124,16 @@ struct PackDescriptor {
using VariableGroup_t = std::vector<std::pair<VarID, Uid_t>>;
using SelectorFunction_t = std::function<bool(int, const VarID &, const Metadata &)>;
using SelectorFunctionUid_t = std::function<bool(int, const Uid_t &, const Metadata &)>;

void Print() const;

template <class GROUP_t, class SELECTOR_t>
PackDescriptor(StateDescriptor *psd,
const std::vector<GROUP_t> &var_groups_in,
const SELECTOR_t &selector,
const std::set<PDOpt> &options)

template <class GROUP_t, class SELECTOR_t>
PackDescriptor(StateDescriptor *psd, const std::vector<GROUP_t> &var_groups_in,
const SELECTOR_t &selector, const std::set<PDOpt> &options)
: nvar_groups(var_groups_in.size()), var_group_names(MakeGroupNames(var_groups_in)),
var_groups(BuildUids(var_groups_in.size(), psd, selector)),
with_fluxes(options.count(PDOpt::WithFluxes)), coarse(options.count(PDOpt::Coarse)),
flat(options.count(PDOpt::Flatten)) {
with_fluxes(options.count(PDOpt::WithFluxes)),
coarse(options.count(PDOpt::Coarse)), flat(options.count(PDOpt::Flatten)) {
PARTHENON_REQUIRE(!(with_fluxes && coarse),
"Probably shouldn't be making a coarse pack with fine fluxes.");
}
Expand All @@ -150,25 +146,23 @@ struct PackDescriptor {
const bool flat;

private:

template <class FUNC_t>
std::vector<PackDescriptor::VariableGroup_t>
BuildUids(int nvgs, const StateDescriptor *const psd,
const FUNC_t &selector) {
BuildUids(int nvgs, const StateDescriptor *const psd, const FUNC_t &selector) {
auto fields = psd->AllFields();
std::vector<VariableGroup_t> vgs(nvgs);
for (auto [id, md] : fields) {
for (int i = 0; i < nvgs; ++i) {
auto uid = Variable<Real>::GetUniqueID(id.label());
if constexpr (std::is_invocable<FUNC_t, int, VarID, Metadata>::value) {
if constexpr (std::is_invocable<FUNC_t, int, VarID, Metadata>::value) {
if (selector(i, id, md)) {
vgs[i].push_back({id, uid});
}
} else if constexpr (std::is_invocable<FUNC_t, int, Uid_t, Metadata>::value) {
} else if constexpr (std::is_invocable<FUNC_t, int, Uid_t, Metadata>::value) {
if (selector(i, uid, md)) {
vgs[i].push_back({id, uid});
}
} else {
} else {
PARTHENON_FAIL("Passing the wrong sort of selector.");
}
}
Expand All @@ -184,13 +178,14 @@ struct PackDescriptor {
return vgs;
}

template <class base_t>
template <class base_t>
std::vector<std::string> MakeGroupNames(const std::vector<base_t> &var_groups) {
if constexpr (std::is_same<base_t, std::string>::value) {
return var_groups;
} else if constexpr (std::is_same<base_t, Uid_t>::value) {
std::vector<std::string> var_group_names;
for (auto &vg : var_groups) var_group_names.push_back(std::to_string(vg));
if constexpr (std::is_same<base_t, std::string>::value) {
return var_groups;
} else if constexpr (std::is_same<base_t, Uid_t>::value) {
std::vector<std::string> var_group_names;
for (auto &vg : var_groups)
var_group_names.push_back(std::to_string(vg));
return var_group_names;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/parthenon/driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ using ::parthenon::TaskListStatus;
using ::parthenon::TaskRegion;
using ::parthenon::TaskStatus;
using ::parthenon::TaskType;
using ::parthenon::Uid_t;
using ::parthenon::DriverUtils::ConstructAndExecuteBlockTasks;
using ::parthenon::DriverUtils::ConstructAndExecuteTaskLists;
using ::parthenon::Uid_t;

namespace partition {
using ::parthenon::partition::Partition_t;
Expand Down
1 change: 1 addition & 0 deletions src/utils/unique_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define UTILS_UNIQUE_ID_HPP_

#include <cstddef>
#include <vector>

#include <unordered_map>

Expand Down

0 comments on commit c153a90

Please sign in to comment.