Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.1.0 #8

Merged
merged 19 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6bc99f7
MAINT: Initial commit
NateAM Jun 11, 2024
0e32924
Merge pull request #1 from UCBoulder/maint/add-initial-file-structure
NateAM Jun 11, 2024
0d0638b
DOC: Updated the readme to remove leftovers from the tardigrade_hydra…
NateAM Jun 11, 2024
64b0bf4
Merge pull request #2 from UCBoulder/doc/update-readme
NateAM Jun 11, 2024
a4507f5
FEAT: Added the computation of the balance of mass
NateAM Jun 11, 2024
2e43606
FEAT: Added the Jacobians of the balance of mass
NateAM Jun 11, 2024
cf56b69
MAINT: Updated the changelog
NateAM Jun 11, 2024
3f485ec
Merge pull request #3 from UCBoulder/feat/add-balance-of-mass
NateAM Jun 11, 2024
1b924f2
FEAT: Added the calculation of the contribution to the Jacobian of th…
NateAM Jun 11, 2024
8ad2836
MAINT: Corrected the header blocking
NateAM Jun 11, 2024
ca4b39f
MAINT: Updated changelog
NateAM Jun 11, 2024
5726476
Merge pull request #4 from UCBoulder/feat/add-common-finite-element-u…
NateAM Jun 11, 2024
6b99a37
MAINT: This is a header-only library so there shouldn't be a shared o…
NateAM Jun 11, 2024
e75b10a
MAINT: Updated changelog
NateAM Jun 11, 2024
3bae925
Merge pull request #5 from UCBoulder/maint/remove-library-compilation
NateAM Jun 11, 2024
f6ebadf
BUG: Removed leading whitespace in CMakeLists file
NateAM Jun 18, 2024
79405f9
Merge pull request #6 from UCBoulder/bug/fix-cmake-add_library-spacing
NateAM Jun 18, 2024
e471300
MAINT: Allow for the version of the supporting packages to be defined
NateAM Jul 12, 2024
d0dc102
Merge pull request #7 from UCBoulder/maint/allow-package-versions-to-…
NateAM Jul 12, 2024
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
62 changes: 62 additions & 0 deletions .github/workflows/github-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Tests on pull request
run-name: ${{ github.actor }} is testing a pull request
on:
pull_request:
types:
- opened
- edited
- synchronize
branches:
- dev
- main
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
matrix:
os: [ubuntu-latest]
build_type: [Release]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: MiniConda setup
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
channels: conda-forge,defaults
channel-priority: true
auto-activate-base: false
activate-environment: "test-environment"
- name: check solution
run: |
conda env export
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "environment-file=${{ github.workspace }}/reduced_environment.txt" >> "$GITHUB_OUTPUT"
echo "moose-dir=${{ github.workspace }}/moose-dir" >> "$GITHUB_OUTPUT"
- name: Conda environment
shell: bash -el {0}
run: |
mamba install --file ${{ steps.strings.outputs.environment-file }} --yes --channel conda-forge
- name: Build
shell: bash -el {0}
run: |
mkdir build
cd build
cmake .. -DTARDIGRADE_BALANCE_EQUATIONS_BUILD_PYTHON_BINDINGS=OFF
make
- name: Test
shell: bash -el {0}
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
conda activate test-environment
cd build
ctest
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Reference: https://github.com/softprops/action-gh-release
name: Release on new tags

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: 'true'
fetch-depth: 0
- name: Release
uses: softprops/action-gh-release@v1
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Project files
_version.py
conda_bld
conda-bld

# Temp files
*.swp

# C++ and temp files
*.o
*.so
*.nfs*
build*/
*_results.tex
*results.tex
*_results.txt
*results.txt

# Abaqus output files
*.com
*.dat
*.msg
*.odb
*.prt
*.sim
*.sta

# PyCharm IDE
.idea/
189 changes: 189 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#===================================================================================================== PROJECT SETUP ===
cmake_minimum_required(VERSION 3.19)
cmake_policy(SET CMP0110 NEW)
project(tardigrade_balance_equations)

