Skip to content

Commit

Permalink
company.
Browse files Browse the repository at this point in the history
  • Loading branch information
Siwang Li committed Jul 21, 2015
1 parent 8c8c049 commit 80cdfe7
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 26 deletions.
6 changes: 3 additions & 3 deletions data/dino/two_decoupled.ini → data/dino/cubes_decoupled.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"save_to" : "tempt_cubes_decoupled",

"newton_max_iteration":1,
"newton_tolerance" :8e-5,
"mprgp_tolerance" :8e-5,
"newton_tolerance" :1e-5,
"mprgp_tolerance" :1e-5,
"mprgp_max_iteration" :1000,

"static_friction" :0.0,
"kinetic_friction" :0.0,

"fem_solver" :"mprgp",
"collision_type" :"surface",
"coll_type" :"surface",
"enable_self_con" :true,

"group_vol_mtl_file" : ["model/mesh.abq", "model/mesh.elastic"],
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions data/dino/two.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"gravity" : [0.0,0.0,0.0],
"coll_pen" : 1e7,
"coll_dectect_depth": 0.0,
"num_frames" : 100,
"num_frames" : 50,
"save_to" : "tempt_two2",

"newton_max_iteration":1,
"newton_tolerance" :1e-3,
"mprgp_tolerance" :1e-3,
"newton_tolerance" :1e-5,
"mprgp_tolerance" :1e-5,
"mprgp_max_iteration" :1000,

"static_friction" :0.0,
Expand Down
4 changes: 3 additions & 1 deletion script/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

# ./bin/release/collision_handle ./data/dino/cubes.ini > tempt/dino_cubes.txt

./bin/release/collision_handle ./data/dino/two_decoupled.ini > tempt/dino_two_decoupled.txt
./bin/release/collision_handle ./data/dino/cubes_decoupled.ini > tempt/dino_decoupled.txt

# ./bin/release/collision_handle ./data/dino/two_general.ini > tempt/dino_two_general.txt

# ./bin/release/collision_handle ./data/dino/two.ini > tempt/dino_two.txt

# ./bin/release/collision_handle ./data/bunny/two.ini > tempt/bunny_two.txt

# ./bin/release/collision_handle ./data/bunny/two_general.ini > tempt/bunny_two_general.txt
Expand Down
2 changes: 1 addition & 1 deletion src/CollisionHandle/LinearConCollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void SurfaceSelfConCache::getConstraints(TRIPS &trips, vector<double> &rhs, cons
}

void LinearConCollider::handle(boost::shared_ptr<FEMBody> b, const Vector4d &plane, const double delta){

for (int i = 0; i < (int)b->nrV(); ++i){
const boost::shared_ptr<FEMVertex> v = b->getVPtr(i);
const Vec3d n = plane.segment<3>(0);
Expand Down
23 changes: 14 additions & 9 deletions src/CollisionHandle/MprgpFemSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,20 +496,25 @@ void DecoupledMprgpFemSolver::forward(const double dt){

SparseMatrix<double> J, J_full;
VectorXd c, c_full;
if(ccd_collider) ccd_collider->setDecoupleConstraints(false);
if(dcd_collider) dcd_collider->setDecoupleConstraints(false);
getCollConstraints(J_full,c_full);

if(ccd_collider) ccd_collider->setDecoupleConstraints(true);
if(dcd_collider) dcd_collider->setDecoupleConstraints(true);
getCollConstraints(J,c);

{
if(ccd_collider) ccd_collider->setDecoupleConstraints(false);
if(dcd_collider) dcd_collider->setDecoupleConstraints(false);
handleCollDetection(dt);
getCollConstraints(J_full,c_full);
INFO_LOG("J_full.rows(), nz: " << J_full.rows()<< ", " << J_full.nonZeros());
}
{
if(ccd_collider) ccd_collider->setDecoupleConstraints(true);
if(dcd_collider) dcd_collider->setDecoupleConstraints(true);
handleCollDetection(dt);
getCollConstraints(J,c);
INFO_LOG("J.rows(), nz: " << J.rows()<< ", " << J.nonZeros());
}
const SparseMatrix<double> JJt_mat = J*J.transpose();
assert_eq_ext(JJt_mat.nonZeros(), J.rows(), "Matrix J is not decoupled.\n" << J);
Vec JJt;
MATH::getDiagonal(JJt_mat, JJt);
DecoupledConProjector<double> projector(J, JJt, c);
INFO_LOG("J.rows(): " << J.rows());

UTILITY::Timer timer;
const VectorXd last_pos = x1;
Expand Down
18 changes: 9 additions & 9 deletions test_case/GeneralDecoupledCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ BOOST_AUTO_TEST_SUITE(gdcompare)

void loadQPFile(const string qp, SparseMatrix<double> &A,
SparseMatrix<double> &J,VectorXd &B,
VectorXd &c, VectorXd &init_x){
VectorXd &c, VectorXd &init_x, const string ext){

const bool load_succ = loadQP(A, B, J, c, init_x, qp);
assert(load_succ);
cout << "A.rows() = " << A.rows() << endl;
cout << "J.rows() = " << J.rows() << endl;
cout << "A.nonZeros() = " << A.nonZeros() << endl;
cout << "J.nonZeros() = " << J.nonZeros() << endl;
cout<< ext << "A.rows() = " << A.rows() << endl;
cout<< ext << "J.rows() = " << J.rows() << endl;
cout<< ext << "A.nonZeros() = " << A.nonZeros() << endl;
cout<< ext << "J.nonZeros() = " << J.nonZeros() << endl;
}

BOOST_AUTO_TEST_CASE(compare){

UTILITY::Timer timer;
const string project_dir = "/home/simba/Workspace/MPRGP/";
const string qp_base = project_dir+"/data/dino/tempt_cubes_decoupled/QP/";
const string qp_base = project_dir+"/data/dino/tempt_two2/QP/";

const double tol = 8e-5; // *B.norm()
const int max_it = 1000;

typedef FixedSparseMatrix<double> MAT;
const int T = 170;
const int T = 30;
SparseMatrix<double> A, J;
VectorXd B, c, init_x, dec_ev, gen_ev;
for (int f = 0; f < T ; ++f){

{// decoupled mprgp
ostringstream qp;
qp << qp_base << "qpdec"<< f << ".b";
loadQPFile(qp.str(),A,J,B,c,init_x);
loadQPFile(qp.str(),A,J,B,c,init_x,"dec ");
MAT FA(A);
VectorXd x = init_x;
if(dec_ev.size() != init_x.size()){
Expand All @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(compare){
{// general mprgp
ostringstream qp;
qp << qp_base << "qpfull"<< f << ".b";
loadQPFile(qp.str(),A,J,B,c,init_x);
loadQPFile(qp.str(),A,J,B,c,init_x,"gen ");
MAT FA(A);
VectorXd x = init_x;
if(gen_ev.size() != init_x.size()){
Expand Down

0 comments on commit 80cdfe7

Please sign in to comment.