24namespace shamrock::solvergraph {
40 field_refs = field.field_data.template map<std::reference_wrapper<PatchDataField<T>>>(
44 spans = field_refs.template map<shamrock::PatchDataFieldSpanPointer<T>>(
45 [&](
u64 id, std::reference_wrapper<PatchDataField<T>> &pdf) {
46 return pdf.get().get_pointer_span();
51 Field(
u32 nvar, std::string name, std::string texsymbol)
65 on_distributeddata_diff(
69 shambase::throw_with_loc<std::runtime_error>(shambase::format(
70 "Missing field ref in distributed data at id {}\n"
72 "Field texsymbol: {}",
75 this->get_tex_symbol()));
81 shambase::throw_with_loc<std::runtime_error>(shambase::format(
82 "Extra field ref in distributed data at id {}\n"
84 "Field texsymbol: {}",
87 this->get_tex_symbol()));
94 auto new_patchdatafield = [&](
u32 size) {
100 auto ensure_patchdatafield_sizes = [&](
u32 size,
auto &pdatfield) {
101 if (pdatfield.get_obj_cnt() != size) {
102 pdatfield.resize(size);
106 on_distributeddata_diff(
110 field.field_data.add_obj(id, new_patchdatafield(sizes.get(id)));
113 ensure_patchdatafield_sizes(sizes.get(id), field.field_data.get(id));
116 field.field_data.erase(id);
127 return field.field_data.
get(id_patch).get_buf();
132 return field.field_data.
get(id_patch);
135 inline u32 get_nvar()
const {
return nvar; }
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
Represents a collection of objects distributed across patches identified by a u64 id.
T & get(u64 id)
Returns a reference to an object in the collection.
virtual const DDPatchDataFieldRef< T > & get_refs() const
Const variant of get_refs.
virtual DDPatchDataFieldRef< T > & get_refs()
Get the DistributedData of PatchDataFieldRefs.
virtual DDPatchDataFieldSpanPointer< T > & get_spans()
Get the DistributedData of spans attached to the underlying field.
virtual void free_alloc()
Free allocated memory.
virtual const DDPatchDataFieldSpanPointer< T > & get_spans() const
Const variant of get_spans.
virtual void check_sizes(const shambase::DistributedData< u32 > &sizes) const
Check that the sizes of the patches in the field match the given sizes.
virtual void ensure_sizes(const shambase::DistributedData< u32 > &sizes)
Ensure that the sizes of the patches in the field match the given sizes (Can resize the underlying fi...
Interface for a solver graph edge representing a field as references to the underlying patch fields.