当前位置: 首页>>代码示例>>C++>>正文


C++ ChSharedPtr::GetCollisionModel方法代码示例

本文整理汇总了C++中ChSharedPtr::GetCollisionModel方法的典型用法代码示例。如果您正苦于以下问题:C++ ChSharedPtr::GetCollisionModel方法的具体用法?C++ ChSharedPtr::GetCollisionModel怎么用?C++ ChSharedPtr::GetCollisionModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChSharedPtr的用法示例。


在下文中一共展示了ChSharedPtr::GetCollisionModel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: add_fancy_items

void add_fancy_items(ChSystemMPI& mySys, double prad, double pmass, double width, double g, double h, int n_batch, int n_curr_spheres)
{
	int id_offset=10;
	double particle_mass =4.0; 
	if (pmass>0.0){
		particle_mass=pmass;
	}

	ChSharedPtr<ChBodyDEMMPI> mybody;

	double spacing = (width-8*prad)/(n_batch-1);
	double first = -(width-8*prad)/2;

	for(int jj=0; jj<n_batch; jj++)
	{
		ChVector<> particle_pos(-g+(ChRandom()*2*prad-prad), h, first+jj*spacing);
		if (mySys.nodeMPI->IsInto(particle_pos))
		{
			ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
			mybody->SetIdentifier(id_offset+n_curr_spheres+jj);
			mySys.Add(mybody);
			mybody->GetCollisionModel()->ClearModel();
			mybody->GetCollisionModel()->AddSphere(prad);
			mybody->GetCollisionModel()->BuildModel();
			mybody->SetCollide(true);
			mybody->SetPos(particle_pos);
			mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
			mybody->SetMass(particle_mass);
			mybody->GetCollisionModel()->SyncPosition(); // really necessary?
			mybody->Update(); // really necessary?
		}
	}
}
开发者ID:DavidHammen,项目名称:chrono,代码行数:33,代码来源:demo_DEM_MPI.cpp

示例2: onCallback

  virtual void onCallback(ChSharedPtr<ChBody> wheelBody, double radius, double width) {
    wheelBody->GetCollisionModel()->ClearModel();
    wheelBody->GetCollisionModel()->AddCylinder(0.46, 0.46, width / 2);
    wheelBody->GetCollisionModel()->BuildModel();

    wheelBody->GetMaterialSurfaceDEM()->SetFriction(mu_t);
    wheelBody->GetMaterialSurfaceDEM()->SetYoungModulus(Y_t);
    wheelBody->GetMaterialSurfaceDEM()->SetRestitution(cr_t);
  }
开发者ID:rserban,项目名称:chrono-projects,代码行数:9,代码来源:hmmwvDEM.cpp

示例3: AddWall

// -----------------------------------------------------------------------------
// Utility for adding (visible or invisible) walls
// -----------------------------------------------------------------------------
void AddWall(ChSharedPtr<ChBody>& body, const ChVector<>& dim, const ChVector<>& loc, bool visible) {
    body->GetCollisionModel()->AddBox(dim.x, dim.y, dim.z, loc);

    if (visible == true) {
        ChSharedPtr<ChBoxShape> box(new ChBoxShape);
        box->GetBoxGeometry().Size = dim;
        box->Pos = loc;
        box->SetColor(ChColor(1, 0, 0));
        box->SetFading(0.6f);
        body->AddAsset(box);
    }
}
开发者ID:rserban,项目名称:chrono-projects,代码行数:15,代码来源:demo_shear.cpp

示例4: create_falling_items

