Skip to content

Commit cdc96fb

Browse files
committed
7
1 parent 7499205 commit cdc96fb

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

simulators/7_self_contact/src/BarrierEnergy.cu

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const DeviceBuffer<T> &BarrierEnergy<T, dim>::grad()
160160
for (int j = 0; j < dim; j++)
161161
{
162162
T grad =device_contact_area(i) * dhat * (kappa / 2 * (log(s) / dhat + (s - 1) / d)) * device_n_ceil(j);
163-
device_grad(i * dim + j) += grad;
163+
atomicAdd(&device_grad(i * dim + j), grad);
164164
atomicAdd(&device_grad((N-1) * dim + j), -grad);
165165
}
166166
} })
@@ -381,11 +381,14 @@ T BarrierEnergy<T, dim>::init_step_size(const DeviceBuffer<T> &p)
381381
if (bbox_overlap(p, e0, e1, dp, de0, de1, current_alpha))
382382
{
383383
T toc = narrow_phase_CCD(p, e0, e1, dp, de0, de1, current_alpha);
384+
printf("toc: %f\n", toc);
384385
device_alpha1(i) = min(device_alpha1(i), toc);
385386
}
386387
} })
387388
.wait();
388-
return min(min_vector(device_alpha1), current_alpha);
389+
T a = min(min_vector(device_alpha1), current_alpha);
390+
printf("alpha: %f\n", a);
391+
return a;
389392
}
390393
template class BarrierEnergy<float, 2>;
391394
template class BarrierEnergy<float, 3>;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ __device__ __host__ T narrow_phase_CCD(Eigen::Matrix<T, 2, 1> p, Eigen::Matrix<T
3434
{
3535
return toc_upperbound;
3636
}
37-
37+
printf("maxDispMag: %f\n", maxDispMag);
38+
printf("dp: %f, %f\n", dp[0], dp[1]);
39+
printf("de0: %f, %f\n", de0[0], de0[1]);
40+
printf("de1: %f, %f\n", de1[0], de1[1]);
3841
T eta = 0.1; // calculate the toc that first brings the distance to 0.1x the current distance
3942
T dist2_cur = PointEdgeDistanceVal(p, e0, e1);
4043
T dist_cur = std::sqrt(dist2_cur);
@@ -51,6 +54,7 @@ __device__ __host__ T narrow_phase_CCD(Eigen::Matrix<T, 2, 1> p, Eigen::Matrix<T
5154
e1 += tocLowerBound * de1;
5255
dist2_cur = PointEdgeDistanceVal(p, e0, e1);
5356
dist_cur = std::sqrt(dist2_cur);
57+
printf("dist_cur: %f\n", dist_cur);
5458
if (toc != 0 && dist_cur < gap)
5559
{
5660
break;

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 = 3, h = 0.01, side_len = 0.45, tol = 0.01, mu = 0.11;
9+
k = 4e4, initial_stretch = 1, n_seg = 1, 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();

0 commit comments

Comments
 (0)