Skip to content

Commit

Permalink
Merge pull request #1317 from zenustech/flesh-simu-rel
Browse files Browse the repository at this point in the history
Flesh simu rel
  • Loading branch information
littlemine authored Jul 26, 2023
2 parents 921c91a + 82a2d63 commit 28c52ab
Show file tree
Hide file tree
Showing 14 changed files with 1,877 additions and 1,242 deletions.
3 changes: 2 additions & 1 deletion projects/CuLagrange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ target_sources(zeno PRIVATE
geometry/file_parser/vtk_types.hpp
geometry/linear_system/mfcg.hpp
geometry/linear_system/active_set.hpp
geometry/kernel/laplace_matrix.hpp
geometry/kernel/differential_geometry.hpp
geometry/kernel/gradient_field.hpp
geometry/kernel/bary_centric_weights.hpp
geometry/kernel/compute_characteristic_length.hpp
Expand All @@ -127,6 +127,7 @@ target_sources(zeno PRIVATE
# geometry/VectorField.cu
geometry/CollisionVis.cu # CHECK THIS
# geometry/CalcSurfaceArea.cu
geometry/BasicGeoNodes.cu
geometry/MarkSurfaceTag.cu
geometry/SurfaceBinder.cu
geometry/MarkInversion.cu
Expand Down
652 changes: 199 additions & 453 deletions projects/CuLagrange/fem/FleshDynamicStepping.cu

Large diffs are not rendered by default.

516 changes: 405 additions & 111 deletions projects/CuLagrange/fem/collision_energy/evaluate_collision.hpp

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions projects/CuLagrange/geometry/BasicGeoNodes.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "kernel/bary_centric_weights.hpp"
#include "zensim/io/MeshIO.hpp"
#include "zensim/math/bit/Bits.h"
#include "zensim/types/Property.h"
#include <atomic>
#include <zeno/VDBGrid.h>
#include <zeno/types/ListObject.h>
#include <zeno/types/NumericObject.h>
#include <zeno/types/PrimitiveObject.h>
#include <zeno/types/StringObject.h>

#include "zensim/container/Bcht.hpp"
#include "kernel/tiled_vector_ops.hpp"
#include "kernel/geo_math.hpp"

#include <iostream>

namespace zeno {

struct ZSComputeSurfaceArea : zeno::INode {
using T = float;
virtual void apply() override {
using namespace zs;
constexpr auto cuda_space = execspace_e::cuda;
auto cudaPol = cuda_exec();
constexpr auto exec_tag = wrapv<cuda_space>{};

auto zsparticles = get_input<ZenoParticles>("zsparticles");
auto& verts = zsparticles->getParticles();
bool is_tet_volume_mesh = zsparticles->category == ZenoParticles::category_e::tet;
auto &tris = is_tet_volume_mesh ? (*zsparticles)[ZenoParticles::s_surfTriTag] : zsparticles->getQuadraturePoints();

auto attrName = get_param<std::string>("attrName");
if(!verts.hasProperty(attrName)) {
verts.append_channels(cudaPol,{{attrName,1}});
}
TILEVEC_OPS::fill(cudaPol,verts,attrName,(T)0.0);

if(!tris.hasProperty(attrName)) {
tris.append_channels(cudaPol,{{attrName,1}});
}
TILEVEC_OPS::fill(cudaPol,verts,attrName,(T)0.0);

zs::Vector<int> nmIncidentTris{verts.get_allocator(),verts.size()};
cudaPol(zs::range(nmIncidentTris),[] ZS_LAMBDA(int& count) mutable {count = 0;});

cudaPol(zs::range(tris.size()),[
exec_tag,
attrName = zs::SmallString(attrName),
tris = proxy<cuda_space>({},tris),
nmIncidentTris = proxy<cuda_space>(nmIncidentTris),
verts = proxy<cuda_space>({},verts)] ZS_LAMBDA(int ti) mutable {
auto tri = tris.pack(dim_c<3>,"inds",ti,int_c);
zs::vec<T,3> tV[3] = {};
for(int i = 0;i != 3;++i)
tV[i] = verts.pack(dim_c<3>,"x",tri[i]);
auto A = LSL_GEO::area(tV[0],tV[1],tV[2]);
tris(attrName,ti) = A;
for(int i = 0;i != 3;++i) {
atomic_add(exec_tag,&verts(attrName,tri[i]),A);
atomic_add(exec_tag,&nmIncidentTris[0],(int)1);
}
});

cudaPol(zs::range(verts.size()),[
verts = proxy<cuda_space>({},verts),
attrName = zs::SmallString(attrName),
nmIncidentTris = proxy<cuda_space>(nmIncidentTris)] ZS_LAMBDA(int vi) mutable {
if(nmIncidentTris[vi] > 0)
verts(attrName,vi) = verts(attrName,vi) / (T)nmIncidentTris[vi];
});

set_output("zsparticles",zsparticles);
}
};


ZENDEFNODE(ZSComputeSurfaceArea, {{{"zsparticles"}},
{{"zsparticles"}},
{
{"string","attrName","area"}
},
{"ZSGeometry"}});

};
2 changes: 1 addition & 1 deletion projects/CuLagrange/geometry/BiharmonicBoundedWeight.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <zeno/types/PrimitiveObject.h>
#include <zeno/types/StringObject.h>

#include "kernel/laplace_matrix.hpp"
#include "kernel/differential_geometry.hpp"
#include "linear_system/active_set.hpp"

namespace zeno {
Expand Down
355 changes: 184 additions & 171 deletions projects/CuLagrange/geometry/CollisionVis.cu

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion projects/CuLagrange/geometry/SolveLaplacian.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <zeno/types/PrimitiveObject.h>
#include <zeno/types/StringObject.h>

#include "kernel/laplace_matrix.hpp"
#include "kernel/differential_geometry.hpp"
#include "linear_system/mfcg.hpp"

namespace zeno {
Expand Down
Loading

0 comments on commit 28c52ab

Please sign in to comment.