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

try to implement mesh dynamics #647

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
71f2082
first-init
Franguuuu May 31, 2024
dbf8126
2d/3d shared combined
Franguuuu Jun 2, 2024
fcbd090
sync
Franguuuu Jun 3, 2024
47badeb
sync changes
Franguuuu Jun 16, 2024
920845b
gradient wrap
Franguuuu Jun 22, 2024
288b13b
initializeDataInACell wrap
Franguuuu Jun 22, 2024
3c9feeb
(2d) separate index&category
Franguuuu Aug 4, 2024
b760460
(3d) changed
Franguuuu Aug 4, 2024
ceb9d13
(2d) initialize index mesh
Franguuuu Aug 5, 2024
d7b6b0c
(2d) category check reimplement
Franguuuu Aug 5, 2024
c9bcd64
(2d) delete assign
Franguuuu Aug 5, 2024
a688ad9
(wrapped) tag inner
Franguuuu Aug 5, 2024
1fc2f3e
(2d) initialize index
Franguuuu Aug 5, 2024
3213abd
(2d wrapped) inni index
Franguuuu Aug 5, 2024
cc79359
(2d wrapped) except kernel
Franguuuu Aug 5, 2024
9fb3c9f
(wrap) finish package
Franguuuu Aug 5, 2024
536e46a
(2d wrapped) diffuse
Franguuuu Aug 11, 2024
709b189
(2d wrapped) reinitialize
Franguuuu Aug 11, 2024
3008050
(uncomplete) diffuse - input real
Franguuuu Aug 11, 2024
f9eb719
(2d wrapped) redistance
Franguuuu Aug 11, 2024
0c84f0d
(2d wrapped) all
Franguuuu Aug 11, 2024
616a54f
(full)sortIndex
Franguuuu Aug 12, 2024
c01dc4f
merge levelset init 2d/3d
Franguuuu Aug 12, 2024
c135931
temp
Franguuuu Aug 16, 2024
5c93c8c
fix bug
Franguuuu Aug 17, 2024
d7d451e
(3d)org/meshwithgriddatapackages
Franguuuu Aug 17, 2024
d5f1b00
(3d)org/levelset
Franguuuu Aug 17, 2024
9627b04
temp
Franguuuu Aug 17, 2024
267e5d3
fix bug 3d
Franguuuu Aug 18, 2024
bf32227
3d wrap
Franguuuu Aug 18, 2024
dc79ef6
clean
Franguuuu Aug 18, 2024
5f38a47
wrap redistance
Franguuuu Aug 18, 2024
a94885e
(wrapped) init singular
Franguuuu Aug 18, 2024
72be0ee
(3d)org/meshwithgriddatapackages
Franguuuu Aug 17, 2024
b67edd6
(3d)org/levelset
Franguuuu Aug 17, 2024
88bc0f8
fix bug 3d
Franguuuu Aug 18, 2024
568bb22
3d wrap
Franguuuu Aug 18, 2024
31f79d5
clean
Franguuuu Aug 18, 2024
99b021b
wrap redistance
Franguuuu Aug 18, 2024
f43df06
(wrapped) init singular
Franguuuu Aug 18, 2024
52dc1e6
temp
Franguuuu Aug 18, 2024
eb59a15
bug fix
Franguuuu Aug 18, 2024
3e6c808
bug fix
Franguuuu Aug 18, 2024
dffb3a8
wrap finish packages
Franguuuu Aug 19, 2024
1f61683
remove duplicate functions
Franguuuu Aug 19, 2024
a2d1a9e
compute wrap
Franguuuu Aug 19, 2024
d41bc26
wrap all
Franguuuu Aug 26, 2024
00e680b
change implementation
Franguuuu Aug 26, 2024
2dbc22a
temp
Franguuuu Aug 26, 2024
1393363
complete
Franguuuu Aug 26, 2024
b68a460
Merge branch 'master' into dev/organize
Franguuuu Aug 26, 2024
cda96a5
updated
Franguuuu Aug 28, 2024
a31e1a4
separate grid for
Franguuuu Sep 2, 2024
32f67a7
minor
Franguuuu Sep 2, 2024
a80ce96
reorder init
Franguuuu Sep 9, 2024
7e6e0ff
improve code repeating
Franguuuu Sep 30, 2024
3fe594f
update with master
Franguuuu Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
71 changes: 61 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
# A workflow is made up of one or more jobs that can run sequentially or in parallel
jobs:
###############################################################################
Linux-float:
Linux-sycl:
if: ${{ github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-22.04
env:
Expand All @@ -51,6 +51,11 @@ jobs:
libfontconfig1-dev `# From here required for vcpkg opencascade`\
libx11-dev \
libgl-dev
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt update
sudo apt install intel-basekit \
intel-oneapi-runtime-opencl

- uses: hendrikmuhs/ccache-action@v1.2
with:
Expand All @@ -59,7 +64,7 @@ jobs:
- uses: friendlyanon/setup-vcpkg@v1 # Setup vcpkg into ${{github.workspace}}
with:
committish: ${{ env.VCPKG_VERSION }}
cache: false
cache-version: ${{env.VCPKG_VERSION}}

- name: Install dependencies
run: |
Expand All @@ -73,24 +78,70 @@ jobs:
boost-geometry \
simbody \
gtest \
xsimd \
pybind11 \
opencascade
pybind11

- name: Generate buildsystem using float (No test)
- name: Generate buildsystem
run: |
# sycl environment has to be setup for each session
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cmake -G Ninja \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_C_COMPILER=icx -D CMAKE_CXX_COMPILER=icpx \
-D CMAKE_TOOLCHAIN_FILE="${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake" \
-D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D SPHINXSYS_USE_FLOAT=ON \
-D SPHINXSYS_MODULE_OPENCASCADE=ON \
-D SPHINXSYS_CI=ON \
-D SPHINXSYS_USE_SYCL=ON \
-D TEST_STATE_RECORDING=OFF \
-S ${{github.workspace}} \
-B ${{github.workspace}}/build

- name: Build using float
run: cmake --build build --config Release --verbose
- name: Build libraries and tests which are using SYCL
run: |
# sycl environment has to be setup for each session
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cmake --build build --config Release --verbose

- name: Test with the first try
id: first-try
run: |
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cd build/tests/tests_sycl
ctest --output-on-failure --timeout 1000
continue-on-error: true

- name: Test with the second try for failed cases
id: second-try
if: ${{ steps.first-try.outcome == 'failure' }}
run: |
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cd build/tests/tests_sycl
ctest --rerun-failed --output-on-failure --timeout 1000
continue-on-error: true

- name: Test with the third try for failed cases
id: third-try
if: ${{ steps.second-try.outcome == 'failure' }}
run: |
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cd build/tests/tests_sycl
ctest --rerun-failed --output-on-failure --timeout 1000
continue-on-error: true

- name: Test with the fourth try for failed cases
id: fourth-try
if: ${{ steps.third-try.outcome == 'failure' }}
run: |
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cd build/tests/tests_sycl
ctest --rerun-failed --output-on-failure --timeout 1000
continue-on-error: true

- name: Test with the last try for failed cases
if: ${{ steps.fourth-try.outcome == 'failure' }}
run: |
source /opt/intel/oneapi/setvars.sh --include-intel-llvm
cd build/tests/tests_sycl
ctest --rerun-failed --output-on-failure --timeout 1000

###############################################################################
Linux-build:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
##### VS Code
# VS Code setting up
.vscode
*.json
CMakePresets.json

##### Windows
# Windows thumbnail cache files
Expand Down
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ option(SPHINXSYS_DEVELOPER_MODE "Developer mode has more flags active for code q
option(SPHINXSYS_USE_FLOAT "Build using float (single-precision floating-point format) as primary type" OFF)
option(SPHINXSYS_USE_SIMD "Build using SIMD instructions" OFF)
option(SPHINXSYS_MODULE_OPENCASCADE "Build extension relying on OpenCASCADE" OFF)
option(SPHINXSYS_USE_SYCL "Build using SYCL acceleration or not" OFF)

# ------ Global properties (Some cannot be set on INTERFACE targets)
set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Enable verbose compilation commands for Makefile and Ninja" FORCE) # Extra fluff needed for Ninja: https://github.com/ninja-build/ninja/issues/900
Expand Down Expand Up @@ -49,6 +50,14 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# target_compile_options(sphinxsys_core INTERFACE $<$<BOOL:${SPHINXSYS_DEVELOPER_MODE}>:-Wpedantic>) # For strict C++ standard compliance # TODO:
endif()

if(SPHINXSYS_USE_SYCL)
if(NOT SPHINXSYS_USE_FLOAT)
set(SPHINXSYS_USE_FLOAT ON)
message("-- Float is used as required by SPHinXsysSYCL.")
endif()
endif()

target_compile_definitions(sphinxsys_core INTERFACE SPHINXSYS_USE_SYCL=$<BOOL:${SPHINXSYS_USE_SYCL}>)
target_compile_definitions(sphinxsys_core INTERFACE SPHINXSYS_USE_FLOAT=$<BOOL:${SPHINXSYS_USE_FLOAT}>)

# ------ Dependencies
Expand Down Expand Up @@ -98,6 +107,21 @@ if(TARGET Boost::program_options)
target_link_libraries(sphinxsys_core INTERFACE Boost::program_options)
endif()

if(SPHINXSYS_USE_SYCL)
set(SPHINXSYS_USE_SYCL ON)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
message(FATAL_ERROR "-- SPHinXsysSYCL is only supported with IntelLLVM compiler.")
endif()

if(NOT SPHINXSYS_SYCL_TARGETS)
set(SPHINXSYS_SYCL_TARGETS spir64_x86_64)
endif()

message("-- Set SPHinXsysSYCL target as ${SPHINXSYS_SYCL_TARGETS}")
target_compile_options(sphinxsys_core INTERFACE -fsycl -fsycl-targets=${SPHINXSYS_SYCL_TARGETS} -Wno-unknown-cuda-version)
target_link_options(sphinxsys_core INTERFACE -fsycl -fsycl-targets=${SPHINXSYS_SYCL_TARGETS} -Wno-unknown-cuda-version)
endif()

# ------ Setup the concrete libraries
add_subdirectory(src)
add_subdirectory(modules)
Expand Down
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# ![SPHinXsys Logo](assets/logo.png) SPHinXsys

**Notice on repository transfer to SPHinXsys team**
## Notice on the transformation to heterogeneous computational platform

In order to promoting open-source democratization,
this repository will be transferred to the SPHinXsys team
in the next few weeks.
After the transfer, the decision-making process for SPHinXsys will be made by a number of project leaders from different institutions.
SPHinXsys is set to undergo a major transformation, moving from traditional CPU parallelism to a new era of heterogeneous parallelism, where compute-intensive tasks can harness the power of both CPUs and GPUs. This evolution will be driven by SYCL (via Intel's DPC++), enabling us to leverage heterogeneous architectures with standard C++. Importantly, this transformation will be achieved with minimal disruption to the existing codebase, ensuring seamless continuity for current users.

The groundwork for this shift is already laid out. A 2D dambreak test case has been added to the `test/test_sycl` folder, showcasing the capabilities of our specially designed framework. What's unique about this framework is that it allows for the development and testing of numerical methods even in environments without GPUs or DPC++ installed. If these methods are crafted following our specified guidelines and prove functional, they will seamlessly operate in environments equipped with DPC++ and GPU support.

By embracing this new paradigm, SPHinXsys is positioning itself at the forefront of multi-physics modeling, where performance meets versatility.

**Project status**
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand All @@ -19,7 +20,14 @@ After the transfer, the decision-making process for SPHinXsys will be made by a
[![YouTube](https://img.shields.io/badge/YouTube-FF0000.svg?style=flat&logo=YouTube&logoColor=white)](https://www.youtube.com/channel/UCexdJbxOn9dvim6Jg1dnCFQ)
[![Bilibili](https://img.shields.io/badge/bilibili-%E5%93%94%E5%93%A9%E5%93%94%E5%93%A9-critical)](https://space.bilibili.com/1761273682/video)

## Description
## Master and stable branches

The most active development (or default) branch of this repository is `master`.
This branch gives the updated development of SPHinXsys using heterogeneous (using TBB and SYCL) parallelism.

The most stable branch of the repository is `version1.0`, which is based on CPU (using TBB) parallelism.

## Repository Description

SPHinXsys (pronunciation: s'fink-sis) is an acronym from **S**moothed **P**article **H**ydrodynamics for **in**dustrial comple**X** **sys**tems.
The multi-physics library uses SPH (smoothed particle hydrodynamics) as the underlying numerical method
Expand All @@ -46,6 +54,8 @@ Here, we present several short examples in flow, solid dynamics, fluid structure
<img src="https://github.com/Xiangyu-Hu/SPHinXsys-public-files/blob/master/videos/fish-swimming.gif" height="168px"></a>
<a href="https://github.com/Xiangyu-Hu/SPHinXsys/blob/master/tests/2d_examples/test_2d_column_collapse/column_collapse.cpp">
<img src="https://github.com/Xiangyu-Hu/SPHinXsys-public-files/blob/master/videos/2d_column_collapse.gif" height="168px"></a>
<a href="https://github.com/Xiangyu-Hu/SPHinXsys/blob/master/tests/extra_source_and_tests/test_2d_T_pipe_VIPO_shell/T_pipe_VIPO_shell.cpp">
<img src="https://github.com/Xiangyu-Hu/SPHinXsys-public-files/blob/master/videos/fluid-shell-interaction.gif" height="168px"></a>

## Fully compatible to classical FVM method

Expand All @@ -61,36 +71,28 @@ The only difference is that SPHinXsys reads a predefined mesh, other than genera

## Target-driven optimization

The unique target-driven optimization is able to achieve the optimization target and physical solution all-in-once,
The unique target-driven optimization is able to achieve the optimization target and physical solution all-in-once,
which is able to accelerate optimization process greatly.
The following gives an example of optimizing the conductivity distribution
The following gives an example of optimizing the conductivity distribution
for a thermal domain problem targeting minimum average temperature.

<a href="https://github.com/Xiangyu-Hu/SPHinXsys/blob/master/tests/optimization/test_2d_VP_heat_flux_optimization/VP_heat_flux_optimization.cpp">
<img src="https://github.com/Xiangyu-Hu/SPHinXsys-public-files/blob/master/videos/optimization.gif" height="192px"></a>

Note that the physical solution of the thermal domain (right) and the optimal distribution of conductivity (left)
are obtained at the same time when optimization is finished.
Also note that the entire optimization process is very fast and
are obtained at the same time when optimization is finished.
Also note that the entire optimization process is very fast and
only several times slower than that for a single physical solution with given conductivity distribution.

## Python interface

While SPHinXsys is written in C++, it provides a python interface for users to write python scripts to control the simulation,
While SPHinXsys is written in C++, it provides a python interface for users to write python scripts to control the simulation,
including carry out regression tests for continuous integration (CI) and other tasks.
One example is given below for the dambreak case.
Please check the source code of
[2D Dambreak case with python interface](https://github.com/Xiangyu-Hu/SPHinXsys/tree/master/tests/2d_examples/test_2d_dambreak_python)
Please check the source code of
[2D Dambreak case with python interface](https://github.com/Xiangyu-Hu/SPHinXsys/tree/master/tests/2d_examples/test_2d_dambreak_python)
for the usage.

## Heterogenous computing

Recently, we have a preview release for the heterogeneous computing version of SPHinXsys.
By using SYCL, a royalty-free open standard developed by the Khronos Group that allows developers
to program heterogeneous architectures in standard C++, SPHinXsys is able to utilize the power of GPU.
Please check the [Preview Release](https://github.com/Xiangyu-Hu/SPHinXsys/releases/tag/v1.0-beta.08-sycl)
and the [SYCL branch](https://github.com/Xiangyu-Hu/SPHinXsys/tree/sycl) for details.

## Publications

Main publication on the library:
Expand All @@ -114,10 +116,10 @@ For a Docker image, check <https://hub.docker.com/r/toshev/sphinxsys>.

## Interaction with SPHinXsys and the team

Thank you for using and supporting our open-source project!
Thank you for using and supporting our open-source project!
We value each feedback.

#### For SPHinXsys users:
#### For SPHinXsys users

Your input is crucial to us. We encourage you to report any issues you encounter with the library, including:

Expand All @@ -128,7 +130,7 @@ Your input is crucial to us. We encourage you to report any issues you encounter

We particularly appreciate feedback stemming from practical simulations or projects, as these insights are essential for improving SPHinXsys.

#### For SPHinXsys developers:
#### For SPHinXsys developers

If you don't have a GitHub account yet, please register for one. Fork the SPHinXsys repository to add new features or improve existing ones. Once your changes are ready, commit them and initiate a pull request to have your contributions merged into the main repository.

Expand Down
14 changes: 7 additions & 7 deletions modules/opencascade/opencascade/relax_dynamics_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace relax_dynamics
{
//=================================================================================================//
ShapeSurfaceBounding2::ShapeSurfaceBounding2(RealBody &real_body_)
: LocalDynamics(real_body_), DataDelegateSimple(real_body_),
pos_(*particles_->getVariableDataByName<Vecd>("Position"))
: LocalDynamics(real_body_),
pos_(particles_->getVariableDataByName<Vecd>("Position"))
{
shape_ = &real_body_.getInitialShape();
}
Expand All @@ -24,7 +24,7 @@ void ShapeSurfaceBounding2::update(size_t index_i, Real dt)
//=================================================================================================//
RelaxationStepInnerFirstHalf::
RelaxationStepInnerFirstHalf(BaseInnerRelation &inner_relation)
: BaseDynamics<void>(inner_relation.getSPHBody()), real_body_(inner_relation.real_body_),
: BaseDynamics<void>(), real_body_(inner_relation.real_body_),
inner_relation_(inner_relation), relaxation_acceleration_inner_(inner_relation) {}
//=================================================================================================//
void RelaxationStepInnerFirstHalf::exec(Real dt)
Expand All @@ -37,7 +37,7 @@ void RelaxationStepInnerFirstHalf::exec(Real dt)
//=================================================================================================//
RelaxationStepInnerSecondHalf::
RelaxationStepInnerSecondHalf(BaseInnerRelation &inner_relation)
: BaseDynamics<void>(inner_relation.getSPHBody()), real_body_(inner_relation.real_body_),
: BaseDynamics<void>(), real_body_(inner_relation.real_body_),
get_time_step_square_(*real_body_), update_particle_position_(*real_body_),
surface_bounding_(*real_body_)
{
Expand All @@ -52,10 +52,10 @@ void RelaxationStepInnerSecondHalf::exec(Real dt)

//=================================================================================================//
SurfaceNormalDirection::SurfaceNormalDirection(SPHBody &sph_body)
: DataDelegateSimple(sph_body), LocalDynamics(sph_body),
: LocalDynamics(sph_body),
surface_shape_(DynamicCast<SurfaceShape>(this, &sph_body.getInitialShape())),
pos_(*particles_->getVariableDataByName<Vecd>("Position")),
n_(*particles_->registerSharedVariable<Vecd>("NormalDirection")) {}
pos_(particles_->getVariableDataByName<Vecd>("Position")),
n_(particles_->registerStateVariable<Vecd>("NormalDirection")) {}

//=================================================================================================//
void SurfaceNormalDirection::update(size_t index_i, Real dt)
Expand Down
9 changes: 4 additions & 5 deletions modules/opencascade/opencascade/relax_dynamics_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ class SurfaceShape;

namespace relax_dynamics
{
class ShapeSurfaceBounding2 : public LocalDynamics,
public DataDelegateSimple
class ShapeSurfaceBounding2 : public LocalDynamics
{
public:
ShapeSurfaceBounding2(RealBody &real_body_);
virtual ~ShapeSurfaceBounding2(){};
void update(size_t index_i, Real dt = 0.0);

protected:
StdLargeVec<Vecd> &pos_;
Vecd *pos_;
Shape *shape_;
};

Expand Down Expand Up @@ -86,7 +85,7 @@ class RelaxationStepInnerSecondHalf : public BaseDynamics<void>
* @class SurfaceNormalDirection
* @brief get the normal direction of surface particles.
*/
class SurfaceNormalDirection : public DataDelegateSimple, public LocalDynamics
class SurfaceNormalDirection : public LocalDynamics
{
public:
explicit SurfaceNormalDirection(SPHBody &sph_body);
Expand All @@ -95,7 +94,7 @@ class SurfaceNormalDirection : public DataDelegateSimple, public LocalDynamics

protected:
SurfaceShape *surface_shape_;
StdLargeVec<Vecd> &pos_, &n_;
Vecd *pos_, *n_;
};

} // namespace relax_dynamics
Expand Down
Loading