Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
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
21
23
24 template<class T>
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
std::uint32_t u32
32 bit unsigned integer
virtual std::string _impl_get_tex() const
get the tex of the node
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
namespace for the basegodunov model modules