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
30 changes: 30 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build_and_test:
runs-on: ubuntu-latest

steps:
- name: clone
uses: actions/checkout@v4 # Action to check out your repository

- name: dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake

- name: build
working-directory: ${{ github.workspace }}
run: |
cmake -DMPM_TESTING_ONLY=ON .
make -j

- name: test
working-directory: ${{ github.workspace }}
run: make test
105 changes: 34 additions & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,85 +1,48 @@
# Copyright (c) 2016 Matt Overby
#
# MPM-OPTIMIZATION Uses the BSD 2-Clause License (http://www.opensource.org/licenses/BSD-2-Clause)
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF MINNESOTA, DULUTH OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.27)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

cmake_minimum_required(VERSION 3.0)
project(mpm C CXX)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_BUILD_TYPE Release)
# Options
option(MPM_TESTING_ONLY "Only compile lib and tests" OFF)

add_definitions(-DMPM_SRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}")

############################################################
#
# Libraries
#
############################################################

# libigl for rendering
include(DownloadProject)
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF) # off = header only
option(LIBIGL_WITH_COMISO "Use CoMiso" OFF)
option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" OFF)
option(LIBIGL_WITH_PNG "Use PNG" OFF)
option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
option(LIBIGL_WITH_PREDICATES "Use exact predicates" OFF)
option(LIBIGL_WITH_XML "Use XML" OFF)
download_project(PROJ libigl
GIT_REPOSITORY https://github.com/libigl/libigl.git
GIT_TAG main
UPDATE_DISCONNECTED 1
QUIET)
add_subdirectory(${libigl_SOURCE_DIR} ${libigl_BINARY_DIR})
# Libigl also includes Eigen, etc
include(libigl)

# OpenMP
# (TO-DO: replace with TBB)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
add_definitions(-DOMP_NESTED)
endif()

# Include headers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/deps/mcloptlib/include)
include_directories(SYSTEM ${glad_SOURCE_DIR}/include)
include_directories(SYSTEM ${libigl_SOURCE_DIR}/include)
include_directories(SYSTEM ${libigl_SOURCE_DIR}/external/eigen)

set(MPM_SRCS
src/Solver.hpp
src/Solver.cpp
src/MPM.hpp
src/MPM.cpp
src/Interp.hpp
src/Particle.hpp)

############################################################
#
# Binaries
#
############################################################
# Simulation library
set(MPM_SRC
${CMAKE_CURRENT_SOURCE_DIR}/src/LBFGS.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Solver.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Solver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MPM.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MPM.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Interp.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Particle.hpp)
add_library(mpm_optimization ${MPM_SRC})
target_link_libraries(mpm_optimization PUBLIC igl::core)

# Interactive viewer
if (NOT MPM_TESTING_ONLY)
igl_include(glfw)
add_executable(sphere ${CMAKE_CURRENT_SOURCE_DIR}/test/sphere.cpp)
target_link_libraries(sphere PUBLIC mpm_optimization igl::glfw)
target_include_directories(sphere PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
endif()

add_executable(sphere src/sphere.cpp ${MPM_SRCS})
target_link_libraries(sphere glad glfw)
# Unit testing (TO-DO)
enable_testing()
add_executable(test_solver ${CMAKE_CURRENT_SOURCE_DIR}/test/solver.cpp)
target_link_libraries(test_solver PUBLIC mpm_optimization)
target_include_directories(test_solver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_test(NAME TestSolver COMMAND test_solver)
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ of conditions and the following disclaimer in the documentation and/or other mat
provided with the distribution.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF MINNESOTA, DULUTH OR CONTRIBUTORS BE
ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF MINNESOTA OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
Expand Down
11 changes: 11 additions & 0 deletions cmake/libigl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if(TARGET igl::core)
return()
endif()

include(FetchContent)
FetchContent_Declare(
libigl
GIT_REPOSITORY https://github.com/libigl/libigl.git
GIT_TAG v2.5.0
)
FetchContent_MakeAvailable(libigl)
42 changes: 0 additions & 42 deletions deps/mcloptlib/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions deps/mcloptlib/LICENSE

This file was deleted.

29 changes: 0 additions & 29 deletions deps/mcloptlib/README.md

This file was deleted.

81 changes: 0 additions & 81 deletions deps/mcloptlib/cmake/FindEigen3.cmake

This file was deleted.

Loading