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
19
21#include "shambackends/vec.hpp"
28#include <memory>
29
31
32 template<class Tvec, template<class> class SPHKernel>
33 class SPHSetup {
34 public:
35 using Tscal = shambase::VecComponent<Tvec>;
36 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
37 using Kernel = SPHKernel<Tscal>;
38
39 using Config = SolverConfig<Tvec, SPHKernel>;
40 using Storage = SolverStorage<Tvec, u32>;
41
42 ShamrockCtx &context;
43 Config &solver_config;
44 Storage &storage;
45
46 SPHSetup(ShamrockCtx &context, Config &solver_config, Storage &storage)
47 : context(context), solver_config(solver_config), storage(storage) {}
48
49 void apply_setup(
50 SetupNodePtr setup,
51 bool part_reordering,
52 std::optional<u32> insert_step = std::nullopt);
53
54 void apply_setup_new(
55 SetupNodePtr setup,
56 bool part_reordering,
57 std::optional<u32> gen_count_per_step = std::nullopt,
58 std::optional<u32> insert_count_per_step = std::nullopt,
59 std::optional<u64> max_msg_count_per_rank_per_step = std::nullopt,
60 std::optional<u64> max_data_count_per_rank_per_step = std::nullopt,
61 std::optional<u64> max_msg_size = std::nullopt,
62 bool do_setup_log = false,
63 bool speculative_balancing = false);
64
65 std::shared_ptr<ISPHSetupNode> make_generator_lattice_hcp(
66 Tscal dr,
67 std::pair<Tvec, Tvec> box,
68 bool discontinuous = true,
70
71 std::shared_ptr<ISPHSetupNode> make_generator_lattice_fcc(
72 Tscal dr,
73 std::pair<Tvec, Tvec> box,
74 bool discontinuous = true,
76
77 std::shared_ptr<ISPHSetupNode> make_generator_lattice_cubic(
78 Tscal dr, std::pair<Tvec, Tvec> box);
79
80 std::shared_ptr<ISPHSetupNode> make_generator_disc_mc(
81 Tscal part_mass,
82 Tscal disc_mass,
83 Tscal r_in,
84 Tscal r_out,
85 std::function<Tscal(Tscal)> sigma_profile,
86 std::function<Tscal(Tscal)> H_profile,
87 std::function<Tvec(Tvec)> vel_profile,
88 std::function<Tscal(Tvec)> cs_profile,
89 std::mt19937_64 eng,
90 Tscal init_h_factor);
91
92 std::shared_ptr<ISPHSetupNode> make_generator_from_context(ShamrockCtx &context_other);
93
94 std::shared_ptr<ISPHSetupNode> make_combiner_add(
95 SetupNodePtr parent1, SetupNodePtr parent2);
96
97 std::shared_ptr<ISPHSetupNode> make_modifier_warp_disc(
98 SetupNodePtr parent, Tscal Rwarp, Tscal Hwarp, Tscal inclination, Tscal posangle);
99
100 std::shared_ptr<ISPHSetupNode> make_modifier_custom_warp(
101 SetupNodePtr parent,
102 std::function<Tscal(Tscal)> inc_profile,
103 std::function<Tscal(Tscal)> psi_profile,
104 std::function<Tvec(Tscal)> k_profile);
105
106 std::shared_ptr<ISPHSetupNode> make_modifier_add_offset(
107 SetupNodePtr parent, Tvec offset_postion, Tvec offset_velocity);
108
109 std::shared_ptr<ISPHSetupNode> make_modifier_filter(
110 SetupNodePtr parent, std::function<bool(Tvec)> filter);
111
112 std::shared_ptr<ISPHSetupNode> make_modifier_split_part(
113 SetupNodePtr parent, u64 n_split, u64 seed, Tscal h_scaling);
114
115 private:
116 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
117
118 u64 injected_parts = 0;
119 };
120
121} // namespace shammodels::sph::modules
SPH setup generator placing particles on a true FCC lattice (ABC stacking).
SPH setup generator placing particles on a HCP lattice.
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:112
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.