-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix last of warnings, cleanup heat_2d_direct, rename naive in a few p…
…laces
- Loading branch information
Showing
9 changed files
with
89 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
*.mp4 | ||
*.sh | ||
*-e | ||
*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
use fftw::array::AlignedVec; | ||
use nhls::domain::*; | ||
use nhls::image::*; | ||
use nhls::stencil::*; | ||
use nhls::util::*; | ||
|
||
fn main() { | ||
// Grid size | ||
let grid_bound = AABB::new(matrix![0, 999; 0, 999]); | ||
|
||
let steps_per_image = 64; | ||
|
||
let n_images = 200; | ||
|
||
let chunk_size = 1000; | ||
|
||
// Step size t | ||
let dt: f32 = 1.0; | ||
|
||
// Step size x | ||
let dx: f32 = 1.0; | ||
|
||
// Step size y | ||
let dy: f32 = 1.0; | ||
|
||
// Heat transfer coefficient | ||
let k_x: f32 = 0.2; | ||
let k_y: f32 = 0.2; | ||
|
||
let stencil = Stencil::new( | ||
[[0, 0], [-1, 0], [1, 0], [0, -1], [0, 1]], | ||
|args: &[f32; 5]| { | ||
let middle = args[0]; | ||
let left = args[1]; | ||
let right = args[2]; | ||
let bottom = args[3]; | ||
let top = args[4]; | ||
middle | ||
+ (k_x * dt / (dx * dx)) * (left - 2.0 * middle + right) | ||
+ (k_y * dt / (dy * dy)) * (top - 2.0 * middle + bottom) | ||
}, | ||
); | ||
|
||
// Create domains | ||
let buffer_size = grid_bound.buffer_size(); | ||
let mut input_buffer = AlignedVec::new(buffer_size); | ||
let mut output_buffer = AlignedVec::new(buffer_size); | ||
let mut input_domain = Domain::new(grid_bound, &mut input_buffer); | ||
let mut output_domain = Domain::new(grid_bound, &mut output_buffer); | ||
|
||
// Fill in with IC values (use normal dist for spike in the middle) | ||
// Write out initial frame | ||
let exclusive_bounds = grid_bound.exclusive_bounds(); | ||
let width_f = exclusive_bounds[0] as f32; | ||
let height_f = exclusive_bounds[1] as f32; | ||
let sigma_sq: f32 = (width_f / 25.0) * (width_f / 25.0); | ||
let ic_gen = |coord: Coord<2>| { | ||
let x = (coord[0] as f32) - (width_f / 2.0); | ||
let y = (coord[1] as f32) - (height_f / 2.0); | ||
let r = (x * x + y * y).sqrt(); | ||
let exp = -r * r / (2.0 * sigma_sq); | ||
exp.exp() | ||
}; | ||
input_domain.par_set_values(ic_gen, chunk_size); | ||
image2d(&input_domain, "heat_2d_direct/frame_0000.png"); | ||
|
||
// Create boundary condition | ||
let bc = ConstantCheck::new( | ||
0.0, | ||
grid_bound); | ||
|
||
// Apply direct solver | ||
for t in 1..n_images { | ||
nhls::solver::direct::box_apply( | ||
&bc, | ||
&stencil, | ||
&mut input_domain, | ||
&mut output_domain, | ||
steps_per_image, | ||
chunk_size); | ||
|
||
std::mem::swap(&mut input_domain, &mut output_domain); | ||
image2d(&input_domain, &format!("heat_2d_direct/frame_{:04}.png", t)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
pub mod fft_plan; | ||
pub mod naive; | ||
pub mod direct; | ||
pub mod periodic_naive; | ||
pub mod periodic_plan; | ||
pub mod trapezoid; |