Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
scheduler_patch_list.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
22#include <nlohmann/json.hpp>
23#include <unordered_map>
24#include <unordered_set>
25#include <array>
26#include <stdexcept>
27#include <tuple>
28#include <vector>
29
35 public:
45
49 std::vector<shamrock::patch::Patch> global;
50
54 std::vector<shamrock::patch::Patch> local;
55
57
60
65 "the load values are invalid please update them", loc);
66 }
67 }
68
74 void build_global();
75
81 [[nodiscard]]
82 std::unordered_set<u64> build_local();
83
108 std::unordered_set<u64> &patch_id_lst,
109 std::vector<u64> &to_send_idx,
110 std::vector<u64> &to_recv_idx);
111
115 std::unordered_map<u64, u64> id_patch_to_global_idx;
116
120 std::unordered_map<u64, u64> id_patch_to_local_idx;
121
127
131 void build_local_idx_map();
132
137
146 std::tuple<u64, u64, u64, u64, u64, u64, u64, u64> split_patch(u64 id_patch);
147
156 void merge_patch(
157 u64 idx0, u64 idx1, u64 idx2, u64 idx3, u64 idx4, u64 idx5, u64 idx6, u64 idx7);
158};
159
166void to_json(nlohmann::json &j, const SchedulerPatchList &p);
167
174void from_json(const nlohmann::json &j, SchedulerPatchList &p);
175
183std::vector<shamrock::patch::Patch> make_fake_patch_list(u32 total_dtcnt, u64 div_limit);
Header file for the patch struct and related function.
Source location utility.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Handle the patch list of the mpi scheduler.
std::vector< shamrock::patch::Patch > local
contain the list of patch owned by the current node
void reset_local_pack_index()
reset Patch's pack index value
bool is_load_values_up_to_date
Are patch load values up to date.
std::unordered_map< u64, u64 > id_patch_to_local_idx
id_patch_to_local_idx[patch_id] = index in local patch list
std::vector< shamrock::patch::Patch > global
contain the list of all patches in the simulation
void build_global()
rebuild global from the local list of each tables
void invalidate_load_values()
Invalidate current load values (To use after a change the patches is made)
void build_local_differantial(std::unordered_set< u64 > &patch_id_lst, std::vector< u64 > &to_send_idx, std::vector< u64 > &to_recv_idx)
Build the local patch list and create a differential of patches to send / recv since last time.
u64 _next_patch_id
The next available patch id.
std::tuple< u64, u64, u64, u64, u64, u64, u64, u64 > split_patch(u64 id_patch)
split the Patch having id_patch as id and return the index of the 8 subpatches in the global vector
std::unordered_set< u64 > build_local()
select owned patches owned by the node to rebuild local
std::unordered_map< u64, u64 > id_patch_to_global_idx
id_patch_to_global_idx[patch_id] = index in global patch list
void merge_patch(u64 idx0, u64 idx1, u64 idx2, u64 idx3, u64 idx4, u64 idx5, u64 idx6, u64 idx7)
merge the 8 given patches index in the global vector
void build_local_idx_map()
recompute id_patch_to_local_idx
void check_load_values_valid(SourceLocation loc=SourceLocation{})
Check if the load values are valid, throw otherwise.
void build_global_idx_map()
recompute id_patch_to_global_idx
This header file contains utility functions related to exception handling in the code.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
void to_json(nlohmann::json &j, const SchedulerPatchList &p)
Serializes a SchedulerPatchList object to a JSON object.
std::vector< shamrock::patch::Patch > make_fake_patch_list(u32 total_dtcnt, u64 div_limit)
generate a fake patch list corresponding to a tree structure
void from_json(const nlohmann::json &j, SchedulerPatchList &p)
Deserializes a JSON object into a SchedulerPatchList object.
provide information about the source location