int main(int argc, char *argv[]) { // Problem setup Tutorial7 problem; // instantiate an object of class Tutorial 6 problem.setName("Tutorial7"); problem.setSystemDimensions(2); problem.setGravity(Vec3D(0.0,0.0,0.0)); problem.setXMax(1); problem.setYMax(0.5); problem.setTimeMax(5.0); //! [T7:speciesProp] // The normal spring stiffness and normal dissipation is computed and set as // For collision time tc=0.005 and restitution coefficeint rc=1.0, auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies()); species->setDensity(2500.0); // sets the species type-0 density species->setStiffness(258.5);// sets the spring stiffness species->setDissipation(0.0);// sets the dissipation //! [T7:speciesProp] problem.setSaveCount(10); problem.dataFile.setFileType(FileType::ONE_FILE); problem.restartFile.setFileType(FileType::ONE_FILE); problem.fStatFile.setFileType(FileType::NO_FILE); problem.eneFile.setFileType(FileType::NO_FILE); problem.setXBallsAdditionalArguments("-solidf -v0 -s .85"); problem.setTimeStep(0.005/50.0);// (collision time)/50.0 problem.solve(argc, argv); return 0; }
void BConstraint::setAllAxisStiffness(float stiffness) { for(int i = 0; i < 6; i++) enableSpring(i, stiffness > 0); for(int i = 0; i < 6; i++) setStiffness(i, stiffness); }
/** * Destructor for oru_walk object */ oru_walk::~oru_walk() { setStiffness(0.0f); // Remove the postProcess call back connection stopWalking ("Module destroyed.\n"); if (solver != NULL) { delete solver; solver = NULL; } }
//-------------------------------------------------------------- void ofxBulletSoftBody::add() { _bAdded = true; _world->getWorld()->addSoftBody(_softBody); if( _type != OFX_BULLET_TRI_MESH_SHAPE ) { setMass(1); } setStiffness(0.9, 0.9, 0.9); setSolverIterations(4); // _softBody->getCollisionShape()->setMargin(getMargin() * 2); }
//! [T1:main] int main(int argc, char *argv[]) { // Problem setup Tutorial1 problem; //! [T1:problemSetup] problem.setName("Tutorial1"); problem.setSystemDimensions(3); problem.setGravity(Vec3D(0.0,0.0,0.0)); problem.setXMax(1.0); problem.setYMax(1.0); problem.setZMax(1.0); problem.setTimeMax(2.0); //! [T1:problemSetup] //! [T1:speciesProp] // The normal spring stiffness and normal dissipation is computed and set as // For collision time tc=0.005 and restitution coefficeint rc=1.0, auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies()); species->setDensity(2500.0); // sets the species type-0 density species->setStiffness(258.5);// sets the spring stiffness species->setDissipation(0.0);// sets the dissipation //! [T1:speciesProp] //! [T1:output] problem.setSaveCount(10); problem.dataFile.setFileType(FileType::ONE_FILE); problem.restartFile.setFileType(FileType::ONE_FILE); problem.fStatFile.setFileType(FileType::NO_FILE); problem.eneFile.setFileType(FileType::NO_FILE); std::cout << problem.dataFile.getCounter() << std::endl; //! [T1:output] //! [T1:visualOutput] problem.setXBallsAdditionalArguments("-solidf -v0"); //! [T1:visualOutput] //! [T1:solve] problem.setTimeStep(.005/50.0); // (collision time)/50.0 problem.solve(argc, argv); //! [T1:solve] return 0; }
// constructor // anchor, axis1 and axis2 are in world coordinate system // axis1 must be orthogonal to axis2 btHinge2Constraint::btHinge2Constraint(btRigidBody& rbA, btRigidBody& rbB, btVector3& anchor, btVector3& axis1, btVector3& axis2) : btGeneric6DofSpringConstraint(rbA, rbB, btTransform::getIdentity(), btTransform::getIdentity(), true), m_anchor(anchor), m_axis1(axis1), m_axis2(axis2) { // build frame basis // 6DOF constraint uses Euler angles and to define limits // it is assumed that rotational order is : // Z - first, allowed limits are (-PI,PI); // new position of Y - second (allowed limits are (-PI/2 + epsilon, PI/2 - epsilon), where epsilon is a small positive number // used to prevent constraint from instability on poles; // new position of X, allowed limits are (-PI,PI); // So to simulate ODE Universal joint we should use parent axis as Z, child axis as Y and limit all other DOFs // Build the frame in world coordinate system first btVector3 zAxis = axis1.normalize(); btVector3 xAxis = axis2.normalize(); btVector3 yAxis = zAxis.cross(xAxis); // we want right coordinate system btTransform frameInW; frameInW.setIdentity(); frameInW.getBasis().setValue( xAxis[0], yAxis[0], zAxis[0], xAxis[1], yAxis[1], zAxis[1], xAxis[2], yAxis[2], zAxis[2]); frameInW.setOrigin(anchor); // now get constraint frame in local coordinate systems m_frameInA = rbA.getCenterOfMassTransform().inverse() * frameInW; m_frameInB = rbB.getCenterOfMassTransform().inverse() * frameInW; // sei limits setLinearLowerLimit(btVector3(0.f, 0.f, -1.f)); setLinearUpperLimit(btVector3(0.f, 0.f, 1.f)); // like front wheels of a car setAngularLowerLimit(btVector3(1.f, 0.f, -SIMD_HALF_PI * 0.5f)); setAngularUpperLimit(btVector3(-1.f, 0.f, SIMD_HALF_PI * 0.5f)); // enable suspension enableSpring(2, true); setStiffness(2, SIMD_PI * SIMD_PI * 4.f); // period 1 sec for 1 kilogramm weel :-) setDamping(2, 0.01f); setEquilibriumPoint(); }
void setupInitialConditions() { auto species = speciesHandler.copyAndAddObject(LinearViscoelasticFrictionSpecies()); species->setDensity(constants::pi / 6.0); double stiffness = 1e5; setParticleDimensions(2); species->setDensity(2500); species->setStiffness(stiffness); species->setSlidingStiffness(2.0 / 7.0 * stiffness); species->setSlidingFrictionCoefficient(0.5); species->setRollingStiffness(2.0 / 5.0 * stiffness); species->setRollingFrictionCoefficient(0.5); species->setTorsionStiffness(2.0 / 5.0 * stiffness); species->setTorsionFrictionCoefficient(0.5); setGravity(Vec3D(0.0, 0.0, 0.0)); setTimeMax(8e-2); setTimeStep(2.0e-4); setFileType(FileType::NO_FILE); setXMin(0.0); setYMin(0.0); setXMax(1.0); setYMax(1.0); PeriodicBoundary b0; b0.set(Vec3D(1, 0, 0), getXMin(), getXMax()); boundaryHandler.copyAndAddObject(b0); b0.set(Vec3D(0, 1, 0), getYMin(), getYMax()); boundaryHandler.copyAndAddObject(b0); BaseParticle P0, P1, P2, P3, P4, P5, P6, P7; //Particle to be removed P0.setPosition(Vec3D(0.1, 0.1, 0.0)); P1.setPosition(Vec3D(0.3, 0.3, 0.0)); //Contacts starts normal becomes periodic P2.setPosition(Vec3D(0.6, 0.041, 0.0)); P2.setAngularVelocity(Vec3D(0.3, 0.6, 0.9)); P3.setPosition(Vec3D(0.4, 0.001, 0.0)); //Normal case P4.setPosition(Vec3D(0.6, 0.82, 0.0)); P4.setAngularVelocity(Vec3D(0.3, 0.6, 0.9)); P5.setPosition(Vec3D(0.4, 0.78, 0.0)); //Contact starts periodic becomes normal and periodic again P6.setPosition(Vec3D(0.02, 0.42, 0.0)); P6.setAngularVelocity(Vec3D(0.3, 0.6, 0.9)); P7.setPosition(Vec3D(0.82, 0.38, 0.0)); P0.setVelocity(Vec3D(0.0, 0.0, 0.0)); P1.setVelocity(Vec3D(0.0, 0.0, 0.0)); P2.setVelocity(Vec3D(-1.0, 0.0, 0.0)); P3.setVelocity(Vec3D(1.0, 0.0, 0.0)); P4.setVelocity(Vec3D(-1.0, 0.0, 0.0)); P5.setVelocity(Vec3D(1.0, 0.0, 0.0)); P6.setVelocity(Vec3D(-1.0, 0.0, 0.0)); P7.setVelocity(Vec3D(1.0, 0.0, 0.0)); P0.setRadius(0.1); P1.setRadius(0.1); P2.setRadius(0.1); P3.setRadius(0.1); P4.setRadius(0.1); P5.setRadius(0.1); P6.setRadius(0.1); P7.setRadius(0.1); particleHandler.copyAndAddObject(P0); particleHandler.copyAndAddObject(P1); particleHandler.copyAndAddObject(P2); particleHandler.copyAndAddObject(P3); particleHandler.copyAndAddObject(P4); particleHandler.copyAndAddObject(P5); particleHandler.copyAndAddObject(P6); particleHandler.copyAndAddObject(P7); }