int main ( int argc, char ** argv ) { glutInit ( &argc, argv ); if ( argc == 1 ) { N = 64; dt = 0.1f; d = 5.f; fprintf ( stderr, "Using defaults : N=%d dt=%g d=%g\n", N, dt, d ); } else { N = atoi(argv[1]); dt = atof(argv[2]); d = atof(argv[3]); } printf ( "\n\nHow to use this application:\n\n" ); printf ( "\t Toggle construction/simulation display with the spacebar key\n" ); printf ( "\t Dump frames by pressing the 'd' key\n" ); printf ( "\t Quit by pressing the 'q' key\n" ); dsim = 0; dump_frames = 0; frame_number = 0; init_system(); win_x = 512; win_y = 512; open_glut_window (); glutMainLoop (); exit ( 0 ); }
int main(int argc, char **argv) { glutInit(&argc, argv); if (argc != 1 && argc != 7) { fprintf(stderr, "usage : %s N dt diff visc force source\n", argv[0]); fprintf(stderr, "where:\n");\ fprintf(stderr, "\t N : grid resolution\n"); fprintf(stderr, "\t dt : time step\n"); fprintf(stderr, "\t diff : diffusion rate of the density\n"); fprintf(stderr, "\t visc : viscosity of the fluid\n"); fprintf(stderr, "\t force : scales the mouse movement that generate a force\n"); fprintf(stderr, "\t source : amount of density that will be deposited\n"); exit(1); } if (argc == 1) { N = 64; dt = 0.1f; diff = 0.0f; visc = 0.0f; force = 5.0f; source = 100.0f; fprintf(stderr, "Using defaults : N=%d dt=%g diff=%g visc=%g force = %g source=%g\n", N, dt, diff, visc, force, source); } else { N = atoi(argv[1]); dt = atof(argv[2]); diff = atof(argv[3]); visc = atof(argv[4]); force = atof(argv[5]); source = atof(argv[6]); } printf("\n\nHow to use this demo:\n\n"); printf("\t Add densities with the right mouse button\n"); printf("\t Add velocities with the left mouse button and dragging the mouse\n"); printf("\t Toggle density/velocity display with the 'v' key\n"); printf("\t Clear the simulation by pressing the 'c' key\n"); printf("\t Toggle particle display with the 'p' key ('P' resets particles)\n"); printf("\t 's' creates a new particle system connected by springs (cloth)\n"); printf("\t 'S' creates a new particle system without springs\n"); printf("\t '@' toggles vorticity confinement (It looks like a swirl :)\n"); printf("\t Space pauses the simulation\n"); printf("\t Quit by pressing the 'q' key\n"); dvel = 0; dpar = 0; if (!allocate_data()) exit(1); clear_data(); win_x = 512; win_y = 512; open_glut_window(); glutMainLoop(); exit(0); }
int main ( int argc, char ** argv ) { glutInit ( &argc, argv ); printf ( "\n\nHow to use this demo:\n\n" ); printf ( "\t Start and Stop the demo with the 'p' key\n" ); printf ( "\t Toggle density/velocity display with the 'x' key\n" ); printf ( "\t Clear the simulation by pressing the 'c' key\n" ); printf ( "\t Quit by pressing the 'q' key\n" ); open_glut_window (); timer.Reset(); glutMainLoop (); exit ( 0 ); }
int main(int argc, char **argv) { glutInit(&argc, argv); if (argc == 1) { N = 64; dt = 0.1f; d = 5.f; fprintf(stderr, "Using defaults : N=%d dt=%g d=%g\n", N, dt, d); } else { N = atoi(argv[1]); dt = atof(argv[2]); d = atof(argv[3]); } printf("\n\nHow to use this application:\n\n"); printf("\t Toggle construction/simulation display with the spacebar key\n"); printf("\t Dump frames by pressing the 'd' key\n"); printf("\t Quit by pressing the 'q' key\n"); printf("\t 'e' = Euler\n"); printf("\t 'm' = Midpoint\n"); printf("\t 'r' = Runge Kutta\n\n"); printf("\t '+, >' = Increase dt with 0.01, 0.1\n"); printf("\t '-, <' = Decrease dt with 0.01, 0.1\n"); printf("\t 'a, z' = Increase, decrease mouse radius\n"); dsim = 0; dump_frames = 0; frame_number = 0; init_system(); win_x = 512; win_y = 512; open_glut_window(); glutMainLoop(); exit(0); }
/////////////////////////////////////////////////////////////////////////////// /// Main routine of FFD /// ///\para coupled simulation Integer to identify the simulation type /// ///\return 0 if no error occurred /////////////////////////////////////////////////////////////////////////////// int ffd(int cosimulation) { #ifndef _MSC_VER //Linux //Initialize glut library char fakeParam[] = "fake"; char *fakeargv[] = { fakeParam, NULL }; int fakeargc = 1; glutInit( &fakeargc, fakeargv ); #endif // Initialize the parameters para.geom = &geom; para.inpu = &inpu; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; para.sens = &sens; para.init = &init; // Stand alone simulation: 0; Cosimulaiton: 1 para.solv->cosimulation = cosimulation; if(initialize(¶)!=0) { ffd_log("ffd(): Could not initialize simulation parameters.", FFD_ERROR); return 1; } // Overwrite the mesh and simulation data using SCI generated file if(para.inpu->parameter_file_format == SCI) { if(read_sci_max(¶, var)!=0) { ffd_log("ffd(): Could not read SCI data.", FFD_ERROR); return 1; } } // Allocate memory for the variables if(allocate_memory(¶)!=0) { ffd_log("ffd(): Could not allocate memory for the simulation.", FFD_ERROR); return 1; } // Set the initial values for the simulation data if(set_initial_data(¶, var, BINDEX)) { ffd_log("ffd(): Could not set initial data.", FFD_ERROR); return 1; } // Read previous simulation data as initial values if(para.inpu->read_old_ffd_file==1) read_ffd_data(¶, var); ffd_log("ffd.c: Start FFD solver.", FFD_NORMAL); //write_tecplot_data(¶, var, "initial"); // Solve the problem if(para.outp->version==DEMO) { open_glut_window(); glutMainLoop(); } else if(FFD_solver(¶, var, BINDEX)!=0) { ffd_log("ffd(): FFD solver failed.", FFD_ERROR); return 1; } /*--------------------------------------------------------------------------- | Post Process ---------------------------------------------------------------------------*/ // Calculate mean value if(para.outp->cal_mean == 1) average_time(¶, var); if(write_unsteady(¶, var, "unsteady")!=0) { ffd_log("FFD_solver(): Could not write the file unsteady.plt.", FFD_ERROR); return 1; } if(write_tecplot_data(¶, var, "result")!=0) { ffd_log("FFD_solver(): Could not write the file result.plt.", FFD_ERROR); return 1; } if(para.outp->version == DEBUG) write_tecplot_all_data(¶, var, "result_all"); // Write the data in SCI format write_SCI(¶, var, "output"); // Free the memory free_data(var); free_index(BINDEX); // End the simulation if(para.outp->version==DEBUG || para.outp->version==DEMO) {}//getchar(); // Inform Modelica the stopping command has been received if(para.solv->cosimulation==1) { para.cosim->para->flag = 2; ffd_log("ffd(): Sent stopping signal to Modelica", FFD_NORMAL); } return 0; } // End of ffd( )
int main ( int argc, char ** argv ) { //glutInit ( &argc, argv ); if(!glfwInit()) { fprintf( stderr, "Failed to initialize GLFW\n" ); return EXIT_FAILURE; } // GLenum err = glewInit(); // if (GLEW_OK != err) { // fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); // } if ( argc != 1 && argc != 6 ) { fprintf ( stderr, "usage : %s N dt diff visc force source\n", argv[0] ); fprintf ( stderr, "where:\n" );\ fprintf ( stderr, "\t N : grid resolution\n" ); fprintf ( stderr, "\t dt : time step\n" ); fprintf ( stderr, "\t diff : diffusion rate of the density\n" ); fprintf ( stderr, "\t visc : viscosity of the fluid\n" ); fprintf ( stderr, "\t force : scales the mouse movement that generate a force\n" ); fprintf ( stderr, "\t source : amount of density that will be deposited\n" ); exit ( 1 ); } if ( argc == 1 ) { N = 64; dt = 0.1f; diff = 0.0f; visc = 0.0f; force = 5.0f; source = 100.0f; fprintf ( stderr, "Using defaults : N=%d dt=%g diff=%g visc=%g force = %g source=%g\n", N, dt, diff, visc, force, source ); } else { N = atoi(argv[1]); dt = atof(argv[2]); diff = atof(argv[3]); visc = atof(argv[4]); force = atof(argv[5]); source = atof(argv[6]); } printf ( "\n\nHow to use this demo:\n\n" ); printf ( "\t Add densities with the right mouse button\n" ); printf ( "\t Add velocities with the left mouse button and dragging the mouse\n" ); printf ( "\t Toggle density/velocity display with the 'v' key\n" ); printf ( "\t Clear the simulation by pressing the 'c' key\n" ); printf ( "\t Quit by pressing the 'q' key\n" ); dvel = 2; if ( !allocate_data () ) exit ( 1 ); clear_data (); win_x = 512; win_y = 512; open_glut_window (); while(1) { idle_func(); display_func(); mouse(); if (!glfwGetWindowParam(GLFW_OPENED)) { exit(0); } } glfwTerminate(); //glutMainLoop (); exit ( 0 ); }
int main ( int argc, char ** argv ) { // Parse command line options // int use_gpu = 1; int use_interop = 0; for(int i = 0; i < argc && argv; i++) { if(!argv[i]) continue; if(strstr(argv[i], "cpu")) use_gpu = 0; else if(strstr(argv[i], "gpu")) use_gpu = 1; else if(strstr(argv[i], "interop")) use_interop = 1; } printf("Parameter detect %s device (%s)\n",use_gpu==1?"GPU":"CPU",use_interop==1?"Share OpenGL":"Not Sharing OpenGL"); OPENCL_SHARE_WITH_OPENGL = use_interop; //testCG(); win_x = 512; win_y = 512; glutInit ( &argc, argv ); open_glut_window (); //test_opencl_opengl_interop(); dt = 0.1f; force = 10.0f; source = 10.0f; printf ( "\n\nHow to use this demo:\n\n" ); printf ( "\t Add densities with the left mouse button\n" ); printf ( "\t Add velocities with the left mouse button and dragging the mouse\n" ); printf ( "\t Toggle density/velocity display with the 'v' key\n" ); printf ( "\t Clear the simulation by pressing the 'x' key\n" ); printf ( "\t switch poisson solvers from jacobi to conjugate gradient by pressing the 'c' key\n" ); printf ( "\t switch advection scheme from RK2 to MacCormack by pressing the 'm' key\n" ); printf ( "\t toggle vorticity confinement by pressing the 'o' key\n" ); printf ( "\t Quit by pressing the 'q' key\n" ); dvel = 0; step = 0; maccormack = 0; vorticity = 0; useCG = 0; if ( !allocate_data () ) exit ( 1 ); clear_data (); //setupMatrix(g_laplacian_matrix); // FOR_EACH_FACE // { // //if(i < NX - NX*0.4 && i > NX*0.4 // // && // // j < NY - NY*0.4 && j > NY*0.4 ) // { // g_u_prev[IX(i,j,0)] = -0.01 * cosf(3.14159 * 2.0 * i/NX); // g_v_prev[IX(i,j,0)] = 0.01 * sinf(3.14159 * 2.0 * j/NY); // } // } #if RUN_TIMINGS runTimings(use_gpu); exit(0); #endif copy_grid(g_u_prev, g_u); copy_grid(g_v_prev, g_v); g_dens_prev[IX(16,3,0)] = 10.0f; //g_u_prev[IX(16,3,0)] = 10.0f; /* calculate_divergence(g_divergence, g_u_prev, g_v_prev, g_w_prev, dt); pressure_solve(g_pressure,g_pressure_prev, g_divergence, dt); pressure_apply(g_u_prev, g_v_prev, g_w_prev, g_pressure, dt); //project(dt,g_u_prev,g_v_prev, g_w_prev, g_divergence, g_pressure, g_pressure_prev); SWAP(g_u_prev,g_u); SWAP(g_v_prev,g_v); SWAP(g_w_prev,g_w); if(!check_divergence(g_u_prev, g_v_prev, g_w_prev)) { printf("Initial field wasn't divergence free!\n"); } */ //print_platforms_devices(); // run_opencl_test(use_gpu); // run_tests(); #if USE_OPENCL init_opencl(use_gpu); load_cl_kernels(&clData); allocate_cl_buffers(&clData); transfer_buffers_to_gpu(); flush_cl_queue(); #endif glutMainLoop (); #if USE_OPENCL cleanup_cl(&clData); #endif exit ( 0 ); }
int main ( int argc, char ** argv ) { glutInit ( &argc, argv ); if( argc < 2 ){ printf("Usage: ./%s integrator=(1-euler, 2-RK2, 3-sympleticEuler, 4-RK4) [N dt d]", argv[0]); exit(0); } // decide which integrator to use switch ( argv[1][0] ) { case '1': integrator = new EulerIntegrator(); break; case '2': integrator = new RK2Integrator(); break; case '3': integrator = new SymplecticEulerIntegrator(); break; case '4': integrator = new RK4Integrator(); break; default: integrator = new RK4Integrator(); } if ( argc == 2 ) { N = 64; dt = 0.01f; d = 5.f; fprintf ( stderr, "Using defaults : N=%d dt=%g d=%g\n", N, dt, d ); } else { N = atoi(argv[2]); dt = atof(argv[3]); d = atof(argv[4]); } printf ( "\n\nHow to use this application:\n\n" ); printf ( "\t Toggle construction/simulation display with the spacebar key\n" ); printf ( "\t Dump frames by pressing the 'd' key\n" ); printf ( "\t Quit by pressing the 'q' key\n" ); dsim = 0; dump_frames = 0; frame_number = 0; init_system(); win_x = 720; win_y = 720; open_glut_window (); glutMainLoop (); exit ( 0 ); }