Page MenuHomec4science

pypart.cc
No OneTemporary

File Metadata

Created
Wed, May 22, 08:51

pypart.cc

#include <functional>
#include <iostream>
#include <pybind11/pybind11.h>
#include "system_evolution.hh"
#include "particles_factory_interface.hh"
#include "csv_writer.hh"
#include "compute.hh"
#include "compute_temperature.hh"
#include "material_points_factory.hh"
#include "ping_pong_balls_factory.hh"
#include "planets_factory.hh"
namespace py = pybind11;
PYBIND11_MODULE(pypart, m) {
m.doc() = "Python binding for the particles code.";
// Class System
py::class_<System>(m, "System");
// Class SystemEvolution
py::class_<SystemEvolution, std::unique_ptr<SystemEvolution>>(m, "SystemEvolution",
py::dynamic_attr())
.def(py::init([](std::unique_ptr<System>()){return std::unique_ptr<SystemEvolution>();}),
py::return_value_policy::move)
.def("evolve", &SystemEvolution::evolve)
.def("addCompute", &SystemEvolution::addCompute)
.def("getSystem", &SystemEvolution::getSystem, py::return_value_policy::reference)
.def("setNSteps", &SystemEvolution::setNSteps)
.def("setDumpFreq", &SystemEvolution::setDumpFreq);
// Class ParticlesFactoryInterface
py::class_<ParticlesFactoryInterface>(m, "ParticlesFactoryInterface",
py::dynamic_attr())
.def_static("getInstance", &ParticlesFactoryInterface::getInstance,
py::return_value_policy::reference)
.def("getSystemEvolution", &ParticlesFactoryInterface::getSystemEvolution,
py::return_value_policy::reference)
.def_property_readonly("system_evolution",&ParticlesFactoryInterface::getSystemEvolution);
// Class MaterialPointsFactory
py::class_<MaterialPointsFactory, ParticlesFactoryInterface,
std::shared_ptr<MaterialPointsFactory>>(m, "MaterialPointsFactory")
.def("getInstance", &MaterialPointsFactory::getInstance,
py::return_value_policy::reference)
.def("createSimulation",
py::overload_cast<const std::string &, Real, py::function>(
&MaterialPointsFactory::createSimulation<py::function>),
py::return_value_policy::reference);
// Class PlanetsFactory
py::class_<PlanetsFactory, ParticlesFactoryInterface,
std::shared_ptr<PlanetsFactory>>(m, "PlanetsFactory")
.def("getInstance", &PlanetsFactory::getInstance,
py::return_value_policy::reference)
.def("createSimulation",
py::overload_cast<const std::string &, Real, bool>(
&ParticlesFactoryInterface::createSimulation),
py::return_value_policy::reference);
}

Event Timeline