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
16
17
#include "
shambase/string.hpp
"
18
#include "
shambackends/kernel_call_distrib.hpp
"
19
#include "
shamcomm/logs.hpp
"
20
#include "
shammath/riemann.hpp
"
21
#include "
shammodels/ramses/modules/ComputeSumOverV.hpp
"
22
#include "
shamrock/patch/PatchDataField.hpp
"
23
#include "
shamsys/NodeInstance.hpp
"
24
25
namespace
shammodels::basegodunov::modules
{
26
27
template
<
class
T>
28
void
NodeComputeSumOverV<T>::_impl_evaluate_internal
() {
29
auto
edges = get_edges();
30
31
edges.spans_field.check_sizes(edges.sizes.indexes);
32
33
T loc_val = {};
34
edges.spans_field.get_refs().for_each([&](
u32
i,
PatchDataField<T>
&field_ref) {
35
loc_val += field_ref.compute_sum();
36
});
37
38
T global_sum = shamalgs::collective::allreduce_sum(loc_val);
39
40
edges.mean_val.value = (global_sum / edges.total_volume.value);
41
42
// logger::raw_ln(loc_val, global_sum, edges.mean_val.value,edges.total_volume.value);
43
}
44
45
template
<
class
T>
46
std::string
NodeComputeSumOverV<T>::_impl_get_tex
()
const
{
47
std::string tex = R
"tex(
48
Compute cell mass
49
50
\begin{align}
51
{mean_val} &=\sum_{i\in \Omega} {spans_field}_i / {total_volume} \\
52
\Omega = [0,{sizes} * N_{\rm cell/block}) \\
53
N_{\rm cell/block} & = {block_size}
54
\end{align}
55
)tex";
56
57
replace_edges_tex_symbols(tex);
58
59
shambase::replace_all
(tex,
"{block_size}"
, sham::format(
"{}"
, block_size));
60
61
return
tex;
62
}
63
64
}
// namespace shammodels::basegodunov::modules
65
66
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:40
shammodels::basegodunov::modules::NodeComputeSumOverV::_impl_evaluate_internal
void _impl_evaluate_internal()
evaluate the node
Definition
ComputeSumOverV.cpp:28
shammodels::basegodunov::modules::NodeComputeSumOverV::_impl_get_tex
virtual std::string _impl_get_tex() const
get the tex of the node
Definition
ComputeSumOverV.cpp:46
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:106
shammodels::basegodunov::modules
namespace for the basegodunov model modules
Definition
AMRCellInfos.hpp:20
riemann.hpp
Umbrella header pulling in the gas states and all gas Riemann solvers (Rusanov, HLL,...
logs.hpp
string.hpp
Generated on
for Shamrock by
1.15.0