24template<
class Tvec,
template<
class>
class SPHKernel>
28 std::mt19937_64 eng_local(seed);
30 Tscal fmax = f_func(r_out);
34 Tscal u2 = shamalgs::primitives::mock_value<Tscal>(eng_local, 0, fmax);
35 Tscal r = shamalgs::primitives::mock_value<Tscal>(eng_local, r_in, r_out);
42 auto theta = shamalgs::primitives::mock_value<Tscal>(eng_local, 0, _2pi);
43 auto Gauss = shamalgs::random::mock_gaussian<Tscal>(eng_local);
47 Tscal rot_speed = rot_profile(r);
48 Tscal cs = cs_profile(r);
49 Tscal sigma = sigma_profile(r);
50 Tscal H = H_profile(r);
54 auto pos = sycl::vec<Tscal, 3>{r * sycl::cos(theta), r * sycl::sin(theta), z};
56 auto etheta = sycl::vec<Tscal, 3>{-pos.y(), pos.x(), 0};
57 etheta /= sycl::length(etheta);
59 auto vel = rot_speed * etheta;
63 Tscal rho = (sigma * fs) * sycl::exp(-z * z / (2 * H * H));
65 DiscOutput out{pos, vel, cs, rho};
69 if (current_index == Npart) {
76template<
class Tvec,
template<
class>
class SPHKernel>
78 return generator.is_done();
81template<
class Tvec,
template<
class>
class SPHKernel>
85 using namespace shamrock::patch;
88 std::vector<DiscOutput> pos_data;
91 if (!generator.is_done()) {
92 u64 loc_gen_count = nmax;
93 pos_data = generator.next_n(loc_gen_count);
97 std::vector<Tvec> vec_pos;
98 std::vector<Tvec> vec_vel;
99 std::vector<Tscal> vec_u;
100 std::vector<Tscal> vec_h;
101 std::vector<Tscal> vec_cs;
103 for (DiscOutput o : pos_data) {
104 vec_pos.push_back(o.pos);
105 vec_vel.push_back(o.velocity);
107 Tscal h = shamrock::sph::h_rho(pmass, o.rho, Kernel::hfactd) * init_h_factor;
109 vec_cs.push_back(o.cs);
114 if (!pos_data.empty()) {
115 tmp.resize(pos_data.size());
119 u32 len = pos_data.size();
121 = tmp.get_field<Tvec>(sched.pdl_old().
get_field_idx<Tvec>(
"xyz"));
122 sycl::buffer<Tvec> buf(vec_pos.data(), len);
123 f.override(buf, len);
127 u32 len = pos_data.size();
129 = tmp.get_field<Tvec>(sched.pdl_old().
get_field_idx<Tvec>(
"vxyz"));
130 sycl::buffer<Tvec> buf(vec_vel.data(), len);
131 f.override(buf, len);
134 u32 len = vec_pos.size();
136 = tmp.get_field<Tscal>(sched.pdl_old().
get_field_idx<Tscal>(
"hpart"));
137 sycl::buffer<Tscal> buf(vec_h.data(), len);
138 f.override(buf, len);
141 if (solver_config.is_eos_locally_isothermal()) {
142 u32 len = vec_pos.size();
144 = tmp.get_field<Tscal>(sched.pdl_old().
get_field_idx<Tscal>(
"soundspeed"));
145 sycl::buffer<Tscal> buf(vec_cs.data(), len);
146 f.override(buf, len);
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
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...
bool is_done()
This function return true if the setup is done.
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.
Class holding the value of numerous constants generated from the following source.
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