Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
AddExtForceField.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_a_field.check_sizes(edges.sizes.indexes);
30 edges.spans_a_ext.check_sizes(edges.sizes.indexes);
31
33 = edges.sizes.indexes.template map<u32>([&](u64 id, u32 block_count) {
34 return block_count * block_size;
35 });
36
38 shamsys::instance::get_compute_scheduler_ptr(),
39 sham::DDMultiRef{edges.spans_a_field.get_spans()},
40 sham::DDMultiRef{edges.spans_a_ext.get_spans()},
41 cell_counts,
42 [](u32 i, const Tvec *__restrict a_field, Tvec *__restrict a_ext) {
43 a_ext[i] += a_field[i];
44 });
45 }
46
47 template<class Tvec>
49 auto a_field = get_ro_edge_base(1).get_tex_symbol();
50 auto a_ext = get_rw_edge_base(0).get_tex_symbol();
51
52 std::string tex = R"tex(
53 Add an acceleration field to the external forces acceleration
54
55 \begin{align}
56 {a_ext}_i &= {a_ext}_i + {a_field}_i
57 \end{align}
58 )tex";
59
60 shambase::replace_all(tex, "{a_ext}", a_ext);
61 shambase::replace_all(tex, "{a_field}", a_field);
62
63 return tex;
64 }
65
66} // namespace shammodels::basegodunov::modules
67
Node adding a per cell acceleration field 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 per cell acceleration field (e.g. the self-gravity acceleration) to the external forces acceler...
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.