Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 10 additions & 7 deletions .github/workflows/test_pyfans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v7

- name: Generate build directory
run: mkdir -p ${{ env.FANS_BUILD_DIR }}

- name: Install dependencies
run: |
apt update
Expand All @@ -43,11 +40,17 @@ jobs:
. .venv/bin/activate
pip install micro-manager-precice

- name: Configure
working-directory: ${{ env.FANS_BUILD_DIR }}
- name: Build and install FANS
run: |
cmake -S . -B ${{ env.FANS_BUILD_DIR }}
cmake --build ${{ env.FANS_BUILD_DIR }} -j
cmake --install ${{ env.FANS_BUILD_DIR }}
ldconfig

- name: Install pyfans against it
run: |
cmake .. -DFANS_LIBRARY_FOR_MICRO_MANAGER=ON
make
. .venv/bin/activate
pip install ./pyfans

- name: Run a dummy macro-micro coupling test
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# FANS Changelog

## latest

- Build pyFANS as a standalone nanobind project against an installed FANS, so FANS itself no longer depends on Python [#155](https://github.com/DataAnalyticsEngineering/FANS/pull/155)

## v0.8.0

- Make PyFANS installable (also with pixi build) [#152](https://github.com/DataAnalyticsEngineering/FANS/pull/152)
Expand Down
95 changes: 9 additions & 86 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,12 @@ endif ()

set(HDF5_PREFER_PARALLEL TRUE)
find_package(HDF5 REQUIRED COMPONENTS C CXX)

find_package(Eigen3 REQUIRED)

find_package(MPI REQUIRED)

find_package(FFTW3 REQUIRED COMPONENTS DOUBLE MPI)

option(FANS_LIBRARY_FOR_MICRO_MANAGER "Building FANS as a library to be used by the Micro Manager." OFF)

if (FANS_LIBRARY_FOR_MICRO_MANAGER)
set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 CONFIG REQUIRED)
endif()
find_package(nlohmann_json REQUIRED)
find_package(spdlog CONFIG REQUIRED)

# ##############################################################################
# TARGETS
# ##############################################################################
Expand Down Expand Up @@ -133,42 +124,16 @@ add_custom_command(
COMMENT "Create a symlink for FANS executable to ${CMAKE_CURRENT_SOURCE_DIR}/test/"
)

if (FANS_LIBRARY_FOR_MICRO_MANAGER)
add_subdirectory(pyfans)
endif ()

# ##############################################################################
# HEADERS
# ##############################################################################

target_include_directories(FANS_FANS PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

# TODO: when creating a shared library in the future, maybe create one single
# FANS.h header that consuming projects can use
set_property(TARGET FANS_FANS PROPERTY PUBLIC_HEADER
include/general.h
include/logging.h
include/matmodel.h
include/LargeStrainMechModel.h
include/MaterialManager.h
include/reader.h
include/solverCG.h
include/solverFP.h
include/solver.h
include/setup.h
include/mixedBCs.h

include/material_models/thermal/LinearThermal.h
include/material_models/thermal/GBDiffusion.h

include/material_models/small_strain/LinearElastic.h
include/material_models/small_strain/PseudoPlastic.h
include/material_models/small_strain/J2Plasticity.h
include/material_models/small_strain/J2PlasticityNew.h

include/material_models/large_strain/SaintVenantKirchhoff.h
include/material_models/large_strain/CompressibleNeoHookean.h
include/material_models/large_strain/FiniteStrainJ2Plasticity.h
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FANS
FILES_MATCHING PATTERN "*.h"
)

# version.h is generated and added to the build include directory
Expand All @@ -182,42 +147,25 @@ target_include_directories(FANS_main PRIVATE "${PROJECT_BINARY_DIR}/include")
# SOURCES
# ##############################################################################

target_sources(FANS_FANS PRIVATE
src/reader.cpp
)

target_sources(FANS_main PRIVATE
src/main.cpp
)
target_sources(FANS_FANS PRIVATE src/reader.cpp)
target_sources(FANS_main PRIVATE src/main.cpp)

# ##############################################################################
# LINKING
# ##############################################################################

target_link_libraries(FANS_FANS PRIVATE m)

# TODO: when switching to a newer CMake version this can all be done by one
# call to target_link_libraries(FANS_FANS PUBLIC HDF5::HDF5). But CMake 3.16
# does not yet support this.
target_include_directories(FANS_FANS PRIVATE ${HDF5_INCLUDE_DIRS})
target_link_libraries(FANS_FANS PUBLIC ${HDF5_C_LIBRARIES})
target_link_libraries(FANS_FANS PUBLIC ${HDF5_CXX_LIBRARIES})
target_compile_definitions(FANS_FANS PUBLIC ${HDF5_DEFINITIONS})
target_link_libraries(FANS_FANS PUBLIC HDF5::HDF5)
if (HDF5_IS_PARALLEL)
target_compile_definitions(FANS_FANS PUBLIC H5_HAVE_PARALLEL)
endif ()

target_link_libraries(FANS_FANS PUBLIC MPI::MPI_CXX)

target_include_directories(FANS_FANS PRIVATE ${FFTW3_INCLUDE_DIRS})
target_link_libraries(FANS_FANS PUBLIC ${FFTW3_LIBRARIES})
target_compile_definitions(FANS_FANS PUBLIC ${FFTW3_DEFINITIONS})

target_link_libraries(FANS_FANS PUBLIC fftw3::double::serial fftw3::double::mpi)
target_link_libraries(FANS_FANS PUBLIC Eigen3::Eigen)
target_link_libraries(FANS_FANS PUBLIC nlohmann_json::nlohmann_json)
target_link_libraries(FANS_FANS PUBLIC spdlog::spdlog)

target_include_directories(FANS_main PRIVATE ${HDF5_INCLUDE_DIRS} ${FFTW3_INCLUDE_DIRS})
target_link_libraries(FANS_main PRIVATE FANS::FANS)

# ##############################################################################
Expand All @@ -237,40 +185,28 @@ install(
EXPORT FANS
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT FANS_Runtime
NAMELINK_COMPONENT FANS_Development
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT FANS_Development
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FANS
PUBLIC_HEADER
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FANS
COMPONENT FANS_Development
PRIVATE_HEADER
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/FANS
COMPONENT FANS_Development
)

install(
TARGETS FANS_main
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT FANS_Runtime
)

install(
EXPORT FANS
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/FANS
NAMESPACE FANS::
FILE FANSTargets.cmake
COMPONENT FANS_Development
)

install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/FindFFTW3.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/FANS/modules
COMPONENT FANS_Development
)

write_basic_package_version_file(
Expand All @@ -288,7 +224,6 @@ install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/FANSConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/FANSConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/FANS
COMPONENT FANS_Development
)

# ##############################################################################
Expand All @@ -303,15 +238,3 @@ if (FANS_ENABLE_TESTING)
enable_testing()
add_subdirectory(test)
endif ()

# ##############################################################################
# PACKAGING
# ##############################################################################

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(FANS_ENABLE_PACKAGING_DEFAULT ON)
endif ()
option(FANS_ENABLE_PACKAGING "Enable creation of Debian packages" ${FANS_ENABLE_PACKAGING_DEFAULT})
if (FANS_ENABLE_PACKAGING)
add_subdirectory(cmake/packaging)
endif ()
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ cd ../test
| `CMAKE_INTERPROCEDURAL_OPTIMIZATION` | Enable link-time optimization (LTO) | `ON` (if supported) |
| `FANS_BUILD_STATIC` | Build static library | `OFF` |
| `CMAKE_INSTALL_PREFIX` | Installation directory | System default |
| `FANS_LIBRARY_FOR_MICRO_MANAGER` | Build Python bindings using Pybind11 (needed) | `OFF` |
| `FANS_ENABLE_SANITIZERS` | Enable runtime sanitizers (AddressSanitizer and LeakSanitizer) for memory debugging | `OFF` |

---
Expand Down
5 changes: 3 additions & 2 deletions cmake/FANSConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ include(CMakeFindDependencyMacro)
set(HDF5_ENABLE_PARALLEL ON)
set(HDF5_PREFER_PARALLEL ON)
find_dependency(HDF5 REQUIRED COMPONENTS C CXX)
if (NOT HDF5_C_IS_PARALLEL)
message(FATAL_ERROR "Parallel HDF5 implementation (mpi) required but not found!")
if (DEFINED HDF5_C_IS_PARALLEL AND NOT HDF5_C_IS_PARALLEL)
message(WARNING "HDF5 does not look MPI-parallel; FANS needs a parallel HDF5 at runtime.")
endif()
find_dependency(Eigen3)
find_dependency(MPI)
find_dependency(FFTW3 COMPONENTS DOUBLE MPI)
find_dependency(nlohmann_json)
find_dependency(spdlog CONFIG)

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH_save}")
Expand Down
57 changes: 0 additions & 57 deletions cmake/packaging/CMakeLists.txt

