Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SchedulerPatchData.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
27#include <cmath>
28#include <map>
29#include <utility>
30
31namespace shamrock::scheduler {
32
33 using Patch = shamrock::patch::Patch;
34 using PatchData = shamrock::patch::PatchDataLayer;
35 using PatchDataLayerLayout = shamrock::patch::PatchDataLayerLayout;
36 using SimulationBoxInfo = shamrock::patch::SimulationBoxInfo;
37
43 public:
44 std::shared_ptr<PatchDataLayerLayout> pdl_ptr;
45
47 return shambase::get_check_ref(pdl_ptr);
48 }
49
50 inline std::shared_ptr<shamrock::patch::PatchDataLayerLayout> get_layout_ptr() const {
51 return pdl_ptr;
52 }
53
59
60 inline bool has_patch(u64 id) { return owned_data.has_key(id); }
61
62 inline PatchData &get_pdat(u64 id) { return owned_data.get(id); }
63
64 inline void for_each_patchdata(std::function<void(u64, PatchData &)> &&f) {
65 owned_data.for_each(std::forward<std::function<void(u64, PatchData &)>>(f));
66 }
67
73
82 SchedulerPatchList &patch_list);
83
90 void split_patchdata(u64 key_orginal, const std::array<shamrock::patch::Patch, 8> patches);
91
98 void merge_patchdata(u64 new_key, const std::array<u64, 8> old_keys);
99
100 inline SchedulerPatchData(
101 const std::shared_ptr<shamrock::patch::PatchDataLayerLayout> &pdl_ptr,
102 shamrock::patch::PatchCoord<3> patch_coord_range)
103 : pdl_ptr(pdl_ptr), sim_box(pdl(), patch_coord_range) {}
104 };
105
106} // namespace shamrock::scheduler
function to run load balancing with the hilbert curve
Header file for the patch struct and related function.
std::uint64_t u64
64 bit unsigned integer
Handle the patch list of the mpi scheduler.
Represents a collection of objects distributed across patches identified by a u64 id.
PatchDataLayer container class, the layout is described in patchdata_layout.
Store the information related to the size of the simulation box to convert patch integer coordinates ...
Definition SimBox.hpp:35
Class to handle PatchData owned by the node.
void merge_patchdata(u64 new_key, const std::array< u64, 8 > old_keys)
merge 8 old patchdata into one
shamrock::patch::SimulationBoxInfo sim_box
simulation box geometry info
void apply_change_list(const shamrock::scheduler::LoadBalancingChangeList &change_list, SchedulerPatchList &patch_list)
apply a load balancing change list to shuffle patchdata arround the cluster
void split_patchdata(u64 key_orginal, const std::array< shamrock::patch::Patch, 8 > patches)
split a patchdata into 8 childs according to the 8 patches in arguments
shambase::DistributedData< PatchData > owned_data
map container for patchdata owned by the current node (layout : id_patch,data)
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...
Definition memory.hpp:110
Class to handle the patch list of the mpi scheduler.
Patch object that contain generic patch information.
Definition Patch.hpp:33