29 auto edges = get_edges();
31 edges.spans_rho_next.check_sizes(edges.sizes.indexes);
32 edges.spans_rhov_next.check_sizes(edges.sizes.indexes);
33 edges.spans_rhoe_next.check_sizes(edges.sizes.indexes);
34 edges.spans_rho_d_next.check_sizes(edges.sizes.indexes);
35 edges.spans_rhov_d_next.check_sizes(edges.sizes.indexes);
36 edges.spans_rho.check_sizes(edges.sizes.indexes);
37 edges.spans_rhov.check_sizes(edges.sizes.indexes);
38 edges.spans_rhoe.check_sizes(edges.sizes.indexes);
39 edges.spans_rho_d.check_sizes(edges.sizes.indexes);
40 edges.spans_rhov_d.check_sizes(edges.sizes.indexes);
42 Tscal dt = edges.dt.value;
43 u32 ndust = this->ndust;
44 u32 friction_control = (enable_frictional_heating ==
false) ? 1 : 0;
46 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
51 edges.sizes.indexes.for_each([&](
u64 id_patch,
u32 block_count) {
52 u32 cell_count = block_count * block_size;
55 dev_sched->get_queue(),
57 edges.spans_rho_next.get_spans().get(id_patch),
58 edges.spans_rhov_next.get_spans().get(id_patch),
59 edges.spans_rhoe_next.get_spans().get(id_patch),
60 edges.spans_rho_d_next.get_spans().get(id_patch),
61 edges.spans_rhov_d_next.get_spans().get(id_patch),
64 edges.spans_rho.get_spans().get(id_patch),
65 edges.spans_rhov.get_spans().get(id_patch),
66 edges.spans_rhoe.get_spans().get(id_patch),
67 edges.spans_rho_d.get_spans().get(id_patch),
68 edges.spans_rhov_d.get_spans().get(id_patch)},
70 [dt, ndust, friction_control](
72 const Tscal *__restrict rho_next,
73 const Tvec *__restrict rhov_next,
74 const Tscal *__restrict rhoe_next,
75 const Tscal *__restrict rho_d_next,
76 const Tvec *__restrict rhov_d_next,
77 const Tscal *__restrict alphas,
78 Tscal *__restrict rho,
79 Tvec *__restrict rhov,
80 Tscal *__restrict rhoe,
81 Tscal *__restrict rho_d,
82 Tvec *__restrict rhov_d) {
83 Tvec tmp_mom_1 = rhov_next[id_a];
84 Tscal tmp_rho = rho[id_a];
86 for (u32 i = 0; i < ndust; i++) {
87 const Tscal inv_dt_alphas = 1.0 / (1.0 + alphas[i] * dt);
88 const Tscal dt_alphas = dt * alphas[i];
91 = tmp_mom_1 + dt_alphas * inv_dt_alphas * rhov_d_next[id_a * ndust + i];
92 tmp_rho = tmp_rho + dt_alphas * inv_dt_alphas * rho_d[id_a * ndust + i];
95 Tscal tmp_inv_rho = 1.0 / tmp_rho;
96 Tvec tmp_vel = tmp_inv_rho * tmp_mom_1;
99 Tscal inv_rho_g = 1.0 / rho_next[id_a];
100 Tvec vg_bf = inv_rho_g * rhov_next[id_a];
101 Tvec vg_af = inv_rho_g * rho[id_a] * tmp_vel;
105 * ((rho[id_a] * tmp_vel[0] - rhov_next[id_a][0]) * (vg_bf[0] + vg_af[0])
106 + (rho[id_a] * tmp_vel[1] - rhov_next[id_a][1]) * (vg_bf[1] + vg_af[1])
107 + (rho[id_a] * tmp_vel[2] - rhov_next[id_a][2])
108 * (vg_bf[2] + vg_af[2]));
109 Tscal dissipation = 0.0;
110 for (
u32 i = 0; i < ndust; i++) {
111 const Tscal inv_dt_alphas = 1.0 / (1.0 + alphas[i] * dt);
112 const Tscal dt_alphas = dt * alphas[i];
113 Tscal inv_rho_d = 1.0 / rho_d_next[id_a * ndust + i];
114 Tvec vd_bf = inv_rho_d * rhov_d_next[id_a * ndust + i];
115 Tvec vd_af = inv_rho_d * inv_dt_alphas
116 * (rhov_d_next[id_a * ndust + i]
117 + dt_alphas * rho_d[id_a * ndust + i] * tmp_vel);
118 dissipation += 0.5 * dt_alphas * inv_dt_alphas
119 * ((rho_d[id_a * ndust + i] * tmp_vel[0]
120 - rhov_d_next[id_a * ndust + i][0])
121 * (vd_af[0] + vd_bf[0])
122 + (rho_d[id_a * ndust + i] * tmp_vel[1]
123 - rhov_d_next[id_a * ndust + i][1])
124 * (vd_af[1] + vd_bf[1])
125 + (rho_d[id_a * ndust + i] * tmp_vel[2]
126 - rhov_d_next[id_a * ndust + i][2])
127 * (vd_af[2] + vd_bf[2]));
130 Eg += rhoe_next[id_a] + (1 - friction_control) * work_drag
131 - friction_control * dissipation;
132 rhov[id_a] = tmp_vel * rho[id_a];
134 rho[id_a] = rho_next[id_a];
135 for (
u32 i = 0; i < ndust; i++) {
136 const Tscal inv_dt_alphas = 1.0 / (1.0 + alphas[i] * dt);
137 const Tscal dt_alphas = dt * alphas[i];
138 rhov_d[id_a * ndust + i]
140 * (rhov_d_next[id_a * ndust + i]
141 + dt_alphas * rho_d[id_a * ndust + i] * tmp_vel);
142 rho_d[id_a * ndust + i] = rho_d_next[id_a * ndust + i];