26template<
class Tvec,
class Tgr
idVec>
29 if (solver.solver_config.scheduler_conf.split_load_value == 0) {
31 "Scheduler load value should be greater than 0");
34 solver.init_required_fields();
37 solver.solver_config.scheduler_conf.split_load_value,
38 solver.solver_config.scheduler_conf.merge_load_value);
40 using namespace shamrock::patch;
53 solver.ensure_time_state_edges();
55 solver.init_solver_graph();
58template<
class Tvec,
class Tgr
idVec>
59void shammodels::basegodunov::Model<Tvec, TgridVec>::make_base_grid(
60 TgridVec bmin, TgridVec cell_size, u32_3 cell_count) {
62 if (cell_size.x() < Solver::Config::AMRBlock::Nside) {
64 "the x block size must be larger than {}, currently : cell_size = {}",
65 Solver::Config::AMRBlock::Nside,
68 if (cell_size.y() < Solver::Config::AMRBlock::Nside) {
70 "the y block size must be larger than {}, currently : cell_size = {}",
71 Solver::Config::AMRBlock::Nside,
74 if (cell_size.z() < Solver::Config::AMRBlock::Nside) {
76 "the z block size must be larger than {}, currently : cell_size = {}",
77 Solver::Config::AMRBlock::Nside,
81 modules::AMRSetup<Tvec, TgridVec> setup(ctx, solver.solver_config, solver.storage);
82 setup.make_base_grid(bmin, cell_size, {cell_count[0], cell_count[1], cell_count[2]});
100template<
class Tvec,
class Tgr
idVec>
101void shammodels::basegodunov::Model<Tvec, TgridVec>::dump_vtk(std::string filename) {
110 u32 block_size = Solver::AMRBlock::block_size;
112 u64 num_obj = sched.get_rank_count();
114 std::unique_ptr<sycl::buffer<TgridVec>> pos1 = sched.rankgather_field<TgridVec>(0);
115 std::unique_ptr<sycl::buffer<TgridVec>> pos2 = sched.rankgather_field<TgridVec>(1);
117 sycl::buffer<Tvec> pos_min_cell(num_obj * block_size);
118 sycl::buffer<Tvec> pos_max_cell(num_obj * block_size);
125 sycl::accessor cell_min{pos_min_cell, cgh, sycl::write_only, sycl::no_init};
126 sycl::accessor cell_max{pos_max_cell, cgh, sycl::write_only, sycl::no_init};
128 using Block =
typename Solver::AMRBlock;
130 shambase::parallel_for(cgh, num_obj,
"rescale cells", [=](
u64 id_a) {
131 Tvec block_min = acc_p1[id_a].template convert<Tscal>();
132 Tvec block_max = acc_p2[id_a].template convert<Tscal>();
134 Tvec delta_cell = (block_max - block_min) / Block::side_size;
136 for (
u32 ix = 0; ix < Block::side_size; ix++) {
138 for (
u32 iy = 0; iy < Block::side_size; iy++) {
140 for (
u32 iz = 0; iz < Block::side_size; iz++) {
141 u32 i = Block::get_index({ix, iy, iz});
142 Tvec delta_val = delta_cell * Tvec{ix, iy, iz};
143 cell_min[id_a * block_size + i] = block_min + delta_val;
144 cell_max[id_a * block_size + i]
145 = block_min + (delta_cell) + delta_val;
153 writer.write_voxel_cells(pos_min_cell, pos_max_cell, num_obj * block_size);
155 writer.add_cell_data_section();
158 if (solver.solver_config.is_dust_on()) {
159 u32 ndust = solver.solver_config.dust_config.ndust;
160 fieldnum += 2 * ndust;
162 writer.add_field_data_section(fieldnum);
164 std::unique_ptr<sycl::buffer<Tscal>> fields_rho = sched.rankgather_field<Tscal>(2);
165 writer.write_field(
"rho", fields_rho, num_obj * block_size);
167 std::unique_ptr<sycl::buffer<Tvec>> fields_vel = sched.rankgather_field<Tvec>(3);
168 writer.write_field(
"rhovel", fields_vel, num_obj * block_size);
170 std::unique_ptr<sycl::buffer<Tscal>> fields_eint = sched.rankgather_field<Tscal>(4);
171 writer.write_field(
"rhoetot", fields_eint, num_obj * block_size);
173 if (solver.solver_config.is_dust_on()) {
174 u32 ndust = solver.solver_config.dust_config.ndust;
180 std::unique_ptr<sycl::buffer<Tscal>> fields_rho_dust
181 = sched.rankgather_field<Tscal>(irho_dust);
184 if (fields_rho_dust) {
185 u32 nobj = fields_rho_dust->size();
188 for (
u32 off = 0; off < nsplit; off++) {
190 sycl::buffer<Tscal> partition(nobj / nsplit);
193 .submit([&, off, nsplit](sycl::handler &cgh) {
194 sycl::accessor out{partition, cgh, sycl::write_only, sycl::no_init};
195 sycl::accessor in{*fields_rho_dust, cgh, sycl::read_only};
197 shambase::parallel_for(
198 cgh, nobj / nsplit,
"split field for dump", [=](
u64 i) {
199 out[i] = in[i * nsplit + off];
205 std::string(
"rho_dust") + std::to_string(off),
207 num_obj * block_size);
211 std::unique_ptr<sycl::buffer<Tvec>> fields_vel_dust
212 = sched.rankgather_field<Tvec>(irhovel_dust);
213 if (fields_vel_dust) {
214 u32 nobj = fields_vel_dust->size();
217 for (
u32 off = 0; off < nsplit; off++) {
219 sycl::buffer<Tvec> partition(nobj / nsplit);
222 .submit([&, off, nsplit](sycl::handler &cgh) {
223 sycl::accessor out{partition, cgh, sycl::write_only, sycl::no_init};
224 sycl::accessor in{*fields_vel_dust, cgh, sycl::read_only};
226 shambase::parallel_for(
227 cgh, nobj / nsplit,
"split field for dump", [=](
u64 i) {
228 out[i] = in[i * nsplit + off];
234 std::string(
"rhovel_dust") + std::to_string(off),
236 num_obj * block_size);
241 }
catch (std::runtime_error e) {
244 "std::runtime_error catched while MPI file open -> unrecoverable\n what():\n",
246 }
catch (std::exception e) {
249 "exception catched while MPI file open -> unrecoverable\n what():\n",
252 logger::err_ln(
"Godunov",
"something unknwon catched while MPI file open -> unrecoverable");
Header file describing a Node Instance.
sycl::queue & get_compute_queue(u32 id=0)
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
void init()
Initialise the model and all the related data structures (patch scheduler in particular).
u32 get_field_idx(const std::string &field_name) const
Get the field id if matching name & type.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
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...
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
void err_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.