1
1
#ifndef PHARE_PYTHON_CPP_SIMULATOR_HPP
2
2
#define PHARE_PYTHON_CPP_SIMULATOR_HPP
3
3
4
- #include < vector>
5
- #include < cstddef>
6
4
7
- #include " core/def/phare_mpi .hpp"
5
+ #include " phare/phare .hpp"
8
6
9
7
#include " core/utilities/mpi_utils.hpp"
10
- #include " core/data/particles/particle.hpp"
11
- #include " core/utilities/meta/meta_utilities.hpp"
8
+
12
9
#include " amr/wrappers/hierarchy.hpp"
13
- #include " phare/phare.hpp"
14
- #include " simulator/simulator.hpp"
15
10
16
- #include " python3/pybind_def.hpp"
17
- #include " pybind11/stl.h"
18
- #include " pybind11/numpy.h"
19
- #include " pybind11/chrono.h"
20
- #include " pybind11/complex.h"
21
- #include " pybind11/functional.h"
11
+ // #include "simulator/simulator.hpp"
22
12
23
13
#include " python3/particles.hpp"
24
- #include " python3/patch_data.hpp"
25
- #include " python3/patch_level.hpp"
26
- #include " python3/data_wrangler.hpp"
27
14
15
+ #include " pybind11/numpy.h"
28
16
17
+ #include < cstddef>
29
18
30
19
namespace py = pybind11;
31
20
32
21
namespace PHARE ::pydata
33
22
{
34
- template <typename Type, std::size_t dimension>
35
- void declarePatchData (py::module& m, std::string key)
36
- {
37
- using PatchDataType = PatchData<Type, dimension>;
38
- py::class_<PatchDataType>(m, key.c_str ())
39
- .def_readonly (" patchID" , &PatchDataType::patchID)
40
- .def_readonly (" origin" , &PatchDataType::origin)
41
- .def_readonly (" lower" , &PatchDataType::lower)
42
- .def_readonly (" upper" , &PatchDataType::upper)
43
- .def_readonly (" nGhosts" , &PatchDataType::nGhosts)
44
- .def_readonly (" data" , &PatchDataType::data);
45
- }
23
+
46
24
47
25
template <std::size_t dim>
48
26
void declareDim (py::module& m)
@@ -57,9 +35,6 @@ void declareDim(py::module& m)
57
35
.def_readwrite (" charge" , &CP::charge)
58
36
.def_readwrite (" v" , &CP::v)
59
37
.def (" size" , &CP::size);
60
-
61
- name = " PatchData" + name;
62
- declarePatchData<CP, dim>(m, name.c_str ());
63
38
}
64
39
65
40
template <typename Simulator, typename PyClass>
@@ -84,47 +59,12 @@ void declare_etc(py::module& m)
84
59
constexpr auto interp = _interp{}();
85
60
constexpr auto nbRefinedPart = _nbRefinedPart{}();
86
61
87
- std::string type_string = " _" + std::to_string (dim) + " _" + std::to_string (interp) + " _"
88
- + std::to_string (nbRefinedPart);
89
-
90
- using Sim = Simulator<dim, interp, nbRefinedPart>;
91
- using DW = DataWrangler<dim, interp, nbRefinedPart>;
92
- std::string name = " DataWrangler" + type_string;
93
- py::class_<DW, std::shared_ptr<DW>>(m, name.c_str ())
94
- .def (py::init<std::shared_ptr<Sim> const &, std::shared_ptr<amr::Hierarchy> const &>())
95
- .def (py::init<std::shared_ptr<ISimulator> const &, std::shared_ptr<amr::Hierarchy> const &>())
96
- .def (" sync_merge" , &DW::sync_merge)
97
- .def (" getPatchLevel" , &DW::getPatchLevel)
98
- .def (" getNumberOfLevels" , &DW::getNumberOfLevels);
99
-
100
- using PL = PatchLevel<dim, interp, nbRefinedPart>;
101
- name = " PatchLevel_" + type_string;
102
-
103
- py::class_<PL, std::shared_ptr<PL>>(m, name.c_str ())
104
- .def (" getEM" , &PL::getEM)
105
- .def (" getE" , &PL::getE)
106
- .def (" getB" , &PL::getB)
107
- .def (" getBx" , &PL::getBx)
108
- .def (" getBy" , &PL::getBy)
109
- .def (" getBz" , &PL::getBz)
110
- .def (" getEx" , &PL::getEx)
111
- .def (" getEy" , &PL::getEy)
112
- .def (" getEz" , &PL::getEz)
113
- .def (" getVix" , &PL::getVix)
114
- .def (" getViy" , &PL::getViy)
115
- .def (" getViz" , &PL::getViz)
116
- .def (" getDensity" , &PL::getDensity)
117
- .def (" getBulkVelocity" , &PL::getBulkVelocity)
118
- .def (" getPopDensities" , &PL::getPopDensities)
119
- .def (" getPopFluxes" , &PL::getPopFlux)
120
- .def (" getFx" , &PL::getFx)
121
- .def (" getFy" , &PL::getFy)
122
- .def (" getFz" , &PL::getFz)
123
- .def (" getParticles" , &PL::getParticles, py::arg (" userPopName" ) = " all" );
62
+ std::string const type_string = " _" + std::to_string (dim) + " _" + std::to_string (interp) + " _"
63
+ + std::to_string (nbRefinedPart);
124
64
125
65
using _Splitter
126
66
= PHARE::amr::Splitter<_dim, _interp, core::RefinedParticlesConst<nbRefinedPart>>;
127
- name = " Splitter" + type_string;
67
+ std::string name = " Splitter" + type_string;
128
68
py::class_<_Splitter, std::shared_ptr<_Splitter>>(m, name.c_str ())
129
69
.def (py::init<>())
130
70
.def_property_readonly_static (" weight" , [](py::object) { return _Splitter::weight; })
@@ -169,15 +109,15 @@ void declare_all(py::module& m, std::tuple<Dimension, InterpOrder, NbRefinedPart
169
109
});
170
110
}
171
111
172
- void declare_essential (py::module& m)
112
+ void inline declare_essential (py::module& m)
173
113
{
174
114
py::class_<SamraiLifeCycle, std::shared_ptr<SamraiLifeCycle>>(m, " SamraiLifeCycle" )
175
115
.def (py::init<>())
176
116
.def (" reset" , &SamraiLifeCycle::reset);
177
117
178
118
py::class_<PHARE::amr::Hierarchy, std::shared_ptr<PHARE::amr::Hierarchy>>(m, " AMRHierarchy" );
179
- m.def (" make_hierarchy" , []() { return PHARE::amr::Hierarchy::make (); });
180
119
120
+ m.def (" make_hierarchy" , []() { return PHARE::amr::Hierarchy::make (); });
181
121
m.def (" mpi_size" , []() { return core::mpi::size (); });
182
122
m.def (" mpi_rank" , []() { return core::mpi::rank (); });
183
123
m.def (" mpi_barrier" , []() { core::mpi::barrier (); });
@@ -189,7 +129,7 @@ void declare_essential(py::module& m)
189
129
190
130
// https://stackoverflow.com/a/51061314/795574
191
131
// ASAN detects leaks by default, even in system/third party libraries
192
- inline const char * __asan_default_options ()
132
+ inline char const * __asan_default_options ()
193
133
{
194
134
return " detect_leaks=0" ;
195
135
}
0 commit comments