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

Master engine #20

Merged
merged 2 commits into from
Oct 30, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev

- name: Build
run: |
Expand All @@ -48,7 +48,7 @@ jobs:
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev

- name: Build
run: |
Expand Down
4 changes: 4 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"COVERAGE_OUTPUT_DIR": {
"type": "STRING",
"value": "${sourceDir}/build/coverage"
},
"VTK_OPT": {
"type": "BOOL",
"value": "FALSE"
}
}
},
Expand Down
18 changes: 15 additions & 3 deletions cmake/3rd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ CPMAddPackage(
GITHUB_REPOSITORY glfw/glfw
GIT_TAG 3.3.8
OPTIONS
"GLFW_BUILD_TESTS OFF"
"GLFW_BUILD_EXAMPLES OFF"
"GLFW_BULID_DOCS OFF"
"GLFW_BUILD_TESTS OFF"
"GLFW_BUILD_EXAMPLES OFF"
"GLFW_BULID_DOCS OFF"
)

# https://github.com/g-truc/glm
Expand Down Expand Up @@ -214,3 +214,15 @@ if (NOT GLUT_FOUND)
message(FATAL_ERROR "GLUT not found.\n"
"Following https://www.opengl.org/resources/libraries/glut/ to install.")
endif ()

find_package(OpenGL REQUIRED)
if (NOT OpenGL_FOUND)
message(FATAL_ERROR "OpenGL not found.\n"
"Following https://www.opengl.org/ to install.")
endif ()

find_package(VTK REQUIRED)
if (NOT VTK_FOUND)
message(FATAL_ERROR "VTK not found.\n"
"Following https://vtk.org/ to install.")
endif ()
11 changes: 0 additions & 11 deletions cmake/add_header.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion deps.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

ubuntu
```shell
sudo apt install -y doxygen graphviz clang-format clang-tidy cppcheck lcov gcc g++ libspdlog-dev libcgal-dev freeglut3-dev
sudo apt install -y doxygen graphviz clang-format clang-tidy cppcheck lcov gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev
```
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# CMakeLists.txt for Simple-XX/SimplePhysicsEngine.

add_subdirectory(engine)
# add_subdirectory(demo2d)
# add_subdirectory(demo3d)
add_subdirectory(demo2d)
add_subdirectory(demo3d)
40 changes: 21 additions & 19 deletions src/demo2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,35 @@
#
# CMakeLists.txt for Simple-XX/SimplePhysicsEngine.

cmake_minimum_required(VERSION 2.6)

project(demo2d)

file(GLOB_RECURSE demo2d_FILES
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
)

add_executable(${PROJECT_NAME}
${demo2d_FILES}
add_executable(${PROJECT_NAME}
${demo2d_FILES}
)

target_include_directories(${PROJECT_NAME} PRIVATE
include
../
../engine/dtk
../engine/math
../engine/physics
)
include
../
../engine/dtk
../engine/math
../engine/physics
)

target_link_libraries(${PROJECT_NAME} PRIVATE
dtk
Boost
CGAL
GLUT
glfw
glm
Eigen
dtk
Boost::headers
Boost::dynamic_linking
CGAL
GLUT::GLUT
glfw
glm
Eigen
OpenGL::GL
glut
GLU
)
1 change: 1 addition & 0 deletions src/demo2d/include/SPHSolver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <vector>
#include <memory>

#include "Particle.h"
#include "Grid.h"
Expand Down
6 changes: 3 additions & 3 deletions src/demo2d/src/SPHSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ void SPHSolver::findNeighborhoods()
neighborhoods = vector<vector<int>>();
float maxDist2 = KERNEL_RANGE * KERNEL_RANGE;

