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

use pybind to compile 2d_dambreak case #212

Closed
wants to merge 21 commits into from
Closed
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
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ jobs:

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v2
with:
submodules: '3rd_party/pybind11@3cc7e42'


- name: Install system dependencies
run: |
Expand Down Expand Up @@ -121,6 +124,9 @@ jobs:

steps:
- uses: actions/checkout@v3 # Checks-out the repository under ${{github.workspace}}
with:
submodules: '3rd_party/pybind11@3cc7e42'


- name: Update ccache and ninja # For correct caching with ccache on Windows
shell: bash
Expand Down Expand Up @@ -210,6 +216,9 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: '3rd_party/pybind11@3cc7e42'


- name: Install system dependencies
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "3rd_party/wasmtbb"]
path = 3rd_party/wasmtbb
url = https://github.com/hpcwasm/wasmtbb.git
[submodule "3rd_party/pybind11"]
path = 3rd_party/pybind11
url = https://github.com/pybind/pybind11.git
1 change: 1 addition & 0 deletions 3rd_party/pybind11
Submodule pybind11 added at 3cc7e4
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
else()
target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-Werror>)
target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-Wall>)
target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-fPIC>) # For pybind in Linux
# target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-Wextra>) # TODO:
# target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-Wpedantic>) # For strict C++ standard compliance # TODO:
endif()
Expand Down Expand Up @@ -80,6 +81,7 @@ endif()
#------ Setup the concrete libraries
add_subdirectory(SPHINXsys)
add_subdirectory(modules)
add_subdirectory(3rd_party/pybind11)

#------ Setup the tests
if(SPHINXSYS_BUILD_TESTS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "level_set.h"

#include "mesh_with_data_packages.hpp"
#include "mesh_iterators.hpp"
#include "base_kernel.h"
#include "base_particles.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "level_set.h"
#include "mesh_with_data_packages.hpp"
#include "mesh_iterators.hpp"
#include "base_kernel.h"
#include "base_particles.h"
Expand Down
2 changes: 0 additions & 2 deletions SPHINXsys/src/shared/geometries/level_set.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "level_set.h"
#include "adaptation.h"

#include "mesh_with_data_packages.hpp"

namespace SPH
{
//=================================================================================================//
Expand Down
2 changes: 1 addition & 1 deletion SPHINXsys/src/shared/geometries/level_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef LEVEL_SET_H
#define LEVEL_SET_H

#include "mesh_with_data_packages.h"
#include "mesh_with_data_packages.hpp"
#include "adaptation.h"
#include "base_geometry.h"

Expand Down
1 change: 1 addition & 0 deletions SPHINXsys/src/shared/include/sphinxsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
#include "io_all.h"
#include "parameterization.h"
#include "regression_test.h"
#include "sph_python.h"

#endif //SPHINXSYS_H
45 changes: 45 additions & 0 deletions SPHINXsys/src/shared/sphinxsys_python/sph_python.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* -------------------------------------------------------------------------*
* SPHinXsys *
* -------------------------------------------------------------------------*
* SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle*
* Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
* physical accurate simulation and aims to model coupled industrial dynamic*
* systems including fluid, solid, multi-body dynamics and beyond with SPH *
* (smoothed particle hydrodynamics), a meshless computational method using *
* particle discretization. *
* *
* SPHinXsys is partially funded by German Research Foundation *
* (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1, *
* HU1527/12-1 and HU1527/12-4 *
* *
* Portions copyright (c) 2017-2022 Technical University of Munich and *
* the authors' affiliations. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may *
* not use this file except in compliance with the License. You may obtain a*
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
* *
* ------------------------------------------------------------------------*/
/**
* @file sph_python.h
* @brief Interface for sph and pyhton code.
*/

#ifndef SPH_PYTHON_H
#define SPH_PYTHON_H

namespace SPH {

class SphPython
{
public:
explicit SphPython() {};
virtual ~SphPython() {};

//*** Functions for override. ***//
virtual int cmakeTest() = 0;
virtual void runCase(Real End_time) = 0;
};
};

#endif // SPH_PYTHON_H
28 changes: 28 additions & 0 deletions tests/2d_examples/test_2d_dambreak_python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # main (top) cmake dir

set(CMAKE_VERBOSE_MAKEFILE on)

STRING( REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR} )
PROJECT("${CURRENT_FOLDER}")

SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/bin/")
SET(BUILD_INPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/input")
SET(BUILD_RELOAD_PATH "${EXECUTABLE_OUTPUT_PATH}/reload")
SET(BUILD_BIND_PATH "${EXECUTABLE_OUTPUT_PATH}/bind")

file(MAKE_DIRECTORY ${BUILD_INPUT_PATH})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/regression_test_tool/
DESTINATION ${BUILD_INPUT_PATH})

file(MAKE_DIRECTORY ${BUILD_BIND_PATH})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pybind_tool/
DESTINATION ${BUILD_BIND_PATH})

aux_source_directory(. DIR_SRCS)
pybind11_add_module(${PROJECT_NAME} ${EXECUTABLE_OUTPUT_PATH} ${DIR_SRCS} )
set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
target_link_libraries(${PROJECT_NAME} PRIVATE sphinxsys_2d)

add_test(NAME ${PROJECT_NAME} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pybind_tool/pybind_test.py)
set_tests_properties(${PROJECT_NAME} PROPERTIES PASS_REGULAR_EXPRESSION "1")
Loading