Skip to content
Snippets Groups Projects
Commit bee06533 authored by Dave Moxey's avatar Dave Moxey
Browse files

Add automatic compilation of boost.numpy if numpy is not shipped with boost

parent d39dde0b
No related branches found
No related tags found
No related merge requests found
Showing
with 90 additions and 91 deletions
builds/
ThirdParty/
......@@ -15,7 +15,7 @@ LINK_DIRECTORIES(${NEKTAR++_LIBRARY_DIRS} ${NEKTAR++_TP_LIBRARY_DIRS})
MESSAGE(STATUS "Found Nektar++: version ${NEKTAR++_VERSION}")
# Find Boost.Python
FIND_PACKAGE(Boost REQUIRED COMPONENTS python system numpy)
FIND_PACKAGE(Boost REQUIRED COMPONENTS python system)
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
SET(BOOST_TMP_LIBS "${Boost_LIBRARIES}")
......@@ -24,10 +24,40 @@ FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibsNew REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
IF (Boost_VERSION VERSION_LESS 1.63)
# Find Boost.NumPy
FIND_PACKAGE(BoostNumPy REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${BOOST_NUMPY_INCLUDE_DIR})
SET(TPSRC ${CMAKE_SOURCE_DIR}/ThirdParty)
SET(TPBUILD ${CMAKE_BINARY_DIR}/ThirdParty)
SET(TPDIST ${CMAKE_BINARY_DIR}/ThirdParty/dist)
IF (NOT EXISTS ${TPSRC})
FILE(MAKE_DIRECTORY ${TPSRC})
ENDIF ()
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
# Try to find Boost.NumPy
FIND_PACKAGE(Boost QUIET COMPONENTS numpy)
IF (NOT BOOST_NUMPY_FOUND)
INCLUDE(ExternalProject)
EXTERNALPROJECT_ADD(
boost-numpy
PREFIX ${TPSRC}
GIT_REPOSITORY http://github.com/ndarray/Boost.NumPy.git
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/boost-numpy
BINARY_DIR ${TPBUILD}/boost-numpy
TMP_DIR ${TPBUILD}/boost-numpy-tmp
INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
${TPSRC}/boost-numpy
)
message(STATUS ${TPDIST})
SET(BOOST_NUMPY_LIB ${TPDIST}/lib64/${CMAKE_SHARED_LIBRARY_PREFIX}boost_numpy${CMAKE_SHARED_LIBRARY_SUFFIX})
INCLUDE_DIRECTORIES(SYSTEM ${TPDIST}/include)
ELSE()
ADD_DEFINITIONS(-DBOOST_HAS_NUMPY)
ENDIF()
# Define a macro which will create our libraries.
......@@ -38,9 +68,12 @@ MACRO(ADD_NEKPY_LIBRARY name sources)
SET_TARGET_PROPERTIES(_${name} PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(_${name} PROPERTIES SUFFIX ".so")
ADD_DEPENDENCIES(_${name} boost-numpy)
# Add target link libraries.
TARGET_LINK_LIBRARIES(_${name}
${BOOST_TMP_LIBS}
${BOOST_NUMPY_LIB}
${PYTHON_LIBRARIES}
${NEKTAR++_LIBRARIES}
${NEKTAR++_TP_LIBRARIES}
......
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <boost/python.hpp>
#include <NekPyConfig.hpp>
using namespace Nektar::LibUtilities;
namespace py = boost::python;
/**
* @brief Thin wrapper around SessionReader to provide a nicer Pythonic
* interface.
......
#include <vector>
#include <LibUtilities/BasicUtils/ShapeType.hpp>
#include <boost/python.hpp>
#include <NekPyConfig.hpp>
using namespace Nektar::LibUtilities;
namespace py = boost::python;
/**
* @brief Export for ShapeType enumeration.
......
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
//#include <numpy/ndarrayobject.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::LibUtilities;
namespace py = boost::python;
namespace np = boost::python::numpy;
template<typename T>
void CapsuleDestructor(void *ptr)
{
......
#include <LibUtilities/Foundations/Basis.h>
#include <LibUtilities/Foundations/ManagerAccess.h>
#include <boost/python.hpp>
#include "../Helper.hpp"
namespace py = boost::python;
#include <NekPyConfig.hpp>
using namespace Nektar::LibUtilities;
BasisSharedPtr Basis_Create(const BasisKey &pts)
......
#include <LibUtilities/Foundations/ManagerAccess.h>
#include <LibUtilities/Foundations/Points.h>
#include <LibUtilities/Foundations/PointsType.h>
#include <boost/python.hpp>
#include "../Helper.hpp"
#include <NekPyConfig.hpp>
namespace py = boost::python;
using namespace Nektar::LibUtilities;
typedef boost::shared_ptr<Points<double> > PointsSharedPtr;
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <NekPyConfig.hpp>
void export_Basis();
void export_Points();
......@@ -9,8 +8,6 @@ void export_ShapeType();
template<typename T>
void export_SharedArray();
namespace np = boost::python::numpy;
BOOST_PYTHON_MODULE(_LibUtilities)
{
np::initialize();
......
#ifdef BOOST_HAS_NUMPY
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
namespace py = boost::python;
namespace np = boost::python::numpy;
#else
#include <boost/python.hpp>
#include <boost/numpy.hpp>
namespace py = boost::python;
namespace np = boost::numpy;
#endif
#define SIZENAME(s) SIZE_##s
#define NEKPY_WRAP_ENUM(ENUMNAME,MAPNAME) \
{ \
......
#include <boost/python.hpp>
#include <SpatialDomains/Geometry.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
namespace py = boost::python;
// Thin wrapper for ContainsPoint
bool Geometry_ContainsPoint(GeometrySharedPtr geom,
const Array<OneD, const NekDouble>& gloCoord)
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <SpatialDomains/Geometry1D.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
namespace py = boost::python;
namespace np = boost::python::numpy;
void export_Geometry1D()
{
py::class_<Geometry1D, py::bases<Geometry>, boost::shared_ptr<Geometry1D>,
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <SpatialDomains/Geometry2D.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
namespace py = boost::python;
namespace np = boost::python::numpy;
void export_Geometry2D()
{
py::class_<Geometry2D, py::bases<Geometry>, boost::shared_ptr<Geometry2D>,
......
#include <SpatialDomains/MeshGraph.h>
#include <boost/python.hpp>
#include <NekPyConfig.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
using namespace boost::python;
/*
* @brief Lightweight wrapper around MeshGraph::Read to avoid wrapping
......@@ -25,18 +24,18 @@ static boost::shared_ptr<MeshGraph> (*MeshGraph_Read_2)(
*/
void export_MeshGraph()
{
class_<SegGeomMap>("SegGeomMap")
.def(map_indexing_suite<SegGeomMap, true>());
class_<QuadGeomMap>("QuadGeomMap")
.def(map_indexing_suite<QuadGeomMap, true>());
class_<TriGeomMap>("TriGeomMap")
.def(map_indexing_suite<TriGeomMap, true>());
class_<MeshGraph,
boost::shared_ptr<MeshGraph> >(
"MeshGraph", init<>())
.def(init<int, int>())
.def(init<LibUtilities::SessionReaderSharedPtr >())
py::class_<SegGeomMap>("SegGeomMap")
.def(py::map_indexing_suite<SegGeomMap, true>());
py::class_<QuadGeomMap>("QuadGeomMap")
.def(py::map_indexing_suite<QuadGeomMap, true>());
py::class_<TriGeomMap>("TriGeomMap")
.def(py::map_indexing_suite<TriGeomMap, true>());
py::class_<MeshGraph,
boost::shared_ptr<MeshGraph> >(
"MeshGraph", py::init<>())
.def(py::init<int, int>())
.def(py::init<LibUtilities::SessionReaderSharedPtr >())
.def("Read", MeshGraph_Read)
.def("Read", MeshGraph_Read_2)
......@@ -44,11 +43,11 @@ void export_MeshGraph()
.def("GetMeshDimension", &MeshGraph::GetMeshDimension)
.def("GetAllSegGeoms", &MeshGraph::GetAllSegGeoms,
return_internal_reference<>())
py::return_internal_reference<>())
.def("GetAllQuadGeoms", &MeshGraph::GetAllQuadGeoms,
return_internal_reference<>())
py::return_internal_reference<>())
.def("GetAllTriGeoms", &MeshGraph::GetAllTriGeoms,
return_internal_reference<>())
py::return_internal_reference<>())
;
}
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <SpatialDomains/QuadGeom.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
namespace py = boost::python;
namespace np = boost::python::numpy;
void export_QuadGeom()
{
py::class_<QuadGeom, py::bases<Geometry2D>, boost::shared_ptr<QuadGeom> >(
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <SpatialDomains/SegGeom.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
namespace py = boost::python;
namespace np = boost::python::numpy;
void export_SegGeom()
{
py::class_<SegGeom, py::bases<Geometry1D>, boost::shared_ptr<SegGeom> >(
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
namespace np = boost::python::numpy;
#include <NekPyConfig.hpp>
void export_Geometry();
void export_Geometry1D();
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <SpatialDomains/TriGeom.h>
#include <NekPyConfig.hpp>
using namespace Nektar;
using namespace Nektar::SpatialDomains;
namespace py = boost::python;
namespace np = boost::python::numpy;
void export_TriGeom()
{
py::class_<TriGeom, py::bases<Geometry2D>, boost::shared_ptr<TriGeom> >(
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <NekPyConfig.hpp>
#include <StdRegions/StdExpansion.h>
using namespace Nektar;
using namespace Nektar::StdRegions;
namespace py = boost::python;
namespace np = boost::python::numpy;
Array<OneD, NekDouble> StdExpansion_FwdTrans(
StdExpansionSharedPtr exp,
const Array<OneD, const NekDouble> &in)
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <NekPyConfig.hpp>
#include <StdRegions/StdQuadExp.h>
using namespace Nektar;
using namespace Nektar::StdRegions;
namespace py = boost::python;
namespace np = boost::python::numpy;
void export_StdQuadExp()
{
py::class_<StdQuadExp, py::bases<StdExpansion>,
......
#include <boost/python.hpp>
#include <boost/python/numpy.hpp>
#include <NekPyConfig.hpp>
void export_StdExpansion();
void export_StdSegExp();
void export_StdTriExp();
void export_StdQuadExp();
namespace np = boost::python::numpy;
BOOST_PYTHON_MODULE(_StdRegions)
{
np::initialize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment