Commit 8f358485 authored by Spencer Sherwin's avatar Spencer Sherwin

Added a StdRegions python test

parent ab7e7b38
......@@ -288,4 +288,10 @@ MACRO(ADD_NEKPY_EXECUTABLE name source)
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
ENDMACRO()
MACRO(ADD_NEKPY_TEST testname)
ADD_TEST(NAME python_${testname}
COMMAND $<TARGET_FILE:Tester>
${CMAKE_CURRENT_SOURCE_DIR}/Python/Tests/${testname}.tst)
ENDMACRO()
......@@ -37,7 +37,6 @@ MESSAGE(STATUS "Searching for Boost:")
# Minimum version and boost libraries required
SET(MIN_VER "1.56.0")
SET(NEEDED_BOOST_LIBS thread iostreams filesystem system program_options regex)
<<<<<<< HEAD
IF (NEKTAR_BUILD_PYTHON)
# We need to try a few variants, depending on if we're doing Python 2 or
......@@ -63,7 +62,8 @@ IF (NEKTAR_BUILD_PYTHON)
ENDFOREACH()
ELSE()
NektarFindBoost()
=======
ENDIF()
SET(Boost_NO_BOOST_CMAKE ON)
IF( BOOST_ROOT )
SET(Boost_NO_SYSTEM_PATHS ON)
......@@ -83,7 +83,6 @@ ELSE ()
SET(BOOST_ROOT ${TPDIST})
FIND_PACKAGE( Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS} )
ENDIF()
>>>>>>> master
ENDIF()
# Check what we found and determine if we need to build boost
......
......@@ -17,7 +17,7 @@ IF (NEKTAR_BUILD_PYTHON)
boost-numpy
PREFIX ${TPSRC}
URL ${TPURL}/boost-numpy_1.0.1.tar.bz2
URL_MD5 de7a432749bee4132abbc607ef21a6bf
URL_MD5 ae8c6f4d114a9c20dff72e915288a408
STAMP_DIR ${TPBUILD}/stamp
DOWNLOAD_DIR ${TPSRC}
SOURCE_DIR ${TPSRC}/boost-numpy
......
......@@ -56,3 +56,8 @@ ADD_NEKTAR_TEST(StdProject_Diff3D_Hex_Mod_P6_Q7)
ADD_NEKTAR_TEST(StdProject_Diff3D_Hex_Lagrange_P6_Q7)
ADD_NEKTAR_TEST(StdProject_Diff3D_Hex_Legendre_P6_Q7)
ADD_NEKTAR_TEST(StdProject_Diff3D_Hex_Chebyshev_P6_Q7)
IF (NEKTAR_BUILD_PYTHON)
ADD_NEKPY_EXECUTABLE(StdProject1D.py Python/StdProject1D.py)
ADD_NEKPY_TEST(StdProject1D-python)
ENDIF()
##
## NekPy example: basic interactions with the StdRegions classes
##
## This example constructs some simple StdRegions shapes and shows some of the
## operations that can be performed on the wrapper classes.
##
# Import necessary LibUtilities and StdRegions components
from NekPy.LibUtilities import PointsKey, Points, Basis, BasisKey, PointsType, BasisType
from NekPy.StdRegions import StdSegExp, StdQuadExp
# Other Python imports
from math import sin, cos
import numpy as np
# Create a PointsKey and a Points object for numPts GLL points. Create a
# Modified_A basis for the segment.
numPts = 10
numModes = 9
ptsKey = PointsKey(numPts, PointsType.GaussLobattoLegendre)
basisKey = BasisKey(BasisType.Modified_A, numModes, ptsKey)
# Create StdSegExp
seg = StdSegExp(basisKey)
# Use GetCoords to get coordinates of the segment. Note GetCoords always returns
# a tuple.
func = np.sin(seg.GetCoords()[0])
# Project sin(x). You can check the output here with the manual implementation
# in Basis.py.
print("Coefficients of projection of sin(x):")
print(seg.FwdTrans(func))
# Now let's create a quad on a tensor product of the points and basis above.
quad = StdQuadExp(basisKey, basisKey)
# Calculate the integral of the function cos(x)cos(y) on [-1,1]^2
xi, yi = quad.GetCoords()
func = np.cos(xi) * np.cos(yi)
integral = quad.Integral(func)
# Print details of our calculation.
print("Integral of cos(x) * cos(y) over the square [-1,1]^2")
print(" calculated = %g" % integral)
print(" error = %g" % abs(4.0 * sin(1) * sin(1) - integral))
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description> Std Projection in 1D </description>
<executable python="true"> StdProject1D.py </executable>
<parameters></parameters>
<metrics>
<metric type="regex" id="1">
<regex> error = ^([-+]?\d*\.?\d+)(?:[eE]([-+]?\d+))?$</regex>
<matches>
<match>
<field id="0">4.44089e-16</field>
</match>
</matches>
</metric>
</metrics>
</test>
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