Skip to content

Commit

Permalink
revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryichando committed Dec 26, 2024
1 parent 926afa0 commit e372146
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 28 deletions.
5 changes: 1 addition & 4 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Args {
#[clap(long, default_value_t = 0.025)]
pub strain_limit_eps: f32,

#[clap(long, default_value_t = 1024)]
#[clap(long, default_value_t = 64)]
pub binary_search_max_iter: u32,

#[clap(long)]
Expand All @@ -76,9 +76,6 @@ pub struct Args {
#[clap(long, default_value_t = 0.01)]
pub ccd_reduction: f32,

#[clap(long, default_value_t = 0.0025)]
pub ccd_reduction_eps: f32,

#[clap(long, default_value_t = 1e-2)]
pub eiganalysis_eps: f32,

Expand Down
1 change: 0 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ pub fn make_param(args: &Args) -> data::ParamSet {
line_search_max_t: args.line_search_max_t,
ccd_tol: args.contact_ghat,
ccd_reduction: args.ccd_reduction,
ccd_reduction_eps: args.ccd_reduction_eps,
ccd_max_iters: args.ccd_max_iters,
eiganalysis_eps: args.eiganalysis_eps,
friction: args.friction,
Expand Down
6 changes: 3 additions & 3 deletions src/cpp/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#define __host__
#endif

#define EPSILON 1e-8f
#define FLT_MAX 1e8f
#define FLT_MIN -1e8f
#define EPSILON 1.0e-8f
#define FLT_MAX 1.0e8f
#define FLT_MIN -1.0e8f
#define DT_MIN 1e-5f
#define PI 3.14159265358979323846f
#define DEBUG_MODE 0
Expand Down
5 changes: 2 additions & 3 deletions src/cpp/contact/accd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ __device__ float ccd_helper(const Mat3x4f &x0, const Mat3x4f &dx, float u_max,
const ParamSet &param) {
float toi = 0.0f;
float max_t = param.line_search_max_t;
float gap = sqrtf(square_dist_func(x0)) - offset;
float eps = param.ccd_reduction_eps * gap;
float target = param.ccd_reduction * gap + offset;
float eps = param.ccd_reduction * (sqrtf(square_dist_func(x0)) - offset);
float target = 2.0f * eps + offset;
float eps_sqr = eps * eps;
float inv_u_max = 1.0f / u_max;
for (unsigned k = 0; k < param.ccd_max_iters; ++k) {
Expand Down
1 change: 0 additions & 1 deletion src/cpp/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ struct ParamSet {
float line_search_max_t;
float ccd_tol;
float ccd_reduction;
float ccd_reduction_eps;
unsigned ccd_max_iters;
float eiganalysis_eps;
float friction;
Expand Down
26 changes: 11 additions & 15 deletions src/cpp/strainlimiting/strainlimiting.cu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "../utility/dispatcher.hpp"
#include "../utility/utility.hpp"
#include "strainlimiting.hpp"
#include <limits>

namespace strainlimiting {

Expand Down Expand Up @@ -109,31 +108,28 @@ float line_search(const DataSet &data, const Kinematic &kinematic,
const Mat3x2f F1 =
utility::compute_deformation_grad(x1, inv_rest2x2[i]);
const Mat3x2f dF = F1 - F0;
float gap = max_sigma - utility::svd3x2(F0).S.maxCoeff();
float target = max_sigma - param.ccd_reduction * gap;
if (utility::svd3x2(F0 + t * dF).S.maxCoeff() > target) {
if (utility::svd3x2(F0 + t * dF).S.maxCoeff() >= max_sigma) {
float tol = param.ccd_reduction *
(max_sigma - utility::svd3x2(F0).S.maxCoeff());
float target = max_sigma - 2.0f * tol;
float upper_t = t;
float lower_t = 0.0f;
unsigned iter(0);
while (true) {
for (unsigned k = 0; k < param.binary_search_max_iter; ++k) {
t = 0.5f * (upper_t + lower_t);
Svd3x2 svd = utility::svd3x2(F0 + t * dF);
float diff = svd.S.maxCoeff() - target;
if (diff < 0.0f) {
if (fabs(diff) < tol) {
break;
} else if (diff < 0.0f) {
lower_t = t;
} else {
upper_t = t;
}
if (lower_t > 0.0f) {
if (upper_t - lower_t < param.ccd_reduction * lower_t) {
break;
}
}
assert(t > std::numeric_limits<float>::epsilon());
}
t = lower_t;
while (utility::svd3x2(F0 + t * dF).S.maxCoeff() >= target) {
t *= param.dt_decrease_factor;
}
}
assert(utility::svd3x2(F0 + t * dF).S.maxCoeff() <= target);
}
toi[i] = t;
} DISPATCH_END;
Expand Down
1 change: 0 additions & 1 deletion src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ pub struct ParamSet {
pub line_search_max_t: f32,
pub ccd_tol: f32,
pub ccd_reduction: f32,
pub ccd_reduction_eps: f32,
pub ccd_max_iters: u32,
pub eiganalysis_eps: f32,
pub friction: f32,
Expand Down

0 comments on commit e372146

Please sign in to comment.