Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AMRGridRefinementHandler.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
19
20#include "shambackends/vec.hpp"
25
27 using namespace shamrock::patch;
28 using Direction_ = shammodels::basegodunov::modules::Direction;
29 using AMRGraphLinkiterator = shammodels::basegodunov::modules::AMRGraph::ro_access;
30
31 template<class Tvec, class TgridVec>
32 class AMRGridRefinementHandler {
33
34 class AMRBlockFinder;
35 class AMRLowering;
36
37 public:
38 using Tscal = shambase::VecComponent<Tvec>;
39 using Tgridscal = shambase::VecComponent<TgridVec>;
40 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
41 static constexpr u32 split_count = shambase::pow_constexpr<dim>(2);
42
43 using Config = SolverConfig<Tvec, TgridVec>;
45 using u_morton = u64;
46 using AMRBlock = typename Config::AMRBlock;
48 using OrientedAMRGraph = OrientedAMRGraph<Tvec, TgridVec>;
49
50 using TgridUint = typename std::make_unsigned<shambase::VecComponent<TgridVec>>::type;
51
52 ShamrockCtx &context;
53 Config &solver_config;
54 Storage &storage;
55
56 AMRGridRefinementHandler(ShamrockCtx &context, Config &solver_config, Storage &storage)
57 : context(context), solver_config(solver_config), storage(storage) {}
58
59 void update_refinement_old();
61
62 private:
77 template<class UserAcc, class... T>
78 void gen_refine_block_changes_old(
81 T &&...args);
82
83 template<class UserAcc>
84 bool internal_refine_grid_old(
86
87 template<class UserAcc>
88 bool internal_derefine_grid_old(
90
91 template<class UserAccCrit, class UserAccSplit, class UserAccMerge>
92 void internal_update_refinement_old();
93
108 template<class UserAcc, class... T>
109 void gen_refine_block_changes_new(
112 T &&...args);
113
117 void enforce_two_to_one_refinement_new(
119
123 void enforce_two_to_one_derefinement_new(
126
127 template<class UserAcc>
128 bool internal_refine_grid_new(
130
131 template<class UserAcc>
132 bool internal_derefine_grid_new(
134
135 template<class UserAccCrit, class UserAccSplit, class UserAccMerge>
136 void internal_update_refinement_new();
137
138 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
139 };
140
141} // namespace shammodels::basegodunov::modules
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
The MPI scheduler.
A buffer allocated in USM (Unified Shared Memory).
Represents a collection of objects distributed across patches identified by a u64 id.
constexpr T pow_constexpr(T a) noexcept
Calculates the power of a number at compile time.
Definition integer.hpp:174
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
namespace for the basegodunov model modules