Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122329527
py_part.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jul 17, 05:57
Size
3 KB
Mime Type
text/x-c
Expires
Sat, Jul 19, 05:57 (2 d)
Engine
blob
Format
Raw Data
Handle
27467000
Attached To
R7561 SP4E_HW1
py_part.cpp
View Options
#include <functional>
#include <iostream>
#include <pybind11/pybind11.h>
#include "planets_factory.hh"
#include "ping_pong_balls_factory.hh"
#include "material_points_factory.hh"
#include "csv_writer.hh"
#include "compute_temperature.hh"
namespace py = pybind11;
PYBIND11_MODULE(pypart, m) {
m.doc() = "pybind particle plugin"; // optional docstring
// wrap the class
py::class_<ParticlesFactoryInterface>(m, "ParticlesFactoryInterface")
.def("getInstance", &ParticlesFactoryInterface::getInstance,
py::return_value_policy::reference);
py::class_<PingPongBallsFactory, ParticlesFactoryInterface>(m, "PingPongBallsFactory")
.def("getInstance", &PingPongBallsFactory::getInstance,
py::return_value_policy::reference)
.def("createSimulation", &PingPongBallsFactory::createSimulation,
py::return_value_policy::reference);
py::class_<PlanetsFactory, ParticlesFactoryInterface>(m, "PlanetsFactory")
.def("getInstance", &PlanetsFactory::getInstance,
py::return_value_policy::reference)
.def("createSimulation", &PlanetsFactory::createSimulation,
py::return_value_policy::reference);
py::class_<MaterialPointsFactory, ParticlesFactoryInterface>(m, "MaterialPointsFactory")
.def("getInstance", &MaterialPointsFactory::getInstance,
py::return_value_policy::reference)
.def("createSimulation",
(SystemEvolution & (MaterialPointsFactory::*)(const std::string &, Real))
&MaterialPointsFactory::createSimulation, 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);
py::class_<SystemEvolution>(m, "SystemEvolution")
.def("setNSteps", &SystemEvolution::setNSteps)
.def("setDumpFreq", &SystemEvolution::setDumpFreq)
.def("evolve", &SystemEvolution::evolve)
.def("getSystem", &SystemEvolution::getSystem,
py::return_value_policy::reference);
py::class_<CsvWriter>(m, "CsvWriter")
.def(py::init<const std::string&>())
.def("write", &CsvWriter::write);
py::class_<System>(m, "System");
//Compute and ComputeTemperature wrappers are not implemented;
//only name of the class ComputeTemperature for python script's header
py::class_<Compute, std::shared_ptr<Compute>>(m, "Compute");
py::class_<ComputeTemperature, Compute>(m, "ComputeTemperature")
.def_property("conductivity", &ComputeTemperature::getConductivity, &ComputeTemperature::setConductivity)
.def_property("capacity", &ComputeTemperature::getCapacity, &ComputeTemperature::setCapacity)
.def_property("desnsity", &ComputeTemperature::getDensity, &ComputeTemperature::setDensity)
.def_property("L", &ComputeTemperature::getL, &ComputeTemperature::setL)
.def_property("deltat", &ComputeTemperature::getDeltat, &ComputeTemperature::setDeltat);
}
Event Timeline
Log In to Comment