void create_falling_items(ChSystemMPI& mySys, double prad, int n_bodies,double box_dim, double pmass){	
	double particle_mass =4.0; 
	if (pmass>0.0){
		particle_mass=pmass;
	}

	ChSharedPtr<ChBodyDEMMPI> mybody;

	double boxxx=box_dim-2*prad;
	for (int ii=0; ii<n_bodies; ii++){
		ChVector<> particle_pos(ChRandom()*boxxx-boxxx/2,ChRandom()*boxxx/2+boxxx/2+prad, ChRandom()*boxxx-boxxx/2);
		if (mySys.nodeMPI->IsInto(particle_pos))
		{
			ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
			mybody->SetIdentifier(10+ii);
			mySys.Add(mybody);
			mybody->GetCollisionModel()->ClearModel();
			mybody->GetCollisionModel()->AddSphere(prad);
			mybody->GetCollisionModel()->BuildModel();
			mybody->SetCollide(true);
			mybody->SetPos(particle_pos);
			mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
			mybody->SetMass(particle_mass);
			mybody->GetCollisionModel()->SyncPosition(); // really necessary?
			mybody->Update(); // really necessary?
		}
	}

	/*
	ChVector<> pp1(0.5*box_dim/2,box_dim/2,0.5*box_dim/2);
	if (mySys.nodeMPI->IsInto(pp1))
	{
		mybody = ChSharedPtr<ChBodyDEMMPI>(new ChBodyDEMMPI);
		mybody->SetIdentifier(11);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(pp1);
		mybody->SetMass(particle_mass);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*prad*prad*ChVector<>(1.0,1.0,1.0));
	}

	ChVector<> pp2(-0.5*box_dim/2,box_dim/2,0.5*box_dim/2);
	if (mySys.nodeMPI->IsInto(pp2))
	{
		mybody = ChSharedPtr<ChBodyDEMMPI>(new ChBodyDEMMPI);
		mybody->SetIdentifier(22);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(pp2);
		mybody->SetMass(particle_mass);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*prad*prad*ChVector<>(1.0,1.0,1.0));
	}

	ChVector<> pp3(0.5*box_dim/2,box_dim/2,-0.5*box_dim/2);
	if (mySys.nodeMPI->IsInto(pp3))
	{
		mybody = ChSharedPtr<ChBodyDEMMPI>(new ChBodyDEMMPI);
		mybody->SetIdentifier(33);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(pp3);
		mybody->SetMass(particle_mass);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*prad*prad*ChVector<>(1.0,1.0,1.0));
	}

	ChVector<> pp4(-0.5*box_dim/2,box_dim/2,-0.5*box_dim/2);
	if (mySys.nodeMPI->IsInto(pp4))
	{
		mybody = ChSharedPtr<ChBodyDEMMPI>(new ChBodyDEMMPI);
		mybody->SetIdentifier(44);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(pp4);
		mybody->SetMass(particle_mass);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*prad*prad*ChVector<>(1.0,1.0,1.0));
	}
	*/

}
开发者ID:DavidHammen,项目名称:chrono,代码行数:91,代码来源:demo_DEM_MPI.cpp

示例5: add_batch

