@@ -213,6 +213,7 @@ const DeviceTripletMatrix<T, 1> &BarrierEnergy<T, dim>::hess()
213213 int Nbp = device_bp.size (), Nbe = device_be.size () / 2 ;
214214 int Npe = Nbp * Nbe;
215215 int N = device_x.size () / dim;
216+ device_hess_val.fill (0 );
216217 ParallelFor (256 ).apply (N, [device_x = device_x.cviewer (), device_contact_area = device_contact_area.cviewer (), device_hess_val = device_hess_val.viewer (), device_hess_row_idx = device_hess_row_idx.viewer (), device_hess_col_idx = device_hess_col_idx.viewer (), N, device_n = device_n.cviewer (), device_o = device_o.cviewer ()] __device__ (int i) mutable
217218 {
218219 T d = 0 ;
@@ -230,8 +231,6 @@ const DeviceTripletMatrix<T, 1> &BarrierEnergy<T, dim>::hess()
230231 device_hess_col_idx (idx) = i * dim + k;
231232 if (d < dhat)
232233 device_hess_val (idx) = device_contact_area (i) * dhat * kappa / (2 * d * d * dhat) * (d + dhat) * device_n (j) * device_n (k);
233- else
234- device_hess_val (idx) = 0 ;
235234 }
236235 } })
237236 .wait ();
@@ -257,8 +256,6 @@ const DeviceTripletMatrix<T, 1> &BarrierEnergy<T, dim>::hess()
257256 device_hess_val (idx) = device_contact_area (i) * dhat * kappa / (2 * d * d * dhat) * (d + dhat) * device_n_ceil (j) * device_n_ceil (k);
258257 else
259258 device_hess_val (idx) = -device_contact_area (i) * dhat * kappa / (2 * d * d * dhat) * (d + dhat) * device_n_ceil (j) * device_n_ceil (k);
260- else
261- device_hess_val (idx) = 0 ;
262259 }
263260 } })
264261 .wait ();
@@ -276,7 +273,6 @@ const DeviceTripletMatrix<T, 1> &BarrierEnergy<T, dim>::hess()
276273 int idx = N * dim * dim + (N - 1 ) * dim * dim * 4 + i * dim * dim*9 + nI * dim * dim*3 + nJ * dim * dim + j * dim + k;
277274 device_hess_row_idx (idx) = index[nI] * dim + j;
278275 device_hess_col_idx (idx) = index[nJ] * dim + k;
279- device_hess_val (idx) = 0 ;
280276 }
281277 }
282278 if (xI != eI0 && xI != eI1){
@@ -398,17 +394,17 @@ template class BarrierEnergy<double, 2>;
398394template class BarrierEnergy <double , 3 >;
399395
400396template <typename T, int dim>
401- void BarrierEnergy<T, dim>::compute_mu_lambda(T mu, DeviceBuffer<T>& device_mu_lambda)
397+ void BarrierEnergy<T, dim>::compute_mu_lambda(T mu, DeviceBuffer<T> & device_mu_lambda)
402398{
403- auto & device_x = pimpl_->device_x ;
404- auto & device_n = pimpl_->device_n ;
405- auto & device_o = pimpl_->device_o ;
406- auto & device_contact_area = pimpl_->device_contact_area ;
399+ auto & device_x = pimpl_->device_x ;
400+ auto & device_n = pimpl_->device_n ;
401+ auto & device_o = pimpl_->device_o ;
402+ auto & device_contact_area = pimpl_->device_contact_area ;
407403 int N = device_x.size () / dim;
408404 device_mu_lambda.fill (0 );
409405 ParallelFor (256 )
410406 .apply (N, [device_x = device_x.cviewer (), device_mu_lambda = device_mu_lambda.viewer (), mu, device_n = device_n.cviewer (), device_o = device_o.cviewer (), device_contact_area = device_contact_area.cviewer ()] __device__ (int i) mutable
411- {
407+ {
412408 T d = 0 ;
413409 for (int j = 0 ; j < dim; j++)
414410 {
@@ -418,7 +414,6 @@ void BarrierEnergy<T, dim>::compute_mu_lambda(T mu, DeviceBuffer<T>& device_mu_l
418414 {
419415 T s = d / dhat;
420416 device_mu_lambda (i) = mu * -device_contact_area (i) * dhat * (kappa / 2 * (log (s) / dhat + (s - 1 ) / d));
421- }
422- })
417+ } })
423418 .wait ();
424419}
0 commit comments