Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddExtForceConstantGravity.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
18
19#include "shambase/string.hpp"
24
26
27 template<class Tvec>
29 auto edges = get_edges();
30
31 edges.spans_a_ext.check_sizes(edges.sizes.indexes);
32
34 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 block_count) {
35 return block_count * block_size;
36 });
37
39 shamsys::instance::get_compute_scheduler_ptr(),
41 sham::DDMultiRef{edges.spans_a_ext.get_spans()},
42 cell_counts,
43 [g = g](u32 i, Tvec *__restrict a_ext) {
44 a_ext[i] += g;
45 });
46 }
47
48 template<class Tvec>
50 auto a_ext = get_rw_edge_base(0).get_tex_symbol();
51
52 std::string tex = R"tex(
53 Add constant gravity to the external forces acceleration
54
55 \begin{align}
56 {a_ext}_i &= {a_ext}_i + \mathbf{g}
57 \end{align}
58 )tex";
59
60 shambase::replace_all(tex, "{a_ext}", a_ext);
61
62 return tex;
63 }
64
65} // namespace shammodels::basegodunov::modules
66
Node adding a constant gravitational acceleration to the external forces acceleration.
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.
Add a constant gravitational acceleration g to the external forces acceleration.
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
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.