Skip to content

Commit

Permalink
begin zsfem & femmesh
Browse files Browse the repository at this point in the history
  • Loading branch information
littlemine committed Oct 11, 2021
1 parent e2ed74d commit 2135774
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 14 deletions.
2 changes: 1 addition & 1 deletion projects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
52 changes: 40 additions & 12 deletions projects/gmpm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $<$<COMPILE_LANGUAGE:CUDA>:${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 $<$<LINK_LANGUAGE:CUDA>:-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 $<$<COMPILE_LANGUAGE:CUDA>:${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 $<$<LINK_LANGUAGE:CUDA>:-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)
Expand All @@ -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)
39 changes: 39 additions & 0 deletions projects/gmpm/ZensimMesh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once
#include "zensim/math/Vec.h"
#include "zensim/math/matrix/Matrix.hpp"
#include "zensim/math/matrix/Matrix.hpp"
#include <zeno/types/PrimitiveObject.h>

namespace zeno {

struct ZenoFEMMesh : zeno::IObject {

using value_type = float;
using spmat_type = zs::YaleSparseMatrix<value_type, int>;
using allocator_type = zs::ZSPmrAllocator<>;

std::shared_ptr<zeno::PrimitiveObject> _mesh;
zs::Vector<int> _bouDoFs;
zs::Vector<int> _freeDoFs;
zs::Vector<int> _DoF2FreeDoF;
zs::Vector<int> _SpMatFreeDoFs;
zs::Vector<zs::vec<int, 12, 12>> _elmSpIndices;

zs::Vector<value_type> _elmMass;
zs::Vector<value_type> _elmVolume;
zs::Vector<zs::vec<value_type, 9, 12>> _elmdFdx;
zs::Vector<zs::vec<value_type, 4, 4>> _elmMinv;

zs::Vector<value_type> _elmYoungModulus;
zs::Vector<value_type> _elmPossonRatio;
zs::Vector<value_type> _elmDensity;

spmat_type _connMatrix;
spmat_type _freeConnMatrix;

zs::Vector<zs::vec<value_type, 3, 3>> _elmAct;
zs::Vector<zs::vec<value_type, 3, 3>> _elmOrient;
zs::Vector<zs::vec<value_type, 3>> _elmWeight;
};

} // namespace zeno
1 change: 1 addition & 0 deletions projects/gmpm/fem/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../ZensimMesh.h"
2 changes: 1 addition & 1 deletion projects/gmpm/zecomp

0 comments on commit 2135774

Please sign in to comment.