Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
FindGhostLayerCandidates.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
17
18#include "shammath/AABB.hpp"
30
32
33 enum class GhostType { None, Periodic, Reflective };
34
36 GhostType ghost_type_x;
37 GhostType ghost_type_y;
38 GhostType ghost_type_z;
39 };
40
41 template<class TgridVec>
44
45 TgridVec box_size = sim_box.upper - sim_box.lower;
46 TgridVec box_center = (sim_box.upper + sim_box.lower) / 2;
47
49
50 { // check that rebuildind the AABB from size and center gives the same AABB
52 = {box_center - box_size / 2, box_center + box_size / 2};
53 if (new_box != sim_box) {
55 "Rebuilding AABB from size and center gives a different AABB");
56 }
57 }
58
60 box_size,
61 box_center,
62 mode.ghost_type_x == GhostType::Periodic,
63 mode.ghost_type_y == GhostType::Periodic,
64 mode.ghost_type_z == GhostType::Periodic};
65 }
66
67 template<class Func>
68 void for_each_paving_tile(GhostLayerGenMode mode, Func &&func) {
69
70 // if the ghost type is none, we do not need to repeat as there is no ghost layer
71 i32 repetition_x = mode.ghost_type_x != GhostType::None;
72 i32 repetition_y = mode.ghost_type_y != GhostType::None;
73 i32 repetition_z = mode.ghost_type_z != GhostType::None;
74
75 for (i32 xoff = -repetition_x; xoff <= repetition_x; xoff++) {
76 for (i32 yoff = -repetition_y; yoff <= repetition_y; yoff++) {
77 for (i32 zoff = -repetition_z; zoff <= repetition_z; zoff++) {
78 func(xoff, yoff, zoff);
79 }
80 }
81 }
82 }
83
85 i32 xoff;
86 i32 yoff;
87 i32 zoff;
88 };
89
90#define NODE_EDGES(X_RO, X_RW) \
91 /* ------------------- inputs ------------------- */ \
92 X_RO(shamrock::solvergraph::IDataEdge<std::vector<u64>>, ids_to_check) \
93 X_RO(shamrock::solvergraph::ScalarEdge<shammath::AABB<TgridVec>>, sim_box) \
94 X_RO(shamrock::solvergraph::SerialPatchTreeRefEdge<TgridVec>, patch_tree) \
95 X_RO(shamrock::solvergraph::ScalarsEdge<shammath::AABB<TgridVec>>, patch_boxes) \
96 \
97 /* ------------------- outputs ------------------- */ \
98 X_RW(shamrock::solvergraph::DDSharedScalar<GhostLayerCandidateInfos>, ghost_layers_candidates)
99
100 template<class TgridVec>
101 class FindGhostLayerCandidates : public shamrock::solvergraph::INode {
102
104
105 public:
106 FindGhostLayerCandidates(GhostLayerGenMode mode) : mode(mode) {}
107
108 EXPAND_NODE_EDGES(NODE_EDGES)
109
111
112 inline virtual std::string _impl_get_label() const { return "FindGhostLayerCandidates"; };
113
114 virtual std::string _impl_get_tex() const;
115 };
116} // namespace shammodels::basegodunov::modules
117
118#undef NODE_EDGES
Shared distributed data layer for patch data management in solver graphs.
Defines the PatchDataLayerRefs class for managing distributed references to patch data layers.
std::int32_t i32
32 bit integer
#define SHAM_ASSERT(x)
Shorthand for SHAM_ASSERT_NAMED without a message.
Definition assert.hpp:67
virtual std::string _impl_get_label() const
get the label of the node
virtual std::string _impl_get_tex() const
get the tex of the node
Inode is node between data edges, takes multiple inputs, multiple outputs.
Definition INode.hpp:31
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
namespace for the basegodunov model modules
Axis-Aligned bounding box.
Definition AABB.hpp:99
bool is_volume_not_null() const noexcept
Checks if the AABB has a non-zero volume.
Definition AABB.hpp:280
T lower
Lower bound of the AABB.
Definition AABB.hpp:104
T upper
Upper bound of the AABB.
Definition AABB.hpp:105
A structure for 3D paving functions with general boundary conditions (periodic or reflective per dire...