Hi,
I'm having a problem with collisions when using the ChSystemMulticoreNSC. Basically if I try to make two simple box shapes collide, there seems to be no restitution, and the bodies stick together. On the other hand, with ChSystemNSC, the bodies collide correctly according to the input CoR. Is restitution implemented in ChSystemMulticoreNSC?
I attach a code snippet for more clarity.
Thanks!
Samuele
//========== CREATE CHRONO PHYSICAL SYSTEM ========================//
ChSystemMulticoreNSC sys;
//======================== NUMERICAL SOLVER ======================//
// Set solver parameters
sys.SetCollisionSystemType(ChCollisionSystem::Type::MULTICORE); /*
sys.GetSettings()->solver.max_iteration_bilateral = max_iteration;
sys.GetSettings()->solver.tolerance = tolerance;
// sys.GetSettings()->collision.narrowphase_algorithm = ChNarrowphase::Algorithm::HYBRID; //this is default
sys.GetSettings()->collision.bins_per_axis = vec3(10, 10, 10);
sys.GetSettings()->collision.broadphase_grid = ChBroadphase::GridType::FIXED_DENSITY;
sys.GetSettings()->collision.grid_density = 1;
// Solver type
sys.GetSettings()->solver.solver_type = SolverType::MINIMUM_RESIDUAL;
std::cout << "Solver is Minimum Residual" << std::endl;
//sys.SetNumThreads(21);
// Set number of threads.
int threads = 40;
threads = std::min(threads, ChOMP::GetNumProcs());
sys.SetNumThreads(threads);
std::cout << "Max. threads available " << ChOMP::GetNumProcs() << "\n";
std::cout << "Using " << threads << " threads" << "\n";
#pragma omp parallel
{
printf("thread %d\n", omp_get_thread_num());
}
*/
///// === COMPUTE DERIVED QUANTITIES === ////////
// ============= SET LOCAL GRAVITY ================//
sys.SetGravitationalAcceleration(ChVector3d(gx_local, gy_local, gz_local));
// ============= CREATE CONTACT MATERIAL ==========//
// === Lander material properties === //
auto terrain_mat = chrono_types::make_shared<ChContactMaterialNSC>();
terrain_mat->SetRestitution(CoR_terrain);
// === Container material properties === //
auto container_mat = chrono_types::make_shared<ChContactMaterialNSC>();
container_mat->SetRestitution(CoR_wall);
container_mat->SetStaticFriction(0.1);
// === Ground material properties === //
auto lander_mat = chrono_types::make_shared<ChContactMaterialNSC>();
lander_mat->SetRestitution(CoR_lander);
//lander_mat->SetStaticFriction(0.1);
// ============ CREATE BODIES ==================//
// Container
auto cdim = ChVector3<>(cdimX, cdimY, cdimZ); // half-dims
auto cpos = ChVector3<>(cposX, cposY, cposZ);
auto bin = chrono_types::make_shared<ChBody>();
bin->SetMass(1);
cpos.x() = 0;
cpos.z() = -cdim.z();
bin->SetPos(cpos);
bin->SetRot(ChQuaternion<>(1, 0, 0, 0));
bin->EnableCollision(true);
bin->SetFixed(true);
// floor
chrono::utils::AddBoxGeometry(bin.get(), container_mat, ChVector3<>(cdim.x(), cdim.y(), tw) * 2.0,
ChVector3<>(0, 0, -tw), ChQuaternion<>(1, 0, 0, 0), true);
// left wall
chrono::utils::AddBoxGeometry(bin.get(), container_mat, ChVector3<>(tw, cdim.y(), cdim.z() + tw) * 2.0,
ChVector3<>(-cdim.x() - tw, 0, cdim.z() - tw), ChQuaternion<>(1, 0, 0, 0), false);
// right wall
chrono::utils::AddBoxGeometry(bin.get(), container_mat, ChVector3<>(tw, cdim.y(), cdim.z() + tw) * 2.0,
ChVector3<>(cdim.x() + tw, 0, cdim.z() - tw), ChQuaternion<>(1, 0, 0, 0), false);
// front wall
chrono::utils::AddBoxGeometry(bin.get(), container_mat, ChVector3<>(cdim.x(), tw, cdim.z() + tw) * 2.0,
ChVector3<>(0, -cdim.y() - tw, cdim.z() - tw), ChQuaternion<>(1, 0, 0, 0), true);
// rear wall
chrono::utils::AddBoxGeometry(bin.get(), container_mat, ChVector3<>(cdim.x(), tw, cdim.z() + tw) * 2.0,
ChVector3<>(0, cdim.y() + tw, cdim.z() - tw), ChQuaternion<>(1, 0, 0, 0), false);
sys.AddBody(bin);
std::cout << "Container position is: " << bin->GetPos().x() << " " << bin->GetPos().y() << " " << bin->GetPos().z() << "\n";
// Create lander (cube)
auto lander = std::make_shared<ChBody>();
ChCoordsys<> mcoord; // local coordinates system
mcoord.pos = ChVector3<>(px_lander, py_lander, pz_lander);
//double halfAngle = (Ry / 2.0) * (3.14159265358979311 / 180.);
mcoord.rot = ChQuaternion<>(q0_lander, q1_lander, q2_lander, q3_lander);
lander->SetCoordsys(mcoord);
lander->SetPosDt(ChVector3<>(vx_lander, vy_lander, vz_lander));
lander->SetPosDt2(ChVector3<>(0, 0, 0));
lander->SetMass(mass_lander);
lander->EnableCollision(true);
utils::AddBoxGeometry(lander.get(), lander_mat, ChVector3<>(lx_lander, ly_lander, lz_lander), ChVector3<>(0, 0, 0), ChQuaternion<>(1, 0, 0, 0), true);
sys.AddBody(lander);