Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SolverConfig.cpp
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
17
20
21namespace shammodels::sph {
22
23 template<class Tvec, template<class> class SPHKernel>
24 void SolverConfig<Tvec, SPHKernel>::set_layout(shamrock::patch::PatchDataLayerLayout &pdl) {
25 pdl.add_field<Tvec>("xyz", 1);
26 pdl.add_field<Tvec>("vxyz", 1);
27 pdl.add_field<Tvec>("axyz", 1);
28 pdl.add_field<Tvec>("axyz_ext", 1);
29 pdl.add_field<Tscal>("hpart", 1);
30
31 if (track_particles_id) {
32 pdl.add_field<u64>("part_id", 1);
33 }
34
35 if (has_field_uint()) {
36 pdl.add_field<Tscal>("uint", 1);
37 pdl.add_field<Tscal>("duint", 1);
38 }
39
40 if (has_field_alphaAV()) {
41 pdl.add_field<Tscal>("alpha_AV", 1);
42 }
43
44 if (has_field_divv()) {
45 pdl.add_field<Tscal>("divv", 1);
46 }
47
48 if (has_field_dtdivv()) {
49 pdl.add_field<Tscal>("dtdivv", 1);
50 }
51
52 if (has_field_curlv()) {
53 pdl.add_field<Tvec>("curlv", 1);
54 }
55
56 if (has_field_soundspeed()) {
57
58 // this should not be needed idealy, but we need the pressure on the ghosts and
59 // we don't want to communicate it as it can be recomputed from the other fields
60 // hence we copy the soundspeed at the end of the step to a field in the patchdata
61 pdl.add_field<Tscal>("soundspeed", 1);
62 }
63
64 if (has_field_b_on_rho()) {
65
66 pdl.add_field<Tvec>("B/rho", 1);
67 pdl.add_field<Tvec>("dB/rho", 1);
68 pdl.add_field<Tscal>("drho/dt", 1);
69 }
70
71 if (has_field_psi_on_ch()) {
72 pdl.add_field<Tscal>("psi/ch", 1);
73 pdl.add_field<Tscal>("dpsi/ch", 1);
74 }
75 if (has_field_div_b()) {
76 pdl.add_field<Tscal>("divB", 1);
77 }
78
79 if (has_field_curl_b()) {
80 pdl.add_field<Tvec>("curlB", 1);
81 }
82
83 if (do_nimhd()) {
84 pdl.add_field<Tvec>("J", 1);
85 }
86
87 if (dust_config.has_epsilon_field()) {
88 u32 ndust = dust_config.get_dust_nvar();
89 pdl.add_field<Tscal>("epsilon", ndust);
90 pdl.add_field<Tscal>("dtepsilon", ndust);
91 }
92
93 if (dust_config.has_deltav_field()) {
94 u32 ndust = dust_config.get_dust_nvar();
95 pdl.add_field<Tvec>("deltav", ndust);
96 pdl.add_field<Tvec>("dtdeltav", ndust);
97 }
98
99 if (compute_luminosity) {
100 pdl.add_field<Tscal>("luminosity", 1);
101 }
102
103 if (do_MHD_debug()) {
104 pdl.add_field<Tvec>("gas_pressure", 1);
105 pdl.add_field<Tvec>("mag_pressure", 1);
106 pdl.add_field<Tvec>("mag_tension", 1);
107 pdl.add_field<Tvec>("tensile_corr", 1);
108
109 pdl.add_field<Tscal>("psi_propag", 1);
110 pdl.add_field<Tscal>("psi_diff", 1);
111 pdl.add_field<Tscal>("psi_cons", 1);
112 pdl.add_field<Tscal>("u_mhd", 1);
113 }
114
115 if (should_save_dt_to_fields()) {
116 pdl.add_field<Tscal>("dt_part", 1);
117 }
118
119 if (dust_config.has_s_j_field()) {
120 u32 ndust = dust_config.get_dust_nvar();
121 // s_j := sqrt(rho * epsilon_j), the TVA evolved dust variable (positivity-preserving
122 // substitute for the dust fraction epsilon_j) -- see DustConfig::MonofluidTVA
123 pdl.add_field<Tscal>("s_j", ndust);
124 pdl.add_field<Tscal>("ds_j_dt", ndust);
125 pdl.add_field<Tvec>("delta_v", ndust);
126 }
127 }
128
129 template<class Tvec, template<class> class SPHKernel>
130 void SolverConfig<Tvec, SPHKernel>::set_ghost_layout(
131 shamrock::patch::PatchDataLayerLayout &ghost_layout) {
132
133 ghost_layout.add_field<Tscal>("hpart", 1);
134 ghost_layout.add_field<Tscal>("uint", 1);
135 ghost_layout.add_field<Tvec>("vxyz", 1);
136
137 if (has_axyz_in_ghost()) {
138 ghost_layout.add_field<Tvec>("axyz", 1);
139 }
140 ghost_layout.add_field<Tscal>("omega", 1);
141
142 if (ghost_has_soundspeed()) {
143 ghost_layout.add_field<Tscal>("soundspeed", 1);
144 }
145
146 if (has_field_b_on_rho()) {
147 ghost_layout.add_field<Tvec>("B/rho", 1);
148 }
149
150 if (has_field_psi_on_ch()) {
151 ghost_layout.add_field<Tscal>("psi/ch", 1);
152 }
153
154 if (has_field_curl_b()) {
155 ghost_layout.add_field<Tvec>("curlB", 1);
156 }
157
158 if (dust_config.has_epsilon_field()) {
159 u32 ndust = dust_config.get_dust_nvar();
160 ghost_layout.add_field<Tscal>("epsilon", ndust);
161 }
162
163 if (dust_config.has_deltav_field()) {
164 u32 ndust = dust_config.get_dust_nvar();
165 ghost_layout.add_field<Tvec>("deltav", ndust);
166 }
167
168 if (dust_config.has_s_j_field()) {
169 u32 ndust = dust_config.get_dust_nvar();
170 ghost_layout.add_field<Tscal>("s_j", ndust);
171 }
172 }
173
174}; // namespace shammodels::sph
175
176using namespace shammath;
177
181
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
void add_field(const std::string &field_name, u32 nvar, SourceLocation loc=SourceLocation{})
add a field of type T to the layout
namespace for math utility
Definition AABB.hpp:26
namespace for the sph model
The configuration for a sph solver.