Skip to content

Commit

Permalink
rm datawrangler/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Mar 6, 2025
1 parent fc34c08 commit 188828a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 641 deletions.
7 changes: 1 addition & 6 deletions src/python3/cpp_simulator.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

#include "python3/cpp_simulator.hpp"
#include "core/utilities/meta/meta_utilities.hpp"

#if !defined(PHARE_CPP_MOD_NAME)
#define PHARE_CPP_MOD_NAME cpp
#endif

namespace py = pybind11;

namespace PHARE::pydata
{
PYBIND11_MODULE(PHARE_CPP_MOD_NAME, m)
Expand All @@ -18,9 +17,5 @@ PYBIND11_MODULE(PHARE_CPP_MOD_NAME, 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
84 changes: 12 additions & 72 deletions src/python3/cpp_simulator.hpp
Original file line number Diff line number Diff line change
@@ -1,48 +1,26 @@
#ifndef PHARE_PYTHON_CPP_SIMULATOR_HPP
#define PHARE_PYTHON_CPP_SIMULATOR_HPP

#include <vector>
#include <cstddef>

#include "core/def/phare_mpi.hpp"
#include "phare/phare.hpp"

#include "core/utilities/mpi_utils.hpp"
#include "core/data/particles/particle.hpp"
#include "core/utilities/meta/meta_utilities.hpp"

#include "amr/wrappers/hierarchy.hpp"
#include "phare/phare.hpp"
#include "simulator/simulator.hpp"

#include "python3/pybind_def.hpp"
#include "pybind11/stl.h"
#include "pybind11/numpy.h"
#include "pybind11/chrono.h"
#include "pybind11/complex.h"
#include "pybind11/functional.h"
// #include "simulator/simulator.hpp"

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

#include "python3/particles.hpp"
#include "python3/patch_data.hpp"
#include "python3/patch_level.hpp"
#include "python3/data_wrangler.hpp"

#include "pybind11/numpy.h"

#include <cstddef>

namespace py = pybind11;

namespace PHARE::pydata
{
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())
.def_readonly("patchID", &PatchDataType::patchID)
.def_readonly("origin", &PatchDataType::origin)
.def_readonly("lower", &PatchDataType::lower)
.def_readonly("upper", &PatchDataType::upper)
.def_readonly("nGhosts", &PatchDataType::nGhosts)
.def_readonly("data", &PatchDataType::data);
}


template<std::size_t dim>
void declareDim(py::module& m)
Expand All @@ -57,9 +35,6 @@ void declareDim(py::module& m)
.def_readwrite("charge", &CP::charge)
.def_readwrite("v", &CP::v)
.def("size", &CP::size);

name = "PatchData" + name;
declarePatchData<CP, dim>(m, name.c_str());
}

template<typename Simulator, typename PyClass>
Expand All @@ -84,47 +59,12 @@ void declare_etc(py::module& m)
constexpr auto interp = _interp{}();
constexpr auto nbRefinedPart = _nbRefinedPart{}();

std::string type_string = "_" + std::to_string(dim) + "_" + std::to_string(interp) + "_"
+ std::to_string(nbRefinedPart);

using Sim = Simulator<dim, interp, nbRefinedPart>;
using DW = DataWrangler<dim, interp, nbRefinedPart>;
std::string name = "DataWrangler" + type_string;
py::class_<DW, std::shared_ptr<DW>>(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)
.def("getPatchLevel", &DW::getPatchLevel)
.def("getNumberOfLevels", &DW::getNumberOfLevels);

using PL = PatchLevel<dim, interp, nbRefinedPart>;
name = "PatchLevel_" + type_string;

py::class_<PL, std::shared_ptr<PL>>(m, name.c_str())
.def("getEM", &PL::getEM)
.def("getE", &PL::getE)
.def("getB", &PL::getB)
.def("getBx", &PL::getBx)
.def("getBy", &PL::getBy)
.def("getBz", &PL::getBz)
.def("getEx", &PL::getEx)
.def("getEy", &PL::getEy)
.def("getEz", &PL::getEz)
.def("getVix", &PL::getVix)
.def("getViy", &PL::getViy)
.def("getViz", &PL::getViz)
.def("getDensity", &PL::getDensity)
.def("getBulkVelocity", &PL::getBulkVelocity)
.def("getPopDensities", &PL::getPopDensities)
.def("getPopFluxes", &PL::getPopFlux)
.def("getFx", &PL::getFx)
.def("getFy", &PL::getFy)
.def("getFz", &PL::getFz)
.def("getParticles", &PL::getParticles, py::arg("userPopName") = "all");
std::string const type_string = "_" + std::to_string(dim) + "_" + std::to_string(interp) + "_"
+ std::to_string(nbRefinedPart);

using _Splitter
= PHARE::amr::Splitter<_dim, _interp, core::RefinedParticlesConst<nbRefinedPart>>;
name = "Splitter" + type_string;
std::string name = "Splitter" + type_string;
py::class_<_Splitter, std::shared_ptr<_Splitter>>(m, name.c_str())
.def(py::init<>())
.def_property_readonly_static("weight", [](py::object) { return _Splitter::weight; })
Expand Down Expand Up @@ -169,15 +109,15 @@ void declare_all(py::module& m, std::tuple<Dimension, InterpOrder, NbRefinedPart
});
}

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

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

m.def("make_hierarchy", []() { return PHARE::amr::Hierarchy::make(); });
m.def("mpi_size", []() { return core::mpi::size(); });
m.def("mpi_rank", []() { return core::mpi::rank(); });
m.def("mpi_barrier", []() { core::mpi::barrier(); });
Expand All @@ -189,7 +129,7 @@ void declare_essential(py::module& m)

// https://stackoverflow.com/a/51061314/795574
// ASAN detects leaks by default, even in system/third party libraries
inline const char* __asan_default_options()
inline char const* __asan_default_options()
{
return "detect_leaks=0";
}
Expand Down
185 changes: 0 additions & 185 deletions src/python3/data_wrangler.hpp

This file was deleted.

Loading

0 comments on commit 188828a

Please sign in to comment.