28 template<
class Tvec,
bool Discontinuous = true>
38 template<
class Tvec,
bool Discontinuous = true>
40 using Tscal = shambase::VecComponent<Tvec>;
43 using LatticeIter =
typename IteratorTypeGetter<Tvec, Discontinuous>::type;
49 LatticeIter generator;
51 static auto init_gen(Tscal dr, std::pair<Tvec, Tvec> box) {
53 auto [idxs_min, idxs_max] = Lattice::get_box_index_bounds(dr, box.first, box.second);
55 return LatticeIter(dr, idxs_min, idxs_max);
60 : context(context), dr(dr), box(box), generator(init_gen(dr, box)) {}
62 bool is_done() {
return generator.is_done(); }
67 using namespace shamrock::patch;
70 std::vector<Tvec> pos_data;
74 u64 loc_gen_count = nmax;
76 auto gen_info = shamalgs::collective::fetch_view(loc_gen_count);
78 u64 skip_start = gen_info.head_offset;
79 u64 gen_cnt = loc_gen_count;
80 u64 skip_end = gen_info.total_byte_count - loc_gen_count - gen_info.head_offset;
83 "GeneratorLatticeHCP",
89 skip_start + gen_cnt + skip_end);
91 generator.skip(skip_start);
92 auto tmp = generator.next_n(gen_cnt);
93 generator.skip(skip_end);
96 if (Patch::is_in_patch_converted(r, box.
lower, box.
upper)) {
97 pos_data.push_back(r);
104 if (!pos_data.empty()) {
105 tmp.resize(pos_data.size());
109 u32 len = pos_data.size();
111 = tmp.get_field<Tvec>(sched.pdl_old().
get_field_idx<Tvec>(
"xyz"));
113 f.override(pos_data, len);
118 = tmp.get_field<Tscal>(sched.pdl_old().
get_field_idx<Tscal>(
"hpart"));
125 std::string
get_name() {
return "GeneratorLatticeHCP"; }
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
Iterator utility to generate the lattice.
Iterator utility to generate the lattice.
utility for generating HCP crystal lattices
bool is_done()
This function return true if the setup is done.
ISPHSetupNode_Dot get_dot_subgraph()
Get a dot subgraph describing the node and its childrens (recursively)
std::string get_name()
Get the name of the node.
shamrock::patch::PatchDataLayer next_n(u32 nmax)
This function generate patchdata with at most nmax per MPI ranks This function is always assumed as c...
This class is an interface that all SPH setup nodes must implement. It describe an operation associat...
u32 get_field_idx(const std::string &field_name) const
Get the field id if matching name & type.
PatchDataLayer container class, the layout is described in patchdata_layout.
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 sph model modules
This file contains the definition for the stacktrace related functionality.
Axis-Aligned bounding box.
T lower
Lower bound of the AABB.
T upper
Upper bound of the AABB.
This struct is used to generate a dot graph of the setup tree.