Loading src/Python/pytnl/tnl_mpi/DistributedMeshWriters.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,7 @@ void export_DistributedMeshWriter( py::module & m, const char* name ) }, py::arg("array"), py::arg("name"), py::arg("numberOfComponents") = 1) // NOTE: only the overload intended for sequential writing is exported, because we don't // have type casters for Communicators::MpiCommunicator::CommunicationGroup // (ideally, the communication group would be compatible with the mpi4py objects) // have type casters for MPI_Comm (ideally, it would be compatible with the mpi4py objects) .def("addPiece", static_cast< std::string (Writer::*)(const TNL::String&, unsigned) >( &Writer::addPiece ), py::arg("mainFileName"), py::arg("subdomainIndex")) ; Loading src/Python/pytnl/tnl_mpi/tnl_mpi.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ // conversions have to be registered for each object file #include "../tnl_conversions.h" #include "TNL/MPI/Wrappers.h" // external functions void export_DistributedMeshes( py::module & m ); Loading @@ -18,15 +19,15 @@ PYBIND11_MODULE(PYTNL_MODULE_NAME(tnl_mpi), m) // MPI initialization and finalization // https://stackoverflow.com/q/64647846 if( ! TNL::Communicators::MpiCommunicator::IsInitialized() ) { if( ! TNL::MPI::Initialized() ) { int argc = 0; char** argv = nullptr; TNL::Communicators::MpiCommunicator::Init( argc, argv ); TNL::MPI::Init( argc, argv ); } // https://pybind11.readthedocs.io/en/stable/advanced/misc.html#module-destructors auto cleanup_callback = []() { if( TNL::Communicators::MpiCommunicator::IsInitialized() ) TNL::Communicators::MpiCommunicator::Finalize(); if( TNL::MPI::Initialized() && ! TNL::MPI::Finalized() ) TNL::MPI::Finalize(); }; m.add_object("_cleanup", py::capsule(cleanup_callback)); Loading Loading
src/Python/pytnl/tnl_mpi/DistributedMeshWriters.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -78,8 +78,7 @@ void export_DistributedMeshWriter( py::module & m, const char* name ) }, py::arg("array"), py::arg("name"), py::arg("numberOfComponents") = 1) // NOTE: only the overload intended for sequential writing is exported, because we don't // have type casters for Communicators::MpiCommunicator::CommunicationGroup // (ideally, the communication group would be compatible with the mpi4py objects) // have type casters for MPI_Comm (ideally, it would be compatible with the mpi4py objects) .def("addPiece", static_cast< std::string (Writer::*)(const TNL::String&, unsigned) >( &Writer::addPiece ), py::arg("mainFileName"), py::arg("subdomainIndex")) ; Loading
src/Python/pytnl/tnl_mpi/tnl_mpi.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ // conversions have to be registered for each object file #include "../tnl_conversions.h" #include "TNL/MPI/Wrappers.h" // external functions void export_DistributedMeshes( py::module & m ); Loading @@ -18,15 +19,15 @@ PYBIND11_MODULE(PYTNL_MODULE_NAME(tnl_mpi), m) // MPI initialization and finalization // https://stackoverflow.com/q/64647846 if( ! TNL::Communicators::MpiCommunicator::IsInitialized() ) { if( ! TNL::MPI::Initialized() ) { int argc = 0; char** argv = nullptr; TNL::Communicators::MpiCommunicator::Init( argc, argv ); TNL::MPI::Init( argc, argv ); } // https://pybind11.readthedocs.io/en/stable/advanced/misc.html#module-destructors auto cleanup_callback = []() { if( TNL::Communicators::MpiCommunicator::IsInitialized() ) TNL::Communicators::MpiCommunicator::Finalize(); if( TNL::MPI::Initialized() && ! TNL::MPI::Finalized() ) TNL::MPI::Finalize(); }; m.add_object("_cleanup", py::capsule(cleanup_callback)); Loading