diff --git a/apps/pythonmodule/PythonModule.cpp b/apps/pythonmodule/PythonModule.cpp index 43afcff724a02aca9babb38e7eabc7db56e820bf..61a6c2ac1ceb3a2fd61351e8597842363b302fde 100644 --- a/apps/pythonmodule/PythonModule.cpp +++ b/apps/pythonmodule/PythonModule.cpp @@ -35,55 +35,9 @@ #include "cuda/python/Exports.h" #endif -#include <boost/mpl/vector.hpp> -#include <boost/mpl/insert_range.hpp> - - -namespace bmpl = boost::mpl; using namespace walberla; -typedef bmpl::vector< - Field<walberla::real_t,1>, - Field<walberla::real_t,2>, - Field<walberla::real_t,3>, - Field<walberla::real_t,4>, - Field<walberla::real_t,5>, - Field<walberla::real_t,6>, - Field<walberla::real_t,9>, - Field<walberla::real_t,15>, - Field<walberla::real_t,19>, - Field<walberla::real_t,27>, - - Field<walberla::int8_t,1>, - Field<walberla::int16_t,1>, - Field<walberla::int32_t,1>, - - Field<walberla::int64_t,1>, - Field<walberla::int64_t,2>, - Field<walberla::int64_t,3>, - Field<walberla::int64_t,4>, - - Field<walberla::uint8_t,1>, - Field<walberla::uint16_t,1>, - Field<walberla::uint32_t,1> - > FieldTypes; - - -typedef bmpl::vector< - GhostLayerField<walberla::real_t,1>, - GhostLayerField<walberla::real_t,3> - > FieldTypesForMeshGeneration; - - -typedef bmpl::vector< FlagField<walberla::uint8_t>, - FlagField<walberla::uint16_t> > FlagFieldTypes; - -typedef bmpl::vector< stencil::D2Q5, - stencil::D2Q9, - stencil::D3Q7, - stencil::D3Q19, - stencil::D3Q27 > Stencils; typedef GhostLayerField<walberla::real_t,3> VecField_T; @@ -94,17 +48,33 @@ struct InitObject { InitObject() { - namespace bmpl = boost::mpl; - auto pythonManager = python_coupling::Manager::instance(); // Field - pythonManager->addExporterFunction( field::exportModuleToPython<FieldTypes> ); - pythonManager->addExporterFunction( field::exportGatherFunctions<FieldTypes> ); - pythonManager->addBlockDataConversion<FieldTypes>() ; + pythonManager->addExporterFunction( field::exportModuleToPython<Field<walberla::real_t,1>, Field<walberla::real_t,2>, Field<walberla::real_t,3>, + Field<walberla::real_t,4>, Field<walberla::real_t,5>, Field<walberla::real_t,6>, + Field<walberla::real_t,9>, Field<walberla::real_t,15>, Field<walberla::real_t,19>, + Field<walberla::real_t,27>, Field<walberla::int8_t,1>, Field<walberla::int16_t,1>, + Field<walberla::int32_t,1>, Field<walberla::int64_t,1>, Field<walberla::int64_t,2>, + Field<walberla::int64_t,3>, Field<walberla::int64_t,4>, Field<walberla::uint8_t,1>, + Field<walberla::uint16_t,1>, Field<walberla::uint32_t,1>> ); + pythonManager->addExporterFunction( field::exportGatherFunctions<Field<walberla::real_t,1>, Field<walberla::real_t,2>, Field<walberla::real_t,3>, + Field<walberla::real_t,4>, Field<walberla::real_t,5>, Field<walberla::real_t,6>, + Field<walberla::real_t,9>, Field<walberla::real_t,15>, Field<walberla::real_t,19>, + Field<walberla::real_t,27>, Field<walberla::int8_t,1>, Field<walberla::int16_t,1>, + Field<walberla::int32_t,1>, Field<walberla::int64_t,1>, Field<walberla::int64_t,2>, + Field<walberla::int64_t,3>, Field<walberla::int64_t,4>, Field<walberla::uint8_t,1>, + Field<walberla::uint16_t,1>, Field<walberla::uint32_t,1>> ); + pythonManager->addBlockDataConversion<Field<walberla::real_t,1>, Field<walberla::real_t,2>, Field<walberla::real_t,3>, + Field<walberla::real_t,4>, Field<walberla::real_t,5>, Field<walberla::real_t,6>, + Field<walberla::real_t,9>, Field<walberla::real_t,15>, Field<walberla::real_t,19>, + Field<walberla::real_t,27>, Field<walberla::int8_t,1>, Field<walberla::int16_t,1>, + Field<walberla::int32_t,1>, Field<walberla::int64_t,1>, Field<walberla::int64_t,2>, + Field<walberla::int64_t,3>, Field<walberla::int64_t,4>, Field<walberla::uint8_t,1>, + Field<walberla::uint16_t,1>, Field<walberla::uint32_t,1>>() ; // Blockforest - pythonManager->addExporterFunction( blockforest::exportModuleToPython<Stencils> ); + pythonManager->addExporterFunction( blockforest::exportModuleToPython<stencil::D2Q5, stencil::D2Q9, stencil::D3Q7, stencil::D3Q19, stencil::D3Q27> ); // Geometry pythonManager->addExporterFunction( geometry::exportModuleToPython ); @@ -113,23 +83,32 @@ struct InitObject pythonManager->addExporterFunction( vtk::exportModuleToPython ); // Postprocessing - pythonManager->addExporterFunction( postprocessing::exportModuleToPython<FieldTypesForMeshGeneration, FlagFieldTypes> ); + pythonManager->addExporterFunction( postprocessing::exportModuleToPython<std::tuple<GhostLayerField<walberla::real_t,1>, GhostLayerField<walberla::real_t,3>>, + std::tuple<FlagField<walberla::uint8_t>, FlagField<walberla::uint16_t>>> ); // Timeloop pythonManager->addExporterFunction( timeloop::exportModuleToPython ); #ifdef WALBERLA_BUILD_WITH_OPENMESH - pythonManager->addExporterFunction( mesh::exportModuleToPython<FlagFieldTypes> ); + pythonManager->addExporterFunction( mesh::exportModuleToPython<FlagField<walberla::uint8_t>, FlagField<walberla::uint16_t>> ); #endif #ifdef WALBERLA_BUILD_WITH_CUDA using walberla::cuda::GPUField; - typedef bmpl::vector<GPUField<double>, GPUField<float>, - GPUField<int8_t>, GPUField<int16_t>, GPUField<int32_t>, GPUField<int64_t>, - GPUField<uint8_t>, GPUField<uint16_t>, GPUField<uint32_t>,GPUField<uint64_t> > GPUFields; - pythonManager->addExporterFunction( cuda::exportModuleToPython<GPUFields, FieldTypes> ); - pythonManager->addBlockDataConversion<GPUFields>(); + pythonManager->addExporterFunction( cuda::exportModuleToPython<GPUField<double>, GPUField<float>, + GPUField<int8_t>, GPUField<int16_t>, GPUField<int32_t>, GPUField<int64_t>, + GPUField<uint8_t>, GPUField<uint16_t>, GPUField<uint32_t>,GPUField<uint64_t>, + Field<walberla::real_t,1>, Field<walberla::real_t,2>, Field<walberla::real_t,3>, + Field<walberla::real_t,4>, Field<walberla::real_t,5>, Field<walberla::real_t,6>, + Field<walberla::real_t,9>, Field<walberla::real_t,15>, Field<walberla::real_t,19>, + Field<walberla::real_t,27>, Field<walberla::int8_t,1>, Field<walberla::int16_t,1>, + Field<walberla::int32_t,1>, Field<walberla::int64_t,1>, Field<walberla::int64_t,2>, + Field<walberla::int64_t,3>, Field<walberla::int64_t,4>, Field<walberla::uint8_t,1>, + Field<walberla::uint16_t,1>, Field<walberla::uint32_t,1>> ); + pythonManager->addBlockDataConversion<GPUField<double>, GPUField<float>, + GPUField<int8_t>, GPUField<int16_t>, GPUField<int32_t>, GPUField<int64_t>, + GPUField<uint8_t>, GPUField<uint16_t>, GPUField<uint32_t>,GPUField<uint64_t>>(); #endif python_coupling::initWalberlaForPythonModule(); diff --git a/apps/showcases/PhaseFieldAllenCahn/CPU/PythonExports.cpp b/apps/showcases/PhaseFieldAllenCahn/CPU/PythonExports.cpp index 40bb8c52bf9a4b320b3f5300c0714ef8bda06e43..1d702bf33d9b943abf541888d6db0a0b36825a81 100644 --- a/apps/showcases/PhaseFieldAllenCahn/CPU/PythonExports.cpp +++ b/apps/showcases/PhaseFieldAllenCahn/CPU/PythonExports.cpp @@ -41,44 +41,21 @@ namespace walberla { // clang-format off void exportDataStructuresToPython() { - namespace bmpl = boost::mpl; - auto pythonManager = python_coupling::Manager::instance(); - typedef bmpl::vector< - Field<walberla::real_t, 1>, - Field<walberla::real_t, 3>, - Field<walberla::real_t, 9>, - Field<walberla::real_t, 19>, - Field<walberla::real_t, 27>> - FieldTypes; - - typedef bmpl::vector<stencil::D2Q9, - stencil::D3Q19, - stencil::D3Q27> - Stencils; - - typedef bmpl::vector< - GhostLayerField<real_t,1>, - GhostLayerField<real_t,3>> - RealFieldTypes; - - typedef bmpl::vector< - FlagField<flag_t>> - FlagFieldTypes; // Field - pythonManager->addExporterFunction(field::exportModuleToPython<FieldTypes>); - pythonManager->addExporterFunction(field::exportGatherFunctions<FieldTypes>); - pythonManager->addBlockDataConversion<FieldTypes>(); + pythonManager->addExporterFunction(field::exportModuleToPython<Field<walberla::real_t, 1>, Field<walberla::real_t, 3>, Field<walberla::real_t, 9>, Field<walberla::real_t, 19>, Field<walberla::real_t, 27>>); + pythonManager->addExporterFunction(field::exportGatherFunctions<Field<walberla::real_t, 1>, Field<walberla::real_t, 3>, Field<walberla::real_t, 9>, Field<walberla::real_t, 19>, Field<walberla::real_t, 27>>); + pythonManager->addBlockDataConversion<Field<walberla::real_t, 1>, Field<walberla::real_t, 3>, Field<walberla::real_t, 9>, Field<walberla::real_t, 19>, Field<walberla::real_t, 27>>(); // Blockforest - pythonManager->addExporterFunction(blockforest::exportModuleToPython<Stencils>); + pythonManager->addExporterFunction(blockforest::exportModuleToPython<stencil::D2Q9, stencil::D3Q19, stencil::D3Q27>); // Timeloop pythonManager->addExporterFunction(timeloop::exportModuleToPython); // Postprocessing - pythonManager->addExporterFunction( postprocessing::exportModuleToPython<RealFieldTypes, FlagFieldTypes> ); + pythonManager->addExporterFunction( postprocessing::exportModuleToPython<std::tuple<GhostLayerField<real_t,1>, GhostLayerField<real_t,3>>, std::tuple<FlagField<flag_t>>> ); // Geometry pythonManager->addExporterFunction( geometry::exportModuleToPython ); diff --git a/apps/showcases/PhaseFieldAllenCahn/GPU/PythonExports.cpp b/apps/showcases/PhaseFieldAllenCahn/GPU/PythonExports.cpp index 40bb8c52bf9a4b320b3f5300c0714ef8bda06e43..7e4c594dfd8a3869672621bbc2c8d1250256bd5a 100644 --- a/apps/showcases/PhaseFieldAllenCahn/GPU/PythonExports.cpp +++ b/apps/showcases/PhaseFieldAllenCahn/GPU/PythonExports.cpp @@ -41,44 +41,22 @@ namespace walberla { // clang-format off void exportDataStructuresToPython() { - namespace bmpl = boost::mpl; - auto pythonManager = python_coupling::Manager::instance(); - typedef bmpl::vector< - Field<walberla::real_t, 1>, - Field<walberla::real_t, 3>, - Field<walberla::real_t, 9>, - Field<walberla::real_t, 19>, - Field<walberla::real_t, 27>> - FieldTypes; - - typedef bmpl::vector<stencil::D2Q9, - stencil::D3Q19, - stencil::D3Q27> - Stencils; - - typedef bmpl::vector< - GhostLayerField<real_t,1>, - GhostLayerField<real_t,3>> - RealFieldTypes; - - typedef bmpl::vector< - FlagField<flag_t>> - FlagFieldTypes; // Field - pythonManager->addExporterFunction(field::exportModuleToPython<FieldTypes>); - pythonManager->addExporterFunction(field::exportGatherFunctions<FieldTypes>); - pythonManager->addBlockDataConversion<FieldTypes>(); + pythonManager->addExporterFunction(field::exportModuleToPython<Field<walberla::real_t, 1>, Field<walberla::real_t, 3>, Field<walberla::real_t, 9>, Field<walberla::real_t, 19>, Field<walberla::real_t, 27>>); + pythonManager->addExporterFunction(field::exportGatherFunctions<Field<walberla::real_t, 1>, Field<walberla::real_t, 3>, Field<walberla::real_t, 9>, Field<walberla::real_t, 19>, Field<walberla::real_t, 27>>); + pythonManager->addBlockDataConversion<Field<walberla::real_t, 1>, Field<walberla::real_t, 3>, Field<walberla::real_t, 9>, Field<walberla::real_t, 19>, Field<walberla::real_t, 27>>(); // Blockforest - pythonManager->addExporterFunction(blockforest::exportModuleToPython<Stencils>); + pythonManager->addExporterFunction(blockforest::exportModuleToPython<stencil::D2Q9, stencil::D3Q19, stencil::D3Q27>); // Timeloop pythonManager->addExporterFunction(timeloop::exportModuleToPython); // Postprocessing - pythonManager->addExporterFunction( postprocessing::exportModuleToPython<RealFieldTypes, FlagFieldTypes> ); + pythonManager->addExporterFunction( postprocessing::exportModuleToPython<std::tuple<GhostLayerField<real_t,1>, GhostLayerField<real_t,3>>, + std::tuple<FlagField<flag_t>>> ); // Geometry pythonManager->addExporterFunction( geometry::exportModuleToPython ); diff --git a/src/blockforest/python/CommunicationExport.h b/src/blockforest/python/CommunicationExport.h index f47406da073bbfe361abcfd00f1913e38bc3a91e..d0e4dedcf813a45fc917fbee99a8a151c901a63a 100644 --- a/src/blockforest/python/CommunicationExport.h +++ b/src/blockforest/python/CommunicationExport.h @@ -27,10 +27,10 @@ namespace walberla { namespace blockforest { - template<typename Stencils> + template<typename... Stencils> void exportUniformBufferedScheme(); - template<typename Stencils> + template<typename... Stencils> void exportUniformDirectScheme(); diff --git a/src/blockforest/python/CommunicationExport.impl.h b/src/blockforest/python/CommunicationExport.impl.h index d079e0e466fe943bc81bdad011584ac837aae7a0..999085d87d024427de0fe1ba23d4e176296f6e73 100644 --- a/src/blockforest/python/CommunicationExport.impl.h +++ b/src/blockforest/python/CommunicationExport.impl.h @@ -100,13 +100,13 @@ namespace internal }; - template<typename Stencils> + template<typename... Stencils> boost::python::object createUniformBufferedScheme( const shared_ptr<StructuredBlockForest> & bf, const std::string & stencil, const int tag ) { UniformBufferedSchemeCreator creator( bf, stencil, tag ); - python_coupling::for_each_noncopyable_type< Stencils > ( std::ref(creator) ); + python_coupling::for_each_noncopyable_type< Stencils... > ( std::ref(creator) ); if ( creator.getResult() == boost::python::object() ) { @@ -180,12 +180,12 @@ namespace internal }; - template<typename Stencils> + template<typename... Stencils> boost::python::object createUniformDirectScheme( const shared_ptr<StructuredBlockForest> & bf, const std::string & stencil, const int tag ) { UniformDirectSchemeCreator creator( bf, stencil, tag ); - python_coupling::for_each_noncopyable_type< Stencils > ( std::ref(creator) ); + python_coupling::for_each_noncopyable_type< Stencils... > ( std::ref(creator) ); if ( creator.getResult() == boost::python::object() ) { @@ -198,7 +198,7 @@ namespace internal } -template<typename Stencils> +template<typename... Stencils> void exportUniformBufferedScheme() { using namespace boost::python; @@ -209,21 +209,21 @@ void exportUniformBufferedScheme() .value("BUFFER", BUFFER) .export_values(); - python_coupling::for_each_noncopyable_type< Stencils > ( internal::UniformBufferedSchemeExporter() ); + python_coupling::for_each_noncopyable_type< Stencils... > ( internal::UniformBufferedSchemeExporter() ); - def( "createUniformBufferedScheme", &internal::createUniformBufferedScheme<Stencils>, + def( "createUniformBufferedScheme", &internal::createUniformBufferedScheme<Stencils...>, ( ( arg("blockForest"), arg("stencilName"), arg("tag")=778 ) ) ); } -template<typename Stencils> +template<typename... Stencils> void exportUniformDirectScheme() { using namespace boost::python; - python_coupling::for_each_noncopyable_type< Stencils > ( internal::UniformDirectSchemeExporter() ); + python_coupling::for_each_noncopyable_type< Stencils... > ( internal::UniformDirectSchemeExporter() ); - def( "createUniformDirectScheme", &internal::createUniformDirectScheme<Stencils>, + def( "createUniformDirectScheme", &internal::createUniformDirectScheme<Stencils...>, ( ( arg("blockForest"), arg("stencilName"), arg("tag")=778 ) ) ); } diff --git a/src/blockforest/python/Exports.h b/src/blockforest/python/Exports.h index a910b0541d075fd3e93948824d91b41a12090ea4..b63722c10696470600803d91197fb9e54d28fb87 100644 --- a/src/blockforest/python/Exports.h +++ b/src/blockforest/python/Exports.h @@ -36,12 +36,12 @@ namespace blockforest { void exportBlockForest(); - template<typename Stencils> + template<typename... Stencils> void exportModuleToPython() { exportBlockForest(); - exportUniformBufferedScheme<Stencils>(); - exportUniformDirectScheme<Stencils>(); + exportUniformBufferedScheme<Stencils...>(); + exportUniformDirectScheme<Stencils...>(); } } // namespace blockforest diff --git a/src/field/python/GatherExport.h b/src/field/python/GatherExport.h index 1105caa000f61bf0a3e7454ff725ee8420ecd38c..8cf3197b4bd2f079c9ce1bd53172169ff75e3d43 100644 --- a/src/field/python/GatherExport.h +++ b/src/field/python/GatherExport.h @@ -26,7 +26,7 @@ namespace walberla { namespace field { -template<typename FieldTypes > +template<typename... FieldTypes > void exportGatherFunctions(); diff --git a/src/field/python/GatherExport.impl.h b/src/field/python/GatherExport.impl.h index 545b10fd2453347607d862ba3b5c931150f57c4c..677674dd8d9e585063d3d61df9f9b1a1ec30d3e4 100644 --- a/src/field/python/GatherExport.impl.h +++ b/src/field/python/GatherExport.impl.h @@ -57,7 +57,7 @@ namespace internal { boost::python::object( const shared_ptr<StructuredBlockStorage> &, BlockDataID, CellInterval,int ) ); - template<typename FieldTypes> + template<typename... FieldTypes> static boost::python::object gatherWrapper ( const shared_ptr<StructuredBlockStorage> & blocks, const std::string & blockDataStr, const boost::python::tuple & slice, int targetRank = 0 ) { @@ -74,7 +74,7 @@ namespace internal { } IBlock * firstBlock = & ( * blocks->begin() ); - python_coupling::Dispatcher<Exporter_gatherToObject, FieldTypes > dispatcher( firstBlock ); + python_coupling::Dispatcher<Exporter_gatherToObject, FieldTypes... > dispatcher( firstBlock ); auto func = dispatcher( fieldID ); if ( !func ) { @@ -91,13 +91,13 @@ namespace internal { -template<typename FieldTypes > +template<typename... FieldTypes > void exportGatherFunctions() { using namespace boost::python; python_coupling::ModuleScope fieldModule( "field" ); - def( "gather", &internal::gatherWrapper<FieldTypes>, ( arg("blocks"), arg("blockDataName"), arg("slice"), arg("targetRank") = 0 ) ); + def( "gather", &internal::gatherWrapper<FieldTypes...>, ( arg("blocks"), arg("blockDataName"), arg("slice"), arg("targetRank") = 0 ) ); } diff --git a/src/postprocessing/python/Exports.h b/src/postprocessing/python/Exports.h index 17cd6b07a079c50724e4eafc2578b96471865d2e..ab9430451bcb3a7ca4ec18a8d9517f984db3cde0 100644 --- a/src/postprocessing/python/Exports.h +++ b/src/postprocessing/python/Exports.h @@ -28,7 +28,7 @@ namespace walberla { namespace postprocessing { - template<typename RealFields, typename FlagFields> + template<typename RealFieldTuple, typename FlagFieldTuple> void exportModuleToPython(); diff --git a/src/postprocessing/python/Exports.impl.h b/src/postprocessing/python/Exports.impl.h index d0e97b4a6b31dcdda54dbfe8ebcd6ff8b0bf5353..de245d4e1c5bc08c40b03034b3c560565558c836 100644 --- a/src/postprocessing/python/Exports.impl.h +++ b/src/postprocessing/python/Exports.impl.h @@ -42,7 +42,7 @@ FunctionExporterClass( realFieldToSurfaceMesh, shared_ptr<geometry::TriangleMesh>( const shared_ptr<StructuredBlockStorage> &, ConstBlockDataID, real_t, uint_t, bool, int, MPI_Comm ) ); -template<typename FieldVector> +template<typename... FieldTypes> static shared_ptr<geometry::TriangleMesh> exp_realFieldToSurfaceMesh ( const shared_ptr<StructuredBlockStorage> & bs, const std::string & blockDataStr, real_t threshold, uint_t fCoord = 0, bool calcNormals = false, int targetRank = 0 ) @@ -53,7 +53,7 @@ static shared_ptr<geometry::TriangleMesh> exp_realFieldToSurfaceMesh auto fieldID = python_coupling::blockDataIDFromString( *bs, blockDataStr ); - python_coupling::Dispatcher<Exporter_realFieldToSurfaceMesh, FieldVector > dispatcher( firstBlock ); + python_coupling::Dispatcher<Exporter_realFieldToSurfaceMesh, FieldTypes... > dispatcher( firstBlock ); return dispatcher( fieldID )( bs, fieldID, threshold, fCoord, calcNormals, targetRank, MPI_COMM_WORLD) ; } @@ -100,7 +100,7 @@ FunctionExporterClass( adaptedFlagFieldToSurfaceMesh, const std::vector< std::string > &, bool,int ) ); -template<typename FieldVector> +template<typename... FieldTypes> static boost::python::object exp_flagFieldToSurfaceMesh ( const shared_ptr<StructuredBlockStorage> & bs, const std::string & blockDataName, const boost::python::list & flagList, @@ -114,21 +114,21 @@ static boost::python::object exp_flagFieldToSurfaceMesh ( const shared_ptr<Struc auto fieldID = python_coupling::blockDataIDFromString( *bs, blockDataName ); auto flagVector = python_coupling::pythonIterableToStdVector<std::string>( flagList ); - python_coupling::Dispatcher<Exporter_adaptedFlagFieldToSurfaceMesh, FieldVector > dispatcher( firstBlock ); + python_coupling::Dispatcher<Exporter_adaptedFlagFieldToSurfaceMesh, FieldTypes... > dispatcher( firstBlock ); return dispatcher( fieldID )( bs, fieldID, flagVector, calcNormals, targetRank ); } -template<typename RealFields, typename FlagFields> +template<typename RealFieldTuple, typename FlagFieldTuple> void exportModuleToPython() { python_coupling::ModuleScope fieldModule( "postprocessing" ); - def( "realFieldToMesh", &exp_realFieldToSurfaceMesh<RealFields>, + def( "realFieldToMesh", &exp_realFieldToSurfaceMesh<RealFields...>, ( arg("blocks"), arg("blockDataName"), arg("fCoord")=0, arg("calcNormals") = false, arg("targetRank")=0 ) ); - def( "flagFieldToMesh", &exp_flagFieldToSurfaceMesh<FlagFields>, + def( "flagFieldToMesh", &exp_flagFieldToSurfaceMesh<FlagFields...>, ( arg("blocks"), arg("blockDataName"), arg("flagList"), arg("calcNormals") = false, arg("targetRank")=0 ) ); }