void add_batch(ChSystemMPI& mySys, double prad, double box_dim, double pmass, int n_batch, int n_curr_spheres)
{
	int id_offset=10;
	double particle_mass =4.0; 
	if (pmass>0.0){
		particle_mass=pmass;
	}

	ChSharedPtr<ChBodyDEMMPI> mybody;

	double boxxx=box_dim-4*prad;
	double spacing = (boxxx-8*prad)/((n_batch/4)-1);
	double first = -boxxx/2;
	int cid = 0;

	for(int ii=0; ii<n_batch/4; ii++)
	{
		ChVector<> particle_pos(boxxx/2-2*prad,box_dim/2+2*prad, first+ii*spacing+0.0001);
		if (mySys.nodeMPI->IsInto(particle_pos))
		{
			ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
			mybody->SetIdentifier(id_offset+n_curr_spheres+cid);
			mybody->SetCollide(true);
			mybody->GetCollisionModel()->ClearModel();
			mybody->GetCollisionModel()->AddSphere(prad);
			mybody->GetCollisionModel()->BuildModel();
			mySys.Add(mybody);
			mybody->SetPos(particle_pos);
			mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
			mybody->SetMass(particle_mass);
			mybody->GetCollisionModel()->SyncPosition(); // really necessary?
			mybody->Update(); // really necessary?
		}
		cid++;
	}

	for(int ii=0; ii<n_batch/4; ii++)
	{
		ChVector<> particle_pos(boxxx/2-6*prad,box_dim/2+2*prad, first+ii*spacing+0.0001);
		if (mySys.nodeMPI->IsInto(particle_pos))
		{
			ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
			mybody->SetIdentifier(id_offset+n_curr_spheres+cid);
			mybody->SetCollide(true);
			mybody->GetCollisionModel()->ClearModel();
			mybody->GetCollisionModel()->AddSphere(prad);
			mybody->GetCollisionModel()->BuildModel();
			mySys.Add(mybody);
			mybody->SetPos(particle_pos);
			mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
			mybody->SetMass(particle_mass);
			mybody->GetCollisionModel()->SyncPosition(); // really necessary?
			mybody->Update(); // really necessary?
		}
		cid++;
	}

	//other edge
	for(int ii=0; ii<n_batch/4; ii++)
	{
		ChVector<> particle_pos(first+ii*spacing+0.0001,box_dim/2+2*prad,boxxx/2-2*prad);
		if (mySys.nodeMPI->IsInto(particle_pos))
		{
			ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
			mybody->SetIdentifier(id_offset+n_curr_spheres+cid);
			mybody->SetCollide(true);
			mybody->GetCollisionModel()->ClearModel();
			mybody->GetCollisionModel()->AddSphere(prad);
			mybody->GetCollisionModel()->BuildModel();
			mySys.Add(mybody);
			mybody->SetPos(particle_pos);
			mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
			mybody->SetMass(particle_mass);
			mybody->GetCollisionModel()->SyncPosition(); // really necessary?
			mybody->Update(); // really necessary?
		}
		cid++;
	}

	for(int ii=0; ii<n_batch/4; ii++)
	{
		ChVector<> particle_pos(first+ii*spacing+0.0001,box_dim/2+2*prad,boxxx/2-6*prad);
		if (mySys.nodeMPI->IsInto(particle_pos))
		{
			ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
			mybody->SetIdentifier(id_offset+n_curr_spheres+cid);
			mybody->SetCollide(true);
			mybody->GetCollisionModel()->ClearModel();
			mybody->GetCollisionModel()->AddSphere(prad);
			mybody->GetCollisionModel()->BuildModel();
			mySys.Add(mybody);
			mybody->SetPos(particle_pos);
			mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
			mybody->SetMass(particle_mass);
			mybody->GetCollisionModel()->SyncPosition(); // really necessary?
			mybody->Update(); // really necessary?
		}
		cid++;
	}
}
开发者ID:DavidHammen,项目名称:chrono,代码行数:100,代码来源:demo_DEM_MPI.cpp

示例6: add_falling_item

void add_falling_item(ChSystemMPI& mySys, double prad, double box_dim, double pmass, int n_curr_spheres)
{
	int id_offset=10;
	double particle_mass =4.0; 
	if (pmass>0.0){
		particle_mass=pmass;
	}

	ChSharedPtr<ChBodyDEMMPI> mybody;

	double boxxx=box_dim-2*prad;
	ChVector<> particle_pos(0.8*boxxx/2,box_dim/2+2*prad, 0.6*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_spheres+1);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
		mybody->SetMass(particle_mass);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
	ChVector<> particle_pos2(0.8*boxxx/2,box_dim/2+2*prad, 0.2*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos2))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_spheres+2);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos2);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
		mybody->SetMass(particle_mass);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
	ChVector<> particle_pos3(0.8*boxxx/2,box_dim/2+2*prad, -0.2*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos3))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_spheres+3);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos3);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
		mybody->SetMass(particle_mass);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
	ChVector<> particle_pos4(0.8*boxxx/2,box_dim/2+2*prad, -0.6*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos4))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_spheres+4);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddSphere(prad);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos4);
		mybody->SetInertiaXX((2.0/5.0)*particle_mass*pow(prad,2)*ChVector<>(1,1,1));
		mybody->SetMass(particle_mass);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
}
开发者ID:DavidHammen,项目名称:chrono,代码行数:76,代码来源:demo_DEM_MPI.cpp

