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


C++ ParticleSystem::cleanUp方法代码示例

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


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

示例1: main

int main(int argc, char **argv) {
	unsigned int n_particles = NUM_PARTICLES;

	namespace po = boost::program_options;

	po::options_description desc("Allowed options");
	desc.add_options()
			("help,h", "Produces help message")
			("file,f", po::value<std::string>(), "Output file")
			(",n", po::value<unsigned int>(), "Particle number")
			("algorithm,a", po::value<std::string>(), "Contact Detection algorithm")
			("distribution,d", po::value<std::string>(), "Type of distribution (fluid, sparse or dense)");

	po::variables_map vm;
	po::store(po::parse_command_line(argc,argv,desc), vm);
	po::notify(vm);

	if(vm.count("help")){
		std::cout << desc << std::endl;
		return 0;
	}

	if(vm.count("-n")){
		//std::cout << vm << std::endl;
		n_particles = vm["-n"].as<unsigned int>();
	}
	NeighboorAlg neighAlg = DM;
	if(vm.count("algorithm")){
		std::string alg = vm["algorithm"].as<std::string>();
		if(alg=="DC") neighAlg = DC;
		else if(alg=="SCD") neighAlg = SCD;
		else if(alg=="DM") neighAlg = DM;
		else if(alg=="CM") neighAlg = CM;
		else if(alg=="SAS") neighAlg = SAS;
	}

	SystemType distr = DENSE;
	if(vm.count("distribution")){
		std::string d = vm["distribution"].as<std::string>();
		if(d=="dense") distr = DENSE;
		else if(d=="fluid") distr = FLUID;
		else if(d=="sparse") distr = SPARSE;
	}

	ParticleSystem *system = new ParticleSystem(n_particles, neighAlg, distr);

	std::cout << "Starting simulation..." << std::endl << "N = " << n_particles << std::endl;
	std::string out_file;
	if(vm.count("file")){
		out_file = vm["file"].as<std::string>();
		system->setOutputFile(out_file);
		std::cout << "Output = " << out_file << std::endl;
	}

	float total_time;

	system->printInfo();
	total_time = system->run();
	system->cleanUp();

	std::cout << "Total time = " << total_time << " ms" << std::endl;

	//TODO Fazer grid-size relatico a quantidade de partículas e a
	// 		tipo de simulação por linha de comando

	//TODO botar para selecionar device por entrada tbm


	// cleanup
	delete system;
	cudaDeviceReset();
}
开发者ID:jollyrog3r,项目名称:pex,代码行数:72,代码来源:main.cpp


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