for each (const Particle &p in particles)
for (const Particle &p : particles)
{
vector<int> neighbors = vector<int>();
vector<Cell> neighboringCells = grid.getNeighboringCells(p.position);

for each (const Cell &cell in neighboringCells)
for (const Cell &cell : neighboringCells)
{
for each (int index in cell)
for (int index : cell)
{
Eigen::Vector2f x = p.position - particles[index].position;
float dist2 = x[0] * x[0] + x[1] * x[1];
Expand Down
94 changes: 39 additions & 55 deletions src/demo3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,7 @@
#
# CMakeLists.txt for Simple-XX/SimplePhysicsEngine.

cmake_minimum_required(VERSION 3.0)
project(demo3d)
set(CMAKE_CXX_STANDARD 11)

aux_source_directory(. dir_source)
file(GLOB dir_headers *.h)

include_directories({dir_headers})

if(WIN32)
set(freeglut_include_dir "${SPE_DEPS}/freeglut/include")
set(freeglut_libraries_dir "${SPE_DEPS}/freeglut/lib")
set(EIGEN_PATH "${SPE_DEPS}/eigen")
if(${VTK_OPT})
set(vtk_include_dir D:\\Envs\\VTK\\include\\vtk-8.2)
set(vtk_libraries_dir D:\\Envs\\VTK\\lib)
endif()
elseif(UNIX)
set(GLM_INCLUDE_DIR /usr/local/include/glm)
set(freeglut_include_dir /usr/include/GL)
set(freeglut_libraries_dir /usr/lib/x86_64-linux-gnu)
set(EIGEN_PATH /usr/local/include/eigen3/Eigen)
set(Boost_INCLUDE_DIR /usr/include/boost)
set(Boost_LIBRARIES_DIR /usr/lib/x86_64-linux-gnu)
set(DTK_INCLUDE_DIR /usr/local/include)
set(DTK_LIBRARIES_DIR /usr/local/lib)
endif()

if(${VTK_OPT})
add_definitions(-DUSE_VTK)
endif()

include_directories(${GLM_INCLUDE_DIR})
include_directories(${freeglut_include_dir})
link_directories(${freeglut_libraries_dir})
include_directories(${EIGEN_PATH})
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARIES_DIR})
include_directories(${DTK_INCLUDE_DIR})
link_directories(${DTK_LIBRARIES_DIR})

if(${VTK_OPT})
include_directories(${vtk_include_dir})
link_libraries(${vtk_libraries_dir}/*.lib)
endif()

#link

#single lib
#glfw static library include glfw3.lib
Expand All @@ -60,15 +14,45 @@ endif()
#glfw static library include glfw3_mt.lib
#glfw dynamic library include glfw3dll.lib glfw3.dll

add_executable(demo3d
main.cpp
dtkFemSimulation.cpp
dtkScene.cpp
)

target_include_directories(demo3d PRIVATE
./
../
../engine/dtk
../engine/math
../engine/physics
)

target_link_libraries(demo3d PRIVATE
dtk
Boost::headers
Boost::dynamic_linking
CGAL
GLUT::GLUT
glfw
glm
Eigen
OpenGL::GL
glut
GLU
)

target_compile_definitions(demo3d PRIVATE
# $<VTK_OPT:USE_VTK>
)

add_executable(demo3d ${dir_source} ${dir_headers})
#target_link_libraries(FemSimulation ${GLFW_LIBRARIES} glfw3dll.lib glfw3.dll ${Boost_LIBRARIES} CGAL)

if(WIN32)
target_link_libraries(demo3d ${GLFW_LIBRARIES} ${Boost_LIBRARIES} freeglut opengl32 glu32)
if(${VTK_OPT})
target_link_libraries(demo3d ${vtk_libraries_dir}/*.lib)
endif()
elseif(UNIX)
target_link_libraries(demo3d ${GLFW_LIBRARIES} ${Boost_LIBRARIES} CGAL glut OpenGL GLU dtk)
endif()
#if (WIN32)
# target_link_libraries(demo3d ${GLFW_LIBRARIES} ${Boost_LIBRARIES} freeglut opengl32 glu32)
# if (${VTK_OPT})
# target_link_libraries(demo3d ${vtk_libraries_dir}/*.lib)
# endif ()
#elseif (UNIX)
# target_link_libraries(demo3d ${GLFW_LIBRARIES} ${Boost_LIBRARIES} CGAL glut OpenGL GLU dtk)
#endif ()
2 changes: 1 addition & 1 deletion src/demo3d/dtkFemSimulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ float radius = 0.05;

int iterate_time = 3;

double M_PI = acos(-1);
//double M_PI = acos(-1);

inline int mesh(int i, int j, int k) {
return k * (n_node_y * n_node_x) + j * n_node_x + i;
Expand Down
Loading
Loading