Skip to content

Commit 360a202

Browse files
committed
8
1 parent c23b208 commit 360a202

53 files changed

Lines changed: 3642 additions & 102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

img/7.png

-337 Bytes
Loading

simulators/4_friction/include/BarrierEnergy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BarrierEnergy
1919
T val(); // Calculate the value of the energy
2020
const DeviceBuffer<T> &grad(); // Calculate the gradient of the energy
2121
const DeviceTripletMatrix<T, 1> &hess(); // Calculate the Hessian matrix of the energy
22-
const DeviceBuffer<T> compute_mu_lambda(T mu);
22+
void compute_mu_lambda(T mu, DeviceBuffer<T> &device_mu_lambda);
2323
T init_step_size(const DeviceBuffer<T> &p); // Calculate the initial step size for the line search
2424

2525
private:

simulators/4_friction/include/FrictionEnergy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FrictionEnergy
1717
FrictionEnergy &operator=(FrictionEnergy &&rhs);
1818

1919
void update_v(const DeviceBuffer<T> &v);
20-
void update_mu_lambda(const DeviceBuffer<T> &mu_lambda);
20+
DeviceBuffer<T> &get_mu_lambda();
2121
T val(); // Calculate the value of the energy
2222
const DeviceBuffer<T> &grad(); // Calculate the gradient of the energy
2323
const DeviceTripletMatrix<T, 1> &hess(); // Calculate the Hessian matrix of the energy

simulators/4_friction/src/BarrierEnergy.cu

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,13 @@ template class BarrierEnergy<double, 2>;
184184
template class BarrierEnergy<double, 3>;
185185

186186
template <typename T, int dim>
187-
const DeviceBuffer<T> BarrierEnergy<T, dim>::compute_mu_lambda(T mu)
187+
void BarrierEnergy<T, dim>::compute_mu_lambda(T mu, DeviceBuffer<T> &device_mu_lambda)
188188
{
189189
auto &device_x = pimpl_->device_x;
190190
auto &device_n = pimpl_->device_n;
191191
auto &device_o = pimpl_->device_o;
192192
auto &device_contact_area = pimpl_->device_contact_area;
193193
int N = device_x.size() / dim;
194-
DeviceBuffer<T> device_mu_lambda(N);
195194
device_mu_lambda.fill(0);
196195
ParallelFor(256)
197196
.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
@@ -207,5 +206,4 @@ const DeviceBuffer<T> BarrierEnergy<T, dim>::compute_mu_lambda(T mu)
207206
device_mu_lambda(i) = mu*-device_contact_area(i) * dhat *(kappa / 2 * (log(s) / dhat + (s - 1) / d));
208207
} })
209208
.wait();
210-
return device_mu_lambda;
211209
}

simulators/4_friction/src/FrictionEnergy.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void FrictionEnergy<T, dim>::update_v(const DeviceBuffer<T> &v)
5555
pimpl_->device_v.view().copy_from(v);
5656
}
5757
template <typename T, int dim>
58-
void FrictionEnergy<T, dim>::update_mu_lambda(const DeviceBuffer<T> &mu_lambda)
58+
DeviceBuffer<T> &FrictionEnergy<T, dim>::get_mu_lambda()
5959
{
60-
pimpl_->device_mu_lambda.view().copy_from(mu_lambda);
60+
return pimpl_->device_mu_lambda;
6161
}
6262

6363
template <typename T, int dim>

simulators/4_friction/src/simulator.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void FrictionSimulator<T, dim>::Impl::step_forward()
127127
{
128128
DeviceBuffer<T> x_tilde(x.size()); // Predictive position
129129
update_x_tilde(add_vector<T>(x, v, 1, h));
130-
frictionenergy.update_mu_lambda(barrierenergy.compute_mu_lambda(mu));
130+
barrierenergy.compute_mu_lambda(mu, frictionenergy.get_mu_lambda());
131131
DeviceBuffer<T> x_n = x; // Copy current positions to x_n
132132
update_v(add_vector<T>(x, x_n, 1 / h, -1 / h));
133133
int iter = 0;

simulators/5_mov_dirichlet/include/BarrierEnergy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BarrierEnergy
1919
T val(); // Calculate the value of the energy
2020
const DeviceBuffer<T> &grad(); // Calculate the gradient of the energy
2121
const DeviceTripletMatrix<T, 1> &hess(); // Calculate the Hessian matrix of the energy
22-
const DeviceBuffer<T> compute_mu_lambda(T mu);
22+
void compute_mu_lambda(T mu, DeviceBuffer<T> &device_mu_lambda);
2323
T init_step_size(const DeviceBuffer<T> &p); // Calculate the initial step size for the line search
2424

2525
private:

simulators/5_mov_dirichlet/include/FrictionEnergy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FrictionEnergy
1717
FrictionEnergy &operator=(FrictionEnergy &&rhs);
1818

1919
void update_v(const DeviceBuffer<T> &v);
20-
void update_mu_lambda(const DeviceBuffer<T> &mu_lambda);
20+
DeviceBuffer<T> &get_mu_lambda();
2121
T val(); // Calculate the value of the energy
2222
const DeviceBuffer<T> &grad(); // Calculate the gradient of the energy
2323
const DeviceTripletMatrix<T, 1> &hess(); // Calculate the Hessian matrix of the energy

simulators/5_mov_dirichlet/src/BarrierEnergy.cu

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,13 @@ template class BarrierEnergy<double, 2>;
262262
template class BarrierEnergy<double, 3>;
263263

264264
template <typename T, int dim>
265-
const DeviceBuffer<T> BarrierEnergy<T, dim>::compute_mu_lambda(T mu)
265+
void BarrierEnergy<T, dim>::compute_mu_lambda(T mu, DeviceBuffer<T> &device_mu_lambda)
266266
{
267267
auto &device_x = pimpl_->device_x;
268268
auto &device_n = pimpl_->device_n;
269269
auto &device_o = pimpl_->device_o;
270270
auto &device_contact_area = pimpl_->device_contact_area;
271271
int N = device_x.size() / dim;
272-
DeviceBuffer<T> device_mu_lambda(N);
273272
device_mu_lambda.fill(0);
274273
ParallelFor(256)
275274
.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
@@ -285,5 +284,4 @@ const DeviceBuffer<T> BarrierEnergy<T, dim>::compute_mu_lambda(T mu)
285284
device_mu_lambda(i) = mu*-device_contact_area(i) * dhat *(kappa / 2 * (log(s) / dhat + (s - 1) / d));
286285
} })
287286
.wait();
288-
return device_mu_lambda;
289287
}

simulators/5_mov_dirichlet/src/FrictionEnergy.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ void FrictionEnergy<T, dim>::update_v(const DeviceBuffer<T> &v)
5555
pimpl_->device_v.view().copy_from(v);
5656
}
5757
template <typename T, int dim>
58-
void FrictionEnergy<T, dim>::update_mu_lambda(const DeviceBuffer<T> &mu_lambda)
58+
DeviceBuffer<T> &FrictionEnergy<T, dim>::get_mu_lambda()
5959
{
60-
pimpl_->device_mu_lambda.view().copy_from(mu_lambda);
60+
return pimpl_->device_mu_lambda;
6161
}
6262

6363
template <typename T, int dim>

0 commit comments

Comments
 (0)