Commit 14b6c976 authored by Dave Moxey's avatar Dave Moxey

Lots of updates to code locations, get Tester working with tutorial

parent af8a95db
......@@ -160,7 +160,6 @@ OPTION(NEKTAR_BUILD_PYTHON "Build Nektar++ Python bindings" OFF)
OPTION(NEKTAR_BUILD_PACKAGES "Build Nektar++ binary packages" OFF)
MARK_AS_ADVANCED(NEKTAR_BUILD_PACKAGES)
OPTION(NEKTAR_TEST_ALL "Include full set of regression tests to this build." OFF)
OPTION(NEKTAR_TEST_USE_HOSTFILE "Use a hostfile to explicitly specify number of
slots." OFF)
......@@ -250,6 +249,7 @@ INCLUDE (ThirdPartyOCE)
INCLUDE (ThirdPartyTriangle)
INCLUDE (ThirdPartyTetGen)
INCLUDE (ThirdPartyCCM)
INCLUDE (ThirdPartyPython)
INCLUDE (FindCFI)
INCLUDE (Doxygen)
......
......@@ -249,3 +249,43 @@ MACRO(ADD_NEKTAR_TEST name)
COMMAND Tester ${CMAKE_CURRENT_SOURCE_DIR}/Tests/${name}.tst)
ENDIF()
ENDMACRO(ADD_NEKTAR_TEST)
#
# ADD_NEKPY_LIBRARY(name SOURCES src1 src2 ...)
#
# Adds a new NekPy library with the given sources.
#
MACRO(ADD_NEKPY_LIBRARY name)
CMAKE_PARSE_ARGUMENTS(NEKPY "" "" "SOURCES" ${ARGN})
SET(NEKPY_NAME ${name})
# Create library.
ADD_LIBRARY(_${name} SHARED ${NEKPY_SOURCES})
# Python requires a .so extension, even on OS X.
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_SYSTEM_LIBRARY}
${Boost_PYTHON_LIBRARY}
${BOOST_NUMPY_LIB}
${PYTHON_LIBRARIES}
${name})
# Install __init__.py files.
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/python/init.py.in
${CMAKE_BINARY_DIR}/NekPy/${name}/__init__.py)
SET_TARGET_PROPERTIES(_${name} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/NekPy/${name})
ENDMACRO()
MACRO(ADD_NEKPY_EXECUTABLE name source)
# Copy the files into binary directory.
INSTALL(FILES ${source} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
FILE(COPY ${source} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
ADD_CUSTOM_TARGET(${name} SOURCES ${source})
ENDMACRO()
\ No newline at end of file
########################################################################
#
# ThirdParty configuration for Nektar++
#
# Python interfaces
#
########################################################################
IF (NEKTAR_BUILD_PYTHON)
# Find Python
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibsNew REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
# Include headers from root directory for config file.
# Try to find Boost.NumPy
FIND_LIBRARY(BOOST_NUMPY_LIB boost_numpy PATHS ${Boost_LIBRARY_DIRS})
# If we can't find it, pull it from git and compile it
IF (NOT BOOST_NUMPY_LIB)
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} -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DLIBRARY_TYPE=STATIC
${TPSRC}/boost-numpy
)
SET(BOOST_NUMPY_LIB ${TPDIST}/lib64/${CMAKE_STATIC_LIBRARY_PREFIX}boost_numpy${CMAKE_STATIC_LIBRARY_SUFFIX})
INCLUDE_DIRECTORIES(SYSTEM ${TPDIST}/include)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/python/setup.py.in ${CMAKE_BINARY_DIR}/setup.py)
ADD_CUSTOM_TARGET(nekpy-install-user
DEPENDS _MultiRegions
COMMAND python setup.py install --user
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/NekPy)
FILE(WRITE ${CMAKE_BINARY_DIR}/NekPy/__init__.py "# placeholder")
ELSE()
ADD_CUSTOM_TARGET(boost-numpy ALL)
ADD_DEFINITIONS(-DBOOST_HAS_NUMPY)
ENDIF()
ENDIF()
from ._${NEKPY_NAME} import *
from distutils.core import setup
libs = ['LibUtilities', 'StdRegions', 'SpatialDomains', 'LocalRegions', 'MultiRegions']
setup(name='NekPy',
version='${NEKTAR_VERSION}',
package_dir={ '': '${CMAKE_BINARY_DIR}' },
packages=[ 'NekPy' ] + [ 'NekPy.%s' % l for l in libs ],
package_data={ 'NekPy.%s' % l : ['_%s.so' % l] for l in libs }
)
......@@ -28,6 +28,5 @@ IF (NEKTAR_UTILITY_FIELDCONVERT OR NEKTAR_UTILITY_NEKMESH OR NEKTAR_BUILD_SOLVER
ENDIF()
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
INCLUDE_DIRECTORIES(Python)
ENDIF()
......@@ -431,6 +431,10 @@ IF( NEKTAR_USE_PETSC )
ADD_DEPENDENCIES(LibUtilities petsc-3.7.2)
ENDIF( NEKTAR_USE_PETSC )
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
ENDIF()
# HDF5
IF( NEKTAR_USE_HDF5 )
TARGET_LINK_LIBRARIES(LibUtilities LINK_PUBLIC ${HDF5_LIBRARIES})
......
SET(LIBUTILITIES_SOURCES
ADD_NEKPY_LIBRARY(LibUtilities SOURCES
LibUtilities.cpp
BasicUtils/SessionReader.cpp
BasicUtils/SharedArray.cpp
......@@ -7,5 +7,3 @@ SET(LIBUTILITIES_SOURCES
Foundations/Points.cpp
LinearAlgebra/NekMatrix.cpp
)
ADD_NEKPY_LIBRARY(LibUtilities LIBUTILITIES_SOURCES)
......@@ -49,5 +49,9 @@ ADD_NEKTAR_LIBRARY(LocalRegions
SUMMARY "Nektar++ LocalRegions library"
DESCRIPTION "This library provides physical space expansions on the various supported regions.")
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
ENDIF()
INSTALL(DIRECTORY ./ DESTINATION ${NEKTAR_INCLUDE_DIR}/LocalRegions
COMPONENT dev FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
SET(LOCALREGIONS_SOURCES
ADD_NEKPY_LIBRARY(LocalRegions SOURCES
LocalRegions.cpp
Expansion.cpp
QuadExp.cpp
SegExp.cpp
TriExp.cpp
)
ADD_NEKPY_LIBRARY(LocalRegions LOCALREGIONS_SOURCES)
......@@ -150,6 +150,10 @@ IF( NEKTAR_USE_PETSC )
ADD_DEPENDENCIES(MultiRegions petsc-3.7.2)
ENDIF( NEKTAR_USE_PETSC )
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
ENDIF()
INSTALL(DIRECTORY ./ DESTINATION ${NEKTAR_INCLUDE_DIR}/MultiRegions COMPONENT dev FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
......
SET(MULTIREGIONS_SOURCES
ADD_NEKPY_LIBRARY(MultiRegions SOURCES
MultiRegions.cpp
ExpList.cpp
ExpList2D.cpp
)
ADD_NEKPY_LIBRARY(MultiRegions MULTIREGIONS_SOURCES)
......@@ -78,5 +78,9 @@ IF( NEKTAR_USE_SCOTCH )
ADD_DEPENDENCIES(SpatialDomains scotch-6.0.0)
ENDIF ()
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
ENDIF()
INSTALL(DIRECTORY ./ DESTINATION ${NEKTAR_INCLUDE_DIR}/SpatialDomains
COMPONENT dev FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
SET(SPATIALDOMAINS_SOURCES
ADD_NEKPY_LIBRARY(SpatialDomains SOURCES
SpatialDomains.cpp
Geometry.cpp
Geometry1D.cpp
......@@ -7,6 +7,4 @@ SET(SPATIALDOMAINS_SOURCES
SegGeom.cpp
QuadGeom.cpp
TriGeom.cpp
)
ADD_NEKPY_LIBRARY(SpatialDomains SPATIALDOMAINS_SOURCES)
)
\ No newline at end of file
......@@ -55,5 +55,9 @@ ADD_NEKTAR_LIBRARY(StdRegions
SUMMARY "Nektar++ StdRegions library"
DESCRIPTION "This library provides construction of the reference expansions for the various 1D, 2D and 3D regions.")
IF (NEKTAR_BUILD_PYTHON)
SUBDIRS(Python)
ENDIF()
INSTALL(DIRECTORY ./ DESTINATION ${NEKTAR_INCLUDE_DIR}/StdRegions COMPONENT dev FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
SET(STDREGIONS_SOURCES
ADD_NEKPY_LIBRARY(StdRegions SOURCES
StdRegions.cpp
StdExpansion.cpp
StdSegExp.cpp
StdTriExp.cpp
StdQuadExp.cpp
)
ADD_NEKPY_LIBRARY(StdRegions STDREGIONS_SOURCES)
......@@ -83,6 +83,11 @@ namespace Nektar
return m_processes;
}
bool TestData::IsPythonTest() const
{
return m_pythonTest;
}
std::string TestData::GetMetricType(unsigned int pId) const
{
ASSERTL0(pId < m_metrics.size(), "Metric ID out of range.");
......@@ -147,10 +152,16 @@ namespace Nektar
tmp = testElement->FirstChildElement("executable");
ASSERTL0(tmp, "Cannot find 'executable' for test.");
m_executable = fs::path(tmp->GetText());
// Test to see if this test requires Python
std::string needsPython;
tmp->QueryStringAttribute("python", &needsPython);
m_pythonTest = needsPython == "true";
#if defined(RELWITHDEBINFO)
m_executable += "-rg";
m_executable += m_pythonTest ? "" : "-rg";
#elif !defined(NDEBUG)
m_executable += "-g";
m_executable += m_pythonTest ? "" : "-g";
#endif
}
......
......@@ -65,6 +65,7 @@ namespace Nektar
const fs::path& GetExecutable() const;
const std::string& GetParameters() const;
const unsigned int& GetNProcesses() const;
bool IsPythonTest() const;
std::string GetMetricType(unsigned int pId) const;
unsigned int GetNumMetrics() const;
......@@ -85,6 +86,7 @@ namespace Nektar
TiXmlDocument* m_doc;
std::vector<TiXmlElement*> m_metrics;
std::vector<DependentFile> m_files;
bool m_pythonTest;
void Parse(TiXmlDocument* pDoc);
};
......
......@@ -198,13 +198,15 @@ int main(int argc, char *argv[])
fs::copy_file(source, dest);
}
// If we're Python, copy script too.
// Construct test command to run. If in debug mode, append "-g"
// Output from stdout and stderr are directed to the files output.out
// and output.err, respectively.
#ifdef NEKTAR_TEST_FORCEMPIEXEC
#else
if (file.GetNProcesses() > 1)
if (file.GetNProcesses() > 1)
#endif
{
command += "@MPIEXEC@ @MPIEXEC_NUMPROC_FLAG@ "
......@@ -220,9 +222,16 @@ int main(int argc, char *argv[])
fs::path execPath = startDir / file.GetExecutable();
if (!fs::exists(execPath))
{
ASSERTL0(!file.IsPythonTest(), "Python script not found.");
execPath = file.GetExecutable();
}
if (file.IsPythonTest())
{
command += "PYTHONPATH=\"@BUILD_PATH\" ";
command += "python ";
}
command += PortablePath(execPath);
command += " ";
command += file.GetParameters();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment