Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
CopyPatchDataField.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
17
19
20namespace shamrock::solvergraph {
21
22 template<class T>
24 StackEntry stack_loc{};
25
26 auto edges = get_edges();
27
28 // Collect size information from source fields
30
31 edges.original.get_refs().for_each([&](u64 id_patch, const PatchDataField<T> &field) {
32 sizes.add_obj(id_patch, u32(field.get_obj_cnt()));
33 });
34
35 // Ensure target field has correct size for each patch
36 edges.target.ensure_sizes(sizes);
37
38 // Copy the fields from the original to the target
39 edges.target.get_refs().for_each([&](u64 id_patch, PatchDataField<T> &field) {
40 auto &source_field = edges.original.get_field(id_patch);
41 if (field.get_nvar() != source_field.get_nvar()) {
43 "nvar mismatch between source and target fields for patch "
44 + std::to_string(id_patch)
45 + ". Source nvar: " + std::to_string(source_field.get_nvar())
46 + ", Target nvar: " + std::to_string(field.get_nvar()));
47 }
48 field.overwrite(source_field, field.get_obj_cnt());
49 });
50 }
51
52 template<class T>
54 std::string tex = R"tex(Copy field ${original} to ${target})tex";
55
56 replace_edges_tex_symbols(tex);
57
58 return tex;
59 }
60
61 template class CopyPatchDataField<f64>;
62 template class CopyPatchDataField<f64_3>;
63
64} // namespace shamrock::solvergraph
Defines the CopyPatchDataField class for copying fields between patch data field references.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Represents a collection of objects distributed across patches identified by a u64 id.
A solver graph node that copies field data from source field references to target fields.
void _impl_evaluate_internal()
Internal implementation of the field copying operation.
std::string _impl_get_tex() const
Returns the LaTeX representation of this node for documentation.
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.