32 using Direction = shammodels::basegodunov::modules::Direction;
34 template<
class Tvec,
class Tgr
idVec>
36 using Tscal = shambase::VecComponent<Tvec>;
37 using OrientedAMRGraph = shammodels::basegodunov::modules::OrientedAMRGraph<Tvec, TgridVec>;
38 using AMRGraph = shammodels::basegodunov::modules::AMRGraph;
39 using Edges =
typename shammodels::basegodunov::modules::CGInit<Tvec, TgridVec>::Edges;
42 inline static void kernel(Edges &edges,
u32 block_size, Tscal fourPiG) {
43 edges.cell_neigh_graph.graph.for_each([&](
u64 id,
44 const OrientedAMRGraph &oriented_cell_graph) {
45 auto &cell_sizes_span = edges.spans_block_cell_sizes.get_spans().get(
id);
46 auto &phi_span = edges.spans_phi.get_spans().get(
id);
47 auto &rho_span = edges.spans_rho.get_spans().get(
id);
48 auto &mean_rho = edges.mean_rho.value;
49 auto &phi_res_span = edges.spans_phi_res.get_spans().get(
id);
50 auto &phi_p_span = edges.spans_phi_p.get_spans().get(
id);
51 auto &rhs_span = edges.spans_rhs.get_spans().get(
id);
52 auto &phi_z_span = edges.spans_phi_z.get_spans().get(
id);
54 AMRGraph &graph_neigh_xp
56 AMRGraph &graph_neigh_xm
58 AMRGraph &graph_neigh_yp
60 AMRGraph &graph_neigh_ym
62 AMRGraph &graph_neigh_zp
64 AMRGraph &graph_neigh_zm
67 sham::EventList depends_list;
69 auto cell_sizes = cell_sizes_span.get_read_access(depends_list);
70 auto phi = phi_span.get_read_access(depends_list);
71 auto rho = rho_span.get_read_access(depends_list);
72 auto phi_res = phi_res_span.get_write_access(depends_list);
73 auto phi_p = phi_p_span.get_write_access(depends_list);
74 auto rhs = rhs_span.get_write_access(depends_list);
75 auto phi_z = phi_z_span.get_write_access(depends_list);
77 auto graph_iter_xp = graph_neigh_xp.get_read_access(depends_list);
78 auto graph_iter_xm = graph_neigh_xm.get_read_access(depends_list);
79 auto graph_iter_yp = graph_neigh_yp.get_read_access(depends_list);
80 auto graph_iter_ym = graph_neigh_ym.get_read_access(depends_list);
81 auto graph_iter_zp = graph_neigh_zp.get_read_access(depends_list);
82 auto graph_iter_zm = graph_neigh_zm.get_read_access(depends_list);
84 sham::DeviceQueue &q = shamsys::instance::get_compute_scheduler().
get_queue();
85 auto e = q.
submit(depends_list, [&](sycl::handler &cgh) {
86 u32 cell_count = (edges.sizes.indexes.get(
id)) * block_size;
88 shambase::parallel_for(cgh, cell_count,
"init step for cg", [=](
u64 gid) {
89 const u32 cell_global_id = (
u32) gid;
90 const u32 block_id = cell_global_id / block_size;
91 const u32 cell_loc_id = cell_global_id % block_size;
93 Tscal delta_cell = cell_sizes[block_id];
111 auto dV = delta_cell * delta_cell * delta_cell;
112 auto b_rhs = -fourPiG * (rho[cell_global_id] - mean_rho) * dV;
114 auto res = b_rhs - Aphi;
115 phi_res[cell_global_id] = res;
116 rhs[cell_global_id] = b_rhs;
119 phi_z[cell_global_id] = res / Aii;
120 phi_p[cell_global_id] = res / Aii;
124 cell_sizes_span.complete_event_state(e);
125 phi_span.complete_event_state(e);
126 rho_span.complete_event_state(e);
127 phi_res_span.complete_event_state(e);
128 phi_p_span.complete_event_state(e);
129 rhs_span.complete_event_state(e);
130 phi_z_span.complete_event_state(e);
132 graph_neigh_xp.complete_event_state(e);
133 graph_neigh_xm.complete_event_state(e);
134 graph_neigh_yp.complete_event_state(e);
135 graph_neigh_ym.complete_event_state(e);
136 graph_neigh_zp.complete_event_state(e);
137 graph_neigh_zm.complete_event_state(e);
144 template<
class Tvec,
class Tgr
idVec>
147 auto edges = get_edges();
149 edges.spans_block_cell_sizes.check_sizes(edges.sizes.indexes);
150 edges.spans_phi.check_sizes(edges.sizes.indexes);
151 edges.spans_rho.check_sizes(edges.sizes.indexes);
152 edges.spans_phi_res.check_sizes(edges.sizes.indexes);
153 edges.spans_phi_p.check_sizes(edges.sizes.indexes);
154 edges.spans_rhs.check_sizes(edges.sizes.indexes);
155 edges.spans_phi_z.check_sizes(edges.sizes.indexes);
157 _Kernel<Tvec, TgridVec>::kernel(edges, block_size, fourPiG);
160 template<
class Tvec,
class Tgr
idVec>
171 std::string tex = R
"tex(
172 Initiation step of CG
7-point stencil for the discrete Laplacian operator
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
sycl::event submit(Fct &&fct)
Submits a kernel to the SYCL queue.
DeviceQueue & get_queue(u32 id=0)
Get a reference to a DeviceQueue.
virtual std::string _impl_get_tex() const
get the tex of the node
void _impl_evaluate_internal()
evaluate the node
IEdge & get_rw_edge_base(int slot)
Get a reference to a read write edge and cast it to the type IEdge.
const IEdge & get_ro_edge_base(int slot)
Get a reference to a read only edge.
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
namespace for the basegodunov model modules
T laplacian_7pt_with_Aii(const shambase::VecComponent< Tvec > *cell_sizes, const u32 block_size, const u32 cell_global_id, const AMRGraphLinkiterator &graph_iter_xp, const AMRGraphLinkiterator &graph_iter_xm, const AMRGraphLinkiterator &graph_iter_yp, const AMRGraphLinkiterator &graph_iter_ym, const AMRGraphLinkiterator &graph_iter_zp, const AMRGraphLinkiterator &graph_iter_zm, ACCField &&field_access, T &Aii)
Get the discretized (finite volume) Laplacian, and the diagonal coefficient of the associated matrix.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.