diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ea2435e59..73703dca6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -9,6 +9,10 @@ Notable changes include: * added MFV hydro from Hopkins 2015 with extension for ALE options * Build changes / improvements: + * PYBind11 libraries no longer depend on the structure of the PYB11 source directory. + * CMake interface for adding PYBind11 target libraries is modified to more closely match how C++ libraries are created. + * Multiple Spheral Python modules / CMake targets can be specified for a single directory. + * KernelIntegrator and FieldList directories are divided into 2 modules / targets. * tpl-manager.py will no longer use generic x86_64 configs for non LC systems. Users will be required to supply their own configs for pointing spack at external packages. * Bug Fixes / improvements: diff --git a/cmake/spheral/SpheralAddLibs.cmake b/cmake/spheral/SpheralAddLibs.cmake index 925957a3c..c4e0e20e2 100644 --- a/cmake/spheral/SpheralAddLibs.cmake +++ b/cmake/spheral/SpheralAddLibs.cmake @@ -123,26 +123,35 @@ function(spheral_add_cxx_library package_name _cxx_obj_list) set_target_properties(Spheral_${package_name} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endfunction() +#---------------------------------------------------------------------------------------- +# spheral_add_pybin11_library_package +#---------------------------------------------------------------------------------------- +# ------------------------------------------- +# VARIABLES THAT NEED TO BE PREVIOUSLY DEFINED +# ------------------------------------------- +# SPHERAL_BLT_DEPENDS : REQUIRED : List of external dependencies +# EXTRA_PYB11_SPHERAL_ENV_VARS : OPTIONAL : Additional directories containing python filed, used by LLNLSpheral +# _headers : OPTIONAL : List of necessary headers to include +# _sources : OPTIONAL : List of necessary source files to include +# SPHERAL_SUBMOD_DEPENDS : REQUIRED : List of submodule dependencies +# ---------------------- +# INPUT-OUTPUT VARIABLES +# ---------------------- +# package_name : REQUIRED : Desired package name +# module_list_name : REQUIRED : The NAME of the global variable that is the list of +# Spheral python modules (not the list itself) +# INCLUDES : OPTIONAL : Target specific includes +# DEPENDS : OPTIONAL : Target specific dependencies +# SOURCE : OPTIONAL : Target specific sources +# ----------------------- +# OUTPUT VARIABLES TO USE - Made available implicitly after function call +# ----------------------- +# Spheral : Target for a given Spheral python module +# Spheral_src : Target for the PYB11Generated source code for a given Spheral module +# : List of Spheral python modules, appended with current module name +#---------------------------------------------------------------------------------------- -#----------------------------------------------------------------------------------- -# spheral_add_pybind11_library -# - Generate the python friendly Spheral package lib -# -# Args: -# package_name : *name* of spheral package to make into a library -# INCLUDES : optional, any additional include paths -# SOURCES : optional, any additional source files to compile into the library -# DEPENDS : optional, extra dependencies -# -# Variables that must be set before calling spheral_add_obj_library: -# spheral_depends -# - List of targets the library depends on -# SPHERAL_BLT_DEPENDS -# - List of blt/libs the library depends on -# -#----------------------------------------------------------------------------------- - -function(spheral_add_pybind11_library package_name) +function(spheral_add_pybind11_library package_name module_list_name) # Define our arguments set(options ) @@ -205,8 +214,6 @@ function(spheral_add_pybind11_library package_name) # Get the TPL dependencies get_property(SPHERAL_BLT_DEPENDS GLOBAL PROPERTY SPHERAL_BLT_DEPENDS) - get_property(spheral_tpl_includes GLOBAL PROPERTY spheral_tpl_includes) - get_property(spheral_tpl_libraries GLOBAL PROPERTY spheral_tpl_libraries) # If building shared libraries, use the SPHERAL_OBJ_LIBS global list # Note, LLNLSpheral has appended any local targets to this list as well if(ENABLE_DEV_BUILD) @@ -222,8 +229,7 @@ function(spheral_add_pybind11_library package_name) SOURCE ${package_name}_PYB11.py DEPENDS ${SPHERAL_BLT_DEPENDS} ${SPHERAL_CXX_DEPENDS} ${EXTRA_CXX_DEPENDS} ${SPHERAL_DEPENDS} PYTHONPATH ${PYTHON_ENV_STR} - INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${SPHERAL_INCLUDES} ${${package_name}_INCLUDES} ${spheral_tpl_includes} ${PYBIND11_ROOT_DIR}/include - LINKS ${spheral_tpl_libraries} + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${${package_name}_INCLUDES} ${PYBIND11_ROOT_DIR}/include COMPILE_OPTIONS ${SPHERAL_PYB11_TARGET_FLAGS} USE_BLT ON EXTRA_SOURCE ${${package_name}_SOURCES} @@ -235,7 +241,7 @@ function(spheral_add_pybind11_library package_name) install(TARGETS ${MODULE_NAME} DESTINATION ${SPHERAL_SITE_PACKAGES_PATH}/Spheral ) - + set_property(GLOBAL APPEND PROPERTY ${module_list_name} ${package_name}) # Set the r-path of the C++ lib such that it is independent of the build dir when installed set_target_properties(${MODULE_NAME} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") diff --git a/cmake/spheral/SpheralInstallPythonFiles.cmake b/cmake/spheral/SpheralInstallPythonFiles.cmake index f5cf96408..01f90b749 100644 --- a/cmake/spheral/SpheralInstallPythonFiles.cmake +++ b/cmake/spheral/SpheralInstallPythonFiles.cmake @@ -12,7 +12,7 @@ function(spheral_install_python_files) if (NOT ENABLE_CXXONLY) install(FILES ${ARGV} - DESTINATION DESTINATION ${SPHERAL_SITE_PACKAGES_PATH}/Spheral) + DESTINATION ${SPHERAL_SITE_PACKAGES_PATH}/Spheral) install(CODE "execute_process( \ COMMAND ${PYTHON_EXE} -m compileall DESTINATION ${SPHERAL_SITE_PACKAGES_PATH}/Spheral \ WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX})") diff --git a/src/PYB11/ANEOS/CMakeLists.txt b/src/PYB11/ANEOS/CMakeLists.txt index fb3653ffb..3928d40ca 100644 --- a/src/PYB11/ANEOS/CMakeLists.txt +++ b/src/PYB11/ANEOS/CMakeLists.txt @@ -1,2 +1,2 @@ -spheral_add_pybind11_library(ANEOS - INCLUDES ${SPHERAL_ROOT_DIR}/src/Pybind11Wraps/ANEOS) +spheral_add_pybind11_library(ANEOS SPHERAL_MODULE_LIST + INCLUDES ${SPHERAL_ROOT_DIR}/src/Pybind11Wraps/ANEOS SPHERAL_MODULE_LIST) diff --git a/src/PYB11/ArtificialConduction/CMakeLists.txt b/src/PYB11/ArtificialConduction/CMakeLists.txt index 5c44d52ed..f84b877e9 100644 --- a/src/PYB11/ArtificialConduction/CMakeLists.txt +++ b/src/PYB11/ArtificialConduction/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(ArtificialConduction) +spheral_add_pybind11_library(ArtificialConduction SPHERAL_MODULE_LIST) diff --git a/src/PYB11/ArtificialViscosity/CMakeLists.txt b/src/PYB11/ArtificialViscosity/CMakeLists.txt index bd55c1a13..61c6cb737 100644 --- a/src/PYB11/ArtificialViscosity/CMakeLists.txt +++ b/src/PYB11/ArtificialViscosity/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(ArtificialViscosity) +spheral_add_pybind11_library(ArtificialViscosity SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Boundary/CMakeLists.txt b/src/PYB11/Boundary/CMakeLists.txt index 7cbc49954..0e58f9f04 100644 --- a/src/PYB11/Boundary/CMakeLists.txt +++ b/src/PYB11/Boundary/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Boundary) +spheral_add_pybind11_library(Boundary SPHERAL_MODULE_LIST) diff --git a/src/PYB11/CMakeLists.txt b/src/PYB11/CMakeLists.txt index 0bd7616c5..5f315c582 100644 --- a/src/PYB11/CMakeLists.txt +++ b/src/PYB11/CMakeLists.txt @@ -1,3 +1,4 @@ +# When Python targets are created, they add the module name to SPHERAL_MODULE_LIST set (_python_packages CXXTypes CXXTests @@ -65,7 +66,9 @@ foreach(_python_package ${_python_packages}) add_subdirectory(${_python_package}) endforeach() -string(REPLACE ";" " " PYTHONPKGS "${_python_packages}") +# This global list is filled in each spheral_add_pybind11_library call +get_property(SPHERAL_MODULE_LIST GLOBAL PROPERTY SPHERAL_MODULE_LIST) +string(REPLACE ";" " " PYTHONPKGS "${SPHERAL_MODULE_LIST}") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/SpheralCompiledPackages.py.in ${CMAKE_CURRENT_BINARY_DIR}/SpheralCompiledPackages.py) diff --git a/src/PYB11/CRKSPH/CMakeLists.txt b/src/PYB11/CRKSPH/CMakeLists.txt index 95da6e17b..cbf094303 100644 --- a/src/PYB11/CRKSPH/CMakeLists.txt +++ b/src/PYB11/CRKSPH/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(CRKSPH) +spheral_add_pybind11_library(CRKSPH SPHERAL_MODULE_LIST) diff --git a/src/PYB11/CXXTests/CMakeLists.txt b/src/PYB11/CXXTests/CMakeLists.txt index 0f0e06c14..0fb9f3d46 100644 --- a/src/PYB11/CXXTests/CMakeLists.txt +++ b/src/PYB11/CXXTests/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(CXXTests) +spheral_add_pybind11_library(CXXTests SPHERAL_MODULE_LIST) diff --git a/src/PYB11/CXXTypes/CMakeLists.txt b/src/PYB11/CXXTypes/CMakeLists.txt index f2da69bcc..7cd5128e3 100644 --- a/src/PYB11/CXXTypes/CMakeLists.txt +++ b/src/PYB11/CXXTypes/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(CXXTypes) +spheral_add_pybind11_library(CXXTypes SPHERAL_MODULE_LIST) diff --git a/src/PYB11/DEM/CMakeLists.txt b/src/PYB11/DEM/CMakeLists.txt index f3bca78b6..4ea9b8d57 100644 --- a/src/PYB11/DEM/CMakeLists.txt +++ b/src/PYB11/DEM/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(DEM) +spheral_add_pybind11_library(DEM SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Damage/CMakeLists.txt b/src/PYB11/Damage/CMakeLists.txt index e0bcf9aca..fd99f8525 100644 --- a/src/PYB11/Damage/CMakeLists.txt +++ b/src/PYB11/Damage/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Damage) +spheral_add_pybind11_library(Damage SPHERAL_MODULE_LIST) diff --git a/src/PYB11/DataBase/CMakeLists.txt b/src/PYB11/DataBase/CMakeLists.txt index 282fae011..cbf20d21c 100644 --- a/src/PYB11/DataBase/CMakeLists.txt +++ b/src/PYB11/DataBase/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(DataBase) +spheral_add_pybind11_library(DataBase SPHERAL_MODULE_LIST) diff --git a/src/PYB11/DataOutput/CMakeLists.txt b/src/PYB11/DataOutput/CMakeLists.txt index 2fc511f0d..46f27e5dd 100644 --- a/src/PYB11/DataOutput/CMakeLists.txt +++ b/src/PYB11/DataOutput/CMakeLists.txt @@ -1,3 +1,3 @@ -spheral_add_pybind11_library(DataOutput +spheral_add_pybind11_library(DataOutput SPHERAL_MODULE_LIST SOURCES RestartableObject.cc - INCLUDES ${SPHERAL_ROOT_DIR}/src/Pybind11Wraps/DataOutput) + INCLUDES ${SPHERAL_ROOT_DIR}/src/Pybind11Wraps/DataOutput SPHERAL_MODULE_LIST) diff --git a/src/PYB11/DeviceTestLib/CMakeLists.txt b/src/PYB11/DeviceTestLib/CMakeLists.txt index 34cbcefba..d13d8afcd 100644 --- a/src/PYB11/DeviceTestLib/CMakeLists.txt +++ b/src/PYB11/DeviceTestLib/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(DeviceTestLib) +spheral_add_pybind11_library(DeviceTestLib SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Distributed/CMakeLists.txt b/src/PYB11/Distributed/CMakeLists.txt index e06115c23..3379683c1 100644 --- a/src/PYB11/Distributed/CMakeLists.txt +++ b/src/PYB11/Distributed/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Distributed) +spheral_add_pybind11_library(Distributed SPHERAL_MODULE_LIST) diff --git a/src/PYB11/ExternalForce/CMakeLists.txt b/src/PYB11/ExternalForce/CMakeLists.txt index d5d94ec18..ff6afcda9 100644 --- a/src/PYB11/ExternalForce/CMakeLists.txt +++ b/src/PYB11/ExternalForce/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(ExternalForce) +spheral_add_pybind11_library(ExternalForce SPHERAL_MODULE_LIST) diff --git a/src/PYB11/FSISPH/CMakeLists.txt b/src/PYB11/FSISPH/CMakeLists.txt index 7def85deb..87856b9f0 100644 --- a/src/PYB11/FSISPH/CMakeLists.txt +++ b/src/PYB11/FSISPH/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(FSISPH) +spheral_add_pybind11_library(FSISPH SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Field/CMakeLists.txt b/src/PYB11/Field/CMakeLists.txt index cef6c4d1b..cd57e205e 100644 --- a/src/PYB11/Field/CMakeLists.txt +++ b/src/PYB11/Field/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Field) +spheral_add_pybind11_library(Field SPHERAL_MODULE_LIST) diff --git a/src/PYB11/FieldList/ArithmeticFieldList.py b/src/PYB11/FieldList/ArithmeticFieldList.py index 06a07b16d..865a6022e 100644 --- a/src/PYB11/FieldList/ArithmeticFieldList.py +++ b/src/PYB11/FieldList/ArithmeticFieldList.py @@ -1,12 +1,13 @@ from PYB11Generator import * -from FieldList import * +import FieldList +import FieldListBase #------------------------------------------------------------------------------- # FieldList with numeric operations #------------------------------------------------------------------------------- @PYB11template("Dimension", "Value") @PYB11pycppname("FieldList") -class ArithmeticFieldList(FieldListBase): +class ArithmeticFieldList(FieldListBase.FieldListBase): PYB11typedefs = """ typedef FieldList<%(Dimension)s, %(Value)s> FieldListType; @@ -138,4 +139,4 @@ def localMax(self): #------------------------------------------------------------------------------- # Inject FieldList #------------------------------------------------------------------------------- -PYB11inject(FieldList, ArithmeticFieldList) +PYB11inject(FieldList.FieldList, ArithmeticFieldList) diff --git a/src/PYB11/FieldList/ArithmeticFieldList_PYB11.py b/src/PYB11/FieldList/ArithmeticFieldList_PYB11.py new file mode 100644 index 000000000..fb6b7e4f9 --- /dev/null +++ b/src/PYB11/FieldList/ArithmeticFieldList_PYB11.py @@ -0,0 +1,62 @@ +""" +Spheral ArithmeticFieldList module. + +Provides the ArithmeticFieldList classes. +""" + +from PYB11Generator import * +from SpheralCommon import * +from spheralDimensions import * +dims = spheralDimensions() + +from ArithmeticFieldList import * +from MinMaxFieldList import * + +#------------------------------------------------------------------------------- +# Includes +#------------------------------------------------------------------------------- +PYB11includes += ['"Geometry/Dimension.hh"', + '"Field/FieldBase.hh"', + '"Field/Field.hh"', + '"Field/FieldList.hh"', + '"Field/FieldListSet.hh"', + '"Utilities/FieldDataTypeTraits.hh"', + '"Utilities/DomainNode.hh"', + '"Geometry/CellFaceFlag.hh"', + ''] + +#------------------------------------------------------------------------------- +# Namespaces +#------------------------------------------------------------------------------- +PYB11namespaces = ["Spheral"] + +#------------------------------------------------------------------------------- +# Do our dimension dependent instantiations. +#------------------------------------------------------------------------------- +for ndim in dims: + + #........................................................................... + # arithmetic fields + for (value, label) in (("int", "Int"), + ("unsigned", "Unsigned"), + ("uint64_t", "ULL"), + ("Dim<%i>::Vector" % ndim, "Vector"), + ("Dim<%i>::Tensor" % ndim, "Tensor"), + ("Dim<%i>::ThirdRankTensor" % ndim, "ThirdRankTensor"), + ("Dim<%i>::FourthRankTensor" % ndim, "FourthRankTensor"), + ("Dim<%i>::FifthRankTensor" % ndim, "FifthRankTensor")): + exec(''' +%(label)sFieldList%(ndim)sd = PYB11TemplateClass(ArithmeticFieldList, template_parameters=("Dim<%(ndim)i>", "%(value)s")) +''' % {"ndim" : ndim, + "value" : value, + "label" : label}) + + #........................................................................... + # A few fields can apply the min/max with a scalar additionally + for (value, label) in (("double", "Scalar"), + ("Dim<%i>::SymTensor" % ndim, "SymTensor")): + exec(''' +%(label)sFieldList%(ndim)sd = PYB11TemplateClass(MinMaxFieldList, template_parameters=("Dim<%(ndim)i>", "%(value)s")) +''' % {"ndim" : ndim, + "value" : value, + "label" : label}) diff --git a/src/PYB11/FieldList/CMakeLists.txt b/src/PYB11/FieldList/CMakeLists.txt index fcaf75a06..31d0d6bf9 100644 --- a/src/PYB11/FieldList/CMakeLists.txt +++ b/src/PYB11/FieldList/CMakeLists.txt @@ -1 +1,2 @@ -spheral_add_pybind11_library(FieldList) +spheral_add_pybind11_library(FieldList SPHERAL_MODULE_LIST) +spheral_add_pybind11_library(ArithmeticFieldList SPHERAL_MODULE_LIST) diff --git a/src/PYB11/FieldList/FieldList_PYB11.py b/src/PYB11/FieldList/FieldList_PYB11.py index 44b93de36..919977646 100644 --- a/src/PYB11/FieldList/FieldList_PYB11.py +++ b/src/PYB11/FieldList/FieldList_PYB11.py @@ -11,8 +11,6 @@ from FieldListBase import * from FieldList import * -from ArithmeticFieldList import * -from MinMaxFieldList import * from FieldListSet import * #------------------------------------------------------------------------------- @@ -58,32 +56,6 @@ ("RKCoefficients>" % ndim, "RKCoefficients")): exec(''' %(label)sFieldList%(ndim)sd = PYB11TemplateClass(FieldList, template_parameters=("Dim<%(ndim)i>", "%(value)s")) -''' % {"ndim" : ndim, - "value" : value, - "label" : label}) - - #........................................................................... - # arithmetic fields - for (value, label) in (("int", "Int"), - ("unsigned", "Unsigned"), - ("uint64_t", "ULL"), - ("Dim<%i>::Vector" % ndim, "Vector"), - ("Dim<%i>::Tensor" % ndim, "Tensor"), - ("Dim<%i>::ThirdRankTensor" % ndim, "ThirdRankTensor"), - ("Dim<%i>::FourthRankTensor" % ndim, "FourthRankTensor"), - ("Dim<%i>::FifthRankTensor" % ndim, "FifthRankTensor")): - exec(''' -%(label)sFieldList%(ndim)sd = PYB11TemplateClass(ArithmeticFieldList, template_parameters=("Dim<%(ndim)i>", "%(value)s")) -''' % {"ndim" : ndim, - "value" : value, - "label" : label}) - - #........................................................................... - # A few fields can apply the min/max with a scalar addtionally - for (value, label) in (("double", "Scalar"), - ("Dim<%i>::SymTensor" % ndim, "SymTensor")): - exec(''' -%(label)sFieldList%(ndim)sd = PYB11TemplateClass(MinMaxFieldList, template_parameters=("Dim<%(ndim)i>", "%(value)s")) ''' % {"ndim" : ndim, "value" : value, "label" : label}) diff --git a/src/PYB11/FieldList/MinMaxFieldList.py b/src/PYB11/FieldList/MinMaxFieldList.py index ba7f3b81b..e07d6cba5 100644 --- a/src/PYB11/FieldList/MinMaxFieldList.py +++ b/src/PYB11/FieldList/MinMaxFieldList.py @@ -1,4 +1,6 @@ from PYB11Generator import * +import FieldList +import FieldListBase from ArithmeticFieldList import * #------------------------------------------------------------------------------- @@ -6,7 +8,7 @@ #------------------------------------------------------------------------------- @PYB11template("Dimension", "Value") @PYB11pycppname("FieldList") -class MinMaxFieldList(FieldListBase): +class MinMaxFieldList(FieldListBase.FieldListBase): PYB11typedefs = """ typedef FieldList<%(Dimension)s, %(Value)s> FieldListType; diff --git a/src/PYB11/FieldOperations/CMakeLists.txt b/src/PYB11/FieldOperations/CMakeLists.txt index 382841c08..88a97063e 100644 --- a/src/PYB11/FieldOperations/CMakeLists.txt +++ b/src/PYB11/FieldOperations/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(FieldOperations) +spheral_add_pybind11_library(FieldOperations SPHERAL_MODULE_LIST) diff --git a/src/PYB11/FileIO/CMakeLists.txt b/src/PYB11/FileIO/CMakeLists.txt index ebf301b6b..0bc255063 100644 --- a/src/PYB11/FileIO/CMakeLists.txt +++ b/src/PYB11/FileIO/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(FileIO) +spheral_add_pybind11_library(FileIO SPHERAL_MODULE_LIST) diff --git a/src/PYB11/GSPH/CMakeLists.txt b/src/PYB11/GSPH/CMakeLists.txt index 6cefb5c49..1d5145dfe 100644 --- a/src/PYB11/GSPH/CMakeLists.txt +++ b/src/PYB11/GSPH/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(GSPH) +spheral_add_pybind11_library(GSPH SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Geometry/CMakeLists.txt b/src/PYB11/Geometry/CMakeLists.txt index dc4597126..c7897781f 100644 --- a/src/PYB11/Geometry/CMakeLists.txt +++ b/src/PYB11/Geometry/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Geometry) +spheral_add_pybind11_library(Geometry SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Gravity/CMakeLists.txt b/src/PYB11/Gravity/CMakeLists.txt index 8a2771873..f5ebde927 100644 --- a/src/PYB11/Gravity/CMakeLists.txt +++ b/src/PYB11/Gravity/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Gravity) +spheral_add_pybind11_library(Gravity SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Helmholtz/CMakeLists.txt b/src/PYB11/Helmholtz/CMakeLists.txt index 7728c4db7..282432baa 100644 --- a/src/PYB11/Helmholtz/CMakeLists.txt +++ b/src/PYB11/Helmholtz/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Helmholtz) +spheral_add_pybind11_library(Helmholtz SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Hydro/CMakeLists.txt b/src/PYB11/Hydro/CMakeLists.txt index 02fa9f751..8184a0f4a 100644 --- a/src/PYB11/Hydro/CMakeLists.txt +++ b/src/PYB11/Hydro/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Hydro) +spheral_add_pybind11_library(Hydro SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Integrator/CMakeLists.txt b/src/PYB11/Integrator/CMakeLists.txt index 7849fe7c4..ece5355cc 100644 --- a/src/PYB11/Integrator/CMakeLists.txt +++ b/src/PYB11/Integrator/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Integrator) +spheral_add_pybind11_library(Integrator SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Kernel/CMakeLists.txt b/src/PYB11/Kernel/CMakeLists.txt index d6594a020..9bb940469 100644 --- a/src/PYB11/Kernel/CMakeLists.txt +++ b/src/PYB11/Kernel/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Kernel) +spheral_add_pybind11_library(Kernel SPHERAL_MODULE_LIST) diff --git a/src/PYB11/KernelIntegrator/CMakeLists.txt b/src/PYB11/KernelIntegrator/CMakeLists.txt index ccdc9b032..f1c3df1c4 100644 --- a/src/PYB11/KernelIntegrator/CMakeLists.txt +++ b/src/PYB11/KernelIntegrator/CMakeLists.txt @@ -1 +1,2 @@ -spheral_add_pybind11_library(KernelIntegrator) +spheral_add_pybind11_library(KernelIntegrator SPHERAL_MODULE_LIST) +spheral_add_pybind11_library(IntegrationKernels SPHERAL_MODULE_LIST) diff --git a/src/PYB11/KernelIntegrator/IntegrationCoefficient.py b/src/PYB11/KernelIntegrator/IntegrationCoefficient.py index 39ab6a73b..505e4d251 100644 --- a/src/PYB11/KernelIntegrator/IntegrationCoefficient.py +++ b/src/PYB11/KernelIntegrator/IntegrationCoefficient.py @@ -60,24 +60,4 @@ def evaluateCoefficient(self, kid = "const KernelIntegrationData<%(Dimension)s>&"): "Return a value for the coefficient" return "%(CoefficientType)s" - -@PYB11template("Dimension", "CoefficientType") -@PYB11holder("std::shared_ptr") -class IntegralDependsOnCoefficient: - def pyinit(self): - "Choose coefficient for integral (coefficient defaults to one)" - - coefficient = PYB11property(doc="The coefficient", - getter = "getCoefficient", - setter = "setCoefficient") -@PYB11template("Dimension", "CoefficientType") -@PYB11holder("std::shared_ptr") -class IntegralDependsOnFieldListCoefficient: - def pyinit(self): - "Choose coefficient for integral" - - coefficient = PYB11property(doc="The coefficient", - getter = "getCoefficient", - setter = "setCoefficient") - diff --git a/src/PYB11/KernelIntegrator/IntegrationKernels_PYB11.py b/src/PYB11/KernelIntegrator/IntegrationKernels_PYB11.py new file mode 100644 index 000000000..85f7fcaa1 --- /dev/null +++ b/src/PYB11/KernelIntegrator/IntegrationKernels_PYB11.py @@ -0,0 +1,90 @@ +""" +Spheral IntegrationKernels module +""" + +from PYB11Generator import * +from SpheralCommon import * +from spheralDimensions import * +dims = spheralDimensions() + +from BilinearIndex import * +from FlatConnectivity import * +from KernelIntegrationData import * +from IntegrationCoefficient import * +from IntegrationKernel import * +from KernelIntegrator import * +from ManufacturedSolution import * +from RKIntegrationKernel import * +from SPHIntegrationKernel import * + +#------------------------------------------------------------------------------- +# Includes +#------------------------------------------------------------------------------- +PYB11includes += ['', + '', + '', + '', + '', + '"Boundary/Boundary.hh"', + '"DataBase/DataBase.hh"', + '"DataBase/State.hh"', + '"Field/FieldList.hh"', + '"Geometry/GeomPlane.hh"', + '"Hydro/HydroFieldNames.hh"', + '"KernelIntegrator/BilinearIndex.hh"', + '"KernelIntegrator/FlatConnectivity.hh"', + '"KernelIntegrator/IntegrationCoefficient.hh"', + '"KernelIntegrator/IntegrationKernel.hh"', + '"KernelIntegrator/KernelIntegrationData.hh"', + '"KernelIntegrator/KernelIntegrator.hh"', + '"KernelIntegrator/ManufacturedSolution.hh"', + '"KernelIntegrator/RKIntegrationKernel.hh"', + '"KernelIntegrator/SPHIntegrationKernel.hh"'] + +#------------------------------------------------------------------------------- +# Namespaces +#------------------------------------------------------------------------------- +PYB11namespaces = ["Spheral"] + +#------------------------------------------------------------------------------- +# Instantiations +#------------------------------------------------------------------------------- +for ndim in dims: + # Dimension-dependent + exec(''' +BilinearIndex%(ndim)id = PYB11TemplateClass(BilinearIndex, template_parameters="Dim<%(ndim)i>") +FlatConnectivity%(ndim)id = PYB11TemplateClass(FlatConnectivity, template_parameters="Dim<%(ndim)i>") +IntegrationKernel%(ndim)id = PYB11TemplateClass(IntegrationKernel, template_parameters="Dim<%(ndim)i>") +SPHIntegrationKernel%(ndim)id = PYB11TemplateClass(SPHIntegrationKernel, template_parameters="Dim<%(ndim)i>") +KernelIntegrator%(ndim)id = PYB11TemplateClass(KernelIntegrator, template_parameters="Dim<%(ndim)i>") +KernelIntegrationData%(ndim)id = PYB11TemplateClass(KernelIntegrationData, template_parameters="Dim<%(ndim)i>") +ManufacturedFunction%(ndim)id = PYB11TemplateClass(ManufacturedFunction, template_parameters="Dim<%(ndim)i>") +ManufacturedSteadyStateFunction%(ndim)id = PYB11TemplateClass(ManufacturedSteadyStateFunction, template_parameters="Dim<%(ndim)i>") +ManufacturedConstantFunction%(ndim)id = PYB11TemplateClass(ManufacturedConstantFunction, template_parameters="Dim<%(ndim)i>") +ManufacturedSinusoidalFunction%(ndim)id = PYB11TemplateClass(ManufacturedSinusoidalFunction, template_parameters="Dim<%(ndim)i>") +ManufacturedWaveFunction%(ndim)id = PYB11TemplateClass(ManufacturedWaveFunction, template_parameters="Dim<%(ndim)i>") +ManufacturedTransportSolution%(ndim)id = PYB11TemplateClass(ManufacturedTransportSolution, template_parameters="Dim<%(ndim)i>") +''' % {"ndim" : ndim}) + + # Dependent on primitives + dim_types = (("Dim<%i>::Scalar" % ndim, "Scalar"), + ("Dim<%i>::Vector" % ndim, "Vector"), + ("Dim<%i>::SymTensor" % ndim, "SymTensor"), + ("Dim<%i>::Tensor" % ndim, "Tensor"), + ("std::vector::Scalar>" % ndim, "StdVectorScalar"), + ("std::vector::Vector>" % ndim, "StdVectorVector")) + for (value, label) in dim_types: + exec(''' +%(label)sConstantIntegrationCoefficient%(ndim)id = PYB11TemplateClass(ConstantIntegrationCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) +%(label)sIntegrationCoefficient%(ndim)id = PYB11TemplateClass(IntegrationCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) +%(label)sFieldListIntegrationCoefficient%(ndim)id = PYB11TemplateClass(FieldListIntegrationCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) +''' % {"ndim" : ndim, + "value" : value, + "label" : label}) + + # Dependent on order + for order in (0, 1, 2, 3, 4, 5, 6, 7): + exec(''' +RKIntegrationKernel%(ndim)id%(order)s = PYB11TemplateClass(RKIntegrationKernel, template_parameters=("Dim<%(ndim)i>", "%(order)s")) +''' % {"ndim" : ndim, + "order" : order}) diff --git a/src/PYB11/KernelIntegrator/KernelIntegral.py b/src/PYB11/KernelIntegrator/KernelIntegral.py index d37a9583d..0f6dbd113 100644 --- a/src/PYB11/KernelIntegrator/KernelIntegral.py +++ b/src/PYB11/KernelIntegrator/KernelIntegral.py @@ -1,5 +1,24 @@ from PYB11Generator import * -from IntegrationCoefficient import * + +@PYB11template("Dimension", "CoefficientType") +@PYB11holder("std::shared_ptr") +class IntegralDependsOnCoefficient: + def pyinit(self): + "Choose coefficient for integral (coefficient defaults to one)" + + coefficient = PYB11property(doc="The coefficient", + getter = "getCoefficient", + setter = "setCoefficient") + +@PYB11template("Dimension", "CoefficientType") +@PYB11holder("std::shared_ptr") +class IntegralDependsOnFieldListCoefficient: + def pyinit(self): + "Choose coefficient for integral" + + coefficient = PYB11property(doc="The coefficient", + getter = "getCoefficient", + setter = "setCoefficient") @PYB11template("Dimension") @PYB11holder("std::shared_ptr") diff --git a/src/PYB11/KernelIntegrator/KernelIntegrator_PYB11.py b/src/PYB11/KernelIntegrator/KernelIntegrator_PYB11.py index 1967f71c3..eead96d2a 100644 --- a/src/PYB11/KernelIntegrator/KernelIntegrator_PYB11.py +++ b/src/PYB11/KernelIntegrator/KernelIntegrator_PYB11.py @@ -7,41 +7,12 @@ from spheralDimensions import * dims = spheralDimensions() -from BilinearIndex import * -from FlatConnectivity import * -from KernelIntegrationData import * -from IntegrationCoefficient import * -from IntegrationKernel import * from KernelIntegral import * -from KernelIntegrator import * -from ManufacturedSolution import * -from RKIntegrationKernel import * -from SPHIntegrationKernel import * #------------------------------------------------------------------------------- # Includes #------------------------------------------------------------------------------- -PYB11includes += ['', - '', - '', - '', - '', - '"Boundary/Boundary.hh"', - '"DataBase/DataBase.hh"', - '"DataBase/State.hh"', - '"Field/FieldList.hh"', - '"Geometry/GeomPlane.hh"', - '"Hydro/HydroFieldNames.hh"', - '"KernelIntegrator/BilinearIndex.hh"', - '"KernelIntegrator/FlatConnectivity.hh"', - '"KernelIntegrator/IntegrationCoefficient.hh"', - '"KernelIntegrator/IntegrationKernel.hh"', - '"KernelIntegrator/KernelIntegral.hh"', - '"KernelIntegrator/KernelIntegrationData.hh"', - '"KernelIntegrator/KernelIntegrator.hh"', - '"KernelIntegrator/ManufacturedSolution.hh"', - '"KernelIntegrator/RKIntegrationKernel.hh"', - '"KernelIntegrator/SPHIntegrationKernel.hh"'] +PYB11includes += ['"KernelIntegrator/KernelIntegral.hh"'] #------------------------------------------------------------------------------- # Namespaces @@ -54,12 +25,6 @@ for ndim in dims: # Dimension-dependent exec(''' -BilinearIndex%(ndim)id = PYB11TemplateClass(BilinearIndex, template_parameters="Dim<%(ndim)i>") -FlatConnectivity%(ndim)id = PYB11TemplateClass(FlatConnectivity, template_parameters="Dim<%(ndim)i>") -IntegrationKernel%(ndim)id = PYB11TemplateClass(IntegrationKernel, template_parameters="Dim<%(ndim)i>") -SPHIntegrationKernel%(ndim)id = PYB11TemplateClass(SPHIntegrationKernel, template_parameters="Dim<%(ndim)i>") -KernelIntegrator%(ndim)id = PYB11TemplateClass(KernelIntegrator, template_parameters="Dim<%(ndim)i>") -KernelIntegrationData%(ndim)id = PYB11TemplateClass(KernelIntegrationData, template_parameters="Dim<%(ndim)i>") KernelIntegralBase%(ndim)id = PYB11TemplateClass(KernelIntegralBase, template_parameters="Dim<%(ndim)i>") LinearKernel%(ndim)id = PYB11TemplateClass(LinearKernel, template_parameters="Dim<%(ndim)i>") LinearGrad%(ndim)id = PYB11TemplateClass(LinearGrad, template_parameters="Dim<%(ndim)i>") @@ -80,12 +45,6 @@ BilinearSurfaceNormalKernelDotGrad%(ndim)id = PYB11TemplateClass(BilinearSurfaceNormalKernelDotGrad, template_parameters="Dim<%(ndim)i>") CellCoefficient%(ndim)id = PYB11TemplateClass(CellCoefficient, template_parameters="Dim<%(ndim)i>") SurfaceNormalCoefficient%(ndim)id = PYB11TemplateClass(SurfaceNormalCoefficient, template_parameters="Dim<%(ndim)i>") -ManufacturedFunction%(ndim)id = PYB11TemplateClass(ManufacturedFunction, template_parameters="Dim<%(ndim)i>") -ManufacturedSteadyStateFunction%(ndim)id = PYB11TemplateClass(ManufacturedSteadyStateFunction, template_parameters="Dim<%(ndim)i>") -ManufacturedConstantFunction%(ndim)id = PYB11TemplateClass(ManufacturedConstantFunction, template_parameters="Dim<%(ndim)i>") -ManufacturedSinusoidalFunction%(ndim)id = PYB11TemplateClass(ManufacturedSinusoidalFunction, template_parameters="Dim<%(ndim)i>") -ManufacturedWaveFunction%(ndim)id = PYB11TemplateClass(ManufacturedWaveFunction, template_parameters="Dim<%(ndim)i>") -ManufacturedTransportSolution%(ndim)id = PYB11TemplateClass(ManufacturedTransportSolution, template_parameters="Dim<%(ndim)i>") ''' % {"ndim" : ndim}) # Dependent on primitives @@ -97,9 +56,6 @@ ("std::vector::Vector>" % ndim, "StdVectorVector")) for (value, label) in dim_types: exec(''' -%(label)sConstantIntegrationCoefficient%(ndim)id = PYB11TemplateClass(ConstantIntegrationCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) -%(label)sIntegrationCoefficient%(ndim)id = PYB11TemplateClass(IntegrationCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) -%(label)sFieldListIntegrationCoefficient%(ndim)id = PYB11TemplateClass(FieldListIntegrationCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) %(label)sIntegralDependsOnCoefficient%(ndim)id = PYB11TemplateClass(IntegralDependsOnCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) %(label)sIntegralDependsOnFieldListCoefficient%(ndim)id = PYB11TemplateClass(IntegralDependsOnFieldListCoefficient, template_parameters=("Dim<%(ndim)i>", "%(value)s")) %(label)sLinearIntegral%(ndim)id = PYB11TemplateClass(LinearIntegral, template_parameters=("Dim<%(ndim)i>", "%(value)s")) @@ -130,9 +86,3 @@ "value" : value, "label" : label}) - # Dependent on order - for order in (0, 1, 2, 3, 4, 5, 6, 7): - exec(''' -RKIntegrationKernel%(ndim)id%(order)s = PYB11TemplateClass(RKIntegrationKernel, template_parameters=("Dim<%(ndim)i>", "%(order)s")) -''' % {"ndim" : ndim, - "order" : order}) diff --git a/src/PYB11/Material/CMakeLists.txt b/src/PYB11/Material/CMakeLists.txt index 6e8e716bf..bf5451e39 100644 --- a/src/PYB11/Material/CMakeLists.txt +++ b/src/PYB11/Material/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Material) +spheral_add_pybind11_library(Material SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Mesh/CMakeLists.txt b/src/PYB11/Mesh/CMakeLists.txt index c540ead3e..dc506f232 100644 --- a/src/PYB11/Mesh/CMakeLists.txt +++ b/src/PYB11/Mesh/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Mesh) +spheral_add_pybind11_library(Mesh SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Neighbor/CMakeLists.txt b/src/PYB11/Neighbor/CMakeLists.txt index 593c0eb1c..5e8f1400f 100644 --- a/src/PYB11/Neighbor/CMakeLists.txt +++ b/src/PYB11/Neighbor/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Neighbor) +spheral_add_pybind11_library(Neighbor SPHERAL_MODULE_LIST) diff --git a/src/PYB11/NodeGenerators/CMakeLists.txt b/src/PYB11/NodeGenerators/CMakeLists.txt index a290129cb..2503281b1 100644 --- a/src/PYB11/NodeGenerators/CMakeLists.txt +++ b/src/PYB11/NodeGenerators/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(NodeGenerators) +spheral_add_pybind11_library(NodeGenerators SPHERAL_MODULE_LIST) diff --git a/src/PYB11/NodeList/CMakeLists.txt b/src/PYB11/NodeList/CMakeLists.txt index 20df18b4d..55484b8d9 100644 --- a/src/PYB11/NodeList/CMakeLists.txt +++ b/src/PYB11/NodeList/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(NodeList) +spheral_add_pybind11_library(NodeList SPHERAL_MODULE_LIST) diff --git a/src/PYB11/OpenMP/CMakeLists.txt b/src/PYB11/OpenMP/CMakeLists.txt index 7330e8208..a704dde86 100644 --- a/src/PYB11/OpenMP/CMakeLists.txt +++ b/src/PYB11/OpenMP/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(OpenMP) +spheral_add_pybind11_library(OpenMP SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Physics/CMakeLists.txt b/src/PYB11/Physics/CMakeLists.txt index 41877686b..61f57969d 100644 --- a/src/PYB11/Physics/CMakeLists.txt +++ b/src/PYB11/Physics/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Physics) +spheral_add_pybind11_library(Physics SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Porosity/CMakeLists.txt b/src/PYB11/Porosity/CMakeLists.txt index 2e6b33f04..7297d43ea 100644 --- a/src/PYB11/Porosity/CMakeLists.txt +++ b/src/PYB11/Porosity/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Porosity) +spheral_add_pybind11_library(Porosity SPHERAL_MODULE_LIST) diff --git a/src/PYB11/RK/CMakeLists.txt b/src/PYB11/RK/CMakeLists.txt index 47390c663..93ae0df86 100644 --- a/src/PYB11/RK/CMakeLists.txt +++ b/src/PYB11/RK/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(RK) +spheral_add_pybind11_library(RK SPHERAL_MODULE_LIST) diff --git a/src/PYB11/SPH/CMakeLists.txt b/src/PYB11/SPH/CMakeLists.txt index 0edd0012f..86faf08d8 100644 --- a/src/PYB11/SPH/CMakeLists.txt +++ b/src/PYB11/SPH/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(SPH) +spheral_add_pybind11_library(SPH SPHERAL_MODULE_LIST) diff --git a/src/PYB11/SVPH/CMakeLists.txt b/src/PYB11/SVPH/CMakeLists.txt index 266df8232..bd78ae13c 100644 --- a/src/PYB11/SVPH/CMakeLists.txt +++ b/src/PYB11/SVPH/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(SVPH) +spheral_add_pybind11_library(SVPH SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Silo/CMakeLists.txt b/src/PYB11/Silo/CMakeLists.txt index c82e3adf6..4749870b0 100644 --- a/src/PYB11/Silo/CMakeLists.txt +++ b/src/PYB11/Silo/CMakeLists.txt @@ -1,8 +1,8 @@ # Ignore -Wterminate warning that is thrown from DBC.hh VERIFY2 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - set_source_files_properties(SpheralSilo.cc PROPERTIES COMPILE_FLAGS -Wno-terminate) + set_source_files_properties(SpheralSilo SPHERAL_MODULE_LIST.cc PROPERTIES COMPILE_FLAGS -Wno-terminate) endif() -spheral_add_pybind11_library(Silo - INCLUDES ${SPHERAL_ROOT_DIR}/src/Pybind11Wraps/Silo) +spheral_add_pybind11_library(Silo SPHERAL_MODULE_LIST + INCLUDES ${SPHERAL_ROOT_DIR}/src/Pybind11Wraps/Silo SPHERAL_MODULE_LIST) diff --git a/src/PYB11/SolidMaterial/CMakeLists.txt b/src/PYB11/SolidMaterial/CMakeLists.txt index 592b32f37..d6c07c99b 100644 --- a/src/PYB11/SolidMaterial/CMakeLists.txt +++ b/src/PYB11/SolidMaterial/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(SolidMaterial) +spheral_add_pybind11_library(SolidMaterial SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Strength/CMakeLists.txt b/src/PYB11/Strength/CMakeLists.txt index 5b9bcb531..3ba24b1ac 100644 --- a/src/PYB11/Strength/CMakeLists.txt +++ b/src/PYB11/Strength/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Strength) +spheral_add_pybind11_library(Strength SPHERAL_MODULE_LIST) diff --git a/src/PYB11/Utilities/CMakeLists.txt b/src/PYB11/Utilities/CMakeLists.txt index 0725a4c04..e6fae8760 100644 --- a/src/PYB11/Utilities/CMakeLists.txt +++ b/src/PYB11/Utilities/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(Utilities) +spheral_add_pybind11_library(Utilities SPHERAL_MODULE_LIST) diff --git a/src/PYB11/polytope/CMakeLists.txt b/src/PYB11/polytope/CMakeLists.txt index 5098ef6f3..d999c1837 100644 --- a/src/PYB11/polytope/CMakeLists.txt +++ b/src/PYB11/polytope/CMakeLists.txt @@ -1 +1 @@ -spheral_add_pybind11_library(polytope) +spheral_add_pybind11_library(polytope SPHERAL_MODULE_LIST)