11#include < algorithm>
22#include < biocma_cst_config.hpp>
33#include < cassert>
4- #include < cma_read/flow_iterator.hpp>
5- #include < cma_read/neighbors.hpp>
6- #include < cmt_common/cma_case.hpp>
74#include < common/logger.hpp>
85#include < core/global_initaliser.hpp>
96#include < core/scalar_factory.hpp>
107#include < core/simulation_parameters.hpp>
118#include < cstddef>
129#include < cstdio>
1310#include < dataexporter/data_exporter.hpp>
14- #include < exception>
15- #include < filesystem>
1611#include < load_balancing/iload_balancer.hpp>
1712#include < load_balancing/impl_lb.hpp>
1813#include < mc/mcinit.hpp>
@@ -49,9 +44,6 @@ namespace
4944 std::vector<double >({0 , 0 .}),
5045 std::vector<size_t >({0 }));
5146
52- void recur_path (std::string_view rootPath,
53- Core::SimulationParameters& params);
54-
5547 // TODO Move elsewhere
5648 double get_time_step (double user_deta_time,
5749 const CmaUtils::TransitionnerPtrType& iterator)
@@ -92,10 +84,7 @@ namespace
9284 double residence_time =
9385 -data[k] / volume; // minus cause transition has negative
9486 // diagonal (leaving flow)
95- if (residence_time < min_residence_time)
96- {
97- min_residence_time = residence_time;
98- }
87+ min_residence_time = std::min (residence_time, min_residence_time);
9988 }
10089 }
10190 }
@@ -278,80 +267,6 @@ namespace Core
278267 return true ;
279268 }
280269
281- // OptionalPtr<CmaRead::FlowIterator> GlobalInitialiser::init_flow_iterator()
282- // {
283-
284- // if (!is_host)
285- // {
286- // validate_step(InitStep::FlowIterator);
287- // return nullptr;
288- // }
289-
290- // const auto flowmap_paths = get_path_files(user_params.cma_case_path);
291- // params.flow_files.clear();
292- // if (user_params.recursive)
293- // {
294-
295- // recur_path(user_params.cma_case_path, params);
296- // }
297- // else
298- // {
299- // params.flow_files.emplace_back(user_params.cma_case_path);
300- // }
301-
302- // if (params.flow_files.empty())
303- // {
304- // throw std::invalid_argument("Missing files path");
305- // }
306-
307- // CmaRead::ReactorState const* state = nullptr;
308- // std::unique_ptr<CmaRead::FlowIterator> flow_handle;
309- // try
310- // {
311- // flow_handle =
312- // std::make_unique<CmaRead::FlowIterator>(params.flow_files,
313- // flowmap_paths);
314- // if (flow_handle == nullptr)
315- // {
316- // throw std::runtime_error("Flow map are not loaded");
317- // }
318-
319- // state = &flow_handle->get_unchecked(0);
320- // if (state == nullptr)
321- // {
322- // throw std::runtime_error("Reactor not correclty initialised");
323- // }
324-
325- // if (logger)
326- // {
327- // // Note final "s"
328- // const auto str = (flow_handle->size() > 1)
329- // ? std::string(" flowmaps loaded with ")
330- // : std::string(" flowmap loaded with ");
331- // const auto compartment_str = (state->n_compartments > 1)
332- // ? std::string(" compartments")
333- // : std::string(" compartment");
334- // logger->print("Initializer",
335- // IO::format(std::to_string(flow_handle->size()),
336- // str,
337- // std::to_string(state->n_compartments),
338- // compartment_str));
339- // }
340- // }
341- // catch (const std::exception& e)
342- // {
343- // throw std::runtime_error(
344- // IO::format("Error while reading files\t: ", e.what()));
345- // }
346- // if (flow_handle == nullptr)
347- // {
348- // return std::nullopt;
349- // }
350-
351- // validate_step(InitStep::FlowIterator);
352- // return flow_handle;
353- // }
354-
355270 std::optional<CmaUtils::TransitionnerPtrType>
356271 GlobalInitialiser::init_transitionner ()
357272 {
@@ -446,19 +361,12 @@ namespace Core
446361 return std::nullopt ;
447362 }
448363
449- const auto n_rows = liquid_volume.size ();
450- const auto n_cols = flat_neighobrs.size () / n_rows;
451- KOKKOS_ASSERT (n_rows * n_cols == flat_neighobrs.size () &&
452- flat_neighobrs.size () % n_rows == 0 );
453- const auto * chunk = flat_neighobrs.data ();
454- CmaUtils::HostNeighsView neighbors_view (chunk, n_rows, n_cols);
455-
456364 auto mc_unit =
457365 AutoGenerated::wrap_init_model_selector (logger,
458366 i_model,
459367 particle_per_process,
460368 liquid_volume,
461- neighbors_view ,
369+ flat_neighobrs ,
462370 params.uniform_mc_init ,
463371 total_mass);
464372
@@ -484,41 +392,6 @@ namespace Core
484392 return mc_unit;
485393 }
486394
487- // std::optional<CmaUtils::TransitionnerPtrType>
488- // GlobalInitialiser::init_transitionner(
489- // std::unique_ptr<CmaRead::FlowIterator>&& flow_handle)
490- // {
491- // if (!check_steps(InitStep::FlowIterator))
492- // {
493- // return std::nullopt;
494- // }
495- // init_state(flow_handle);
496- // // Calculate the total number of time steps
497- // f_init_gas_flow = info.current_rank == 0 && params.is_two_phase_flow;
498- // const auto n_t =
499- // static_cast<size_t>(user_params.final_time / params.d_t) + 1;
500-
501- // // Transitioner handles flowmap transition between time step, flowmaps
502- // are
503- // // only located in host but transitioner handles cache and receiving for
504- // // workers
505- // // auto transitioner = CmaUtils::get_transitioner(
506- // // logger,
507- // // CmaUtils::FlowmapTransitionMethod::Discontinuous,
508- // // params.n_different_maps,
509- // // params.n_per_flowmap,
510- // // n_t,
511- // // std::move(flow_handle),
512- // // f_init_gas_flow);
513-
514- // CmaUtils::TransitionnerPtrType d_transition =
515- // get_dtransitionner("/home_pers/casale/Documents/thesis/cfd/bench/");
516-
517- // validate_step(InitStep::Transitioner);
518-
519- // return d_transition;
520- // }
521-
522395 OptionalPtr<Simulation::SimulationUnit> GlobalInitialiser::init_simulation (
523396 std::unique_ptr<MC::MonteCarloUnit> _unit,
524397 const Simulation::ScalarInitializer& scalar_init)
@@ -726,9 +599,7 @@ namespace Core
726599 const auto n_per_flowmap =
727600 (t_per_flowmap == 0 || params.n_different_maps == 1 )
728601 ? 1
729- : static_cast <size_t >(t_per_flowmap /
730- static_cast <double >(params.d_t )) +
731- 1 ;
602+ : static_cast <size_t >(t_per_flowmap / params.d_t ) + 1 ;
732603
733604 params.n_per_flowmap = n_per_flowmap;
734605
@@ -778,22 +649,3 @@ namespace Core
778649 }
779650
780651} // namespace Core
781-
782- namespace
783- {
784-
785- void recur_path (std::string_view rootPath, Core::SimulationParameters& params)
786- {
787- size_t count = 1 ;
788- std::string dirName = " i_" + std::to_string (count) + " /" ;
789- std::filesystem::path dirPath = std::string (rootPath) + dirName;
790- while (std::filesystem::exists (dirPath) &&
791- std::filesystem::is_directory (dirPath))
792- {
793- ++count;
794- params.flow_files .push_back (dirPath.string ());
795- dirName = " i_" + std::to_string (count) + " /" ;
796- dirPath = std::string (rootPath) + dirName;
797- }
798- }
799- } // namespace
0 commit comments