Skip to content

Commit

Permalink
Add regression tests for TokaMaker (OpenFUSIONToolkit#7)
Browse files Browse the repository at this point in the history
Add regression tests for TokaMaker
 - Update CMAKE build to make python interfaces usable in build directory (pre-install)
 - TokaMaker: Fix h5py bug on some systems with fixed-length strings
 - Add h5py, scipy, and triangle python packages to CI build environment
  • Loading branch information
hansec authored Nov 22, 2023
1 parent e38a11a commit 98e7ac9
Show file tree
Hide file tree
Showing 8 changed files with 2,379 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install prerequisites
run: ${{ matrix.config.pip }} install pytest numpy
run: ${{ matrix.config.pip }} install pytest numpy scipy h5py triangle

- name: Cache external libraries
id: cache-ext-libs
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ if(OFT_PACKAGE_BUILD)
else()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)

########################
# Required library detection and setup
Expand Down
6 changes: 5 additions & 1 deletion src/python/OpenFUSIONToolkit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
install(PROGRAMS util.py DESTINATION python/OpenFUSIONToolkit COMPONENT app)
install(PROGRAMS TokaMaker.py DESTINATION python/OpenFUSIONToolkit COMPONENT app)
install(PROGRAMS Marklin.py DESTINATION python/OpenFUSIONToolkit COMPONENT app)
install(PROGRAMS Marklin.py DESTINATION python/OpenFUSIONToolkit COMPONENT app)

configure_file( util.py ${CMAKE_CURRENT_BINARY_DIR}/util.py COPYONLY)
configure_file( TokaMaker.py ${CMAKE_CURRENT_BINARY_DIR}/TokaMaker.py COPYONLY)
configure_file( Marklin.py ${CMAKE_CURRENT_BINARY_DIR}/Marklin.py COPYONLY)
5 changes: 3 additions & 2 deletions src/python/OpenFUSIONToolkit/TokaMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1667,8 +1667,9 @@ def save_gs_mesh(pts,tris,regions,coil_dict,cond_dict,filename,use_hdf5=True):
h5_file.create_dataset('mesh/r', data=pts, dtype='f8')
h5_file.create_dataset('mesh/lc', data=tris, dtype='i4')
h5_file.create_dataset('mesh/reg', data=regions, dtype='i4')
h5_file.create_dataset('mesh/coil_dict', data=coil_json, dtype=h5py.string_dtype('ascii', len(coil_json)))
h5_file.create_dataset('mesh/cond_dict', data=cond_json, dtype=h5py.string_dtype('ascii', len(cond_json)))
string_datatype = h5py.string_dtype('ascii')
h5_file.create_dataset('mesh/coil_dict', data=coil_json, dtype=string_datatype)
h5_file.create_dataset('mesh/cond_dict', data=cond_json, dtype=string_datatype)
else:
with open(filename, 'w+') as fid:
fid.write(json.dumps({
Expand Down
8 changes: 6 additions & 2 deletions src/tests/physics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if( OFT_BUILD_TESTS )
# Common
file( COPY conftest.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )

# Taylor tests
# Marklin tests
oft_add_test( test_taylor.F90 )
file( COPY test_taylor.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
oft_add_test( test_taylor_inj.F90 )
Expand All @@ -11,7 +11,7 @@ if( OFT_BUILD_TESTS )
#file( COPY torus_test.in.e DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
file( COPY torus_test.g DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )

# MHD tests
# MUG tests
add_library( test_phys_helpers test_phys_helpers.F90 )
add_dependencies( test_phys_helpers oftphysics )
oft_add_test( test_sound.F90 test_phys_helpers )
Expand All @@ -31,4 +31,8 @@ if( OFT_BUILD_TESTS )
file( COPY tw_test-passive.h5 DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
file( COPY tw_test-plate.h5 DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
file( COPY tw_test-torus.h5 DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )

# TokaMaker tests
file( COPY test_TokaMaker.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
file( COPY ITER_geom.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
endif()
Loading

0 comments on commit 98e7ac9

Please sign in to comment.