示例7: add_other_falling_item

void add_other_falling_item(ChSystemMPI& mySys, double prad, double box_dim, double rho, int n_curr_bodies)
{
	int id_offset=10;
	double m_s = (2/3)*CH_C_PI*pow(prad,3)*rho; 
	double m_c = CH_C_PI*pow(prad,2)*(2*prad)*rho;
	double m_cube = prad*prad*prad*rho;

	ChVector<> pos1(0,prad,0);
	ChVector<> pos2(0,-prad,0);

	ChSharedPtr<ChBodyDEMMPI> mybody;

	double boxxx=box_dim-2*prad;
	ChVector<> particle_pos(0.8*boxxx/2,box_dim/2+2*prad, 0.6*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_bodies+1);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddBox(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos1);
		//mybody->GetCollisionModel()->AddCylinder(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos2);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos);
		//mybody->SetInertiaXX(ChVector<>(((7.0/12)*m_c+4.3*m_s)*pow(prad,2),(0.5*m_c+0.8*m_s)*pow(prad,2),((7.0/12)*m_c+4.3*m_s)*pow(prad,2)));
		//mybody->SetMass(m_c+2*m_s);
		mybody->SetInertiaXX((1.0/6.0)*m_cube*pow(prad,2)*ChVector<>(1.0,1.0,1.0));
		mybody->SetMass(m_cube);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
	ChVector<> particle_pos2(0.8*boxxx/2,box_dim/2+2*prad, 0.2*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos2))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_bodies+2);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddBox(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos1);
		//mybody->GetCollisionModel()->AddCylinder(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos2);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos2);
		//mybody->SetInertiaXX(ChVector<>(((7.0/12)*m_c+4.3*m_s)*pow(prad,2),(0.5*m_c+0.8*m_s)*pow(prad,2),((7.0/12)*m_c+4.3*m_s)*pow(prad,2)));
		//mybody->SetMass(m_c+2*m_s);
		mybody->SetInertiaXX((1.0/6.0)*m_cube*pow(prad,2)*ChVector<>(1.0,1.0,1.0));
		mybody->SetMass(m_cube);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
	ChVector<> particle_pos3(0.8*boxxx/2,box_dim/2+2*prad, -0.2*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos3))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_bodies+3);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddBox(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos1);
		//mybody->GetCollisionModel()->AddCylinder(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos2);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos3);
		//mybody->SetInertiaXX(ChVector<>(((7.0/12)*m_c+4.3*m_s)*pow(prad,2),(0.5*m_c+0.8*m_s)*pow(prad,2),((7.0/12)*m_c+4.3*m_s)*pow(prad,2)));
		//mybody->SetMass(m_c+2*m_s);
		mybody->SetInertiaXX((1.0/6.0)*m_cube*pow(prad,2)*ChVector<>(1.0,1.0,1.0));
		mybody->SetMass(m_cube);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
	ChVector<> particle_pos4(0.8*boxxx/2,box_dim/2+2*prad, -0.6*boxxx/2);
	if (mySys.nodeMPI->IsInto(particle_pos4))
	{
		ChSharedPtr<ChBodyDEMMPI> mybody(new ChBodyDEMMPI);
		mybody->SetIdentifier(id_offset+n_curr_bodies+4);
		mySys.Add(mybody);
		mybody->GetCollisionModel()->ClearModel();
		mybody->GetCollisionModel()->AddBox(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos1);
		//mybody->GetCollisionModel()->AddCylinder(prad,prad,prad);
		//mybody->GetCollisionModel()->AddSphere(prad, &pos2);
		mybody->GetCollisionModel()->BuildModel();
		mybody->SetCollide(true);
		mybody->SetPos(particle_pos4);
		//mybody->SetInertiaXX(ChVector<>(((7.0/12)*m_c+4.3*m_s)*pow(prad,2),(0.5*m_c+0.8*m_s)*pow(prad,2),((7.0/12)*m_c+4.3*m_s)*pow(prad,2)));
		//mybody->SetMass(m_c+2*m_s);
		mybody->SetInertiaXX((1.0/6.0)*m_cube*pow(prad,2)*ChVector<>(1.0,1.0,1.0));
		mybody->SetMass(m_cube);
		mybody->GetCollisionModel()->SyncPosition(); // really necessary?
		mybody->Update(); // really necessary?
	}
}
开发者ID:DavidHammen,项目名称:chrono,代码行数:98,代码来源:demo_DEM_MPI.cpp

