Skip to content

Commit e9ad2b6

Browse files
committed
7 self contact simulator
1 parent 033706c commit e9ad2b6

6 files changed

Lines changed: 296 additions & 288 deletions

File tree

simulators/6_inv_free/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 = 4, h = 0.01, side_len = 1, tol = 0.01, mu = 0.11;
9+
k = 4e4, initial_stretch = 1, n_seg = 10, h = 0.01, side_len = 1, 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/include/simulator.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
#include "square_mesh.h"
66
#include <iostream>
77
template <typename T, int dim>
8-
class InvFreeSimulator
8+
class SelfContactSimulator
99
{
1010
public:
11-
InvFreeSimulator();
12-
~InvFreeSimulator();
13-
InvFreeSimulator(InvFreeSimulator &&rhs);
14-
InvFreeSimulator &operator=(InvFreeSimulator &&rhs);
15-
InvFreeSimulator(T rho, T side_len, T initial_stretch, T K, T h, T tol, T mu, T Mu_, T Lam_, int n_seg);
11+
SelfContactSimulator();
12+
~SelfContactSimulator();
13+
SelfContactSimulator(SelfContactSimulator &&rhs);
14+
SelfContactSimulator &operator=(SelfContactSimulator &&rhs);
15+
SelfContactSimulator(T rho, T side_len, T initial_stretch, T K, T h, T tol, T mu, T Mu_, T Lam_, int n_seg);
1616
void run();
1717

1818
private:

simulators/7_self_contact/src/BarrierEnergy.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ const DeviceBuffer<T> &BarrierEnergy<T, dim>::grad()
193193
}
194194
} })
195195
.wait();
196-
196+
std::vector<T> host_grad(device_grad.size());
197+
device_grad.copy_to(host_grad);
197198
return device_grad;
198199
}
199200

simulators/7_self_contact/src/NeoHookeanEnergy.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ const DeviceBuffer<T> &NeoHookeanEnergy<T, dim>::grad()
125125
}
126126
} })
127127
.wait();
128-
128+
std::vector<T> host_grad(device_grad.size());
129+
device_grad.copy_to(host_grad);
129130
return device_grad;
130131
}
131132

simulators/7_self_contact/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ 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 = 2, h = 0.01, side_len = 0.45, tol = 0.01, mu = 0.11;
9+
k = 4e4, initial_stretch = 1, n_seg = 4, h = 0.01, side_len = 0.45, tol = 0.01, mu = 0.4;
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);
11-
InvFreeSimulator<double, 2> simulator(rho, side_len, initial_stretch, k, h, tol, mu, Mu, Lam, n_seg);
11+
SelfContactSimulator<double, 2> simulator(rho, side_len, initial_stretch, k, h, tol, mu, Mu, Lam, n_seg);
1212
simulator.run();
1313
}

0 commit comments

Comments
 (0)