44 std::shared_ptr<shamrock::patch::PatchDataLayerLayout> pdl;
45 std::unique_ptr<PatchScheduler> sched;
47 inline void pdata_layout_new() {
49 throw ShamAPIException(
"cannot modify patch data layout while the scheduler is on");
51 pdl = std::make_shared<shamrock::patch::PatchDataLayerLayout>();
70 throw ShamAPIException(
"cannot modify patch data layout while the scheduler is on");
76 inline void pdata_layout_add_field(std::string fname,
u32 nvar) {
78 throw ShamAPIException(
"cannot modify patch data layout while the scheduler is on");
80 pdl->add_field<T>(fname, nvar);
83 inline void pdata_layout_add_field_t(std::string fname,
u32 nvar, std::string type) {
85 throw ShamAPIException(
"cannot modify patch data layout while the scheduler is on");
87 pdl->add_field_t(fname, nvar, type);
90 inline void pdata_layout_print() {
94 std::cout << pdl->get_description_str() << std::endl;
97 inline void dump_status() {
102 logger::raw_ln(sched->dump_status());
105 inline void init_sched(
u64 crit_split,
u64 crit_merge) {
111 sched = std::make_unique<PatchScheduler>(pdl, crit_split, crit_merge);
112 sched->init_mpi_required_types();
115 inline void close_sched() { sched.reset(); }
125 inline std::vector<std::unique_ptr<shamrock::patch::PatchDataLayer>> gather_data(
u32 rank) {
126 return sched->gather_data(rank);
129 inline std::vector<std::unique_ptr<shamrock::patch::PatchDataLayer>> allgather_data() {
131 using namespace shamsys::instance;
132 using namespace shamrock::patch;
134 std::vector<std::unique_ptr<PatchDataLayer>> recv_data;
138 recv_data = sched->gather_data(i);
140 sched->gather_data(i);
147 void set_coord_domain_bound(std::tuple<f64_3, f64_3> box) {
159 if (pdl->check_main_field_type<f32_3>()) {
160 auto conv_vec = [](f64_3 v) -> f32_3 {
161 return {v.x(), v.y(), v.z()};
164 f32_3 vec0 = conv_vec(a);
165 f32_3 vec1 = conv_vec(b);
167 sched->set_coord_domain_bound<f32_3>(vec0, vec1);
168 }
else if (pdl->check_main_field_type<f64_3>()) {
170 sched->set_coord_domain_bound<f64_3>(a, b);
173 "the chosen type for the main field is not handled");
177 inline void scheduler_step(
bool do_split_merge,
bool do_load_balancing) {
181 sched->scheduler_step(do_split_merge, do_load_balancing);
184 inline std::vector<shamrock::patch::Patch> get_patch_list_global() {
188 return sched->patch_list.global;
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...