示例8: main

int main(int argc, char* argv[]) {
  // Set path to ChronoVehicle data files
  vehicle::SetDataPath(CHRONO_VEHICLE_DATA_DIR);

  // --------------------------
  // Create output directories.
  // --------------------------

  if (povray_output) {
    if (ChFileutils::MakeDirectory(out_dir.c_str()) < 0) {
      cout << "Error creating directory " << out_dir << endl;
      return 1;
    }
    if (ChFileutils::MakeDirectory(pov_dir.c_str()) < 0) {
      cout << "Error creating directory " << pov_dir << endl;
      return 1;
    }
  }

  // --------------
  // Create system.
  // --------------

  ChSystemParallelDEM* system = new ChSystemParallelDEM();

  system->Set_G_acc(ChVector<>(0, 0, -9.81));

  // ----------------------
  // Enable debug log
  // ----------------------

  ////system->SetLoggingLevel(LOG_INFO, true);
  ////system->SetLoggingLevel(LOG_TRACE, true);

  // ----------------------
  // Set number of threads.
  // ----------------------

  int max_threads = omp_get_num_procs();
  if (threads > max_threads)
    threads = max_threads;
  system->SetParallelThreadNumber(threads);
  omp_set_num_threads(threads);
  cout << "Using " << threads << " threads" << endl;

  system->GetSettings()->perform_thread_tuning = thread_tuning;

  // ---------------------
  // Edit system settings.
  // ---------------------

  system->GetSettings()->solver.use_full_inertia_tensor = false;

  system->GetSettings()->solver.tolerance = tolerance;
  system->GetSettings()->solver.max_iteration_bilateral = max_iteration_bilateral;

  system->GetSettings()->solver.contact_force_model = contact_force_model;
  system->GetSettings()->solver.tangential_displ_mode = tangential_displ_mode;

  system->GetSettings()->collision.narrowphase_algorithm = NARROWPHASE_HYBRID_MPR;
  system->GetSettings()->collision.bins_per_axis = I3(20, 20, 10);

  // -------------------
  // Create the terrain.
  // -------------------

  // Ground body
  ChSharedPtr<ChBody> ground = ChSharedPtr<ChBody>(new ChBody(new collision::ChCollisionModelParallel, ChBody::DEM));
  ground->SetIdentifier(-1);
  ground->SetMass(1000);
  ground->SetBodyFixed(true);
  ground->SetCollide(true);

  ground->GetMaterialSurfaceDEM()->SetFriction(mu_g);
  ground->GetMaterialSurfaceDEM()->SetYoungModulus(Y_g);
  ground->GetMaterialSurfaceDEM()->SetRestitution(cr_g);
  ground->GetMaterialSurfaceDEM()->SetCohesion(cohesion_g);

  ground->GetCollisionModel()->ClearModel();

  // Bottom box
  utils::AddBoxGeometry(ground.get_ptr(), ChVector<>(hdimX, hdimY, hthick), ChVector<>(0, 0, -hthick),
                        ChQuaternion<>(1, 0, 0, 0), true);
  if (terrain_type == GRANULAR) {
    // Front box
    utils::AddBoxGeometry(ground.get_ptr(), ChVector<>(hthick, hdimY, hdimZ + hthick),
                          ChVector<>(hdimX + hthick, 0, hdimZ - hthick), ChQuaternion<>(1, 0, 0, 0), visible_walls);
    // Rear box
    utils::AddBoxGeometry(ground.get_ptr(), ChVector<>(hthick, hdimY, hdimZ + hthick),
                          ChVector<>(-hdimX - hthick, 0, hdimZ - hthick), ChQuaternion<>(1, 0, 0, 0), visible_walls);
    // Left box
    utils::AddBoxGeometry(ground.get_ptr(), ChVector<>(hdimX, hthick, hdimZ + hthick),
                          ChVector<>(0, hdimY + hthick, hdimZ - hthick), ChQuaternion<>(1, 0, 0, 0), visible_walls);
    // Right box
    utils::AddBoxGeometry(ground.get_ptr(), ChVector<>(hdimX, hthick, hdimZ + hthick),
                          ChVector<>(0, -hdimY - hthick, hdimZ - hthick), ChQuaternion<>(1, 0, 0, 0), visible_walls);
  }

  ground->GetCollisionModel()->BuildModel();

//.........这里部分代码省略.........
开发者ID:rserban,项目名称:chrono-projects,代码行数:101,代码来源:hmmwvDEM.cpp

示例9: main


//.........这里部分代码省略.........
      msystem->Get_bodylist()->at(1)->AddRef();

      // Create granular material.
      int num_particles = CreateGranularMaterial(msystem);
      cout << "Granular material:  " << num_particles << " particles" << endl;

      break;
    }

    case PRESSING: {
      time_min = time_pressing_min;
      time_end = time_pressing_max;
      out_fps = out_fps_pressing;

      // Create bodies from checkpoint file.
      cout << "Read checkpoint data from " << settled_ckpnt_file;
      utils::ReadCheckpoint(msystem, settled_ckpnt_file);
      cout << "  done.  Read " << msystem->Get_bodylist()->size() << " bodies." << endl;

      // Grab handles to mechanism bodies (must increase ref counts)
      ground = ChSharedPtr<ChBody>(msystem->Get_bodylist()->at(0));
      loadPlate = ChSharedPtr<ChBody>(msystem->Get_bodylist()->at(1));
      msystem->Get_bodylist()->at(0)->AddRef();
      msystem->Get_bodylist()->at(1)->AddRef();

      // Move the load plate just above the granular material.
      double highest, lowest;
      FindHeightRange(msystem, lowest, highest);
      ChVector<> pos = loadPlate->GetPos();
      double z_new = highest + 1.01 * r_g;
      loadPlate->SetPos(ChVector<>(pos.x, pos.y, z_new));

      // Add collision geometry to plate
      loadPlate->GetCollisionModel()->ClearModel();
      utils::AddBoxGeometry(loadPlate.get_ptr(), ChVector<>(hdimX_p, hdimY_p, hdimZ_p), ChVector<>(0, 0, hdimZ_p));
      loadPlate->GetCollisionModel()->BuildModel();

      // If using an actuator, connect the load plate and get a handle to the actuator.
      if (use_actuator) {
        ConnectLoadPlate(msystem, ground, loadPlate);
        prismatic = msystem->SearchLink("prismatic").StaticCastTo<ChLinkLockPrismatic>();
        actuator = msystem->SearchLink("actuator").StaticCastTo<ChLinkLinActuator>();
      }

      // Release the load plate.
      loadPlate->SetBodyFixed(!use_actuator);

      break;
    }

    case TESTING: {
      time_end = time_testing;
      out_fps = out_fps_testing;

      // For TESTING only, increse shearing velocity.
      desiredVelocity = 0.5;

      // Create the mechanism bodies (all fixed).
      CreateMechanismBodies(msystem);

      // Create the test ball.
      CreateBall(msystem);

      // Grab handles to mechanism bodies (must increase ref counts)
      ground = ChSharedPtr<ChBody>(msystem->Get_bodylist()->at(0));
      loadPlate = ChSharedPtr<ChBody>(msystem->Get_bodylist()->at(1));
开发者ID:rserban,项目名称:chrono-projects,代码行数:67,代码来源:pressureSinkage.cpp


注:本文中的ChSharedPtr::GetCollisionModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。