From a0570ff9f5d15804d192d5611ae3a8afd347605f Mon Sep 17 00:00:00 2001 From: littlemine Date: Mon, 25 Sep 2023 22:19:03 +0800 Subject: [PATCH] fix bugs and typos --- .../CuLagrange/fem/FleshDynamicStepping.cu | 2 +- .../collision_energy/evaluate_collision.hpp | 28 ++++++++------- projects/CuLagrange/geometry/Topology.cu | 2 +- .../CuLagrange/geometry/kernel/geo_math.hpp | 6 ++-- .../geometry/kernel/intersection.hpp | 5 +-- .../CuLagrange/geometry/kernel/topology.hpp | 2 +- .../constraint_function_kernel/constraint.cuh | 34 +++++++++---------- 7 files changed, 42 insertions(+), 37 deletions(-) diff --git a/projects/CuLagrange/fem/FleshDynamicStepping.cu b/projects/CuLagrange/fem/FleshDynamicStepping.cu index 62558f2dda..4e298a31fc 100644 --- a/projects/CuLagrange/fem/FleshDynamicStepping.cu +++ b/projects/CuLagrange/fem/FleshDynamicStepping.cu @@ -2315,7 +2315,7 @@ struct FleshDynamicStepping : INode { auto inds = gh_buffer.pack(dim_c<4>,"inds",ei).reinterpret_bits(int_c); for(int i = 0;i != 4;++i) if(inds[i] < 0 || inds[i] >= vsize) - printf("negative sttemp inds : %d %d %d\n",inds[0],inds[1],inds[2],inds[3]); + printf("negative sttemp inds : %d %d %d, %d\n",inds[0],inds[1],inds[2],inds[3]); auto H = gh_buffer.pack(dim_c<12,12>,"H",ei); update_hessian(spmat,inds,H,true); }); diff --git a/projects/CuLagrange/fem/collision_energy/evaluate_collision.hpp b/projects/CuLagrange/fem/collision_energy/evaluate_collision.hpp index 2c2edab20d..acfd1ac74e 100644 --- a/projects/CuLagrange/fem/collision_energy/evaluate_collision.hpp +++ b/projects/CuLagrange/fem/collision_energy/evaluate_collision.hpp @@ -1298,6 +1298,7 @@ void calc_continous_self_PT_collision_impulse(Pol& pol, else triCCDBvh.build(pol,bvs); + auto execTag = wrapv{}; pol(zs::range(verts.size()),[ invMass = proxy({},invMass), xtag = xtag, @@ -1309,7 +1310,7 @@ void calc_continous_self_PT_collision_impulse(Pol& pol, impulse_buffer = proxy(impulse_buffer), impulse_count = proxy(impulse_count), eps = eps, - exec_tag = wrapv{}, + execTag, bvh = proxy(triCCDBvh)] ZS_LAMBDA(int vi) mutable { auto p = verts.pack(dim_c<3>,xtag,vi); auto v = verts.pack(dim_c<3>,vtag,vi); @@ -1392,9 +1393,9 @@ void calc_continous_self_PT_collision_impulse(Pol& pol, for(int i = 0;i != 4;++i) { auto beta = (bary[i] * invMass("minv",inds[i])) / cm; - atomic_add(exec_tag,&impulse_count[inds[i]],1); + atomic_add(execTag,&impulse_count[inds[i]],1); for(int d = 0;d != 3;++d) - atomic_add(exec_tag,&impulse_buffer[inds[i]][d],impulse[d] * beta); + atomic_add(execTag,&impulse_buffer[inds[i]][d],impulse[d] * beta); } }; bvh.iter_neighbors(bv,do_close_proximity_detection); @@ -1435,6 +1436,7 @@ void calc_continous_self_EE_collision_impulse(Pol& pol, else edgeCCDBvh.build(pol,edgeBvs); + auto execTag = wrapv{}; pol(zs::range(edges.size()),[ xtag = xtag, vtag = vtag, @@ -1445,7 +1447,7 @@ void calc_continous_self_EE_collision_impulse(Pol& pol, impulse_count = proxy(impulse_count), // thickness = thickness, eps = eps, - exec_tag = wrapv{}, + execTag, edgeBvs = proxy(edgeBvs), bvh = proxy(edgeCCDBvh)] ZS_LAMBDA(int ei) mutable { auto ea = edges.pack(dim_c<2>,"inds",ei,int_c); @@ -1541,9 +1543,9 @@ void calc_continous_self_EE_collision_impulse(Pol& pol, if(!compute_continous_EE_collision_impulse(ps,vs,minvs,imps)) return; for(int i = 0;i != 4;++i) { - atomic_add(exec_tag,&impulse_count[inds[i]],1); + atomic_add(execTag,&impulse_count[inds[i]],1); for(int d = 0;d != 3;++d) - atomic_add(exec_tag,&impulse_buffer[inds[i]][d],imps[i][d]); + atomic_add(execTag,&impulse_buffer[inds[i]][d],imps[i][d]); } #endif }; @@ -1572,15 +1574,17 @@ void apply_impulse(Pol& pol, zs::Vector impulse_count{verts.get_allocator(),verts.size()}; pol(zs::range(impulse_count),[] ZS_LAMBDA(auto& c) mutable {c = 0;}); + auto execTag = wrapv{}; pol(zs::range(imminent_collision_buffer.size()),[ verts = proxy({},verts), vtag = zs::SmallString(vtag), imminent_collision_buffer = proxy({},imminent_collision_buffer), - exec_tag = wrapv{}, + execTag, eps = eps, restitution_rate = imminent_restitution_rate, impulse_count = proxy(impulse_count), - impulse_buffer = proxy(impulse_buffer)] ZS_LAMBDA(auto ci) mutable { + impulse_buffer = proxy(impulse_buffer) + ] ZS_LAMBDA(auto ci) mutable { auto inds = imminent_collision_buffer.pack(dim_c<4>,"inds",ci,int_c); auto bary = imminent_collision_buffer.pack(dim_c<4>,"bary",ci); auto impulse = imminent_collision_buffer.pack(dim_c<3>,"impulse",ci); @@ -1594,9 +1598,9 @@ void apply_impulse(Pol& pol, for(int i = 0;i != 4;++i) { auto beta = verts("minv",inds[i]) * bary[i] / cminv; - atomic_add(exec_tag,&impulse_count[inds[i]],1); + atomic_add(execTag,&impulse_count[inds[i]],1); for(int d = 0;d != 3;++d) - atomic_add(exec_tag,&impulse_buffer[inds[i]][d],impulse[d] * beta); + atomic_add(execTag,&impulse_buffer[inds[i]][d],impulse[d] * beta); } }); @@ -1607,14 +1611,14 @@ void apply_impulse(Pol& pol, impulse_count = proxy(impulse_count), relaxation_rate = imminent_relaxation_rate, eps = eps, - exec_tag = wrapv{}] ZS_LAMBDA(int vi) mutable { + execTag] ZS_LAMBDA(int vi) mutable { if(impulse_buffer[vi].norm() < eps || impulse_count[vi] == 0) return; auto impulse = relaxation_rate * impulse_buffer[vi] / (T)impulse_count[vi]; // auto dp = impulse * verts("minv",vi); for(int i = 0;i != 3;++i) - atomic_add(exec_tag,&verts(vtag,i,vi),impulse[i]); + atomic_add(execTag,&verts(vtag,i,vi),impulse[i]); }); } diff --git a/projects/CuLagrange/geometry/Topology.cu b/projects/CuLagrange/geometry/Topology.cu index da09523af0..07c0d6ee38 100644 --- a/projects/CuLagrange/geometry/Topology.cu +++ b/projects/CuLagrange/geometry/Topology.cu @@ -313,7 +313,7 @@ struct VisualTetrahedraHalfFacet : zeno::INode { auto opposite_hf_idx = zs::reinterpret_bits(halfFacet("opposite_hf",hf_idx)); if(opposite_hf_idx >= 0) { if(opposite_hf_idx >= halfFacet.size()) { - printf("opposite_hf_idx = %d exceeding size of halfFacet : %d\n",opposite_hf_idx,halfFacet.size()); + printf("opposite_hf_idx = %d exceeding size of halfFacet : %d\n", (int)opposite_hf_idx, (int)halfFacet.size()); return; } auto nti = zs::reinterpret_bits(halfFacet("to_tet",opposite_hf_idx)); diff --git a/projects/CuLagrange/geometry/kernel/geo_math.hpp b/projects/CuLagrange/geometry/kernel/geo_math.hpp index 3c0513ad58..e3cbf5aeb9 100644 --- a/projects/CuLagrange/geometry/kernel/geo_math.hpp +++ b/projects/CuLagrange/geometry/kernel/geo_math.hpp @@ -50,10 +50,10 @@ namespace zeno { namespace LSL_GEO { return (costheta / sintheta); } - template 1)> = 0,typename REAL = VecT::value_type> + template 1)> = 0,typename REAL = typename VecT::value_type> constexpr auto cotTheta(const zs::VecInterface& e0,const zs::VecInterface& e1){ - auto de0 = e0.cast(); - auto de1 = e1.cast(); + auto de0 = e0.template cast(); + auto de1 = e1.template cast(); auto costheta = de0.dot(de1); auto sintheta = de0.cross(de1).norm(); return (REAL)(costheta / sintheta); diff --git a/projects/CuLagrange/geometry/kernel/intersection.hpp b/projects/CuLagrange/geometry/kernel/intersection.hpp index a82b66786e..cf2b2765f0 100644 --- a/projects/CuLagrange/geometry/kernel/intersection.hpp +++ b/projects/CuLagrange/geometry/kernel/intersection.hpp @@ -1969,7 +1969,8 @@ int do_global_self_intersection_analysis_on_surface_mesh_info(Pol& pol, r = LSL_GEO::tri_ray_intersect(v1[j],e1s[j],v0[0],v0[1],v0[2]); if(r < (T)(1.0)) { e1_indices[nm_e1_its] = j; - e1_its[nm_e1_its] = v1[i] + e1s[j] * r; + /// @note both these should be 'j' + e1_its[nm_e1_its] = v1[j] + e1s[j] * r; ++nm_e1_its; } } @@ -3462,7 +3463,7 @@ int do_global_intersection_analysis_with_connected_manifolds(Pol& pol, auto hi = key[0]; auto no = halfedges_tab.query(hi); if(no >= closestTriID.size()) { - printf("closestTriID overflow : %d %d\n",no,closestTriID.size()); + printf("closestTriID overflow : %d %d\n",(int)no, (int)closestTriID.size()); return; } auto cti = closestTriID[no]; diff --git a/projects/CuLagrange/geometry/kernel/topology.hpp b/projects/CuLagrange/geometry/kernel/topology.hpp index 843185142e..5bd39206f4 100644 --- a/projects/CuLagrange/geometry/kernel/topology.hpp +++ b/projects/CuLagrange/geometry/kernel/topology.hpp @@ -403,7 +403,7 @@ namespace zeno { constexpr auto CODIM = VecTi::extent; constexpr auto NM_EDGES = (CODIM - 1) * (CODIM) / 2; - zs::vec out_edges[NM_EDGES] = {}; + zs::vec, NM_EDGES> out_edges{}; int nm_out_edges = 0; for(int i = 0;i != CODIM;++i) for(int j = i + 1;j != CODIM;++j) diff --git a/projects/CuLagrange/pbd/constraint_function_kernel/constraint.cuh b/projects/CuLagrange/pbd/constraint_function_kernel/constraint.cuh index 9215cde901..114b6632ad 100644 --- a/projects/CuLagrange/pbd/constraint_function_kernel/constraint.cuh +++ b/projects/CuLagrange/pbd/constraint_function_kernel/constraint.cuh @@ -133,7 +133,7 @@ namespace zeno { namespace CONSTRAINT { return true; } - template + template constexpr bool init_DihedralBendingConstraint( const VECTOR3d& p0, const VECTOR3d& p1, @@ -229,7 +229,7 @@ namespace zeno { namespace CONSTRAINT { return true; } - template + template constexpr bool solve_DihedralConstraint( const VECTOR3d& p0, const SCALER& invMass0, const VECTOR3d& p1, const SCALER& invMass1, @@ -310,24 +310,24 @@ namespace zeno { namespace CONSTRAINT { const VECTOR3d x[4] = { p2, p3, p0, p1 }; // Q = MATRIX4d::uniform(0); - // const auto e0 = x[1].cast() - x[0].cast(); - // const auto e1 = x[2].cast() - x[0].cast(); - // const auto e2 = x[3].cast() - x[0].cast(); - // const auto e3 = x[2].cast() - x[1].cast(); - // const auto e4 = x[3].cast() - x[1].cast(); + // const auto e0 = x[1].template cast() - x[0].template cast(); + // const auto e1 = x[2].template cast() - x[0].template cast(); + // const auto e2 = x[3].template cast() - x[0].template cast(); + // const auto e3 = x[2].template cast() - x[1].template cast(); + // const auto e4 = x[3].template cast() - x[1].template cast(); - const auto e0 = x[1].cast() - x[0].cast(); - const auto e1 = x[2].cast() - x[0].cast(); - const auto e2 = x[3].cast() - x[0].cast(); - const auto e3 = x[2].cast() - x[1].cast(); - const auto e4 = x[3].cast() - x[1].cast(); + const auto e0 = x[1].template cast() - x[0].template cast(); + const auto e1 = x[2].template cast() - x[0].template cast(); + const auto e2 = x[3].template cast() - x[0].template cast(); + const auto e3 = x[2].template cast() - x[1].template cast(); + const auto e4 = x[3].template cast() - x[1].template cast(); - // auto e0 = e0_.cast(); - // auto e1 = e1_.cast(); - // auto e2 = e2_.cast(); - // auto e3 = e3_.cast(); - // auto e4 = e4_.cast(); + // auto e0 = e0_.template cast(); + // auto e1 = e1_.template cast(); + // auto e2 = e2_.template cast(); + // auto e3 = e3_.template cast(); + // auto e4 = e4_.template cast(); // printf("init isometric bending energy : %f %f %f %f\n", // (float)p0.norm(),