Skip to content

Commit

Permalink
Merge pull request #44 from Autodesk/MultiResLBMOpt
Browse files Browse the repository at this point in the history
Optimized multi resolution LBM
  • Loading branch information
Ahdhn authored Apr 10, 2024
2 parents d5f120d + f8e7a60 commit 82e4c75
Show file tree
Hide file tree
Showing 43 changed files with 132,141 additions and 902 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
with:
cuda: '11.7.0'
linux-local-args: '["--toolkit"]'
- run: sudo apt-get update
- run: sudo apt-get install -y xorg-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev
- run: nvcc -V
- name: Checkout
uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ temp
docs/doxygen/html/

docs/doxygen/latex/

!apps/lbmMultiRes/practice_v28.obj
!apps/lbmMultiRes/sphere3.obj
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Release)
endif ()

if (WIN32)
set(LIBIGL_USE_STATIC_LIBRARY "ON" CACHE BOOL "Use Libigl as a static library")
set(NEON_USE_POLYSCOPE "ON" CACHE BOOL "Enable Ployscope for visualization")
endif()

if(${NEON_USE_POLYSCOPE})
message(STATUS "Polyscope is enabled")
else()
message(STATUS "Polyscope is disabled")
endif()


# Manage between building Neon as shared or static library
include("${PROJECT_SOURCE_DIR}/cmake/ManageLibraryType.cmake")

Expand Down Expand Up @@ -70,6 +82,9 @@ if (NOT OpenMP_CXX_FOUND)
message(FATAL_ERROR "Neon could not find OpenMP")
endif ()
target_link_libraries(NeonDeveloperLib INTERFACE OpenMP::OpenMP_CXX)
if(${NEON_USE_POLYSCOPE})
target_compile_definitions(NeonDeveloperLib INTERFACE NEON_USE_POLYSCOPE)
endif()

#target_link_libraries(libNeonXXX INTERFACE $<BUILD_INTERFACE:NeonDeveloperLib>)

Expand Down
9 changes: 7 additions & 2 deletions apps/lbmMultiRes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)

set (APP_NAME app-lbmMultiRes)
file(GLOB_RECURSE SrcFiles lbmMultiRes.cu lattice.h init.h postProcess.h util.h coalescence.h collide.h explosion.h stream.h store.h verify.h)
file(GLOB_RECURSE SrcFiles lbmMultiRes.cu lbmMultiRes.h lattice.h init.h postProcess.h util.h coalescence.h collide.h explosion.h stream.h store.h verify.h flowOverShape.h lidDrivenCavity.h fusedFinest.h)

add_executable(${APP_NAME} ${SrcFiles})

target_link_libraries(${APP_NAME}
PUBLIC libNeonSkeleton)
PUBLIC libNeonSkeleton glm::glm igl::core)

if(${NEON_USE_POLYSCOPE})
target_link_libraries(${APP_NAME}
PUBLIC libNeonSkeleton polyscope)
endif()

set_target_properties(${APP_NAME} PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
Expand Down
22 changes: 12 additions & 10 deletions apps/lbmMultiRes/coalescence.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#include "lattice.h"

template <typename T, int Q>
inline Neon::set::Container coalescence(Neon::domain::mGrid& grid,
const bool fineInitStore,
const int level,
const Neon::domain::mGrid::Field<int>& sumStore,
const Neon::domain::mGrid::Field<T>& fout,
Neon::domain::mGrid::Field<T>& fin)
inline Neon::set::Container coalescence(Neon::domain::mGrid& grid,
const bool fineInitStore,
const int level,
const Neon::domain::mGrid::Field<float>& sumStore,
const Neon::domain::mGrid::Field<T>& fout,
Neon::domain::mGrid::Field<T>& fin)
{
// Initiated by the coarse level (hence "pull"), this function simply read the missing population
// across the interface between coarse<->fine boundary by reading the population prepare during the store()
Expand All @@ -22,7 +22,8 @@ inline Neon::set::Container coalescence(Neon::domain::mGrid& g
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::mGrid::Idx& cell) mutable {
//If this cell has children i.e., it is been refined, than we should not work on it
//because this cell is only there to allow query and not to operate on
const int refFactor = pout.getRefFactor(level);
//const int refFactor = pout.getRefFactor(level);
constexpr T repRefFactor = 0.5;
if (!pin.hasChildren(cell)) {

for (int q = 0; q < Q; ++q) {
Expand All @@ -32,15 +33,16 @@ inline Neon::set::Container coalescence(Neon::domain::mGrid& g
}
//if we have a neighbor at the same level that has been refined, then cell is on
//the interface and this is where we should do the coalescence
if (pin.hasChildren(cell, dir)) {

if (pin.hasChildren(cell, dir) && pin.isActive(cell, dir)) {
auto neighbor = pout.getNghData(cell, dir, q);
if (neighbor.mIsValid) {
if (fineInitStore) {
auto ssVal = ss.getNghData(cell, dir, q);
assert(ssVal.mData != 0);
pin(cell, q) = neighbor.mData / static_cast<T>(ssVal.mData * refFactor);
pin(cell, q) = neighbor.mData * ssVal.mData;
} else {
pin(cell, q) = neighbor.mData / static_cast<T>(refFactor);
pin(cell, q) = neighbor.mData * repRefFactor;
}
}
}
Expand Down
Loading

0 comments on commit 82e4c75

Please sign in to comment.