Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ForwardEulerGas.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.check_sizes(edges.sizes.indexes);
30 edges.spans_dt_rhov.check_sizes(edges.sizes.indexes);
31 edges.spans_dt_rhoe.check_sizes(edges.sizes.indexes);
32 edges.spans_rho.check_sizes(edges.sizes.indexes);
33 edges.spans_rhov.check_sizes(edges.sizes.indexes);
34 edges.spans_rhoe.check_sizes(edges.sizes.indexes);
35
36 Tscal dt = edges.dt.value;
37
39 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 block_count) {
40 return block_count * block_size;
41 });
42
44 shamsys::instance::get_compute_scheduler_ptr(),
46 edges.spans_dt_rho.get_spans(),
47 edges.spans_dt_rhov.get_spans(),
48 edges.spans_dt_rhoe.get_spans()},
50 edges.spans_rho.get_spans(),
51 edges.spans_rhov.get_spans(),
52 edges.spans_rhoe.get_spans()},
53 cell_counts,
54 [dt](
55 u32 i,
56 const Tscal *__restrict dt_rho,
57 const Tvec *__restrict dt_rhov,
58 const Tscal *__restrict dt_rhoe,
59 Tscal *__restrict rho,
60 Tvec *__restrict rhov,
61 Tscal *__restrict rhoe) {
62 rho[i] += dt * dt_rho[i];
63 rhov[i] += dt * dt_rhov[i];
64 rhoe[i] += dt * dt_rhoe[i];
65 });
66 }
67
68 template<class Tvec>
70 auto dt = get_ro_edge_base(0).get_tex_symbol();
71 auto dt_rho = get_ro_edge_base(2).get_tex_symbol();
72 auto dt_rhov = get_ro_edge_base(3).get_tex_symbol();
73 auto dt_rhoe = get_ro_edge_base(4).get_tex_symbol();
74 auto rho = get_rw_edge_base(0).get_tex_symbol();
75 auto rhov = get_rw_edge_base(1).get_tex_symbol();
76 auto rhoe = get_rw_edge_base(2).get_tex_symbol();
77
78 std::string tex = R"tex(
79 Forward Euler integration of the gas
80
81 \begin{align}
82 {rho}_i &= {rho}_i + {dt} \, {dt_rho}_i \
83 {rhov}_i &= {rhov}_i + {dt} \, {dt_rhov}_i \
84 {rhoe}_i &= {rhoe}_i + {dt} \, {dt_rhoe}_i
85 \end{align}
86 )tex";
87
88 shambase::replace_all(tex, "{dt}", dt);
89 shambase::replace_all(tex, "{dt_rho}", dt_rho);
90 shambase::replace_all(tex, "{dt_rhov}", dt_rhov);
91 shambase::replace_all(tex, "{dt_rhoe}", dt_rhoe);
92 shambase::replace_all(tex, "{rho}", rho);
93 shambase::replace_all(tex, "{rhov}", rhov);
94 shambase::replace_all(tex, "{rhoe}", rhoe);
95
96 return tex;
97 }
98
99} // namespace shammodels::basegodunov::modules
100
Node performing the forward Euler time integration of the gas 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 gas conservative variables, 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.