Skip to content

Commit 38a9d54

Browse files
committed
more NH fixes
1 parent 7e90c9a commit 38a9d54

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

apps/NeoHookean/barrier_energy.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ template <typename ProblemT,
9999
typename T = typename VAttrT::Type>
100100
void ceiling_barrier_energy(ProblemT& problem,
101101
VAttrT& contact_area,
102-
const VAttrT& x,
103102
const T h, // time_step
104103
const vec3<T>& ground_n,
105104
const vec3<T>& ground_o,
@@ -119,10 +118,10 @@ void ceiling_barrier_energy(ProblemT& problem,
119118

120119
const VertexHandle c1 = iter[1];
121120

122-
//???
123-
const Eigen::Vector3<ActiveT> xi = iter_val<ActiveT, 3>(id, iter, x, 0);
121+
const Eigen::Vector3<ActiveT> xi =
122+
iter_val<ActiveT, 3>(id, iter, obj, 0);
124123

125-
const Eigen::Vector3<T> x_dbc = x.template to_eigen<3>(c1);
124+
const Eigen::Vector3<T> x_dbc = obj.template to_eigen<3>(c1);
126125

127126

128127
// ceiling
@@ -138,15 +137,6 @@ void ceiling_barrier_energy(ProblemT& problem,
138137
return ActiveT(std::numeric_limits<PassiveT>::max());
139138
}
140139

141-
if constexpr (is_scalar_v<ActiveT>) {
142-
printf("\n Ceil AC: T= %d, d= %f, s= %f",
143-
threadIdx.x,
144-
d.val(),
145-
s.val());
146-
} else {
147-
printf("\n Ceil PA: T= %d, d= %f, s= %f", threadIdx.x, d, s);
148-
}
149-
150140
E = h_sq * contact_area(c0) * dhat * T(0.5) * kappa * (s - 1) *
151141
log(s);
152142
}

apps/NeoHookean/neo_hookean.cu

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void neo_hookean(RXMeshStatic& rx, T dx)
5353

5454
// TODO the limits and velocity should be different for different Dirichlet
5555
// nodes
56-
const vec3<T> v_dbc_vel(0, -0.9, 0); // Dirichlet node velocity
56+
const vec3<T> v_dbc_vel(0, -1.0, 0); // Dirichlet node velocity
5757
const vec3<T> v_dbc_limit(0, -0.7, 0); // Dirichlet node limit position
5858
const vec3<T> ground_o(0.0f, -1.0f, 0.0f); // a point on the slope
5959
const vec3<T> ground_n =
@@ -166,7 +166,7 @@ void neo_hookean(RXMeshStatic& rx, T dx)
166166
kappa);
167167

168168
ceiling_barrier_energy(
169-
problem, contact_area, x, time_step, ground_n, ground_o, dhat, kappa);
169+
problem, contact_area, time_step, ground_n, ground_o, dhat, kappa);
170170

171171

172172
T line_search_init_step = 0;
@@ -182,8 +182,7 @@ void neo_hookean(RXMeshStatic& rx, T dx)
182182
// ground_n);
183183

184184
// add neo hooken energy
185-
neo_hookean_energy(
186-
problem, x, is_dbc, volume, inv_b, mu_lame, time_step, lam);
185+
neo_hookean_energy(problem, is_dbc, volume, inv_b, mu_lame, time_step, lam);
187186

188187

189188
int steps = 0;
@@ -273,9 +272,7 @@ void neo_hookean(RXMeshStatic& rx, T dx)
273272
line_search_init_step = std::min(nh_step, bar_step);
274273

275274
// TODO: line search should pass the step to the friction energy
276-
if (!newton_solver.line_search(line_search_init_step, 0.5, 5)) {
277-
break;
278-
}
275+
newton_solver.line_search(line_search_init_step, 0.5);
279276

280277
// evaluate energy
281278
add_contact(rx, problem.vv_pairs, v_dbc[0], is_dbc, x, dhat);
@@ -309,7 +306,7 @@ void neo_hookean(RXMeshStatic& rx, T dx)
309306
iter++;
310307
}
311308

312-
RXMESH_INFO("===================");
309+
RXMESH_INFO("\n===================\n");
313310

314311
// update velocity
315312
rx.for_each_vertex(

apps/NeoHookean/neo_hookean_energy.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
using namespace rxmesh;
66

77
template <typename ProblemT,
8-
typename VAttrT,
98
typename VAttrI,
109
typename VAttrF,
1110
typename VAttrFM,
1211
typename T>
1312
void neo_hookean_energy(ProblemT& problem,
14-
const VAttrT& x,
1513
const VAttrI& is_dbc,
1614
const VAttrF& volume,
1715
const VAttrFM& inv_b,
@@ -34,9 +32,9 @@ void neo_hookean_energy(ProblemT& problem,
3432
return ActiveT();
3533
}
3634

37-
Eigen::Vector3<ActiveT> x0 = iter_val<ActiveT, 3>(fh, iter, x, 0);
38-
Eigen::Vector3<ActiveT> x1 = iter_val<ActiveT, 3>(fh, iter, x, 1);
39-
Eigen::Vector3<ActiveT> x2 = iter_val<ActiveT, 3>(fh, iter, x, 2);
35+
Eigen::Vector3<ActiveT> x0 = iter_val<ActiveT, 3>(fh, iter, obj, 0);
36+
Eigen::Vector3<ActiveT> x1 = iter_val<ActiveT, 3>(fh, iter, obj, 1);
37+
Eigen::Vector3<ActiveT> x2 = iter_val<ActiveT, 3>(fh, iter, obj, 2);
4038

4139
Eigen::Vector3<ActiveT> e0 = x2 - x0;
4240
Eigen::Vector3<ActiveT> e1 = x1 - x0;

0 commit comments

Comments
 (0)