Example #1
0
FCFighterFactory::pointer_type FCFighterFactory::createInstance(const std::string& instanceName, parameter_type parameter)
{

	int pos = 0;
	int x = 0;
	int y = 0;
	int id = 0;
	if(parameter)
	{
		parameter_iterator it = parameter->find("pos");
		if(it!= parameter->end())
		{
			pos = boost::get<int>(it->second);
			x = pos/16;
			y = pos%16;
		}

		it = parameter->find("id");
		if(it!= parameter->end())
		{
			id = boost::get<int>(it->second);
		}
	}


	return pointer_type(new FighterBase(instanceName, x, y, id));
}
 void initialise(const vertex_type, const parameter_type& P) {
   if (P.empty())
     throw std::runtime_error
       ("ERROR[MinimumTransversals_VanderWaerden]: "
        "The progression-length must be provided as parameter.");
   prog_gen.set(P.front());
 }
Example #3
0
EnemyControllerFactory::pointer_type EnemyControllerFactory::createInstance(const std::string& instanceName, parameter_type parameter)
{
	std::string fighterName;
	if(parameter)
	{
		parameter_iterator it = parameter->find("fighterName");

		if(it!= parameter->end())
		{
			fighterName = VariantData<std::string>::get(it->second);
		}
	}
	return pointer_type(new EnemyController(instanceName, fighterName));
}
Example #4
0
void
AdvectionDiffusion::exportResults( element_type& U , parameter_type const& mu )
{

    if ( M_do_export )
    {
        LOG(INFO) << "exportResults starts\n";

        std::string exp_name;
        export_ptrtype exporter;
        std::string mu_str;

        for ( int i=0; i<mu.size(); i++ )
        {
            mu_str= mu_str + ( boost::format( "_%1%" ) %mu[i] ).str() ;
        }

        exp_name = "solution_with_parameters_" + mu_str;

        exporter = export_ptrtype( Exporter<mesh_type>::New( "ensight", exp_name  ) );
        exporter->step( 0 )->setMesh( U.functionSpace()->mesh() );
        exporter->step( 0 )->add( "u", U );
        exporter->save();
    }
} // AdvectionDiffusion::export
Example #5
0
ObstacleFactory::pointer_type ObstacleFactory::createInstance(const std::string& instanceName, parameter_type parameter)
{
	Ogre::Vector3 pos = Ogre::Vector3(0.0, 0.0, 0.0);
	double scale = 0.0;
	std::string materialName;
	if(parameter)
	{

		parameter_iterator it = parameter->find("pos");
		if(it!= parameter->end())
			pos = VariantData<Ogre::Vector3>::get(it->second);

		it = parameter->find("scale");
		if(it != parameter->end())
			scale = VariantData<double>::get(it->second);

		it = parameter->find("materialName");
		if(it != parameter->end()){
			materialName = VariantData<std::string>::get(it->second);
		}	

	}

	return pointer_type(new Obstacle(instanceName, pos, scale, materialName));
}
Example #6
0
void
AdvectionDiffusion::solve( parameter_type const& mu, element_ptrtype& T )
{
    this->computeBetaQm( mu );
    this->update( mu );
    backend->solve( _matrix=D,  _solution=T, _rhs=F );
    export_number++;
#if 0
    std::ofstream file;
    std::string mu_str;

    for ( int i=0; i<mu.size(); i++ )
    {
        mu_str= mu_str + ( boost::format( "_%1%" ) %mu[i] ).str() ;
    }

    std::string number =  ( boost::format( "Exp_%1%" ) %export_number ).str();
    std::string name = "PFEMsolution" + mu_str + number;
    file.open( name,std::ios::out );

    for ( int i=0; i<T->size(); i++ ) file<<T->operator()( i )<<"\n";

    file.close();


    std::cout<<"pfem solution ok"<<std::endl;
    std::ofstream file_matrix;
    name = "PFEMmatrix" + mu_str + number;
    file_matrix.open( name,std::ios::out );
    file_matrix<<*D;
    file_matrix.close();

    std::cout<<"pfem matrix ok"<<std::endl;
    name = "PFEMrhs" + mu_str + number;
    std::ofstream file_rhs;
    file_rhs.open( name,std::ios::out );
    file_rhs<<*F;
    file_rhs.close();
    std::cout<<"pfem rhs ok"<<std::endl;
#endif

}