Skip to content

Commit 8906d23

Browse files
committed
7
1 parent 2d39c6a commit 8906d23

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

simulators/7_self_contact/src/BarrierEnergy.cu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,19 @@ T BarrierEnergy<T, dim>::init_step_size(const DeviceBuffer<T> &p)
370370
{
371371
int xI = device_bp(i / Nbe);
372372
int eI0 = device_be(2*(i % Nbe)), eI1 = device_be(2*(i % Nbe) + 1);
373-
Eigen::Matrix<T, 2, 1> p, e0, e1,dp,de0,de1;
373+
if (xI != eI0 && xI != eI1){
374+
Eigen::Matrix<T, 2, 1> p, e0, e1, dp, de0, de1;
374375
p<<device_x(xI*dim),device_x(xI*dim+1);
375376
e0<<device_x(eI0*dim),device_x(eI0*dim+1);
376377
e1<<device_x(eI1*dim),device_x(eI1*dim+1);
377378
dp<<P(xI*dim),P(xI*dim+1);
378379
de0<<P(eI0*dim),P(eI0*dim+1);
379380
de1<<P(eI1*dim),P(eI1*dim+1);
380381
if (bbox_overlap(p,e0,e1,dp,de0,de1,current_alpha)){
382+
//printf("bbox_overlap at %d %d\n",xI,i);
381383
T toc=narrow_phase_CCD(p,e0,e1,dp,de0,de1,current_alpha);
382384
device_alpha1(i)=min(device_alpha1(i),toc);
383-
} })
385+
}} })
384386
.wait();
385387
return min(min_vector(device_alpha1), current_alpha);
386388
}

simulators/7_self_contact/src/NeoHookean_auto.cu

Lines changed: 0 additions & 5 deletions
Large diffs are not rendered by default.

simulators/7_self_contact/src/distance/CCD.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ __device__ __host__ bool bbox_overlap(const Eigen::Matrix<T, 2, 1> &p, const Eig
1515
}
1616
else
1717
{
18+
// printf("min_p: %f %f\n max_p: %f %f\n min_e: %f %f\n max_e: %f %f\n", min_p[0], min_p[1], max_p[0], max_p[1], min_e[0], min_e[1], max_e[0], max_e[1]);
1819
return true;
1920
}
2021
}

simulators/7_self_contact/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int main()
66
double nu = 0.4, E = 1e5;
77
double Mu = E / (2 * (1 + nu)), Lam = E * nu / ((1 + nu) * (1 - 2 * nu));
88
double rho = 1000,
9-
k = 4e4, initial_stretch = 1, n_seg = 10, h = 0.01, side_len = 1, tol = 0.01, mu = 0.11;
9+
k = 4e4, initial_stretch = 1, n_seg = 3, h = 0.01, side_len = 0.45, tol = 0.01, mu = 0.11;
1010
// printf("Running mass-spring simulator with parameters: rho = %f, k = %f, initial_stretch = %f, n_seg = %d, h = %f, side_len = %f, tol = %f\n", rho, k, initial_stretch, n_seg, h, side_len, tol);
1111
InvFreeSimulator<double, 2> simulator(rho, side_len, initial_stretch, k, h, tol, mu, Mu, Lam, n_seg);
1212
simulator.run();

simulators/7_self_contact/src/square_mesh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "square_mesh.h"
2+
#include <stdio.h>
23
template <typename T>
34
void generate(T side_length, int n_seg, std::vector<T> &x, std::vector<int> &e)
45
{
@@ -59,7 +60,7 @@ void find_boundary(const std::vector<int> &e, std::vector<int> &bp, std::vector<
5960
{
6061
// index all half-edges for fast query
6162
std::set<std::pair<int, int>> edge_set;
62-
for (size_t i = 0; i < e.size()/3; i += 3)
63+
for (size_t i = 0; i < e.size() / 3; i++)
6364
{
6465
for (int j = 0; j < 3; ++j)
6566
{

0 commit comments

Comments
 (0)