diff --git a/work/week14/particle-pybind/starting_point/pypart_pybind.cpp b/work/week14/particle-pybind/starting_point/pypart_pybind.cpp index 21dadc3..e15b3a9 100644 --- a/work/week14/particle-pybind/starting_point/pypart_pybind.cpp +++ b/work/week14/particle-pybind/starting_point/pypart_pybind.cpp @@ -1,79 +1,84 @@ #include #include #include #include "my_types.hh" -#include "system_evolution.cc" -#include "system.cc" -#include "csv_writer.cc" -#include "particles_factory_interface.cc" -#include "ping_pong_balls_factory.cc" -#include "material_points_factory.cc" -#include "planets_factory.cc" -#include "compute_temperature.cc" -#include "system_evolution.cc" +#include "system_evolution.hh" +#include "system.hh" +#include "csv_writer.hh" +#include "particles_factory_interface.hh" +#include "ping_pong_balls_factory.hh" +#include "material_points_factory.hh" +#include "planets_factory.hh" +#include "compute_temperature.hh" namespace py = pybind11; PYBIND11_MODULE(pypart, m) { // Wrap the SystemEvolution class py::class_(m, "System") - .def(py::init<>()) // constructor - ; + .def(py::init<>()) // constructor + ; // Wrap the SystemEvolution class py::class_(m, "SystemEvolution") - // .def(py::init>(), - // py::arg("system") = system) // with a default) // constructor - ; + // .def(py::init>()) + .def("addCompute",(&SystemEvolution::addCompute)) + ; // Wrap the ParticlesFactoryInterface class py::class_(m, "ParticlesFactoryInterface") - // .def(py::init<>()) // constructor - .def("getInstance", &ParticlesFactoryInterface::getInstance) // getInstance method - .def("createSimulation",(&ParticlesFactoryInterface::createSimulation)) // overloading with int - ; + // .def(py::init<>()) // constructor + .def("getInstance", &ParticlesFactoryInterface::getInstance) + .def("createSimulation",(&ParticlesFactoryInterface::createSimulation)) + ; // Wrap the PlanetsFactory class py::class_(m, "MaterialPointsFactory") - // .def(py::init<>()) // constructor - .def("getInstance", &PlanetsFactory::getInstance) // getInstance method - - .def("createSimulation", &PlanetsFactory::createSimulation) // overloading with int - ; + // .def(py::init<>()) // constructor + .def("getInstance", &PlanetsFactory::getInstance) + .def("createSimulation", &PlanetsFactory::createSimulation) + ; // Wrap the PingPongBallsFactory class py::class_(m, "MaterialPointsFactory") - // .def(py::init<>()) // constructor - .def("getInstance", &PingPongBallsFactory::getInstance) // getInstance method - - .def("createSimulation", &PingPongBallsFactory::createSimulation) // overloading with int - ; + // .def(py::init<>()) // constructor + .def("getInstance", &PingPongBallsFactory::getInstance) + .def("createSimulation", &PingPongBallsFactory::createSimulation) + ; // Wrap the MaterialPointsFactory class py::class_(m, "MaterialPointsFactory") - // .def(py::init<>()) // constructor - .def("getInstance", &MaterialPointsFactory::getInstance) // getInstance method - - // .def("createSimulation", - // py::overload_cast(&MaterialPointsFactory::createSimulation)) // overloading with int - .def("createSimulation", - py::overload_cast(&MaterialPointsFactory::createSimulation)) // overloading with const - ; + // .def(py::init<>()) // constructor + .def("getInstance", &MaterialPointsFactory::getInstance) + .def("createSimulation", + (SystemEvolution & (MaterialPointsFactory::*)(const std::string &, Real)) + &MaterialPointsFactory::createSimulation) // static casting for "classic" overloaded method + .def("createSimulation", + py::overload_cast + (&MaterialPointsFactory::createSimulation)) // dynamic casting for "functor" overloaded method + ; //Make a shared Compute Method py::class_(m, "Compute") - // .def(py::init<>()) // constructor - ; + // .def(py::init<>()) // constructor + ; //Creates the ComputeTemeprature class and its functions py::class_(m, "ComputeTemperature") - .def(py::init<>()) // constructor) - .def_property("conductivity_property", &ComputeTemperature::setConductivity, &ComputeTemperature::getConductivity) // method only in Dog; - .def_property("capacity_property", &ComputeTemperature::setCapacity, &ComputeTemperature::getCapacity) - .def_property("density_property", &ComputeTemperature::setDensity, &ComputeTemperature::getDensity) - .def_property("l_property", &ComputeTemperature::setL, &ComputeTemperature::getL) - .def_property("deltat_property", &ComputeTemperature::setDeltat, &ComputeTemperature::getDeltat); + .def(py::init<>()) // constructor) + .def_property("conductivity_property", &ComputeTemperature::setConductivity, + &ComputeTemperature::getConductivity) // method only in Dog; + .def_property("capacity_property", &ComputeTemperature::setCapacity, + &ComputeTemperature::getCapacity) + .def_property("density_property", &ComputeTemperature::setDensity, + &ComputeTemperature::getDensity) + .def_property("l_property", &ComputeTemperature::setL, + &ComputeTemperature::getL) + .def_property("deltat_property", &ComputeTemperature::setDeltat, + &ComputeTemperature::getDeltat) + ; } +