| 447 | } |
| 448 | |
| 449 | void lattice_boltzmann_cfd_demo() { |
| 450 | // Define the lattice for the simulation |
| 451 | const size_t len = 128; |
| 452 | const size_t grid_width = len; |
| 453 | const size_t grid_height = len; |
| 454 | |
| 455 | // Specify the image scaling displayed |
| 456 | float scale = 4.0f; |
| 457 | |
| 458 | // Forge window initialization |
| 459 | int height = static_cast<int>(grid_width * scale); |
| 460 | int width = static_cast<int>(grid_height * scale); |
| 461 | af::Window window(height, width, "Driven Cavity Flow"); |
| 462 | |
| 463 | int frame_count = 0; |
| 464 | int max_frames = 20000; |
| 465 | int simulation_frames = 100; |
| 466 | float total_time = 0; |
| 467 | float total_time2 = 0; |
| 468 | |
| 469 | // CFD fluid parameters |
| 470 | const float density = 2.7f; |
| 471 | const float velocity = 0.35f; |
| 472 | const float reynolds = 1e5f; |
| 473 | |
| 474 | const char* ux_image = ASSETS_DIR "/examples/images/default_ux.bmp"; |
| 475 | const char* uy_image = ASSETS_DIR "/examples/images/default_uy.bmp"; |
| 476 | const char* set_boundary_image = |
| 477 | ASSETS_DIR "/examples/images/default_boundary.bmp"; |
| 478 | |
| 479 | // Tesla Valve Fluid Simulation - entering from constricted side |
| 480 | { |
| 481 | // ux_image = ASSETS_DIR "/examples/images/left_tesla_ux.bmp"; |
| 482 | // uy_image = ASSETS_DIR "/examples/images/left_tesla_uy.bmp"; |
| 483 | // set_boundary_image = ASSETS_DIR |
| 484 | // "/examples/images/left_tesla_boundary.bmp"; |
| 485 | } |
| 486 | |
| 487 | // Tesla Valve Fluid Simulation - entering from transfer side |
| 488 | { |
| 489 | // ux_image = ASSETS_DIR |
| 490 | // "/examples/images/right_tesla_ux.bmp"; uy_image = |
| 491 | // ASSETS_DIR "/examples/images/right_tesla_uy.bmp"; |
| 492 | // set_boundary_image = ASSETS_DIR |
| 493 | // "/examples/images/right_tesla_boundary.bmp"; |
| 494 | } |
| 495 | |
| 496 | // Reads the initial values of fluid quantites and simulation parameters |
| 497 | Simulation sim = |
| 498 | create_simulation(grid_width, grid_height, density, velocity, reynolds, |
| 499 | ux_image, uy_image, set_boundary_image); |
| 500 | |
| 501 | // Initializes the simulation quantites |
| 502 | initialize(sim); |
| 503 | |
| 504 | while (!window.close() && frame_count != max_frames) { |
| 505 | af::sync(); |
| 506 | auto begin = std::chrono::high_resolution_clock::now(); |
no test coverage detected