diff --git a/CMakeLists.txt b/CMakeLists.txt index ca56ea19ead85f478ff90748e19b1365543d0ea9..f8d42093476130b7862c20cc995d647b97989995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,14 @@ project(TurTLE) find_program(PYTHON_EXECUTABLE python3) -execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version.py OUTPUT_VARIABLE TURTLE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version.py + OUTPUT_VARIABLE TURTLE_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_version_long.py + OUTPUT_VARIABLE TURTLE_VERSION_LONG + OUTPUT_STRIP_TRAILING_WHITESPACE) project(TurTLE VERSION ${TURTLE_VERSION} @@ -479,12 +486,25 @@ if(EXISTS "${PROJECT_BINARY_DIR}/bash_setup_for_TurTLE.sh") DESTINATION "lib/" ) endif() +install(FILES "${PROJECT_SOURCE_DIR}/TurTLE/test/B32p1e4_checkpoint_0.h5" DESTINATION share/TurTLE-${TURTLE_VERSION_LONG}) +install(DIRECTORY "${PROJECT_SOURCE_DIR}/TurTLE/test/particle_set" DESTINATION share/TurTLE-${TURTLE_VERSION_LONG}/) +install(DIRECTORY "${PROJECT_SOURCE_DIR}/TurTLE/test/profiler" DESTINATION share/TurTLE-${TURTLE_VERSION_LONG}/) ##################################################################################### ## Install the python3 wrapper -# copy command +# copy python package install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/TurTLE ${PROJECT_BINARY_DIR}/python/TurTLE/)") +# install __init__ +configure_file( + "${PROJECT_SOURCE_DIR}/TurTLE/__init__.py.in" + "${PROJECT_BINARY_DIR}/python/TurTLE/__init__.py" + @ONLY) +# update setup.py +configure_file( + "${PROJECT_SOURCE_DIR}/setup.py.in" + "${PROJECT_BINARY_DIR}/python/setup.py" + @ONLY) if(EXISTS "${PROJECT_BINARY_DIR}/host_info.py") install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/host_info.py ${PROJECT_BINARY_DIR}/python/TurTLE/)") else() @@ -494,7 +514,7 @@ else() install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/pc_host_info.py ${PROJECT_BINARY_DIR}/python/TurTLE/host_info.py)") endif() endif() -install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/setup.py install --force --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python/)") +install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py install --force --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python/)") ##################################################################################### @@ -514,6 +534,11 @@ if (BUILD_TESTING) COMMAND turtle.test_Parseval WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY}) ### basic particle functionality + add_test( + NAME test_particles + COMMAND turtle.test_particles p2p_sampling on + WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY}) + set_tests_properties(test_particles PROPERTIES TIMEOUT 2000) add_test( NAME test_tracer_set COMMAND turtle TEST test_tracer_set -n 32 --np 2 --ntpp 2 --simname tracer_set_testsim @@ -521,7 +546,7 @@ if (BUILD_TESTING) ### compare DNS output to stored results add_test( NAME test_NSVEparticles - COMMAND turtle.test_NSVEparticles --np 2 --ntpp 2 --cpp_random_particles 0 + COMMAND turtle.test_NSVEparticles --np 2 --ntpp 2 WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY}) set_tests_properties(test_NSVEparticles PROPERTIES TIMEOUT 2000) ### check whether data is messed up by p2p calculations diff --git a/TurTLE/__init__.py b/TurTLE/__init__.py.in similarity index 83% rename from TurTLE/__init__.py rename to TurTLE/__init__.py.in index bef0ac39b35e7abd352732b525f59124d29a8d5f..4c08dcecdbbf90e24cc693e3a2577e8d2b1bfbbd 100644 --- a/TurTLE/__init__.py +++ b/TurTLE/__init__.py.in @@ -24,20 +24,11 @@ import os -import sys -import pickle -import pkg_resources +__version__ = '@TURTLE_VERSION_LONG@' -__version__ = pkg_resources.require('TurTLE')[0].version +data_dir = os.path.join('@CMAKE_INSTALL_PREFIX@', 'share/TurTLE-@TURTLE_VERSION_LONG@') -_dist = pkg_resources.get_distribution('TurTLE') -dist_loc = os.path.realpath(_dist.location) -here = os.path.normcase(__file__) -header_dir = os.path.join(os.path.join(dist_loc, 'TurTLE'), 'cpp') -lib_dir = os.path.join(dist_loc, 'TurTLE') - -homefolder = os.path.expanduser('~') from .host_info import host_info from .DNS import DNS diff --git a/TurTLE/test/profile_scalar.py b/TurTLE/test/profile_scalar.py index 08ee0f1a5f78434dcf446e2a3b84739a8ea7ba1d..a1ff24090415108d06cf13e460a108ec1518bec3 100644 --- a/TurTLE/test/profile_scalar.py +++ b/TurTLE/test/profile_scalar.py @@ -11,8 +11,8 @@ import TurTLE._base import TurTLE.DNS from TurTLE._code import _code -cpp_location = os.path.join(os.path.join( - TurTLE.lib_dir, 'test'), 'profiler') +cpp_location = os.path.join( + TurTLE.data_dir, 'profiler') class ADNS(TurTLE.DNS): diff --git a/TurTLE/test/test_Heun_p2p.py b/TurTLE/test/test_Heun_p2p.py index a61ab673baefdc2d8096f6846b853f6e6a41c603..ba997c8b687a309d5c95871aa855d122d4f35596 100644 --- a/TurTLE/test/test_Heun_p2p.py +++ b/TurTLE/test/test_Heun_p2p.py @@ -11,8 +11,8 @@ import TurTLE._base import TurTLE.DNS from TurTLE._code import _code -cpp_location = os.path.join(os.path.join( - TurTLE.lib_dir, 'test'), 'particle_set') +cpp_location = os.path.join( + TurTLE.data_dir, 'particle_set') class ADNS(TurTLE.DNS): diff --git a/TurTLE/test/test_bfps_resize.py b/TurTLE/test/test_bfps_resize.py index 4201eff252b97a2d1f2de2d6faabc7d5efe34077..c9d07eb7293e72ac442666fdd76195d8e84793e1 100644 --- a/TurTLE/test/test_bfps_resize.py +++ b/TurTLE/test/test_bfps_resize.py @@ -20,7 +20,7 @@ def main(): ['NSVE', '-n', '32', '--src-simname', 'B32p1e4', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--simname', 'dns_test', '--np', '4', diff --git a/TurTLE/test/test_particle_clouds.py b/TurTLE/test/test_particle_clouds.py index b6c401d18039d2b5b02991bd5a1cf1aae8152a50..17e63175298d79c698cf7afcd0442e35297c72f1 100644 --- a/TurTLE/test/test_particle_clouds.py +++ b/TurTLE/test/test_particle_clouds.py @@ -43,7 +43,7 @@ def basic_test(): c.simname = 'basic_cloud_test' f0 = h5py.File( os.path.join( - os.path.join(TurTLE.lib_dir, 'test'), + TurTLE.data_dir, 'B32p1e4_checkpoint_0.h5'), 'r') ic_file = h5py.File(c.get_checkpoint_0_fname(), 'a') @@ -55,7 +55,7 @@ def basic_test(): '-n', '32', '--src-simname', 'B32p1e4', '--forcing_type', 'linear', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--simname', c.simname, '--np', '4', @@ -70,7 +70,7 @@ def basic_test(): '--wd', './']) f0 = h5py.File( os.path.join( - os.path.join(TurTLE.lib_dir, 'test'), + TurTLE.data_dir, 'B32p1e4_checkpoint_0.h5'), 'r') f1 = h5py.File(c.get_checkpoint_0_fname(), 'r') @@ -118,7 +118,7 @@ def nasty_test(): '--src-simname', 'B32p1e4', '--simname', c.simname, '--forcing_type', 'linear', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--np', '4', '--ntpp', '2', diff --git a/TurTLE/test/test_particles.py b/TurTLE/test/test_particles.py index 4568ea3c35050c47e947dc65b568c809dcff9073..f3afb7f7cbd659311845a6d0c32f00fa9653b022 100644 --- a/TurTLE/test/test_particles.py +++ b/TurTLE/test/test_particles.py @@ -27,7 +27,7 @@ def main(): ['NSVEcomplex_particles', '-n', '32', '--src-simname', 'B32p1e4', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--np', '4', '--ntpp', '1', @@ -37,6 +37,7 @@ def main(): '--checkpoints_per_file', '{0}'.format(3), '--nparticles', '{0}'.format(nparticles), '--particle-rand-seed', '2', + '--cpp_random_particles', '0', '--njobs', '{0}'.format(njobs), '--wd', './'] + sys.argv[3:]) diff --git a/TurTLE/test/test_turtle_NSE.py b/TurTLE/test/test_turtle_NSE.py index 4c39a2cd676aeaa5e16548d6969bb5784abf9b27..6fe5633dfa35e2a5ed1acf4ebc5b4000bb8792d2 100644 --- a/TurTLE/test/test_turtle_NSE.py +++ b/TurTLE/test/test_turtle_NSE.py @@ -49,7 +49,7 @@ def main_basic(): ['NSVE', '-n', '32', '--src-simname', 'B32p1e4', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--simname', 'nsve_for_comparison', '--np', '4', @@ -130,7 +130,7 @@ def main_long(): ['NSVE', '-n', '64', '--src-simname', 'B32p1e4', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--simname', 'nsve_for_long_comparison', '--np', '4', diff --git a/TurTLE/test/test_turtle_NSVEparticles.py b/TurTLE/test/test_turtle_NSVEparticles.py index 8c22f512de8bf8a1fdefd5c6a8221c32b2ca1259..8d5d614da4d5ebe529f61953bc87d0651221600a 100644 --- a/TurTLE/test/test_turtle_NSVEparticles.py +++ b/TurTLE/test/test_turtle_NSVEparticles.py @@ -57,7 +57,7 @@ def main(): ['NSVEparticles', '-n', '32', '--src-simname', 'B32p1e4', - '--src-wd', TurTLE.lib_dir + '/test', + '--src-wd', TurTLE.data_dir, '--src-iteration', '0', '--simname', 'dns_nsveparticles', '--np', '4', @@ -69,12 +69,13 @@ def main(): '--checkpoints_per_file', '{0}'.format(3), '--nparticles', '{0}'.format(nparticles), '--particle-rand-seed', '2', + '--cpp_random_particles', '0', '--njobs', '{0}'.format(njobs), '--wd', './'] + sys.argv[1:]) f0 = h5py.File( os.path.join( - os.path.join(TurTLE.lib_dir, 'test'), + TurTLE.data_dir, 'B32p1e4_checkpoint_0.h5'), 'r') f1 = h5py.File(c.get_checkpoint_0_fname(), 'r') diff --git a/cpp/kspace.hpp b/cpp/kspace.hpp index da1b4669c4e2b7e2282df9c025d934921df321d6..f082f11ed9f73e9dd5b5ba9f11ed0d17a060f777 100644 --- a/cpp/kspace.hpp +++ b/cpp/kspace.hpp @@ -48,8 +48,10 @@ enum kspace_dealias_type {ONE_HALF, TWO_THIRDS, SMOOTH}; * - has methods for filtering. * - has CLOOP methods, useful for computing arbitrary formulas over the * Fourier space grid (i.e. use lambda expressions). + * + * \tparam be field backend, currently only FFTW is possible. + * \tparam dt dealiasing mode, either ONE_HALF, TWO_THIRDS or SMOOTH. */ - template <field_backend be, kspace_dealias_type dt> class kspace @@ -85,6 +87,10 @@ class kspace typename fftw_interface<rnumber>::complex *__restrict__ a, const double kmax); + /** + * \tparam rnumber type of real number, float or double. + * \tparam fc field components, ONE, THREE or THREExTHREE. + */ template <typename rnumber, field_components fc> void Gauss_filter( @@ -103,6 +109,11 @@ class kspace typename fftw_interface<rnumber>::complex *__restrict__ a, const double sigma); + /** + * \tparam rnumber type of real number, float or double. + * \tparam fc field components, ONE, THREE or THREExTHREE. + * \return exit mode (integer), EXIT_SUCCESS or arbitrary value for failure. + */ template <typename rnumber, field_components fc> int filter( diff --git a/get_version_long.py b/get_version_long.py new file mode 100644 index 0000000000000000000000000000000000000000..20accf0bf5a560fe621c64b56f20e210f54ec4e8 --- /dev/null +++ b/get_version_long.py @@ -0,0 +1,64 @@ +################################################################################ +# # +# Copyright 2019 Max Planck Institute for Dynamics and Self-Organization # +# # +# This file is part of TurTLE. # +# # +# TurTLE 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. # +# # +# TurTLE 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 TurTLE. If not, see <http://www.gnu.org/licenses/> # +# # +# Contact: Cristian.Lalescu@ds.mpg.de # +# # +################################################################################ + + + +import datetime +import subprocess + +def main(): + # get current time + now = datetime.datetime.now() + # obtain version + try: + git_branch = subprocess.check_output(['git', + 'rev-parse', + '--abbrev-ref', + 'HEAD']).strip().split()[-1].decode() + git_revision = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() + git_date = datetime.datetime.fromtimestamp(int(subprocess.check_output(['git', 'log', '-1', '--format=%ct']).strip())) + except: + git_revision = '' + git_branch = '' + git_date = now + if git_branch == '': + # there's no git available or something + VERSION = '{0:0>4}{1:0>2}{2:0>2}.{3:0>2}{4:0>2}{5:0>2}'.format( + git_date.year, git_date.month, git_date.day, + git_date.hour, git_date.minute, git_date.second) + VERSION_py = VERSION + else: + VERSION = subprocess.check_output(['git', 'describe', '--tags']).strip().decode().split('-')[0] + if (('develop' in git_branch) or + ('feature' in git_branch) or + ('bugfix' in git_branch)): + VERSION_py = subprocess.check_output( + ['git', 'describe', '--tags', '--dirty']).strip().decode().replace('-g', '+g').replace('-dirty', '.dirty').replace('-', '.post') + else: + VERSION_py = VERSION + print(VERSION_py) + return VERSION_py + +if __name__ == '__main__': + main() + diff --git a/setup.py b/setup.py.in similarity index 62% rename from setup.py rename to setup.py.in index a4f43074563d4f1a29226347a72bec13ca53bb6a..369f51430a095ae3132e27842d42197b7cac7d48 100644 --- a/setup.py +++ b/setup.py.in @@ -26,65 +26,20 @@ AUTHOR = 'Cristian C Lalescu' AUTHOR_EMAIL = 'Cristian.Lalescu@ds.mpg.de' -import os -import shutil -import datetime -import sys -import subprocess import pickle ### package versioning -import get_version -VERSION = get_version.main() +VERSION = '@TURTLE_VERSION_LONG@' print('This is TurTLE version ' + VERSION) - -import distutils.cmd - -class CompileLibCommand(distutils.cmd.Command): - description = 'Compile TurTLE library.' - user_options = [ - ('timing-output=', None, 'Toggle timing output.'), - ('fftw-estimate=', None, 'Use FFTW ESTIMATE.'), - ('split-fftw-many=', None, 'Turn on SPLIT_FFTW_MANY.'), - ('disable-fftw-omp=', None, 'Turn Off FFTW OpenMP.'), - ] - def initialize_options(self): - self.timing_output = 0 - self.fftw_estimate = 0 - self.disable_fftw_omp = 0 - self.split_fftw_many = 0 - return None - def finalize_options(self): - self.timing_output = (int(self.timing_output) == 1) - self.split_fftw_many = (int(self.split_fftw_many) == 1) - self.fftw_estimate = (int(self.fftw_estimate) == 1) - self.disable_fftw_omp = (int(self.disable_fftw_omp) == 1) - return None - def run(self): - ### save compiling information - pickle.dump( - {'install_date' : now, - 'VERSION' : VERSION, - 'git_revision' : git_revision}, - open('turtle/install_info.pickle', 'wb'), - protocol = 2) - return None - from setuptools import setup setup( name = 'TurTLE', packages = ['TurTLE', 'TurTLE/test'], install_requires = ['numpy>=1.8', 'h5py>=2.2.1'], - package_data = {'TurTLE': ['test/B32p1e4_checkpoint_0.h5', - 'test/particle_set/NSVEparticle_set.hpp', - 'test/particle_set/NSVEparticle_set.cpp', - 'test/profiler/scalar_evolution.hpp', - 'test/profiler/scalar_evolution.cpp', - 'test/profiler/Kraichnan_scalar_v1.hpp', - 'test/profiler/Kraichnan_scalar_v1.cpp', - ]}, + # package data is installed by CMake + #package_data = {'TurTLE': []}, entry_points = { 'console_scripts': [ 'turtle = TurTLE.__main__:main',