Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
IFieldRefs.hpp
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
10#pragma once
11
20#include "shambackends/math.hpp"
23
24namespace shamrock::solvergraph {
25
27 template<class T>
28 using PatchDataFieldRef = std::reference_wrapper<PatchDataField<T>>;
29
31 template<class T>
33
42 template<class T>
43 class IFieldRefs : public IFieldSpan<T> {
44 public:
45 using IFieldSpan<T>::IFieldSpan;
46
49
51 virtual const DDPatchDataFieldRef<T> &get_refs() const = 0;
52
54 inline PatchDataField<T> &get_field(u64 id) const { return get_refs().get(id).get(); }
55 };
56
57 template<class T>
58 T get_rank_max(const IFieldRefs<T> &field_refs) {
60 field_refs.get_refs().for_each([&](u64 id, const PatchDataFieldRef<T> &field_ref) {
61 ret = sham::max(ret, field_ref.get().compute_max());
62 });
63 return ret;
64 }
65
66 template<class T>
67 T get_rank_min(const IFieldRefs<T> &field_refs) {
69 field_refs.get_refs().for_each([&](u64 id, const PatchDataFieldRef<T> &field_ref) {
70 ret = sham::min(ret, field_ref.get().compute_min());
71 });
72 return ret;
73 }
74
75} // namespace shamrock::solvergraph
std::reference_wrapper< PatchDataField< T > > PatchDataFieldRef
Alias for a reference to a PatchDataField.
std::uint64_t u64
64 bit unsigned integer
Represents a collection of objects distributed across patches identified by a u64 id.
Interface for a solver graph edge representing a field as references to the underlying patch fields.
virtual DDPatchDataFieldRef< T > & get_refs()=0
Get the DistributedData of PatchDataFieldRefs.
virtual const DDPatchDataFieldRef< T > & get_refs() const =0
Const variant of get_refs.
PatchDataField< T > & get_field(u64 id) const
Get the underlying PatchDataField at the given id.
Interface for a solver graph edge representing a field as spans.