33template<
class Tvec,
class Tgr
idVec>
42 logger::normal_ln(
"amr::Zeus", shambase::format(
"t = {}, dt = {}", t_current, dt_input));
49 return scheduler().patch_data.owned_data.get(p.id_patch).get_obj_cnt();
54 storage.serial_patch_tree.set(std::move(_sptree));
57 modules::GhostZones gz(context, solver_config, storage);
58 gz.build_ghost_cache();
65 modules::AMRTree amrtree(context, solver_config, storage);
66 amrtree.build_trees();
68 amrtree.correct_bounding_box();
71 amrtree.build_neigh_cache();
73 modules::ComputePressure comp_eos(context, solver_config, storage);
76 modules::FaceFlagger compute_face_flag(context, solver_config, storage);
77 compute_face_flag.flag_faces();
78 compute_face_flag.split_face_list();
83 using namespace shamrock::patch;
85 using Block =
typename Config::AMRBlock;
87 "ghost_dump_debug" + std::to_string(t_current) + std::to_string(solver_config.use_van_leer)
88 + std::to_string(solver_config.use_consistent_transport));
90 bool do_debug_dump =
false;
94 debug_dump.create_id(p.id_patch);
99 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
100 debug_dump.get_file(p.id_patch).change_table_name(
"Nobj_original",
"u32");
101 debug_dump.get_file(p.id_patch).write_val(mpdat.original_elements);
102 debug_dump.get_file(p.id_patch).change_table_name(
"Nobj_total",
"u32");
103 debug_dump.get_file(p.id_patch).write_val(mpdat.total_elements);
108 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
120 = mpdat.pdat.get_field_buf_ref<Tscal>(irho_interf);
122 = mpdat.pdat.get_field_buf_ref<Tscal>(ieint_interf);
125 debug_dump.get_file(p.id_patch).change_table_name(
"cell_min",
"i64_3");
126 debug_dump.get_file(p.id_patch)
127 .write_table(cell_min.copy_to_stdvec(), mpdat.total_elements);
128 debug_dump.get_file(p.id_patch).change_table_name(
"cell_max",
"i64_3");
129 debug_dump.get_file(p.id_patch)
130 .write_table(cell_max.copy_to_stdvec(), mpdat.total_elements);
132 debug_dump.get_file(p.id_patch).change_table_name(
"rho",
"f64");
133 debug_dump.get_file(p.id_patch)
135 rho_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
136 debug_dump.get_file(p.id_patch).change_table_name(
"eint",
"f64");
137 debug_dump.get_file(p.id_patch)
139 eint_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
140 debug_dump.get_file(p.id_patch).change_table_name(
"vel",
"f64_3");
141 debug_dump.get_file(p.id_patch)
143 vel_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
157 using MergedPDat = shamrock::MergedPatchData;
158 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(id_patch);
159 return mpdat.pdat.get_field<Tvec>(ivel_interf);
163 modules::ValueLoader<Tvec, TgridVec, Tvec> val_load_vec(context, solver_config, storage);
164 storage.vel_n_xp.set(val_load_vec.load_value_with_gz(
"vel", {1, 0, 0},
"vel_n_xp"));
165 storage.vel_n_yp.set(val_load_vec.load_value_with_gz(
"vel", {0, 1, 0},
"vel_n_yp"));
166 storage.vel_n_zp.set(val_load_vec.load_value_with_gz(
"vel", {0, 0, 1},
"vel_n_zp"));
168 modules::ValueLoader<Tvec, TgridVec, Tscal> val_load_scal(context, solver_config, storage);
169 storage.rho_n_xm.set(val_load_scal.load_value_with_gz(
"rho", {-1, 0, 0},
"rho_n_xm"));
170 storage.rho_n_ym.set(val_load_scal.load_value_with_gz(
"rho", {0, -1, 0},
"rho_n_ym"));
171 storage.rho_n_zm.set(val_load_scal.load_value_with_gz(
"rho", {0, 0, -1},
"rho_n_zm"));
174 storage.pres_n_xm.set(
175 val_load_scal.load_value_with_gz(pressure_field, {-1, 0, 0},
"pres_n_xm"));
176 storage.pres_n_ym.set(
177 val_load_scal.load_value_with_gz(pressure_field, {0, -1, 0},
"pres_n_ym"));
178 storage.pres_n_zm.set(
179 val_load_scal.load_value_with_gz(pressure_field, {0, 0, -1},
"pres_n_zm"));
181 modules::SourceStep src_step(context, solver_config, storage);
182 src_step.compute_forces();
187 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
191 debug_dump.get_file(p.id_patch).change_table_name(
"force_press",
"f64_3");
192 debug_dump.get_file(p.id_patch)
194 forces_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
198 src_step.apply_force(dt_input);
200 src_step.compute_AV();
203 storage.q_AV_n_xm.set(val_load_vec.load_value_with_gz(q_AV, {-1, 0, 0},
"q_AV_n_xm"));
204 storage.q_AV_n_ym.set(val_load_vec.load_value_with_gz(q_AV, {0, -1, 0},
"q_AV_n_ym"));
205 storage.q_AV_n_zm.set(val_load_vec.load_value_with_gz(q_AV, {0, 0, -1},
"q_AV_n_zm"));
207 src_step.apply_AV(dt_input);
211 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
223 = mpdat.pdat.get_field_buf_ref<Tscal>(irho_interf);
225 = mpdat.pdat.get_field_buf_ref<Tscal>(ieint_interf);
228 debug_dump.get_file(p.id_patch).change_table_name(
"eint_post_source",
"f64");
229 debug_dump.get_file(p.id_patch)
231 eint_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
232 debug_dump.get_file(p.id_patch).change_table_name(
"vel_post_source",
"f64_3");
233 debug_dump.get_file(p.id_patch)
235 vel_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
239 src_step.compute_div_v();
240 src_step.update_eint_eos(dt_input);
245 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
249 debug_dump.get_file(p.id_patch).change_table_name(
"divv_source",
"f64");
250 debug_dump.get_file(p.id_patch)
251 .write_table(divv.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
255 storage.div_v_n.reset();
257 modules::WriteBack wb(context, solver_config, storage);
258 wb.write_back_merged_data();
260 storage.merged_patchdata_ghost.reset();
261 storage.ghost_layout.reset();
263 storage.vel_n.reset();
264 storage.vel_n_xp.reset();
265 storage.vel_n_yp.reset();
266 storage.vel_n_zp.reset();
268 storage.rho_n_xm.reset();
269 storage.rho_n_ym.reset();
270 storage.rho_n_zm.reset();
272 storage.pres_n_xm.reset();
273 storage.pres_n_ym.reset();
274 storage.pres_n_zm.reset();
276 storage.q_AV.reset();
277 storage.q_AV_n_xm.reset();
278 storage.q_AV_n_ym.reset();
279 storage.q_AV_n_zm.reset();
287 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
299 = mpdat.pdat.get_field_buf_ref<Tscal>(irho_interf);
301 = mpdat.pdat.get_field_buf_ref<Tscal>(ieint_interf);
304 debug_dump.get_file(p.id_patch).change_table_name(
"eint_start_transp",
"f64");
305 debug_dump.get_file(p.id_patch)
307 eint_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
308 debug_dump.get_file(p.id_patch).change_table_name(
"vel_start_transp",
"f64_3");
309 debug_dump.get_file(p.id_patch)
311 vel_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
315 modules::ValueLoader<Tvec, TgridVec, Tvec> val_load_vec_v2(context, solver_config, storage);
316 storage.vel_n_xp.set(val_load_vec_v2.load_value_with_gz(
"vel", {1, 0, 0},
"vel_n_xp"));
317 storage.vel_n_yp.set(val_load_vec_v2.load_value_with_gz(
"vel", {0, 1, 0},
"vel_n_yp"));
318 storage.vel_n_zp.set(val_load_vec_v2.load_value_with_gz(
"vel", {0, 0, 1},
"vel_n_zp"));
323 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
327 debug_dump.get_file(p.id_patch).change_table_name(
"vel_n_xp",
"f64_3");
328 debug_dump.get_file(p.id_patch)
330 vel_n_xp.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
388 modules::TransportStep transport(context, solver_config, storage);
389 transport.compute_cell_centered_momentas();
392 using Tscal8 = sycl::vec<Tscal, 8>;
395 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
399 debug_dump.get_file(p.id_patch).change_table_name(
"Q",
"f64_8");
400 debug_dump.get_file(p.id_patch)
401 .write_table(Q_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
405 storage.vel_n_xp.reset();
406 storage.vel_n_yp.reset();
407 storage.vel_n_zp.reset();
409 transport.compute_limiter();
412 using Tscal8 = sycl::vec<Tscal, 8>;
415 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
421 debug_dump.get_file(p.id_patch).change_table_name(
"ax",
"f64_8");
422 debug_dump.get_file(p.id_patch)
423 .write_table(ax_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
424 debug_dump.get_file(p.id_patch).change_table_name(
"ay",
"f64_8");
425 debug_dump.get_file(p.id_patch)
426 .write_table(ay_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
427 debug_dump.get_file(p.id_patch).change_table_name(
"az",
"f64_8");
428 debug_dump.get_file(p.id_patch)
429 .write_table(az_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
433 transport.compute_face_centered_moments(dt_input);
438 storage.Q_xm.reset();
439 storage.Q_ym.reset();
440 storage.Q_zm.reset();
442 transport.exchange_face_centered_gz();
445 using Tscal8 = sycl::vec<Tscal, 8>;
448 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
451 = storage.Qstar_x.get().get_buf_check(p.id_patch);
453 = storage.Qstar_y.get().get_buf_check(p.id_patch);
455 = storage.Qstar_z.get().get_buf_check(p.id_patch);
457 debug_dump.get_file(p.id_patch).change_table_name(
"Qstar_x",
"f64_8");
458 debug_dump.get_file(p.id_patch)
460 Qstarx_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
461 debug_dump.get_file(p.id_patch).change_table_name(
"Qstar_y",
"f64_8");
462 debug_dump.get_file(p.id_patch)
464 Qstary_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
465 debug_dump.get_file(p.id_patch).change_table_name(
"Qstar_z",
"f64_8");
466 debug_dump.get_file(p.id_patch)
468 Qstarz_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
472 transport.compute_flux();
475 using Tscal8 = sycl::vec<Tscal, 8>;
478 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
484 debug_dump.get_file(p.id_patch).change_table_name(
"Flux_x",
"f64_8");
485 debug_dump.get_file(p.id_patch)
487 Fluxx_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
488 debug_dump.get_file(p.id_patch).change_table_name(
"Flux_y",
"f64_8");
489 debug_dump.get_file(p.id_patch)
491 Fluxy_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
492 debug_dump.get_file(p.id_patch).change_table_name(
"Flux_z",
"f64_8");
493 debug_dump.get_file(p.id_patch)
495 Fluxz_buf.
copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
499 transport.compute_stencil_flux();
501 transport.update_Q(dt_input);
503 transport.compute_new_qte();
508 MergedPDat &mpdat = storage.merged_patchdata_ghost.get().get(p.id_patch);
517 = mpdat.pdat.get_field_buf_ref<Tscal>(irho_interf);
519 = mpdat.pdat.get_field_buf_ref<Tscal>(ieint_interf);
522 debug_dump.get_file(p.id_patch).change_table_name(
"rho_end_transp",
"f64");
523 debug_dump.get_file(p.id_patch)
525 rho_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
526 debug_dump.get_file(p.id_patch).change_table_name(
"eint_end_transp",
"f64");
527 debug_dump.get_file(p.id_patch)
529 eint_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
530 debug_dump.get_file(p.id_patch).change_table_name(
"vel_end_transp",
"f64_3");
531 debug_dump.get_file(p.id_patch)
533 vel_merged.copy_to_stdvec(), mpdat.total_elements * AMRBlock::block_size);
537 wb.write_back_merged_data();
540 storage.Q_xm.reset();
541 storage.Q_ym.reset();
542 storage.Q_zm.reset();
544 storage.face_lists.reset();
545 storage.pressure.reset();
546 storage.trees.reset();
547 storage.merge_patch_bounds.reset();
548 storage.merged_patchdata_ghost.reset();
549 storage.ghost_layout.reset();
550 storage.ghost_zone_infos.reset();
551 storage.serial_patch_tree.reset();
555 debug_dump.get_file(p.id_patch).close();
570 u64 rank_count = scheduler().get_rank_count() * AMRBlock::block_size;
573 u64 npatch = scheduler().patch_list.local.size();
575 std::string log_step = report_perf_timestep(
587 logger::info_ln(
"amr::Zeus", log_step);
589 "amr::Zeus",
"estimated rate :", dt_input * (3600 / tstep.
elasped_sec()),
"(tsim/hr)");
592 storage.timings_details.reset();
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
A class to dump a simulation state into ASCII files.
A buffer allocated in USM (Unified Shared Memory)
std::vector< T > copy_to_stdvec() const
Copy the content of the buffer to a std::vector.
Class Timer measures the time elapsed since the timer was started.
void end()
Stops the timer and stores the elapsed time in nanoseconds.
f64 elasped_sec() const
Converts the stored nanosecond time to a floating point representation in seconds.
void start()
Starts the timer.
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.
MPI string gather / allgather helpers (declarations; implementations in shamalgs/src/collective/gathe...
MemPerfInfos get_mem_perf_info()
Retrieve the memory performance information.
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...
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
namespace for the main framework
Structure to store the performance informations about memory allocation and deallocation.
f64 time_alloc_host
Time spent allocating memory on the host.
size_t max_allocated_byte_host
max bytes allocated on the host
f64 time_free_device
Time spent deallocating memory on the device.
size_t max_allocated_byte_device
max bytes allocated on the device
f64 time_alloc_device
Time spent allocating memory on the device.
f64 time_free_host
Time spent deallocating memory on the host.
Patch object that contain generic patch information.
f64 get_timer(std::string timername)
get a timer value