28namespace generic::setup::generators {
31 inline sycl::vec<flt, 3> get_box_dim(flt r_particle,
u32 xcnt,
u32 ycnt,
u32 zcnt) {
33 using vec3 = sycl::vec<flt, 3>;
39 auto get_pos = [&](
u32 i,
u32 j,
u32 k) -> vec3 {
41 = {2 * i + ((j + k) % 2),
42 sycl::sqrt(3.) * (j + (1. / 3.) * (k % 2)),
43 2 * sycl::sqrt(6.) * k / 3};
50 return get_pos(im, jm, km);
54 inline std::tuple<sycl::vec<flt, 3>, sycl::vec<flt, 3>> get_ideal_fcc_box(
55 flt r_particle, std::tuple<sycl::vec<flt, 3>, sycl::vec<flt, 3>> box) {
57 using vec3 = sycl::vec<flt, 3>;
59 vec3 box_min = std::get<0>(box);
60 vec3 box_max = std::get<1>(box);
62 vec3 box_dim = box_max - box_min;
64 vec3 iboc_dim = (box_dim / vec3({2, sycl::sqrt(3.), 2 * sycl::sqrt(6.) / 3})) / r_particle;
76 vec3 m1 = get_box_dim(r_particle, i, j, k);
78 return {box_min, box_min + m1};
81 template<
class flt,
class Tpred_select,
class Tpred_pusher>
82 inline void add_particles_fcc(
84 std::tuple<sycl::vec<flt, 3>, sycl::vec<flt, 3>> box,
85 Tpred_select &&selector,
86 Tpred_pusher &&part_pusher) {
88 using vec3 = sycl::vec<flt, 3>;
90 vec3 box_min = std::get<0>(box);
91 vec3 box_max = std::get<1>(box);
93 vec3 box_dim = box_max - box_min;
95 vec3 iboc_dim = (box_dim / vec3({2, sycl::sqrt(3.), 2 * sycl::sqrt(6.) / 3})) / r_particle;
99 u32 ix = std::ceil(iboc_dim.x());
100 u32 iy = std::ceil(iboc_dim.y());
101 u32 iz = std::ceil(iboc_dim.z());
104 logger::info_ln(
"SPH",
"Add fcc lattice size : (", ix, iy, iz,
")");
107 if ((iy % 2) != 0 && (iz % 2) != 0) {
108 std::cout <<
"Warning : particle count is odd on axis y or z -> this may lead to "
109 "periodicity issues";
112 for (
u32 i = 0; i < ix; i++) {
113 for (
u32 j = 0; j < iy; j++) {
114 for (
u32 k = 0; k < iz; k++) {
117 = {2 * i + ((j + k) % 2),
118 sycl::sqrt(3.) * (j + (1. / 3.) * (k % 2)),
119 2 * sycl::sqrt(6.) * k / 3};
125 part_pusher(r_a, r_particle);
131 template<
class Tscal>
133 sycl::vec<Tscal, 3> pos;
134 sycl::vec<Tscal, 3> velocity;
156 std::function<flt(flt)> sigma_profile,
157 std::function<flt(flt)> cs_profile,
158 std::function<flt(flt)> rot_profile,
160 constexpr flt _2pi = 2 * shambase::constants::pi<flt>;
162 auto f_func = [&](flt r) {
163 return r * sigma_profile(r);
166 flt fmax = f_func(r_out);
168 std::mt19937 eng(0x111);
170 auto find_r = [&]() {
172 flt u2 = shamalgs::primitives::mock_value<flt>(eng, 0, fmax);
173 flt r = shamalgs::primitives::mock_value<flt>(eng, r_in, r_out);
174 if (u2 < f_func(r)) {
182 for (
u32 i = 0; i < Npart; i++) {
184 flt theta = shamalgs::primitives::mock_value<flt>(eng, 0, _2pi);
185 flt Gauss = shamalgs::random::mock_gaussian<flt>(eng);
189 flt vk = rot_profile(r);
190 flt cs = cs_profile(r);
191 flt sigma = sigma_profile(r);
198 auto pos = sycl::vec<flt, 3>{r * sycl::cos(theta), z, r * sycl::sin(theta)};
200 auto etheta = sycl::vec<flt, 3>{-pos.z(), 0, pos.x()};
201 etheta /= sycl::length(etheta);
203 auto vel = vk * etheta;
205 flt rho = 0.1 * (sigma / (H * shambase::constants::pi2_sqrt<flt>) )
206 * sycl::exp(-z * z / (2 * H * H));
227 template<
class flt,
class Tpred_pusher>
236 Tpred_pusher &&part_pusher) {
239 flt K = _2pi * rho_0 / m;
242 flt y = K * (r_out - r_in) / c;
244 std::mt19937 eng(0x111);
246 for (
u32 i = 0; i < Npart; i++) {
248 flt r_1 = shamalgs::primitives::mock_value<flt>(eng, 0, y);
250 flt r = sycl::pow(sycl::pow(r_in, c) + c * r_1 / K, 1 / c);
252 flt theta = shamalgs::primitives::mock_value<flt>(eng, 0, _2pi);
254 flt u = shamalgs::random::mock_gaussian<flt>(eng);
256 flt H = 0.1 * sycl::pow(r, (flt) (3. / 2. - q / 2));
259 sycl::vec<flt, 3>({r * sycl::cos(theta), u * H, r * sycl::sin(theta)}), 0.1);
Header file describing a Node Instance.
std::uint32_t u32
32 bit unsigned integer
Class holding the value of numerous constants generated from the following source.
void add_disc2(u32 Npart, flt r_in, flt r_out, std::function< flt(flt)> sigma_profile, std::function< flt(flt)> cs_profile, std::function< flt(flt)> rot_profile, std::function< void(DiscOutput< flt >)> pusher)
void add_disc(u32 Npart, flt p, flt rho_0, flt m, flt r_in, flt r_out, flt q, Tpred_pusher &&part_pusher)
i32 world_rank()
Gives the rank of the current process in the MPI communicator.