Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ForwardEulerDust.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
16
17#include "shambase/string.hpp"
22
24
25 template<class Tvec>
27 auto edges = get_edges();
28
29 edges.spans_dt_rho_dust.check_sizes(edges.sizes.indexes);
30 edges.spans_dt_rhov_dust.check_sizes(edges.sizes.indexes);
31 edges.spans_rho_dust.check_sizes(edges.sizes.indexes);
32 edges.spans_rhov_dust.check_sizes(edges.sizes.indexes);
33
34 Tscal dt = edges.dt.value;
35
36 shambase::DistributedData<u32> dust_cell_counts
37 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 block_count) {
38 return block_count * block_size * ndust;
39 });
40
42 shamsys::instance::get_compute_scheduler_ptr(),
44 edges.spans_dt_rho_dust.get_spans(), edges.spans_dt_rhov_dust.get_spans()},
45 sham::DDMultiRef{edges.spans_rho_dust.get_spans(), edges.spans_rhov_dust.get_spans()},
46 dust_cell_counts,
47 [dt](
48 u32 i,
49 const Tscal *__restrict dt_rho_dust,
50 const Tvec *__restrict dt_rhov_dust,
51 Tscal *__restrict rho_dust,
52 Tvec *__restrict rhov_dust) {
53 rho_dust[i] += dt * dt_rho_dust[i];
54 rhov_dust[i] += dt * dt_rhov_dust[i];
55 });
56 }
57
58 template<class Tvec>
60 auto dt = get_ro_edge_base(0).get_tex_symbol();
61 auto dt_rho_dust = get_ro_edge_base(2).get_tex_symbol();
62 auto dt_rhov_dust = get_ro_edge_base(3).get_tex_symbol();
63 auto rho_dust = get_rw_edge_base(0).get_tex_symbol();
64 auto rhov_dust = get_rw_edge_base(1).get_tex_symbol();
65
66 std::string tex = R"tex(
67 Forward Euler integration of the dust species
68
69 \begin{align}
70 {rho_dust}_i &= {rho_dust}_i + {dt} \, {dt_rho_dust}_i \
71 {rhov_dust}_i &= {rhov_dust}_i + {dt} \, {dt_rhov_dust}_i
72 \end{align}
73 )tex";
74
75 shambase::replace_all(tex, "{dt}", dt);
76 shambase::replace_all(tex, "{dt_rho_dust}", dt_rho_dust);
77 shambase::replace_all(tex, "{dt_rhov_dust}", dt_rhov_dust);
78 shambase::replace_all(tex, "{rho_dust}", rho_dust);
79 shambase::replace_all(tex, "{rhov_dust}", rhov_dust);
80
81 return tex;
82 }
83
84} // namespace shammodels::basegodunov::modules
85
Node performing the forward Euler time integration of the dust conservative state.
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Represents a collection of objects distributed across patches identified by a u64 id.
Forward Euler step of the conservative variables of every dust species, U <- U + dt * dU/dt.
virtual std::string _impl_get_tex() const
get the tex of the node
IEdge & get_rw_edge_base(int slot)
Get a reference to a read write edge and cast it to the type IEdge.
Definition INode.hpp:147
const IEdge & get_ro_edge_base(int slot)
Get a reference to a read only edge.
Definition INode.hpp:138
void distributed_data_kernel_call(sham::DeviceScheduler_ptr dev_sched, RefIn in, RefOut in_out, const shambase::DistributedData< index_t > &thread_counts, Functor &&func)
A variant of sham::kernel_call for distributed data.
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
Definition string.hpp:106
namespace for the basegodunov model modules
A variant of sham::MultiRef for distributed data.