Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SPHSetup.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
21#include "shambackends/vec.hpp"
26#include <memory>
27
29
30 template<class Tvec, template<class> class SPHKernel>
31 class SPHSetup {
32 public:
33 using Tscal = shambase::VecComponent<Tvec>;
35 using Kernel = SPHKernel<Tscal>;
36
39
40 ShamrockCtx &context;
41 Config &solver_config;
42 Storage &storage;
43
44 SPHSetup(ShamrockCtx &context, Config &solver_config, Storage &storage)
45 : context(context), solver_config(solver_config), storage(storage) {}
46
47 void apply_setup(
48 SetupNodePtr setup,
49 bool part_reordering,
50 std::optional<u32> insert_step = std::nullopt);
51
52 void apply_setup_new(
53 SetupNodePtr setup,
54 bool part_reordering,
55 std::optional<u32> gen_count_per_step = std::nullopt,
56 std::optional<u32> insert_count_per_step = std::nullopt,
57 std::optional<u64> max_msg_count_per_rank_per_step = std::nullopt,
58 std::optional<u64> max_data_count_per_rank_per_step = std::nullopt,
59 std::optional<u64> max_msg_size = std::nullopt,
60 bool do_setup_log = false,
61 bool speculative_balancing = false);
62
63 std::shared_ptr<ISPHSetupNode> make_generator_lattice_hcp(
64 Tscal dr, std::pair<Tvec, Tvec> box, bool discontinuous = true);
65
66 std::shared_ptr<ISPHSetupNode> make_generator_lattice_cubic(
67 Tscal dr, std::pair<Tvec, Tvec> box);
68
69 std::shared_ptr<ISPHSetupNode> make_generator_disc_mc(
70 Tscal part_mass,
71 Tscal disc_mass,
72 Tscal r_in,
73 Tscal r_out,
74 std::function<Tscal(Tscal)> sigma_profile,
75 std::function<Tscal(Tscal)> H_profile,
76 std::function<Tscal(Tscal)> rot_profile,
77 std::function<Tscal(Tscal)> cs_profile,
78 std::mt19937_64 eng,
79 Tscal init_h_factor);
80
81 std::shared_ptr<ISPHSetupNode> make_generator_from_context(ShamrockCtx &context_other);
82
83 std::shared_ptr<ISPHSetupNode> make_combiner_add(
84 SetupNodePtr parent1, SetupNodePtr parent2);
85
86 std::shared_ptr<ISPHSetupNode> make_modifier_warp_disc(
87 SetupNodePtr parent, Tscal Rwarp, Tscal Hwarp, Tscal inclination, Tscal posangle);
88
89 std::shared_ptr<ISPHSetupNode> make_modifier_custom_warp(
90 SetupNodePtr parent,
91 std::function<Tscal(Tscal)> inc_profile,
92 std::function<Tscal(Tscal)> psi_profile,
93 std::function<Tvec(Tscal)> k_profile);
94
95 std::shared_ptr<ISPHSetupNode> make_modifier_add_offset(
96 SetupNodePtr parent, Tvec offset_postion, Tvec offset_velocity);
97
98 std::shared_ptr<ISPHSetupNode> make_modifier_filter(
99 SetupNodePtr parent, std::function<bool(Tvec)> filter);
100
101 std::shared_ptr<ISPHSetupNode> make_modifier_split_part(
102 SetupNodePtr parent, u64 n_split, u64 seed, Tscal h_scaling);
103
104 private:
105 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
106
107 u64 injected_parts = 0;
108 };
109
110} // namespace shammodels::sph::modules
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
The MPI scheduler.
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 sph model modules
std::shared_ptr< ISPHSetupNode > SetupNodePtr
Alias for a shared pointer to an ISPHSetupNode.
The configuration for a sph solver.