167 sycl::vec<T, 3> shift;
168 sycl::vec<T, 3> shift_speed;
172 struct ShearPeriodicInfo {
180 inline ShiftInfo<T> compute_shift_infos(
181 i32_3 ioff, ShearPeriodicInfo<T> shear, sycl::vec<T, 3> bsize) {
183 i32 dx = ioff.x() * shear.shear_base.x();
184 i32 dy = ioff.y() * shear.shear_base.y();
185 i32 dz = ioff.z() * shear.shear_base.z();
187 i32 d = dx + dy + dz;
189 sycl::vec<T, 3> shift
190 = {(d * shear.shear_dir.x()) * shear.shear_value + bsize.x() * ioff.x(),
191 (d * shear.shear_dir.y()) * shear.shear_value + bsize.y() * ioff.y(),
192 (d * shear.shear_dir.z()) * shear.shear_value + bsize.z() * ioff.z()};
193 sycl::vec<T, 3> shift_speed
194 = {(d * shear.shear_dir.x()) * shear.shear_speed,
195 (d * shear.shear_dir.y()) * shear.shear_speed,
196 (d * shear.shear_dir.z()) * shear.shear_speed};
198 return {shift, shift_speed};
202 inline void for_each_patch_shift(
203 ShearPeriodicInfo<T> shearinfo,
204 sycl::vec<T, 3> bsize,
205 const std::function<
void(i32_3, ShiftInfo<T>)> &funct) {
207 std::vector<i32_3> list_possible;
211 i32 repetition_x = 1 + sham::abs(shearinfo.shear_dir.x());
212 i32 repetition_y = 1 + sham::abs(shearinfo.shear_dir.y());
213 i32 repetition_z = 1 + sham::abs(shearinfo.shear_dir.z());
215 T sz = bsize.x() * shearinfo.shear_dir.x() + bsize.y() * shearinfo.shear_dir.y()
216 + bsize.z() * shearinfo.shear_dir.z();
218 for (
i32 xoff = -repetition_x; xoff <= repetition_x; xoff++) {
219 for (
i32 yoff = -repetition_y; yoff <= repetition_y; yoff++) {
220 for (
i32 zoff = -repetition_z; zoff <= repetition_z; zoff++) {
222 i32 dx = xoff * shearinfo.shear_base.x();
223 i32 dy = yoff * shearinfo.shear_base.y();
224 i32 dz = zoff * shearinfo.shear_base.z();
226 i32 d = dx + dy + dz;
228 i32 df = -int(d * shearinfo.shear_value / sz);
231 = {shearinfo.shear_dir.x() * df,
232 shearinfo.shear_dir.y() * df,
233 shearinfo.shear_dir.z() * df};
241 list_possible.resize(list_possible.size() + 1);
242 list_possible[list_possible.size() - 1]
243 = i32_3{xoff + off_d.x(), yoff + off_d.y(), zoff + off_d.z()};
248 for (i32_3 off : list_possible) {
249 funct(off, compute_shift_infos(off, shearinfo, bsize));
261 auto edges = get_edges();
266 std::vector<std::pair<u64, CoordRange<Tvec>>> senders;
268 senders.push_back({id, box});
274 sycl::host_accessor acc_tf{edges.interact_radius_tree.get_buf(), sycl::read_only};
276 Tvec periodic_offset = Tvec{0, 0, 0};
281#pragma omp parallel for
282 for (
u32 i = 0; i < senders.size(); i++) {
283 u64 sender_id = senders[i].first;
286 CoordRange<Tvec> sender_bsize_off = sender_bsize.add_offset(periodic_offset);
288 Tscal sender_volume = sender_bsize.get_volume();
290 using PtNode =
typename SerialPatchTree<Tvec>::PtNode;
292 sptree.host_for_each_leafs_internal(
293 [&](
u64 tree_id, PtNode n) {
294 Tscal receiv_h_max = acc_tf[tree_id];
295 CoordRange<Tvec> receiv_exp{n.box_min - receiv_h_max, n.box_max + receiv_h_max};
297 return receiv_exp.get_intersect(sender_bsize_off).is_not_empty();
299 [&](
u64 id_found, PtNode n) {
300 if (id_found == sender_id) {
305 int_range_max.
get(id_found));
308 = sender_bsize.get_intersect(receiv_exp.add_offset(-periodic_offset));
318 interf_volume.get_volume() / sender_volume});
331 auto edges = get_edges();
339 std::vector<std::pair<u64, CoordRange<Tvec>>> senders;
341 senders.push_back({id, box});
347 i32 repetition_x = 1;
348 i32 repetition_y = 1;
349 i32 repetition_z = 1;
351 sycl::host_accessor acc_tf{edges.interact_radius_tree.get_buf(), sycl::read_only};
353 for (
i32 xoff = -repetition_x; xoff <= repetition_x; xoff++) {
354 for (
i32 yoff = -repetition_y; yoff <= repetition_y; yoff++) {
355 for (
i32 zoff = -repetition_z; zoff <= repetition_z; zoff++) {
358 Tvec periodic_offset = Tvec{xoff * bsize.x(), yoff * bsize.y(), zoff * bsize.z()};
360 sycl::host_accessor tree{
362 sycl::host_accessor lpid{
365#pragma omp parallel for
366 for (
u32 i = 0; i < senders.size(); i++) {
367 u64 sender_id = senders[i].first;
370 CoordRange<Tvec> sender_bsize_off = sender_bsize.add_offset(periodic_offset);
372 Tscal sender_volume = sender_bsize.get_volume();
374 using PtNode =
typename SerialPatchTree<Tvec>::PtNode;
376 sptree.host_for_each_leafs_internal(
377 [&](
u64 tree_id, PtNode n) {
378 Tscal receiv_h_max = acc_tf[tree_id];
380 n.box_min - receiv_h_max, n.box_max + receiv_h_max};
382 return receiv_exp.get_intersect(sender_bsize_off).is_not_empty();
384 [&](
u64 id_found, PtNode n) {
385 if ((id_found == sender_id) && (xoff == 0) && (yoff == 0)
392 int_range_max.
get(id_found));
395 receiv_exp.add_offset(-periodic_offset));
405 interf_volume.get_volume() / sender_volume});
422 auto edges = get_edges();
427 ShearPeriodicInfo<Tscal> shear_info{shear_base, shear_dir, edges.shear_value.data, shear_speed};
432 std::vector<std::pair<u64, CoordRange<Tvec>>> senders;
434 senders.push_back({id, box});
440 sycl::host_accessor acc_tf{edges.interact_radius_tree.get_buf(), sycl::read_only};
442 for_each_patch_shift<Tscal>(shear_info, bsize, [&](i32_3 ioff, ShiftInfo<Tscal> shift) {
447 Tvec offset = shift.shift;
450 sycl::host_accessor lpid{
453#pragma omp parallel for
454 for (
u32 i = 0; i < senders.size(); i++) {
455 u64 sender_id = senders[i].first;
460 Tscal sender_volume = sender_bsize.get_volume();
462 using PtNode =
typename SerialPatchTree<Tvec>::PtNode;
464 sptree.host_for_each_leafs_internal(
465 [&](
u64 tree_id, PtNode n) {
466 Tscal receiv_h_max = acc_tf[tree_id];
467 CoordRange<Tvec> receiv_exp{n.box_min - receiv_h_max, n.box_max + receiv_h_max};
469 return receiv_exp.get_intersect(sender_bsize_off).is_not_empty();
471 [&](
u64 id_found, PtNode n) {
472 if ((id_found == sender_id) && (xoff == 0) && (yoff == 0) && (zoff == 0)) {
477 int_range_max.
get(id_found));
480 = sender_bsize.get_intersect(receiv_exp.add_offset(-offset));
490 interf_volume.get_volume() / sender_volume});
Solvergraph nodes finding the SPH ghost interfaces, one node per boundary condition.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::int32_t i32
32 bit integer
Container for objects shared between two distributed data elements.
iterator add_obj(u64 left_id, u64 right_id, T &&obj)
Add an object associated with a patch pair.
Represents a collection of objects distributed across patches identified by a u64 id.
void for_each(std::function< void(u64, T &)> &&f)
Applies a function to each object in the collection.
T & get(u64 id)
Returns a reference to an object in the collection.
Ghost interface finder for free boundaries: only direct neighbouring patches.
void _impl_evaluate_internal()
evaluate the node
virtual std::string _impl_get_tex() const
get the tex of the node
Ghost interface finder for periodic boundaries: neighbouring patches, including through the 26 period...
void _impl_evaluate_internal()
evaluate the node
virtual std::string _impl_get_tex() const
get the tex of the node
Ghost interface finder for shearing periodic boundaries.
virtual std::string _impl_get_tex() const
get the tex of the node
void _impl_evaluate_internal()
evaluate the node
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 math utility
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.
Axis-Aligned bounding box.
T lower
Lower bound of the AABB.
T upper
Upper bound of the AABB.