コード例 #1
0
ファイル: anchor.cpp プロジェクト: rserban/chrono_models
void RunTimeStep(T* mSys, const int frame) {
	if (!save) {
		Vector force = engine_anchor->Get_react_force();
		Vector torque = engine_anchor->Get_react_torque();
		double motor_torque = engine_anchor->Get_mot_torque();
		cout << force.x << " " << force.y << " " << force.z << " " << torque.x << " " << torque.y << " " << torque.z << " " << motor_torque << " " << ANCHOR->GetPos().y << " "
				<< ANCHOR->GetPos_dt().y << endl;

		ANCHOR->SetPos(ChVector<>(REFERENCE->GetPos().x, ANCHOR->GetPos().y, REFERENCE->GetPos().z));
		ANCHOR->SetPos_dt(ChVector<>(REFERENCE->GetPos_dt().x, ANCHOR->GetPos_dt().y, REFERENCE->GetPos_dt().z));
		ANCHOR->SetRot(REFERENCE->GetRot());
		ANCHOR->SetWvel_loc(REFERENCE->GetWvel_loc());

		REFERENCE->SetPos(ChVector<>(REFERENCE->GetPos().x, ANCHOR->GetPos().y, REFERENCE->GetPos().z));
		REFERENCE->SetPos_dt(ChVector<>(REFERENCE->GetPos_dt().x, ANCHOR->GetPos_dt().y, REFERENCE->GetPos_dt().z));
	}
//	real t = frame * timestep * PI * 2 * frequency;
//
//	BLOCK->SetRot(ChQuaternion<>(1, 0, 0, 0));
//	BLOCK->SetWvel_loc(ChVector<>(0, 0, 0));
//	BLOCK->SetPos(ChVector<>(sin(t) * amplitude, BLOCK->GetPos().y, 0));
//	BLOCK->SetPos_dt(ChVector<>(cos(t) * amplitude * 2 * PI * frequency, BLOCK->GetPos_dt().y, 0));
//
//	CONTAINER->SetPos(ChVector<>(sin(t) * amplitude, 0, 0));
//	CONTAINER->SetPos_dt(ChVector<>(cos(t) * amplitude * 2 * PI * frequency, 0, 0));
//	CONTAINER->SetWvel_loc(ChVector<>(0, 0, 0));
//	CONTAINER->SetRot(ChQuaternion<>(1, 0, 0, 0));
//
//
//	real cont_vol = (container_size.x - container_thickness * 2) * 2 * (BLOCK->GetPos().y + container_size.y - 2 * container_thickness) * (container_size.z - container_thickness * 2) * 2;
//	cout << layer_gen->total_volume << " " << layer_gen->total_mass << " " << cont_vol << " " << layer_gen->total_mass / cont_vol << endl;
//

	if (save) {
		if (layers < 130 && frame % 80 == 0) {
			cout << layers << endl;
			layer_gen->addPerturbedVolumeMixture(R3(0, -container_size.y + container_thickness + particle_radius * 5 + frame / 14.0, 0), I3(32, 1, 32), R3(0, 0, 0), R3(0, 0, 0));
			layers++;
		}
	} else {
		//300 - 457.2
//		double time = actuator_anchor->GetChTime();
//		if (ANCHOR->GetPos().y <= 300 - 457.2 && once) {
//			motionFunc1->Set_y0(time * -anchor_vel);
//			motionFunc1->Set_ang(-2);
////			motionFunc2->Set_y0(time * -anchor_rot * 1 / 60.0 * 2 * CH_C_PI);
////			motionFunc2->Set_ang(0);
//			if (ChFunction_Const* mfun = dynamic_cast<ChFunction_Const*>(engine_anchor->Get_spe_funct())) {
//				mfun->Set_yconst(0);     // rad/s  angular speed
//			}
//			once = false;
//		}
	}

}
コード例 #2
0
void createTerrain(ChSystem & sys, double dia, double W, double H, double L)
{
	int x = W/dia-3;
	int y = H/dia;
	int z = L/dia-3;
	double mass = 0.05 * 4/3*CH_C_PI*pow(particleDiameter/2.0,3.0);// density * volume
	double inertia = 0.4*mass*particleDiameter*particleDiameter/4.0;

	ChSharedBodyPtr particle;
	for (int i=3; i<x; i++)
	{
		for (int j=0; j<y; j++)
		{
			for (int k=3; k<z; k++)
			{
				particle=ChSharedBodyPtr(new ChBody);
				particle->SetPos(ChVector<>(-W/2.0,-boxDrop,-(chassisL/2.0)-2.0) + ChVector<>(i+ChRandom()-0.5,j,k+ChRandom()-0.5) * dia);
				particle->SetMass(mass); 
				particle->SetInertiaXX(ChVector<>(inertia,inertia,inertia));
				particle->GetCollisionModel()->AddSphere(dia/2.0);
				particle->SetCollide(true);
				particle->SetPos_dt(ChVector<>(ChRandom()-0.5,-ChRandom(),ChRandom()-0.5)*10 );
				sys.AddBody(particle);
			}
		}
	}
}
コード例 #3
0
ファイル: mixer_fast.cpp プロジェクト: rserban/chrono_models
void RunTimeStep(T* mSys, const int frame) {
	if (mSys->GetNbodies() < max_particles) {
		if (frame % int(100*particle_radius/.2) == 0) {
			layer_gen->addPerturbedVolumeMixture(R3(0, 0, 0), I3(100, 1, 100), R3(.1, 0, .1), R3(0, -5, 0));
		}
	}

	ang -= CH_C_PI * timestep / 2.0;
	if (ang <= 0) {
		ang = 2 * CH_C_PI;
	}
	Quaternion q1;
	q1.Q_from_AngY(ang);
	spinner->SetPos(Vector(0, container_height - container_size.y + 2, 0));
	spinner->SetPos_dt(Vector(0, 0, 0));
	//spinner->SetRot(q1);

	//spinner->SetWvel_loc(Vector(0, -CH_C_PI / 2.0, 0));
}