Page MenuHomec4science

pypart_pybind.cc
No OneTemporary

File Metadata

Created
Tue, Apr 30, 11:40

pypart_pybind.cc

#include "material_points_factory.hh"
#include "particles_factory_interface.hh"
#include "ping_pong_balls_factory.hh"
#include "planets_factory.hh"
#include "compute_temperature.hh"
#include "csv_writer.hh"
#include <pybind11/pybind11.h>
namespace py = pybind11;
PYBIND11_MODULE(pypart, m) {
m.doc() = "pybind for particles code";
py::class_<ParticlesFactoryInterface>(m, "ParticlesFactoryInterface")
.def("getInstance", &ParticlesFactoryInterface::getInstance)
.def("createSimulation", &ParticlesFactoryInterface::createSimulation);
py::class_<MaterialPointsFactory, ParticlesFactoryInterface>(
m, "MaterialPointsFactory")
.def("getInstance", &MaterialPointsFactory::getInstance)
/*.def("createSimulation", py::overload_cast<const std::string &, Real>(
&MaterialPointsFactory::createSimulation))
// no need for py::overload_cast<const std::string &, Real, py::function>
.def("createSimulation",
py::overload_cast<const std::string &, Real, py::function>(
&MaterialPointsFactory::createSimulation<py::function>));
*/
.def("createSimulation", // less elegant way to do the overload cast --> forum
(SystemEvolution& (MaterialPointsFactory::*)(const std::string &, Real)) & MaterialPointsFactory::createSimulation
);
py::class_<PingPongBallsFactory, ParticlesFactoryInterface>(
m, "PingPongBallsFactory")
.def("getInstance", &PingPongBallsFactory::getInstance)
.def("createSimulation", &PingPongBallsFactory::createSimulation);
py::class_<PlanetsFactory, ParticlesFactoryInterface>(m, "PlanetsFactory")
.def("getInstance", &PlanetsFactory::getInstance)
.def("createSimulation", &PlanetsFactory::createSimulation);
py::class_<Compute, std::shared_ptr<Compute>>(m, "Compute");
py::class_<ComputeTemperature, Compute, std::shared_ptr<ComputeTemperature>
>(m, "ComputeTemperature")
.def("compute", &ComputeTemperature::compute)
.def_property("conductivity", &ComputeTemperature::setConductivity,
&ComputeTemperature::getConductivity)
.def_property("capacity", &ComputeTemperature::setCapacity, &ComputeTemperature::getCapacity)
.def_property("density", &ComputeTemperature::setDensity, &ComputeTemperature::getDensity)
.def_property("L", &ComputeTemperature::setL, &ComputeTemperature::getL)
.def_property("delta_t", &ComputeTemperature::setDeltat, &ComputeTemperature::getDeltat);
py::class_<CsvWriter, Compute, std::shared_ptr<CsvWriter>>(m, "CsvWriter")
.def(py::init<const std::string&>())
.def("write", &CsvWriter::write)
;
}

Event Timeline