Commit fb66bdf6 authored by Markus Holzer's avatar Markus Holzer Committed by Dominik Thoennes
Browse files

load pybind11 after finding python libraries

also clean up some old leftovers nearby
parent 2724c85f
This diff is collapsed.
[submodule "extern/pybind11"]
path = extern/pybind11
url = https://github.com/pybind/pybind11.git
......@@ -2,6 +2,11 @@
## [Unreleased]
- Python Coupling now build upon pybind11. Boost.Python is no longer supported
- lbm module dropped from python coupling due to deprecation for a long time
- geometry, postprocessing and timeloop dropped from python coupling due to its low usage
- PEP8-ification of Python API. This means all keyword arguments are now in snake_case and not in CamelCase as before.
## [4.1] - 2019-04-19
### Added
- Galerkin coarsening for Multigrid
......
......@@ -75,8 +75,6 @@ option ( WALBERLA_BUILD_WITH_GCOV "Enables gcov"
option ( WALBERLA_BUILD_WITH_LTO "Enable link time optimizations" )
option ( WALBERLA_BUILD_WITH_OPENMP "Enable OpenMP support" )
option ( WALBERLA_BUILD_WITH_PYTHON "Support for embedding Python" )
option ( WALBERLA_BUILD_WITH_PYTHON_MODULE "Build waLBerla python module" )
option ( WALBERLA_BUILD_WITH_PYTHON_LBM "Include LBM module into python module" OFF )
option ( WALBERLA_BUILD_WITH_CODEGEN "Enable pystencils code generation" OFF )
......@@ -100,6 +98,8 @@ option ( WALBERLA_OPTIMIZE_FOR_LOCALHOST "Enable compiler optimizations spcif
option ( WALBERLA_LOG_SKIPPED "Log skipped cmake targets" ON )
option ( WALBERLA_GIT_SUBMODULE_AUTO "Check submodules during cmake run" ON )
# Installation Directory
set ( CMAKE_INSTALL_PREFIX /usr/local/waLBerla CACHE STRING "The default installation directory." )
......@@ -315,7 +315,6 @@ if( WALBERLA_CXX_COMPILER_IS_IBM )
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1586-267" ) # 1586-267 (I) Inlining of specified subprogram failed due to the presence of a C++ exception handler
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1586-266" ) # 1586-266 (I) Inlining of specified subprogram failed due to the presence of a global label
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1540-0724" ) # 1540-0724 (W) The non-type template argument "2147483648" of type "T" has wrapped [coming from boost/integer_traits.hpp]
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1540-0095" ) # 1540-0095 (W) The friend function declaration ... [coming from boost/mpl/map/aux_/map0.hpp]
add_flag ( CMAKE_CXX_FLAGS "-qsuppress=1500-030" ) # 1500-030: (I) INFORMATION: [...] Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
add_flag ( CMAKE_C_FLAGS "-qsuppress=1500-030" ) # 1500-030: (I) INFORMATION: [...] Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
endif()
......@@ -587,53 +586,56 @@ endif()
#############################################################################################################################
if ( WALBERLA_BUILD_WITH_PYTHON )
set ( waLBerla_REQUIRED_MIN_PYTHON_VERSION "2.7")
find_package( PythonInterp 3 QUIET) # search for Python3 first
find_package( PythonInterp QUIET) # fallback to any Python version
find_package( PythonInterp 3.6 QUIET REQUIRED)
find_package( PythonLibs QUIET REQUIRED)
if( PYTHONLIBS_VERSION_STRING VERSION_LESS ${waLBerla_REQUIRED_MIN_PYTHON_VERSION} )
message( FATAL_ERROR "Found old python library: ${PYTHONLIBS_VERSION_STRING} need at least ${waLBerla_REQUIRED_MIN_PYTHON_VERSION}" )
endif()
option( WALBERLA_USE_PYTHON_DEBUG_LIBRARY "Make use of the python debug library" OFF )
if( WALBERLA_USE_PYTHON_DEBUG_LIBRARY )
# you have to make sure this matches the settings you compiled boost with!
add_definitions( "-DBOOST_DEBUG_PYTHON" )
endif()
if( NOT (PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR ) )
message( FATAL_ERROR "Couldn't find any python library" )
endif()
SET( WALBERLA_BUILD_WITH_PYTHON 1 )
include_directories( ${PYTHON_INCLUDE_DIR} )
list ( APPEND SERVICE_LIBS ${PYTHON_LIBRARY} )
if( NOT WALBERLA_CXX_COMPILER_IS_MSVC )
list ( APPEND SERVICE_LIBS -lutil )
endif()
if ( WALBERLA_BUILD_WITH_PYTHON_MODULE )
# a python module is a shared library - so everything has to be compiled to position independent code
# otherwise linking the static libs into the shared lib will result in errors
if( NOT WALBERLA_CXX_COMPILER_IS_MSVC )
add_flag ( CMAKE_CXX_FLAGS "-fPIC" )
add_flag ( CMAKE_C_FLAGS "-fPIC" )
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pybind11; print(pybind11._version.__version__)"
OUTPUT_VARIABLE pybind11_VERSION ERROR_QUIET RESULT_VARIABLE pybind11_VERSION_RESULT)
string(STRIP "${pybind11_VERSION}" pybind11_VERSION)
if(pybind11_VERSION_RESULT EQUAL "0" AND pybind11_VERSION VERSION_GREATER_EQUAL "2.6.0")
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11 --cmakedir
OUTPUT_VARIABLE PYBIND11_CMAKE_PATH)
string(STRIP "${PYBIND11_CMAKE_PATH}" PYBIND11_CMAKE_PATH)
find_package(pybind11 PATHS "${PYBIND11_CMAKE_PATH}" NO_DEFAULT_PATH REQUIRED)
else()
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
if(WALBERLA_GIT_SUBMODULE_AUTO)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
endif()
if( MSVC10 )
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION( PYTHON_FIXED_HYPOT_REDEFINITION "fixed _hypot redefinition by python" OFF "WALBERLA_BUILD_WITH_PYTHON" OFF )
if( NOT PYTHON_FIXED_HYPOT_REDEFINITION )
message( WARNING "Make sure you modified your pyconfig.h that _hypot is not redefined -> see: http://connect.microsoft.com/VisualStudio/feedback/details/633988/warning-in-math-h-line-162-re-nonstandard-extensions-used" )
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/pybind11/CMakeLists.txt")
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
message(FATAL_ERROR "Please update git submodules or install pybind11 via pip.")
else()
message(FATAL_ERROR "Please install pybind11 via pip or download it to ${PROJECT_SOURCE_DIR}/extern/pybind11.")
endif()
endif()
add_subdirectory(extern/pybind11)
# if pybind11 was installed into ${PYTHON_INCLUDE_DIR} (e.g. by pip), that will have a higher priority than the Git submodule unless we reorder the search path
# introduced in 2.6.0 (https://github.com/pybind/pybind11/issues/2709), fixed in 2.6.2 (https://github.com/pybind/pybind11/pull/2716)
set_property( TARGET pybind11::pybind11
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${PROJECT_SOURCE_DIR}/extern/pybind11/include" "${PYTHON_INCLUDE_DIR}")
endif()
# a python module is a shared library - so everything has to be compiled to position independent code
# otherwise linking the static libs into the shared lib will result in errors
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(WALBERLA_BUILD_DOC)
# Sphinx documentation
......@@ -659,16 +661,6 @@ else()
list ( APPEND waLBerla_OPTIONAL_BOOST_COMPONENTS system )
endif()
if ( WALBERLA_BUILD_WITH_PYTHON )
if( WALBERLA_CXX_COMPILER_IS_MSVC )
get_filename_component(PYTHON_REQUIRED_LIB ${PYTHON_LIBRARY} NAME_WE)
list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS ${PYTHON_REQUIRED_LIB} )
elseif( WALBERLA_USE_STD_FILESYSTEM OR WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM )
list( APPEND waLBerla_REQUIRED_BOOST_COMPONENTS system )
list( REMOVE_ITEM waLBerla_OPTIONAL_BOOST_COMPONENTS system )
endif()
endif()
# This variable is necessary, if the CMAKE version used is not aware of a more recent boost version (keep this up to date!)
set ( Boost_ADDITIONAL_VERSIONS
"1.45" "1.45.0" "1.46" "1.46.0" "1.46.1" "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0"
......@@ -727,18 +719,6 @@ if ( Boost_FOUND )
endif()
add_definitions ( -DBOOST_ALL_NO_LIB ) # Disable Boost auto-linking (CMAKE does that for us...)
#fix for static lib usage: http://stackoverflow.com/questions/11812463/boost-python-link-errors-under-windows-msvc10
if( PYTHONLIBS_FOUND AND Boost_USE_STATIC_LIBS)
add_definitions( -DBOOST_PYTHON_STATIC_LIB )
endif()
#fix for strange link behaviour of boost to python: boost only links to 'pyhton*.lib' and not to the absolute path
if( WIN32 AND PYTHONLIBS_FOUND )
get_filename_component( PYTHON_LIBRARY_DIR ${PYTHON_INCLUDE_DIR} PATH )
link_directories( ${PYTHON_LIBRARY_DIR}/libs )
list( APPEND LINK_DIRS ${PYTHON_LIBRARY_DIR}/libs )
endif()
set( WALBERLA_BUILD_WITH_BOOST TRUE CACHE INTERNAL "Build with Boost" )
else( Boost_FOUND )
if( (WALBERLA_USE_STD_EXPERIMENTAL_FILESYSTEM OR WALBERLA_USE_STD_FILESYSTEM) AND (WALBERLA_USE_STD_EXPERIMENTAL_ANY OR WALBERLA_USE_STD_ANY) AND (WALBERLA_USE_STD_EXPERIMENTAL_OPTIONAL OR WALBERLA_USE_STD_OPTIONAL) AND NOT WALBERLA_BUILD_WITH_PYTHON)
......@@ -754,31 +734,6 @@ else( Boost_FOUND )
endif( Boost_FOUND )
# Check if Python3 found and look for according boost python library
if ( WALBERLA_BUILD_WITH_PYTHON AND NOT WALBERLA_CXX_COMPILER_IS_MSVC)
SET(_boost_MULTITHREADED "")
if (Boost_USE_MULTITHREADED OR Boost_USE_MULTITHREADED_LIBRARY)
SET(_boost_MULTITHREADED "-mt")
endif()
if( PYTHON_LIBRARY MATCHES "python3" )
string(REPLACE "." ";" VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
list(GET VERSION_LIST 0 PY_VER_MAJOR)
list(GET VERSION_LIST 1 PY_VER_MINOR)
find_library( BOOST_PYTHON_LIBRARY NAMES
boost_python${PY_VER_MAJOR}${PY_VER_MINOR}${_boost_MULTITHREADED}
boost_python-py${PY_VER_MAJOR}${PY_VER_MINOR}${_boost_MULTITHREADED}
boost_python${PY_VER_MAJOR}${_boost_MULTITHREADED}
boost_python${_boost_MULTITHREADED}
PATHS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH )
else()
find_library( BOOST_PYTHON_LIBRARY NAMES boost_python${_boost_MULTITHREADED}
PATHS ${Boost_LIBRARY_DIRS} NO_DEFAULT_PATH )
endif()
message(STATUS "Using Boost Python Library ${BOOST_PYTHON_LIBRARY}" )
list ( APPEND SERVICE_LIBS ${BOOST_PYTHON_LIBRARY} )
endif()
############################################################################################################################
......
......@@ -32,6 +32,4 @@ endif()
# Python module
if ( WALBERLA_BUILD_WITH_PYTHON )
add_subdirectory( pythonmodule )
# no else with "EXLUDE_FROM_ALL" here, since if WALBERLA_BUILD_WITH_PYTHON_MODULE is not activated
# waLBerla was build without -fPIC , so no linking into shared library is possible
endif()
\ No newline at end of file
......@@ -15,7 +15,7 @@ add_subdirectory( PoiseuilleChannel )
add_subdirectory( ProbeVsExtraMessage )
add_subdirectory( SchaeferTurek )
add_subdirectory( UniformGrid )
if ( WALBERLA_BUILD_WITH_CODEGEN )
if ( WALBERLA_BUILD_WITH_CODEGEN AND WALBERLA_BUILD_WITH_PYTHON )
add_subdirectory( UniformGridGenerated )
add_subdirectory( PhaseFieldAllenCahn )
endif()
......
......@@ -4,4 +4,4 @@ waLBerla_link_files_to_builddir( "*.py" )
waLBerla_add_executable ( NAME FieldCommunication
DEPENDS blockforest core domain_decomposition field postprocessing sqlite )
DEPENDS blockforest core domain_decomposition field postprocessing sqlite python_coupling )
......@@ -36,7 +36,7 @@ class SingleMessageBufferedScheme
public:
typedef Stencil_T Stencil;
SingleMessageBufferedScheme( const weak_ptr_wrapper< StructuredBlockForest > & bf, const int tag = 17953 )
SingleMessageBufferedScheme( const weak_ptr< StructuredBlockForest > & bf, const int tag = 17953 )
: blockForest_( bf ), tag_( tag ) {}
inline void addDataToCommunicate( const shared_ptr< communication::UniformPackInfo > &packInfo )
......@@ -67,7 +67,7 @@ public:
private:
std::vector< shared_ptr< UniformBufferedScheme< Stencil>> > schemes_;
weak_ptr_wrapper< StructuredBlockForest > blockForest_;
weak_ptr< StructuredBlockForest > blockForest_;
int tag_;
};
......
......@@ -16,6 +16,7 @@ if (WALBERLA_BUILD_WITH_CUDA)
waLBerla_add_executable(NAME benchmark_multiphase
FILES benchmark_multiphase.cpp InitializerFunctions.cpp multiphase_codegen.py
DEPENDS blockforest core cuda field postprocessing lbm geometry timeloop gui BenchmarkPhaseFieldCodeGenGPU)
set_target_properties(benchmark_multiphase PROPERTIES CXX_VISIBILITY_PRESET hidden)
else ()
waLBerla_generate_target_from_python(NAME BenchmarkPhaseFieldCodeGenCPU
FILE multiphase_codegen.py
......@@ -31,5 +32,6 @@ else ()
waLBerla_add_executable(NAME benchmark_multiphase
FILES benchmark_multiphase.cpp InitializerFunctions.cpp multiphase_codegen.py
DEPENDS blockforest core field postprocessing lbm geometry timeloop gui BenchmarkPhaseFieldCodeGenCPU)
set_target_properties(benchmark_multiphase PROPERTIES CXX_VISIBILITY_PRESET hidden)
endif (WALBERLA_BUILD_WITH_CUDA)
......@@ -25,8 +25,6 @@
#include "field/communication/PackInfo.h"
#include "field/vtk/VTKWriter.h"
#include "python_coupling/DictWrapper.h"
namespace walberla
{
using PhaseField_T = GhostLayerField< real_t, 1 >;
......
......@@ -18,15 +18,12 @@
//
//======================================================================================================================
#include "core/Environment.h"
#include "core/logging/Initialization.h"
#include "core/math/Constants.h"
#include "field/FlagField.h"
#include "field/communication/PackInfo.h"
#include "field/vtk/VTKWriter.h"
#include "python_coupling/DictWrapper.h"
#pragma once
namespace walberla
......
......@@ -27,8 +27,6 @@
#include "field/AddToStorage.h"
#include "field/FlagField.h"
#include "field/communication/PackInfo.h"
#include "field/python/Exports.h"
#include "field/vtk/VTKWriter.h"
#include "geometry/InitBoundaryHandling.h"
......
......@@ -27,8 +27,6 @@ class Scenario:
self.scenario = 1 # 1 rising bubble, 2 RTI
self.config_dict = self.config()
self.csv_file = "benchmark.csv"
@wlb.member_callback
def config(self):
return {
......
waLBerla_link_files_to_builddir( "*.prm" )
#waLBerla_link_files_to_builddir( "simulation_setup" )
waLBerla_link_files_to_builddir( "simulation_setup" )
foreach (config srt trt mrt smagorinsky entropic smagorinsky_noopt entropic_kbc_n4
......@@ -25,6 +25,7 @@ foreach (config srt trt mrt smagorinsky entropic smagorinsky_noopt entropic_kbc_
waLBerla_add_executable(NAME UniformGridBenchmarkGPU_${config}
FILES UniformGridGPU.cpp
DEPENDS blockforest boundary core cuda domain_decomposition field geometry timeloop vtk gui UniformGridGPUGenerated_${config})
set_target_properties( UniformGridBenchmarkGPU_${config} PROPERTIES CXX_VISIBILITY_PRESET hidden)
endforeach ()
......@@ -46,4 +47,5 @@ foreach (config srt trt mrt smagorinsky entropic)
waLBerla_add_executable(NAME UniformGridBenchmarkGPU_AA_${config}
FILES UniformGridGPU_AA.cpp
DEPENDS blockforest boundary core cuda domain_decomposition field geometry timeloop vtk gui UniformGridGPUGenerated_AA_${config})
set_target_properties( UniformGridBenchmarkGPU_AA_${config} PROPERTIES CXX_VISIBILITY_PRESET hidden)
endforeach ()
......@@ -30,7 +30,7 @@ template<typename StencilType, typename GPUFieldType >
class UniformGridGPU_Communication
{
public:
explicit UniformGridGPU_Communication(weak_ptr_wrapper<StructuredBlockForest> bf, const BlockDataID & bdId,
explicit UniformGridGPU_Communication(weak_ptr<StructuredBlockForest> bf, const BlockDataID & bdId,
CommunicationSchemeType commSchemeType, bool cudaEnabledMPI = false)
: _commSchemeType(commSchemeType), _cpuCommunicationScheme(nullptr), _gpuPackInfo(nullptr),
_gpuCommunicationScheme(nullptr), _directScheme(nullptr)
......
......@@ -15,6 +15,7 @@ foreach(config trt smagorinsky mrt entropic_kbc_n4 cumulant )
waLBerla_add_executable ( NAME UniformGridBenchmarkGenerated_${config}
FILES UniformGridGenerated.cpp
DEPENDS blockforest boundary core domain_decomposition field geometry timeloop vtk gui
UniformGridGenerated_${config})
UniformGridGenerated_${config} python_coupling)
set_target_properties(UniformGridBenchmarkGenerated_${config} PROPERTIES CXX_VISIBILITY_PRESET hidden)
endforeach()
# waLBerla Python module
if ( WALBERLA_BUILD_WITH_PYTHON_MODULE )
set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field geometry lbm postprocessing python_coupling timeloop vtk)
if (WALBERLA_BUILD_WITH_CUDA)
set(PYTHON_MODULE_DEPENDENCIES ${PYTHON_MODULE_DEPENDENCIES} cuda)
endif()
if (WALBERLA_BUILD_WITH_OPENMESH)
set(PYTHON_MODULE_DEPENDENCIES ${PYTHON_MODULE_DEPENDENCIES} mesh pe)
if ( WALBERLA_BUILD_WITH_PYTHON )
if ( WALBERLA_BUILD_WITH_CUDA )
set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field python_coupling timeloop vtk cuda)
else()
set(PYTHON_MODULE_DEPENDENCIES blockforest boundary domain_decomposition core field python_coupling timeloop vtk)
endif()
if( WALBERLA_CXX_COMPILER_IS_MSVC )
set ( pythonModules ${PYTHON_MODULE_DEPENDENCIES})
set ( pythonModules ${PYTHON_MODULE_DEPENDENCIES})
elseif( APPLE )
set ( pythonModules "-Wl,-force_load" ${PYTHON_MODULE_DEPENDENCIES})
set ( pythonModules "-Wl,-force_load" ${PYTHON_MODULE_DEPENDENCIES})
else()
set ( pythonModules "-Wl,-whole-archive" ${PYTHON_MODULE_DEPENDENCIES} "-Wl,-no-whole-archive" )
set ( pythonModules "-Wl,-whole-archive" ${PYTHON_MODULE_DEPENDENCIES} "-Wl,-no-whole-archive" )
endif()
if( WALBERLA_BUILD_WITH_PYTHON_LBM )
add_library( walberla_cpp SHARED PythonModuleWithLbmModule.cpp )
else()
add_library( walberla_cpp SHARED PythonModule.cpp )
endif()
add_library( walberla_cpp SHARED PythonModule.cpp )
target_link_libraries( walberla_cpp ${WALBERLA_LINK_LIBRARIES_KEYWORD} ${pythonModules} ${SERVICE_LIBS} )
set_target_properties( walberla_cpp PROPERTIES PREFIX "")
if ( APPLE )
set_target_properties( walberla_cpp PROPERTIES SUFFIX ".so")
endif()
target_link_libraries( walberla_cpp ${WALBERLA_LINK_LIBRARIES_KEYWORD} ${pythonModules} ${SERVICE_LIBS} )
set_target_properties(
walberla_cpp PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}"
)
set_target_properties( walberla_cpp PROPERTIES MACOSX_RPATH TRUE )
set_target_properties( walberla_cpp PROPERTIES CXX_VISIBILITY_PRESET hidden)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/setup.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py )
add_custom_target( pythonModule ALL ${PYTHON_EXECUTABLE} setup.py build DEPENDS walberla_cpp )
add_custom_target( pythonModuleInstall ${PYTHON_EXECUTABLE} setup.py install DEPENDS walberla_cpp )
add_test( NAME PythonModuleTest
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover -v -s ${walberla_SOURCE_DIR}/python/waLBerla_tests )
add_custom_target( pythonModuleInstall ${PYTHON_EXECUTABLE} setup.py install --user DEPENDS walberla_cpp )
endif()
......@@ -15,125 +15,84 @@
//
//! \file PythonModule.cpp
//! \author Martin Bauer <martin.bauer@fau.de>
//! \author Markus Holzer <markus.holzer@fau.de>
//
//======================================================================================================================
#include "python_coupling/PythonWrapper.h"
#include "waLBerlaDefinitions.h"
#include "blockforest/python/Exports.h"
#include "field/GhostLayerField.h"
#include "field/python/Exports.h"
#include "mesh/python/Exports.h"
#include "geometry/python/Exports.h"
#include "postprocessing/python/Exports.h"
#include "python_coupling/Manager.h"
#include "python_coupling/export/BlockForestExport.h"
#include "python_coupling/export/FieldExports.h"
#include "python_coupling/export/VTKExport.h"
#include "python_coupling/helper/ModuleInit.h"
#include "stencil/all.h"
#include "timeloop/python/Exports.h"
#include "vtk/python/Exports.h"
#ifdef WALBERLA_BUILD_WITH_CUDA
#include "cuda/python/Exports.h"
#include "python_coupling/export/CUDAExport.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;
using namespace walberla;
#define FIELD_TYPES \
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>
#define GPU_FIELD_TYPES \
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>
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_TYPES> );
pythonManager->addExporterFunction( field::exportGatherFunctions<FIELD_TYPES> );
pythonManager->addBlockDataConversion<FIELD_TYPES>();
// Blockforest
pythonManager->addExporterFunction( blockforest::exportModuleToPython<Stencils> );
// Geometry
pythonManager->addExporterFunction( geometry::exportModuleToPython );
pythonManager->addExporterFunction(blockforest::exportModuleToPython<stencil::D2Q5, stencil::D2Q9, stencil::D3Q7, stencil::D3Q19, stencil::D3Q27>);
// VTK
pythonManager->addExporterFunction( vtk::exportModuleToPython );
// Postprocessing
pythonManager->addExporterFunction( postprocessing::exportModuleToPython<FieldTypesForMeshGeneration, FlagFieldTypes> );
// Timeloop
pythonManager->addExporterFunction( timeloop::exportModuleToPython );
#ifdef WALBERLA_BUILD_WITH_OPENMESH
pythonManager->addExporterFunction( mesh::exportModuleToPython<FlagFieldTypes> );
#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>();
#endif
#ifdef WALBERLA_BUILD_WITH_CUDA
using walberla::cuda::GPUField;
pythonManager->addExporterFunction( cuda::exportModuleToPython<GPU_FIELD_TYPES> );
pythonManager->addExporterFunction( cuda::exportCopyFunctionsToPython<FIELD_TYPES> );
pythonManager->addBlockDataConversion<GPU_FIELD_TYPES>();
#endif
//
python_coupling::initWalberlaForPythonModule();
}
};
InitObject globalInitObject;
InitObject globalInitObject;
\ No newline at end of file
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file PythonModule.cpp
//! \author Martin Bauer <martin.bauer@fau.de>
//
//======================================================================================================================
#include "python_coupling/PythonWrapper.h"