This file was deleted.

6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ RUN apt-get update -qq && apt-get install -y --no-install-recommends \
# Build basics
software-properties-common \
build-essential \
# CMake + git for the CI checkout + file for CPack
# CMake + git for the CI checkout
cmake \
git \
file \
# FANS dependencies \
libhdf5-dev \
libhdf5-openmpi-dev \
Expand All @@ -43,9 +42,8 @@ RUN apt-get update -qq && apt-get install -y --no-install-recommends \
libfftw3-mpi-dev \
nlohmann-json3-dev \
libspdlog-dev \
# Required for preCICE Micro Manager Python bindings
# Required for building pyfans
python3-dev \
pybind11-dev \
# Clean up
&& apt-get clean \
&& apt-get autoremove --purge -y \
Expand Down
2 changes: 1 addition & 1 deletion docs/ReleaseGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The release of the `FANS` repository is made directly from a release branch call

1. Create a branch called `FANS-v1.2.3` from the latest commit of the `develop` branch.

2. Bump the version in the `CHANGELOG.md`, the base `CMakeLists.txt`, and in the `pixi.toml` on the branch `FANS-v1.2.3`.
2. Bump the version in the `CHANGELOG.md`, the base `CMakeLists.txt`, the base `pixi.toml`, and in the `pyfans/pyproject.toml` on the branch `FANS-v1.2.3`.

3. Assuming you have Pixi installed, run the command `pixi lock` in the repository root to update the `pixi.lock` file. Then commit and push the `FANS-v1.2.3` branch to remote.

Expand Down
Loading