Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c0ae0c3
Allow cmake build to work outside of git repo
DanShort12 Nov 5, 2020
4761a88
Simplify version setting
DanShort12 Nov 5, 2020
252dfc1
Remove automatic publish for now
DanShort12 Nov 5, 2020
1b020be
Don't get git history
DanShort12 Nov 5, 2020
5731623
Remove unused requirement
DanShort12 Nov 5, 2020
c18f032
Move files under package
DanShort12 Nov 6, 2020
9a0696f
Add root CMakeLists.txt
DanShort12 Nov 6, 2020
61e8810
Build enhancements to support sdist package
DanShort12 Nov 6, 2020
26db064
Add publish step back in
DanShort12 Nov 6, 2020
5dcda4c
Don't always run publish step
DanShort12 Nov 6, 2020
b6fad93
Fix conditional syntax error
DanShort12 Nov 6, 2020
037fd83
Move condition to job level
DanShort12 Nov 6, 2020
e38cb8f
Use PEP517 standard to control build order
DanShort12 Nov 6, 2020
f163da4
Make sure we have the latest version of pip
DanShort12 Nov 6, 2020
8c84834
Allow pip to seach for dependencies using index
DanShort12 Nov 6, 2020
400d95c
Use file path to install
DanShort12 Nov 6, 2020
a969460
Find links in local dist directory
DanShort12 Nov 6, 2020
0ec4c38
Ignore binaries on PyPI, fix typo, use build
DanShort12 Nov 6, 2020
2c85364
Bump version
DanShort12 Nov 6, 2020
d6bb835
No need for multiple builds
DanShort12 Nov 6, 2020
e85bf9b
Remove matrix from build
DanShort12 Nov 6, 2020
d356378
Version bump
DanShort12 Nov 6, 2020
e552055
Add contributing and code of conduct
DanShort12 Nov 6, 2020
6902e1c
Update include paths to make install more portable
DanShort12 Nov 10, 2020
3cfd906
Version bump following manual upload to test.pypi
DanShort12 Nov 10, 2020
74f17b4
Update fortran API
DanShort12 Nov 10, 2020
313406b
Upgrade to latest OpenMC
DanShort12 Nov 11, 2020
6dc5bb8
Include source_generator in package
DanShort12 Nov 11, 2020
c732080
Run tests with OpenMC installed
DanShort12 Nov 11, 2020
6082f63
Install OpenMC dependencies
DanShort12 Nov 11, 2020
f77e7f0
Only publish of openmc tests work
DanShort12 Nov 11, 2020
e603363
Install openmc python from correct directory
DanShort12 Nov 11, 2020
4b6d524
Version bump
DanShort12 Nov 11, 2020
8196286
Run tests of cmake build using Catch2
DanShort12 Nov 11, 2020
fa3ec0a
Don't run make and make install in same command
DanShort12 Nov 11, 2020
1c936ff
Make sure dependencies are installed
DanShort12 Nov 11, 2020
7fa9042
Install dependencies with sudo rights
DanShort12 Nov 11, 2020
d30fd7e
Catch2 updates
DanShort12 Nov 11, 2020
c45fd0b
Only test plasma source with OpenMC present
DanShort12 Nov 11, 2020
88c5bc3
Use header only Catch2
DanShort12 Nov 11, 2020
ea25c87
Use full path to source_sampling.so
DanShort12 Nov 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/cmake_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: cmake_build_and_test

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
build_and_test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: |
sudo apt-get install g++ cmake libhdf5-dev
- name: Install OpenMC
run: |
cd /opt
git clone https://github.com/openmc-dev/openmc.git
cd openmc
git checkout develop
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=.. ..
make
make install
- name: Build plasma source
run: |
mkdir build && cd build
cmake ..
make
- name: Test plasma source
run: |
cd build
./tests
- name: Check Source Generator
run: |
cd build
./source_generator -l "$PWD/source_sampling.so" -i "major_radius=9.06, minor_radius=2.92258, elongation=1.557, \
triangularity=0.27, shafranov_shift=0.44789, pedestal_radius=2.33806, ion_density_pedestal=1.09e+20, \
ion_density_separatrix=3e+19, ion_density_origin=1.09e+20, ion_density_alpha=1, ion_temperature_pedestal=6.09, \
ion_temperature_separatrix=0.1, ion_temperature_origin=45.9, ion_temperature_alpha=8.06, ion_temperature_beta=6, \
plasma_type=plasma, plasma_id=1, number_of_bins=100, minimum_toroidal_angle=0, maximum_toroidal_angle=360"
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,22 @@ jobs:
build:

runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
fetch-depth: 0 # Get the repo history so we can version by number of commits
- name: Install OpenMC
run: |
yum install -y gcc-c++ cmake3 hdf5-devel
alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
--family cmake
git clone --recurse-submodules https://github.com/openmc-dev/openmc.git
cd openmc
git checkout
mkdir build && cd build
cmake ..
make
make install
python-version: 3.8
- name: Build plasma source
run: |
export PYVER=${{ matrix.python-version }}
alias python=$(ls -d /opt/python/* | grep ${PYVER//.})/bin/python
python -m pip install -r requirements-develop.txt
python -m pip install auditwheel
python setup.py bdist_wheel
python -m auditwheel show dist/*.whl
python -m auditwheel repair dist/*.whl
pip install -r requirements-develop.txt
python -m build --sdist .
- name: Upload wheel artifact
uses: actions/upload-artifact@v2
with:
name: dist
path: wheelhouse
path: dist

test:
runs-on: ubuntu-latest
Expand All @@ -72,16 +50,57 @@ jobs:
path: dist
- name: Install plasma source
run: |
python -m pip install --no-index --find-links=file:dist parametric-plasma-source
python -m pip install dist/parametric_plasma_source-*.tar.gz
- name: Run tests
run: |
python -m pip install -r requirements-develop.txt
cd tests
python -m pytest

test_openmc:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Download build
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Install OpenMC
run: |
cd /opt
sudo apt install g++ cmake libhdf5-dev
git clone https://github.com/openmc-dev/openmc.git
cd openmc
git checkout develop
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=.. ..
make
make install
cd ..
python -m pip install .
- name: Install plasma source
run: |
python -m pip install dist/parametric_plasma_source-*.tar.gz
- name: Run tests
run: |
python -m pip install -r requirements-develop.txt
cd tests
python -m pytest

publish:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')}}
runs-on: ubuntu-latest
needs: test
needs: [test, test_openmc]

steps:
- name: Download build
Expand All @@ -90,6 +109,7 @@ jobs:
name: dist
path: dist
- name: Publish wheel artifact to TestPyPI
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*.out
*.app
source_generator
testprog

# Build path
build/
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "pybind11"]
path = pybind11
url = https://github.com/pybind/pybind11
[submodule "pugixml"]
path = pugixml
url = https://github.com/zeux/pugixml.git
91 changes: 2 additions & 89 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,92 +1,5 @@
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(parametric_plasma_source)

set(CMAKE_VERBOSE_MAKEFILE OFF)

set(SRC_DIR parametric_plasma_source)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

# Ensure submodules are available and up to date
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/pybind11/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

# Build source_sampling
list(APPEND source_sampling_SOURCES
${SRC_DIR}/source_sampling.cpp
${SRC_DIR}/plasma_source.cpp
)

# Use output paths from OpenMC install
# If OpenMC isn't available then we won't be able to build the plugin
# However, the package can still be run by using the sampling methods directly
# So don't terminate the build
find_package(OpenMC QUIET)

if(OpenMC_FOUND)
# Build the source_sampling OpenMC plugin if OpenMC is available
set(OPENMC_INC_DIR ${OpenMC_DIR}/../../../include/openmc)
set(OPENMC_LIB_DIR ${OpenMC_DIR}/../../../lib)

add_library(source_sampling SHARED ${source_sampling_SOURCES})

find_library(OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL)

if (OPENMC_LIB)
set_target_properties(source_sampling PROPERTIES PREFIX "")
set_target_properties(source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(source_sampling PUBLIC ${OPENMC_INC_DIR})
target_link_libraries(source_sampling ${OPENMC_LIB} gfortran)
endif()
else()
message(WARNING "Unable to find OpenMC installation - the source_sampling plugin will not be built.")
endif()

# Build plasma_source Python bindings
list(APPEND plasma_source_pybind_SOURCES
${SRC_DIR}/plasma_source.cpp
${SRC_DIR}/plasma_source_pybind.cpp
)

add_subdirectory(pybind11)

pybind11_add_module(plasma_source ${plasma_source_pybind_SOURCES})

add_subdirectory(pugixml)

# Build source_generator
list(APPEND source_generator_SOURCES
${SRC_DIR}/source_generator.cpp
)

add_executable(source_generator ${source_generator_SOURCES})

find_package(HDF5 REQUIRED)

set_target_properties(source_generator PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(source_generator PUBLIC ${OPENMC_INC_DIR})
target_include_directories(source_generator PUBLIC ${HDF5_INCLUDE_DIRS})
target_include_directories(source_generator PUBLIC ${OPENMC_DIR}/vendor/pugixml)
target_link_libraries(source_generator ${OPENMC_LIB} ${HDF5_LIBRARIES} stdc++fs)
include(parametric_plasma_source/CMakeLists.txt)
include(tests/src/CMakeLists.txt)
Loading