Skip to content

Commit d9ef216

Browse files
committed
feat(cma): clean all unsued and better rust integration
1 parent b21d135 commit d9ef216

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+214
-1799
lines changed

apps/autogenerated/model_loader.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <mc/mcinit.hpp>
55
#include <string_view>
66
#include <unordered_map> // IWYU pragma: keep
7-
7+
#include <cma_utils/alias.hpp>
88
/* ---------------------------------------------------------
99
* BIOCMA_MC ST
1010
*
@@ -28,7 +28,7 @@
2828
const int i_model,
2929
uint64_t number_particle,
3030
std::span<double> liq_volume,
31-
const ::MC::NeighborsView<HostSpace>& liquid_neighbors,
31+
std::span<const size_t> liquid_neighbors,
3232
bool uniform_mc_init,
3333
double& total_mass) noexcept
3434
{

apps/autogenerated/model_loader.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <memory>
1010
#include <span>
1111
#include <string_view>
12-
1312
/* ---------------------------------------------------------
1413
* BIOCMA_MC ST
1514
*
@@ -27,7 +26,7 @@ namespace AutoGenerated
2726
int i_model,
2827
uint64_t number_particle,
2928
std::span<double> liq_volume,
30-
const ::MC::NeighborsView<HostSpace>& liquid_neighbors,
29+
std::span<const size_t> liquid_neighbors,
3130
bool uniform_mc_init,
3231
double& total_mass) noexcept;
3332

apps/core/includes/host_export_handler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __CORE_HOST_EXPORT_HANDLER_HPP__
22
#define __CORE_HOST_EXPORT_HANDLER_HPP__
33

4-
#include <cma_utils/d_transitionner.hpp>
4+
#include <cma_utils/alias.hpp>
55
#include <dataexporter/main_exporter.hpp>
66
#include <dataexporter/partial_exporter.hpp>
77
#include <optional>

apps/core/includes/host_specific.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// #include <common/common.hpp>
55

6-
#include "cma_utils/d_transitionner.hpp"
6+
#include "cma_utils/alias.hpp"
77
#include <common/logger.hpp>
88
#include <core/simulation_parameters.hpp>
99
#include <dataexporter/partial_exporter.hpp>

apps/core/includes/sync.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ namespace Simulation
88
class SimulationUnit;
99
}
1010

11-
#include <mpi_w/wrap_mpi.hpp>
11+
#ifndef NO_MPI
12+
# include <mpi_w/wrap_mpi.hpp>
13+
#else
14+
using MPI_Request = int;
15+
#endif
1216

1317
/**
1418
* @brief Synchronization after particle processing.
@@ -52,4 +56,4 @@ void sync_prepare_next(Simulation::SimulationUnit& simulation,
5256
*/
5357
void last_sync(const ExecInfo& exec, Simulation::SimulationUnit& simulation);
5458

55-
#endif //__SYNC_NODES_HPP__
59+
#endif //__SYNC_NODES_HPP__

apps/core/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dep_core = [
1111
simulation_lib_dependency,
1212
eigen_dep,
1313
blas,
14-
transitionner_dependency,
14+
cma_utils_dependency,
1515
]
1616

1717
if highfive_found
@@ -68,4 +68,4 @@ core_distributed_dependency_static = declare_dependency(
6868

6969
if build_test
7070
subdir('tests')
71-
endif
71+
endif

apps/core/public/core/case_data.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef __CASE_DATA__HPP__
22
#define __CASE_DATA__HPP__
33

4-
#include "cma_utils/d_transitionner.hpp"
4+
#include "cma_utils/alias.hpp"
55
#include <common/execinfo.hpp>
66
#include <common/logger.hpp>
77
#include <core/simulation_parameters.hpp>

apps/core/public/core/global_initaliser.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#ifndef __CORE_GLOBAL_INITIALLISER_HPP__
22
#define __CORE_GLOBAL_INITIALLISER_HPP__
33

4-
#include "cma_utils/d_transitionner.hpp"
4+
#include <cma_utils/alias.hpp>
55
#include "common/logger.hpp"
66
#include <array>
7-
#include <cma_read/flow_iterator.hpp>
8-
#include <cma_read/neighbors.hpp>
9-
#include <cmt_common/cma_case.hpp>
107
#include <common/execinfo.hpp>
118
#include <core/scalar_factory.hpp>
129
#include <core/simulation_parameters.hpp>
@@ -229,8 +226,8 @@ namespace Core
229226
* @param cma_case_path The path for the CMA case.
230227
* @return A structure containing exported paths.
231228
*/
232-
CmtCommons::cma_exported_paths_t
233-
get_path_files(const std::string& cma_case_path);
229+
// CmtCommons::cma_exported_paths_t
230+
// get_path_files(const std::string& cma_case_path);
234231

235232
/**
236233
* @brief Host speciffic state init

apps/core/src/global_initaliser.cpp

Lines changed: 3 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
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

apps/core/src/host_export_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cma_utils/d_transitionner.hpp"
1+
#include "cma_utils/alias.hpp"
22
#include <host_export_handler.hpp>
33
#include <impl_post_process.hpp>
44
#include <iostream>

0 commit comments

Comments
 (0)