Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
UpdateDerivs.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"
26
28
29 template<class Tvec, template<class> class SPHKernel>
30 class UpdateDerivs {
31 public:
32 using Tscal = shambase::VecComponent<Tvec>;
33 static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension;
34 using Kernel = SPHKernel<Tscal>;
35
36 using Config = SolverConfig<Tvec, SPHKernel>;
37 using Storage = SolverStorage<Tvec, u32>;
38
39 ShamrockCtx &context;
40 Config &solver_config;
41 Storage &storage;
42
43 UpdateDerivs(ShamrockCtx &context, Config &solver_config, Storage &storage)
44 : context(context), solver_config(solver_config), storage(storage) {}
45
46 void update_derivs(Tscal dt_hydro);
47
48 private:
49 inline PatchScheduler &scheduler() { return shambase::get_check_ref(context.sched); }
50
51 using Cfg_AV = typename Config::AVConfig;
52
53 using None = typename Cfg_AV::None;
54 using Constant = typename Cfg_AV::Constant;
55 using VaryingMM97 = typename Cfg_AV::VaryingMM97;
56 using VaryingCD10 = typename Cfg_AV::VaryingCD10;
57 using ConstantDisc = typename Cfg_AV::ConstantDisc;
58
59 void update_derivs_noAV(None cfg);
60 void update_derivs_constantAV(Constant cfg);
61 void update_derivs_mm97(VaryingMM97 cfg);
62 void update_derivs_cd10(VaryingCD10 cfg);
63 void update_derivs_disc_visco(ConstantDisc cfg);
64
65 using DustConfig = typename Config::DustConfig;
66
67 void update_derivs_dust_monofluid_tva_Sj(DustConfig cfg, Tscal dt_hydro);
68
69 using Cfg_MHD = typename Config::MHDConfig;
70
71 using NoneMHD = typename Cfg_MHD::None;
72 using IdealMHD = typename Cfg_MHD::IdealMhdConstrainedHyperPara;
73 using NonIdealMHD = typename Cfg_MHD::NonIdealMHD;
74
75 template<shamrock::sph::mhd::MHDType mhd_mode>
76 void compute_j(Tscal mu_0);
77
78 // Adds the pure MHD terms to the derivatives (the hydro ones, i.e. pressure, artificial
79 // viscosity & conductivity, must have been computed beforehand).
80 // One templated implementation, specialised per MHDType at the call sites below.
81 template<shamrock::sph::mhd::MHDType mhd_mode>
82 void update_derivs_mhd_impl(
83 Tscal sigma_mhd, Tscal alpha_B, Tscal etaO, Tscal etaH, Tscal etaAD);
84
85 // Thin wrappers that unpack the variant and forward to the template above.
86 void update_derivs_mhd(IdealMHD cfg);
87 void update_derivs_nimhd(NonIdealMHD cfg);
88 };
89
90} // namespace shammodels::sph::modules
std::uint32_t u32
32 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
file containing formulas for sphmhd forces, evolution of magnetic and divergence cleaning fields.
The configuration for a sph solver.
AVConfig< Tvec > AVConfig
Configuration for the Artificial Viscosity (AV).