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
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_divB()) {
76 pdl.add_field<Tscal>("divB", 1);
77 }
78
79 if (has_field_curlB()) {
80 pdl.add_field<Tvec>("curlB", 1);
81 }
82
83 if (dust_config.has_epsilon_field()) {
84 u32 ndust = dust_config.get_dust_nvar();
85 pdl.add_field<Tscal>("epsilon", ndust);
86 pdl.add_field<Tscal>("dtepsilon", ndust);
87 }
88
89 if (dust_config.has_deltav_field()) {
90 u32 ndust = dust_config.get_dust_nvar();
91 pdl.add_field<Tvec>("deltav", ndust);
92 pdl.add_field<Tvec>("dtdeltav", ndust);
93 }
94
95 if (compute_luminosity) {
96 pdl.add_field<Tscal>("luminosity", 1);
97 }
98
99 if (do_MHD_debug()) {
100 pdl.add_field<Tvec>("gas_pressure", 1);
101 pdl.add_field<Tvec>("mag_pressure", 1);
102 pdl.add_field<Tvec>("mag_tension", 1);
103 pdl.add_field<Tvec>("tensile_corr", 1);
104
105 pdl.add_field<Tscal>("psi_propag", 1);
106 pdl.add_field<Tscal>("psi_diff", 1);
107 pdl.add_field<Tscal>("psi_cons", 1);
108 pdl.add_field<Tscal>("u_mhd", 1);
109 }
110
111 if (should_save_dt_to_fields()) {
112 pdl.add_field<Tscal>("dt_part", 1);
113 }
114 }
115
116 template<class Tvec, template<class> class SPHKernel>
117 void SolverConfig<Tvec, SPHKernel>::set_ghost_layout(
119
120 ghost_layout.add_field<Tscal>("hpart", 1);
121 ghost_layout.add_field<Tscal>("uint", 1);
122 ghost_layout.add_field<Tvec>("vxyz", 1);
123
124 if (has_axyz_in_ghost()) {
125 ghost_layout.add_field<Tvec>("axyz", 1);
126 }
127 ghost_layout.add_field<Tscal>("omega", 1);
128
129 if (ghost_has_soundspeed()) {
130 ghost_layout.add_field<Tscal>("soundspeed", 1);
131 }
132
133 if (has_field_B_on_rho()) {
134 ghost_layout.add_field<Tvec>("B/rho", 1);
135 }
136
137 if (has_field_psi_on_ch()) {
138 ghost_layout.add_field<Tscal>("psi/ch", 1);
139 }
140
141 if (has_field_curlB()) {
142 ghost_layout.add_field<Tvec>("curlB", 1);
143 }
144
145 if (dust_config.has_epsilon_field()) {
146 u32 ndust = dust_config.get_dust_nvar();
147 ghost_layout.add_field<Tscal>("epsilon", ndust);
148 }
149
150 if (dust_config.has_deltav_field()) {
151 u32 ndust = dust_config.get_dust_nvar();
152 ghost_layout.add_field<Tvec>("deltav", ndust);
153 }
154 }
155
156}; // namespace shammodels::sph
157
158using namespace shammath;
159
163
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.