Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels
ramses
src
modules
ComputeSumOverV.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
17
#include "
shammodels/ramses/modules/ComputeSumOverV.hpp
"
18
#include "
shambackends/kernel_call_distrib.hpp
"
19
#include "
shamcomm/logs.hpp
"
20
#include "
shammath/riemann.hpp
"
21
#include "
shamrock/patch/PatchDataField.hpp
"
22
#include "
shamsys/NodeInstance.hpp
"
23
24
namespace
shammodels::basegodunov::modules
{
25
26
template
<
class
T>
27
void
NodeComputeSumOverV<T>::_impl_evaluate_internal
() {
28
auto
edges = get_edges();
29
30
edges.spans_field.check_sizes(edges.sizes.indexes);
31
32
T loc_val = {};
33
edges.spans_field.get_refs().for_each([&](
u32
i,
PatchDataField<T>
&field_ref) {
34
loc_val += field_ref.compute_sum();
35
});
36
37
T global_sum = shamalgs::collective::allreduce_sum(loc_val);
38
39
edges.mean_val.value = (global_sum / edges.total_volume.value);
40
41
// logger::raw_ln(loc_val, global_sum, edges.mean_val.value,edges.total_volume.value);
42
}
43
44
template
<
class
T>
45
std::string
NodeComputeSumOverV<T>::_impl_get_tex
()
const
{
46
47
auto
block_count = get_ro_edge_base(0).get_tex_symbol();
48
auto
field = get_ro_edge_base(1).get_tex_symbol();
49
auto
total_volume = get_ro_edge_base(2).get_tex_symbol();
50
auto
mean = get_rw_edge_base(0).get_tex_symbol();
51
52
std::string tex = R
"tex(
53
Compute cell mass
54
55
\begin{align}
56
{mean} &=\sum_{i\in \Omega} {field}_i / {total_volume} \\
57
\Omega = [0,{block_count} * N_{\rm cell/block}) \\
58
N_{\rm cell/block} & = {block_size}
59
\end{align}
60
)tex";
61
62
shambase::replace_all
(tex,
"{total_volume}"
, total_volume);
63
shambase::replace_all
(tex,
"{field}"
, field);
64
shambase::replace_all
(tex,
"{mean}"
, mean);
65
shambase::replace_all
(tex,
"{block_count}"
, block_count);
66
shambase::replace_all
(tex,
"{block_size}"
, shambase::format(
"{}"
, block_size));
67
68
return
tex;
69
}
70
71
}
// namespace shammodels::basegodunov::modules
72
73
template
class
shammodels::basegodunov::modules::NodeComputeSumOverV<f64>
;
ComputeSumOverV.hpp
NodeInstance.hpp
Header file describing a Node Instance.
PatchDataField.hpp
u32
std::uint32_t u32
32 bit unsigned integer
Definition
aliases_int.hpp:27
PatchDataField
Definition
PatchDataField.hpp:43
shammodels::basegodunov::modules::NodeComputeSumOverV
Definition
ComputeSumOverV.hpp:31
shammodels::basegodunov::modules::NodeComputeSumOverV::_impl_evaluate_internal
void _impl_evaluate_internal()
evaluate the node
Definition
ComputeSumOverV.cpp:27
shammodels::basegodunov::modules::NodeComputeSumOverV::_impl_get_tex
virtual std::string _impl_get_tex() const
get the tex of the node
Definition
ComputeSumOverV.cpp:45
kernel_call_distrib.hpp
shambase::replace_all
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:183
shammodels::basegodunov::modules
namespace for the basegodunov model modules
Definition
AMRCellInfos.hpp:20
riemann.hpp
From original version by Thomas Guillet (T.A.Guillet@exeter.ac.uk)
logs.hpp
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8