# Set common project paths relative to project root directory
set(CPP_SRC_PATH "src/cpp")
set(CPP_TEST_PATH "${CPP_SRC_PATH}/tests")
set(CMAKE_SRC_PATH "src/cmake")
set(DOXYGEN_SRC_PATH "docs/doxygen")
set(SPHINX_SRC_PATH "docs/sphinx")

# Add a flag for whether the python bindings should be built or not
set(TARDIGRADE_BALANCE_EQUATIONS_BUILD_PYTHON_BINDINGS ON CACHE BOOL "Flag for whether the python bindings should be built for hydra")
set(TARDIGRADE_BALANCE_EQUATIONS_USE_LIBXSMM OFF CACHE BOOL "Flag for whether to use libxsmm for matrix math")

# Set the internal support libraries
set(INTERNAL_SUPPORT_LIBRARIES )
set(ADDITIONAL_HEADER_ONLY_LIBRARIES "tardigrade_balance_of_mass" "tardigrade_finite_element_utilities")
set(PROJECT_SOURCE_FILES ${PROJECT_NAME}.cpp ${PROJECT_NAME}.h)
set(PROJECT_PRIVATE_HEADERS "")
foreach(package ${INTERNAL_SUPPORT_LIBRARIES})
set(PROJECT_SOURCE_FILES ${PROJECT_SOURCE_FILES} ${package}.cpp ${package}.h)
set(PROJECT_PRIVATE_HEADERS ${PROJECT_PRIVATE_HEADERS} ${package}.h)
endforeach(package)
foreach(package ${ADDITIONAL_HEADER_ONLY_LIBRARIES})
add_library(${package} INTERFACE "${CPP_SRC_PATH}/${package}.cpp" "${CPP_SRC_PATH}/${package}.h")
endforeach(package)
if(TARDIGRADE_BALANCE_EQUATIONS_USE_LIBXSMM)
message(STATUS "Using libxsmm for matrix math")
find_library(libxsmm_DIR xsmm REQUIRED PATHS "$ENV{CONDA_PREFIX}/lib")
add_definitions(-DTARDIGRADE_BALANCE_EQUATIONS_USE_LLXSMM )
set(PROJECT_LINK_LIBRARIES ${PROJECT_LINK_LIBRARIES} "xsmm" "blas")
endif()

# For each support library you need to set the upstream libraries required via
#set(TARDIGRADE_BALANCE_EQUATIONSMYSUPPORTLIBRARY_UPSTREAM_LIBRARIES "tardigrade_constitutive_tools")

# Set some Abaqus integration variables
set(MISSING_INTEGRATION_DEPS_MESSAGE "Abaqus integration tests will be skipped.")

# Add the cmake folder to locate project CMake module(s)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/${CMAKE_SRC_PATH}" ${CMAKE_MODULE_PATH})

# Set build type checks
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
set(upstream_required "")
set(not_conda_test "true")
if(cmake_build_type_lower STREQUAL "release")
set(upstream_required "REQUIRED")
elseif(cmake_build_type_lower STREQUAL "conda-test")
set(upstream_required "REQUIRED")
set(not_conda_test "false")
# Find the installed project umat
endif()

# Get version number from Git
if(${not_conda_test} STREQUAL "true")
find_package(Python COMPONENTS Interpreter REQUIRED)
execute_process(COMMAND ${Python_EXECUTABLE} -m setuptools_scm
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_STRING_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${${PROJECT_NAME}_VERSION_STRING_FULL} STREQUAL "")
set(${PROJECT_NAME}_VERSION 0.0.0)
else()
string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+" ${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION_STRING_FULL})
endif()
project(${PROJECT_NAME} VERSION ${${PROJECT_NAME}_VERSION})
endif()

# Add installation directory variables
include(GNUInstallDirs)

# Make the code position independent
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Set the c++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt -O3 -DNDEBUG -ggdb")
endif()

# Enable CTest
enable_testing()

#================================================================================================= FIND DEPENDENCIES ===
# Find eigen
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
include_directories(${EIGEN3_INCLUDE_DIR})
if(EIGEN3_FOUND)
message(STATUS "Found Eigen3: ${EIGEN3_INCLUDE_DIR}")
endif()

