diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 6a147a2f2b..39a4bf9df2 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) -set(EXTENSIONS_LIST ZenoFX oldzenbase zenvdb FastFLIP FLIPtools Rigid BulletTools cgmesh gmpm mesher Euler OldZMS OldZFX EasyGL) +set(EXTENSIONS_LIST ZenoFX oldzenbase zenvdb FastFLIP FLIPtools Rigid BulletTools cgmesh gmpm zsfem mesher Euler OldZMS OldZFX EasyGL) set(EXTENSIONS_ENABLE_LIST ZenoFX oldzenbase) add_library(zeno_nodep INTERFACE) diff --git a/projects/gmpm/CMakeLists.txt b/projects/gmpm/CMakeLists.txt index 000f16d6c2..153f665bd5 100644 --- a/projects/gmpm/CMakeLists.txt +++ b/projects/gmpm/CMakeLists.txt @@ -19,6 +19,11 @@ add_subdirectory(zecomp) # cmake_policy(SET CMP0104 OLD) # endif (POLICY CMP0104) +add_library(zeno_zsfem SHARED) +target_sources(zeno_zsfem PRIVATE + fem/test.cpp +) + add_library(zeno_gmpm SHARED) target_sources(zeno_gmpm PRIVATE @@ -48,29 +53,45 @@ endif() if (${ZS_ENABLE_CUDA}) enable_language(CUDA) target_compile_features(zeno_gmpm PRIVATE cuda_std_17) -endif() -target_compile_features(zeno_gmpm PRIVATE cuda_std_17) - -target_compile_features(zeno_gmpm PRIVATE cxx_std_17) + target_compile_options(zeno_gmpm + PRIVATE $<$:${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr --default-stream=per-thread --use_fast_math -lineinfo --ptxas-options=-allow-expensive-optimizations=true> + ) + target_link_options(zeno_gmpm + PUBLIC $<$:-dlto> + ) + set_target_properties(zeno_gmpm + PROPERTIES CUDA_EXTENSIONS ON + CUDA_SEPARABLE_COMPILATION ON + LINKER_LANGUAGE CUDA + POSITION_INDEPENDENT_CODE ON + CUDA_ARCHITECTURES OFF + ) -#simd compiler flags -if (WIN32) -else() -target_compile_options(zeno_gmpm PRIVATE "-march=native") -endif() -target_compile_options(zeno_gmpm + target_compile_features(zeno_zsfem PRIVATE cuda_std_17) + target_compile_options(zeno_zsfem PRIVATE $<$:${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr --default-stream=per-thread --use_fast_math -lineinfo --ptxas-options=-allow-expensive-optimizations=true> ) -target_link_options(zeno_gmpm + target_link_options(zeno_zsfem PUBLIC $<$:-dlto> ) -set_target_properties(zeno_gmpm + set_target_properties(zeno_zsfem PROPERTIES CUDA_EXTENSIONS ON CUDA_SEPARABLE_COMPILATION ON LINKER_LANGUAGE CUDA POSITION_INDEPENDENT_CODE ON CUDA_ARCHITECTURES OFF ) +endif() + +target_compile_features(zeno_gmpm PRIVATE cxx_std_17) +target_compile_features(zeno_zsfem PRIVATE cxx_std_17) + +#simd compiler flags +if (WIN32) +else() +target_compile_options(zeno_gmpm PRIVATE "-march=native") +target_compile_options(zeno_zsfem PRIVATE "-march=native") +endif() target_link_libraries(zeno_gmpm PRIVATE zensim) target_link_libraries(zeno_gmpm PUBLIC zeno) @@ -79,4 +100,11 @@ target_link_libraries(zeno_gmpm PUBLIC ZFX) target_include_directories(zeno_gmpm PRIVATE ../oldzenbase/include) target_include_directories(zeno_gmpm PRIVATE ../zenvdb/include) +target_link_libraries(zeno_zsfem PRIVATE zensim) +target_link_libraries(zeno_zsfem PUBLIC zeno) +target_link_libraries(zeno_zsfem PRIVATE zeno_nodep) +target_link_libraries(zeno_zsfem PUBLIC ZFX) +target_include_directories(zeno_zsfem PRIVATE ../oldzenbase/include) +target_include_directories(zeno_zsfem PRIVATE ../zenvdb/include) + endif(ENABLE_GMPM_BUILD) diff --git a/projects/gmpm/ZensimMesh.h b/projects/gmpm/ZensimMesh.h new file mode 100644 index 0000000000..2d9580d720 --- /dev/null +++ b/projects/gmpm/ZensimMesh.h @@ -0,0 +1,39 @@ +#pragma once +#include "zensim/math/Vec.h" +#include "zensim/math/matrix/Matrix.hpp" +#include "zensim/math/matrix/Matrix.hpp" +#include + +namespace zeno { + +struct ZenoFEMMesh : zeno::IObject { + + using value_type = float; + using spmat_type = zs::YaleSparseMatrix; + using allocator_type = zs::ZSPmrAllocator<>; + + std::shared_ptr _mesh; + zs::Vector _bouDoFs; + zs::Vector _freeDoFs; + zs::Vector _DoF2FreeDoF; + zs::Vector _SpMatFreeDoFs; + zs::Vector> _elmSpIndices; + + zs::Vector _elmMass; + zs::Vector _elmVolume; + zs::Vector> _elmdFdx; + zs::Vector> _elmMinv; + + zs::Vector _elmYoungModulus; + zs::Vector _elmPossonRatio; + zs::Vector _elmDensity; + + spmat_type _connMatrix; + spmat_type _freeConnMatrix; + + zs::Vector> _elmAct; + zs::Vector> _elmOrient; + zs::Vector> _elmWeight; +}; + +} // namespace zeno \ No newline at end of file diff --git a/projects/gmpm/fem/test.cpp b/projects/gmpm/fem/test.cpp new file mode 100644 index 0000000000..b3402e6f98 --- /dev/null +++ b/projects/gmpm/fem/test.cpp @@ -0,0 +1 @@ +#include "../ZensimMesh.h" \ No newline at end of file diff --git a/projects/gmpm/zecomp b/projects/gmpm/zecomp index 4d4e501fd4..7b8c9bcee3 160000 --- a/projects/gmpm/zecomp +++ b/projects/gmpm/zecomp @@ -1 +1 @@ -Subproject commit 4d4e501fd48072573bd4f1e742370f4a6b3c4bd4 +Subproject commit 7b8c9bcee345de532a5ad6bec623e7735355cf15