Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/python3/cpp_etc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ PYBIND11_MODULE(cpp_etc, m)
auto samrai_restart_file = [](std::string path) {
return PHARE::amr::HierarchyRestarter::getRestartFileFullPath(path);
};
py::class_<core::Span<double>, std::shared_ptr<core::Span<double>>>(m, "Span");
py::class_<PyArrayWrapper<double>, std::shared_ptr<PyArrayWrapper<double>>, core::Span<double>>(
m, "PyWrapper");
py::class_<core::Span<double>, py::smart_holder>(m, "Span");
py::class_<PyArrayWrapper<double>, py::smart_holder, core::Span<double>>(m, "PyWrapper");

m.def("makePyArrayWrapper", makePyArrayWrapper<double>);

Expand Down
10 changes: 6 additions & 4 deletions src/python3/cpp_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ namespace py = pybind11;

namespace PHARE::pydata
{

PYBIND11_MODULE(PHARE_CPP_MOD_NAME, m)
{
declarePatchData<std::vector<double>, 1>(m, "PatchDataVectorDouble_1D");
declarePatchData<std::vector<double>, 2>(m, "PatchDataVectorDouble_2D");
declarePatchData<std::vector<double>, 3>(m, "PatchDataVectorDouble_3D");

declare_essential(m);

declareDim<1>(m);
declareDim<2>(m);
declareDim<3>(m);

core::apply(core::possibleSimulators(), [&](auto const& simType) { declare_all(m, simType); });

declarePatchData<std::vector<double>, 1>(m, "PatchDataVectorDouble_1D");
declarePatchData<std::vector<double>, 2>(m, "PatchDataVectorDouble_2D");
declarePatchData<std::vector<double>, 3>(m, "PatchDataVectorDouble_3D");
}

} // namespace PHARE::pydata
17 changes: 8 additions & 9 deletions src/python3/cpp_simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ template<typename Type, std::size_t dimension>
void declarePatchData(py::module& m, std::string key)
{
using PatchDataType = PatchData<Type, dimension>;
py::class_<PatchDataType>(m, key.c_str())
py::class_<PatchDataType, py::smart_holder>(m, key.c_str())
.def_readonly("patchID", &PatchDataType::patchID)
.def_readonly("origin", &PatchDataType::origin)
.def_readonly("lower", &PatchDataType::lower)
Expand All @@ -46,7 +46,7 @@ void declareDim(py::module& m)
{
using CP = core::ContiguousParticles<dim>;
std::string name = "ContiguousParticles_" + std::to_string(dim);
py::class_<CP, std::shared_ptr<CP>>(m, name.c_str())
py::class_<CP, py::smart_holder>(m, name.c_str())
.def(py::init<std::size_t>())
.def_readwrite("iCell", &CP::iCell)
.def_readwrite("delta", &CP::delta)
Expand Down Expand Up @@ -88,7 +88,7 @@ void declare_etc(py::module& m)
using Sim = Simulator<opts>;
using DW = DataWrangler<opts>;
std::string name = "DataWrangler" + type_string;
py::class_<DW, std::shared_ptr<DW>>(m, name.c_str())
py::class_<DW, py::smart_holder>(m, name.c_str())
.def(py::init<std::shared_ptr<Sim> const&, std::shared_ptr<amr::Hierarchy> const&>())
.def(py::init<std::shared_ptr<ISimulator> const&, std::shared_ptr<amr::Hierarchy> const&>())
.def("sync_merge", &DW::sync_merge)
Expand All @@ -97,8 +97,7 @@ void declare_etc(py::module& m)

using PL = PatchLevel<opts>;
name = "PatchLevel_" + type_string;

py::class_<PL, std::shared_ptr<PL>>(m, name.c_str())
py::class_<PL, py::smart_holder>(m, name.c_str())
.def("getEM", &PL::getEM)
.def("getE", &PL::getE)
.def("getB", &PL::getB)
Expand All @@ -123,7 +122,7 @@ void declare_etc(py::module& m)
using _Splitter
= PHARE::amr::Splitter<_dim, _interp, core::RefinedParticlesConst<nbRefinedPart>>;
name = "Splitter" + type_string;
py::class_<_Splitter, std::shared_ptr<_Splitter>>(m, name.c_str())
py::class_<_Splitter, py::smart_holder>(m, name.c_str())
.def(py::init<>())
.def_property_readonly_static("weight", [](py::object) { return _Splitter::weight; })
.def_property_readonly_static("delta", [](py::object) { return _Splitter::delta; });
Expand All @@ -146,7 +145,7 @@ void declare_sim(py::module& m)
using Sim = Simulator<opts>;
std::string name = "Simulator" + type_string;
declareSimulator<Sim>(
py::class_<Sim, std::shared_ptr<Sim>>(m, name.c_str())
py::class_<Sim, py::smart_holder>(m, name.c_str())
.def_property_readonly_static("dims", [](py::object) { return Sim::dimension; })
.def_property_readonly_static("interp_order",
[](py::object) { return Sim::interp_order; })
Expand Down Expand Up @@ -182,11 +181,11 @@ void declare_all(py::module& m, std::tuple<Dimension, InterpOrder, NbRefinedPart

void inline declare_essential(py::module& m)
{
py::class_<SamraiLifeCycle, std::shared_ptr<SamraiLifeCycle>>(m, "SamraiLifeCycle")
py::class_<SamraiLifeCycle, py::smart_holder>(m, "SamraiLifeCycle")
.def(py::init<>())
.def("reset", &SamraiLifeCycle::reset);

py::class_<PHARE::amr::Hierarchy, std::shared_ptr<PHARE::amr::Hierarchy>>(m, "AMRHierarchy");
py::class_<PHARE::amr::Hierarchy, py::smart_holder>(m, "AMRHierarchy");
m.def("make_hierarchy", []() { return PHARE::amr::Hierarchy::make(); });

m.def("mpi_size", []() { return core::mpi::size(); });
Expand Down
3 changes: 2 additions & 1 deletion src/python3/patch_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ struct __attribute__((visibility("hidden"))) PatchData

template<typename... Args>
PatchData(Args&&... args)
: data{std::forward<Args...>(args...)}
requires std::is_constructible_v<Data, Args&&...>
: data{std::forward<Args>(args)...}
{
}
};
Expand Down