# Find bash (Required for abaqus integration tests)
find_program(BASH_PROGRAM bash)
if(BASH_PROGRAM)
message(STATUS "Found bash: ${BASH_PROGRAM}")
else()
message(STATUS "bash not found. ${MISSING_INTEGRATION_DEPS_MESSAGE}")
endif()

# Find related, but external, projects in installed environment
include(FetchContent)
set(upstream_packages "tardigrade_error_tools" "tardigrade_vector_tools")
if(${not_conda_test} STREQUAL "false")
# During conda-build testing, we must find the installed project files as if they were an external project
set(upstream_packages ${upstream_packages} ${PROJECT_NAME})
endif()
set(LOCAL_BUILD_INCLUDE_DIRECTORIES "")
foreach(package ${upstream_packages})
string(TOUPPER "${package}" package_upper)
set(${package_upper}_BUILD_PYTHON_BINDINGS ${TARDIGRADE_BALANCE_EQUATIONS_BUILD_PYTHON_BINDINGS} CACHE INTERNAL "Setting ${package}'s python binding flag to the global value")
find_package(${package} ${upstream_required} CONFIG)
if(${package}_FOUND)
message(STATUS "Found ${package}: ${${package}_DIR}")
else()
# Find related, but external, projects using FetchContent and building locally
message(WARNING "Did not find an installed ${package} package. Attempting local build with FetchContent.")
if(NOT DEFINED ${package_upper}_FETCHCONTENT_VERSION)
set(${package_upper}_FETCHCONTENT_VERSION "origin/dev")
endif()
message("${package_upper} is being built with version ${${package_upper}_FETCHCONTENT_VERSION}")
FetchContent_Declare(
${package}
GIT_REPOSITORY https://github.com/UCBoulder/${package}.git
GIT_TAG ${${package_upper}_FETCHCONTENT_VERSION}
)
FetchContent_MakeAvailable(${package})
set(LOCAL_BUILD_INCLUDE_DIRECTORIES ${LOCAL_BUILD_INCLUDE_DIRECTORIES} ${${package}_SOURCE_DIR}/${CPP_SRC_PATH})
endif()
endforeach(package)

foreach(package ${upstream_packages})
if(NOT cmake_build_type_lower STREQUAL "release")
string(TOLOWER "${package}" lower_package)
foreach(sub_package ${${upper_package}_UPSTREAM_LIBRARIES})
target_include_directories(${package} PUBLIC
${${sub_package}_SOURCE_DIR}/${CPP_SRC_PATH})
endforeach(sub_package)
endif()
endforeach(package)

#=============================================================================================== ADD PROJECT TARGETS ===
# MUST COME AFTER DEPENDENCY LOCATING
# Add project source directories
if(${not_conda_test} STREQUAL "true")
include_directories(${CPP_SRC_PATH})
add_subdirectory(${CPP_SRC_PATH})
endif()

# Only add tests and documentation for current project builds. Protects downstream project builds.
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Find Boost. Required for tests
find_package(Boost 1.53.0 REQUIRED COMPONENTS unit_test_framework)
# Add c++ tests and docs
add_subdirectory(${CPP_TEST_PATH})
if(${not_conda_test} STREQUAL "true")
add_subdirectory(${DOXYGEN_SRC_PATH})
add_subdirectory(${SPHINX_SRC_PATH})
endif()
endif()

#==================================================================================== SETUP INSTALLATION CMAKE FILES ===
if(${not_conda_test} STREQUAL "true")
foreach(package ${PROJECT_NAME})
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${package}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/${CMAKE_SRC_PATH}/Config.cmake.in"
"${PROJECT_BINARY_DIR}/${package}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${package}/cmake)

# CMake won't build the targets for local builds of upstream projects
if(cmake_build_type_lower STREQUAL release)
install(EXPORT ${package}_Targets
FILE ${package}Targets.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${package}/cmake)
endif()

install(FILES "${PROJECT_BINARY_DIR}/${package}Config.cmake"
"${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${package}/cmake)
endforeach(package)
endif()
Loading
Loading