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
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 template<class TgridVec>
92
94
95 public:
97
108
109 inline void set_edges(
110 std::shared_ptr<shamrock::solvergraph::IDataEdge<std::vector<u64>>> ids_to_check,
114 patch_boxes,
116 ghost_layers_candidates) {
117 __internal_set_ro_edges({ids_to_check, sim_box, patch_tree, patch_boxes});
118 __internal_set_rw_edges({ghost_layers_candidates});
119 }
120
121 inline Edges get_edges() {
122 return Edges{
123 get_ro_edge<shamrock::solvergraph::IDataEdge<std::vector<u64>>>(0),
125 get_ro_edge<shamrock::solvergraph::SerialPatchTreeRefEdge<TgridVec>>(2),
127 get_rw_edge<shamrock::solvergraph::DDSharedScalar<GhostLayerCandidateInfos>>(0),
128 };
129 }
130
132
133 inline virtual std::string _impl_get_label() const { return "FindGhostLayerCandidates"; };
134
135 virtual std::string _impl_get_tex() const;
136 };
137} // namespace shammodels::basegodunov::modules
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:30
void __internal_set_rw_edges(std::vector< std::shared_ptr< IEdge > > new_rw_edges)
Set the read write edges.
Definition INode.hpp:181
void __internal_set_ro_edges(std::vector< std::shared_ptr< IEdge > > new_ro_edges)
Set the read only edges.
Definition INode.hpp:171
const T & get_ro_edge(int slot)
Get a read only edge and cast it to the type T.
Definition INode.hpp:80
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...