Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
ReplaceGhostField.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
20
21namespace shamrock::solvergraph {
22 template<class T>
24
25 StackEntry stack_loc{};
26 auto edges = get_edges();
27
28 auto &ghost_fields = edges.ghost_fields;
29 auto &fields = edges.fields;
30
31 std::map<u32, u32> gz_map;
32 ghost_fields.patchdata_fields.for_each(
33 [&](u32 s, u32 r, const PatchDataField<T> &pdat_field) {
34 gz_map[r] += pdat_field.get_obj_cnt();
35 });
36
37 // remove old fields
38 fields.get_refs().for_each([&](u32 id_patch, PatchDataField<T> &field) {
39 // TODO: currently we guess the GZ size using the input, we should use in place ghost
40 // zones really ...
41 field.shrink(gz_map.at(id_patch));
42 });
43
44 // replace new fields
45 ghost_fields.patchdata_fields.for_each(
46 [&](u32 s, u32 r, const PatchDataField<T> &pdat_field) {
47 fields.get_field(r).insert(pdat_field);
48 });
49 }
50
53
54} // namespace shamrock::solvergraph
This module allows replacing ghost values for a generic field with updated values.
std::uint32_t u32
32 bit unsigned integer