Shamrock
2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels
ramses
src
modules
ResidualDot.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
#include "
shammodels/ramses/modules/ResidualDot.hpp
"
19
#include "
shamalgs/collective/reduction.hpp
"
20
#include "
shamrock/patch/PatchDataField.hpp
"
21
22
namespace
shammodels::basegodunov::modules
{
23
24
template
<
class
T>
25
void
ResidualDot<T>::_impl_evaluate_internal
() {
26
auto
edges = get_edges();
27
28
Tscal loc_val = {};
29
edges.spans_phi_res.get_refs().for_each([&](
u32
i,
PatchDataField<T>
&res_field_ref) {
30
loc_val += res_field_ref.compute_dot_sum();
31
});
32
33
edges.res_ddot.value = shamalgs::collective::allreduce_sum(loc_val);
34
}
35
36
template
<
class
T>
37
std::string
ResidualDot<T>::_impl_get_tex
()
const
{
38
auto
field = get_ro_edge_base(0).get_tex_symbol();
39
auto
residual_dot = get_rw_edge_base(0).get_tex_symbol();
40
41
std::string tex = R
"tex(
42
Compute L2-norm squared of residual vector
43
\begin{equation}
44
{residual_dot} &= \sum_{i \in [0,N_{field})} {field}_i \cdot {field}_i
45
\end{equation}
46
)tex";
47
48
shambase::replace_all
(tex,
"{field}"
, field);
49
shambase::replace_all
(tex,
"{residual_dot}"
, residual_dot);
50
51
return
tex;
52
}
53
54
}
// namespace shammodels::basegodunov::modules
55
56
template
class
shammodels::basegodunov::modules::ResidualDot<f64>
;
57
template
class
shammodels::basegodunov::modules::ResidualDot<f64_3>
;
PatchDataField.hpp
ResidualDot.hpp
u32
std::uint32_t u32
32 bit unsigned integer
Definition
aliases_int.hpp:27
PatchDataField
Definition
PatchDataField.hpp:43
shammodels::basegodunov::modules::ResidualDot
Definition
ResidualDot.hpp:27
shammodels::basegodunov::modules::ResidualDot::_impl_get_tex
virtual std::string _impl_get_tex() const
get the tex of the node
Definition
ResidualDot.cpp:37
shammodels::basegodunov::modules::ResidualDot::_impl_evaluate_internal
void _impl_evaluate_internal()
evaluate the node
Definition
ResidualDot.cpp:25
reduction.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
Generated on Wed May 13 2026 13:21:49 for Shamrock by
1.9.8