int main( int argc, char** argv ) { srand(time(0)); #ifdef PNGOUT system("rm pngs/*"); #endif // Parse command line arguments parseCommandLine( argc, argv ); // Function to cleanup at progarm exit atexit(cleanupAtExit); // If requestedm load xml scene parameters if (g_xml_scene) { //g_simulation_ensemble = new TDSmokeEnsemble(100); loadScene( g_xml_scene_file ); g_simulation_ensemble->setVelocityPattern( g_velocity_pattern ); g_simulation_ensemble->setDiffusion( g_diff ); g_simulation_ensemble->setViscosity( g_visc ); g_simulation_ensemble->setSmoothing( g_sigma ); g_simulation_ensemble->setDrivingForceCoeff( g_vf ); g_simulation_ensemble->setAttenuation( g_vd ); g_simulation_ensemble->setGathering( g_vg ); g_simulation_ensemble->setGatheringEnabled( g_vg_enabled ); } else { g_simulation_ensemble = new TDSmokeEnsemble(100); } // Initialization for OpenGL and GLUT if( g_opengl_rendering_enabled ) initializeOpenGLandGLUT(argc,argv); std::cout << outputmod::startgreen; std::cout << "+----------------------------------+" << std::endl; std::cout << "| Target-Driven Smoke Simulation |" << std::endl; std::cout << "+----------------------------------+" << std::endl; std::cout << outputmod::endgreen; // TODO: Print build info here #ifdef CMAKE_BUILD_TYPE std::cout << outputmod::startblue << "Build type: " << outputmod::endblue << CMAKE_BUILD_TYPE << std::endl; #endif std::cout << outputmod::startblue << "Rendering: " << outputmod::endblue << (g_opengl_rendering_enabled?"Enabled":"Disabled") << std::endl; if( g_opengl_rendering_enabled && g_movie_dir != "" ) { std::cout << outputmod::startblue << "Movie output directory: " << outputmod::endblue << g_movie_dir << std::endl; std::cout << outputmod::startblue << "Movie output FPS: " << outputmod::endblue << (1.0/(g_dt*((scalar)g_steps_per_movie_frame))) << std::endl; } if( g_xml_scene ) { std::cout << outputmod::startblue << "Scene: " << outputmod::endblue << g_xml_scene_file << std::endl; std::cout << outputmod::startblue << "Description: " << outputmod::endblue << g_description << std::endl; } else { g_simulation_ensemble->initMarkerAndTarget(); } std::cout << outputmod::startblue << "Smoothing parameter: " << outputmod::endblue << g_sigma << std::endl; std::cout << outputmod::startblue << "Driving force coefficient: " << outputmod::endblue << g_vf << std::endl; std::cout << outputmod::startblue << "Attenuation coefficient: " << outputmod::endblue << g_vd << std::endl; std::cout << outputmod::startblue << "Gathering coefficient: " << outputmod::endblue << g_vg << std::endl; std::cout << outputmod::startblue << "Gathering: " << outputmod::endblue; if (g_vg_enabled) std::cout << "Enabled" << std::endl; else std::cout << "Disabled" << std::endl; if( g_opengl_rendering_enabled ) glutMainLoop(); else headlessSimLoop(); return 0; }
int main( int argc, char** argv ) { // Parse command line arguments parseCommandLine( argc, argv ); assert( !(g_save_to_binary && g_simulate_comparison) ); // Function to cleanup at progarm exit atexit(cleanupAtExit); // Load the user-specified scene loadScene(g_xml_scene_file); //Adding the file loading shit fp = fopen(fileName, "r"); if(!fp) { std::cout << "Music file not found\n"; return 0; } fscanf(fp, "; Sample Rate %d", &sampleRate); std::cout << "Sample rate of music: " << sampleRate << std::endl; SIZE = sampleRate * g_dt; SIZE+=1; //SIZE = (SIZE>MAXSAMPLERATE)?MAXSAMPLERATE:SIZE; std::cout << "Sample size of fft: " << SIZE << std::endl; fgets(fileBuf, 100, fp); fgets(fileBuf, 100, fp); in = (fftw_complex *)fftw_malloc(SIZE*sizeof(fftw_complex)); out = (fftw_complex *)fftw_malloc(SIZE*sizeof(fftw_complex)); // If requested, open the binary output file if( g_save_to_binary ) { // Attempt to open the binary g_binary_output.open(g_binary_file_name.c_str()); if( g_binary_output.fail() ) { std::cerr << outputmod::startred << "ERROR IN INITIALIZATION: " << outputmod::endred << "Failed to open binary output file: " << " `" << g_binary_file_name << "` Exiting." << std::endl; exit(1); } // Save the initial conditions g_executable_simulation->serializeScene(g_binary_output); } // If requested, open the input file for the scene to benchmark else if( g_simulate_comparison ) { // Attempt to open the binary g_binary_input.open(g_comparison_file_name.c_str()); if( g_binary_input.fail() ) { std::cerr << outputmod::startred << "ERROR IN INITIALIZATION: " << outputmod::endred << "Failed to open binary input file: " << " `" << argv[3] << "` Exiting." << std::endl; exit(1); } assert( g_executable_simulation != NULL ); g_executable_simulation->loadComparisonScene(g_binary_input); } // Initialization for OpenGL and GLUT if( g_rendering_enabled ) initializeOpenGLandGLUT(argc,argv); // Print a header std::cout << fosssim_header << std::endl; // Print some status info about this FOSSSim build #ifdef FOSSSIM_VERSION std::cout << outputmod::startblue << "FOSSSim Version: " << outputmod::endblue << FOSSSIM_VERSION << std::endl; #endif #ifdef CMAKE_BUILD_TYPE std::cout << outputmod::startblue << "Build type: " << outputmod::endblue << CMAKE_BUILD_TYPE << std::endl; #endif #ifdef EIGEN_VECTORIZE std::cout << outputmod::startblue << "Vectorization: " << outputmod::endblue << "Enabled" << std::endl; #else std::cout << outputmod::startblue << "Vectorization: " << outputmod::endblue << "Disabled" << std::endl; #endif std::cout << outputmod::startblue << "Scene: " << outputmod::endblue << g_xml_scene_file << std::endl; std::cout << outputmod::startblue << "Integrator: " << outputmod::endblue << g_executable_simulation->getSolverName() << std::endl; std::cout << outputmod::startblue << "Collision Handling: " << outputmod::endblue << g_executable_simulation->getCollisionHandlerName() << std::endl; std::cout << outputmod::startblue << "Description: " << outputmod::endblue << g_description << std::endl; if( g_save_to_binary ) std::cout << outputmod::startpink << "FOSSSim message: " << outputmod::endpink << "Saving simulation to: " << g_binary_file_name << std::endl; if( g_simulate_comparison ) std::cout << outputmod::startpink << "FOSSSim message: " << outputmod::endpink << "Benchmarking simulation in: " << g_comparison_file_name << std::endl; miscOutputInitialization(); if( g_rendering_enabled ) glutMainLoop(); else headlessSimLoop(); fclose(fp); return 0; }