This commit is contained in:
Magnus Ulimoen 2020-01-27 19:49:51 +01:00
parent 19c60fb4b6
commit 7fd69d0619
2 changed files with 13 additions and 13 deletions

16
main.js
View File

@ -104,8 +104,8 @@ import { EulerUniverse, Universe, default as init, set_panic_hook as setPanicHoo
for (let j = 0; j < height; j += 1) {
for (let i = 0; i < width; i += 1) {
const n = width*j + i;
x[n] = 20.0*(i / (width - 1.0));
y[n] = 20.0*(j / (height - 1.0));
x[n] = 20.0*(i / (width - 1.0) - 0.5);
y[n] = 20.0*(j / (height - 1.0) - 0.5);
if (DIAMOND) {
@ -181,7 +181,7 @@ import { EulerUniverse, Universe, default as init, set_panic_hook as setPanicHoo
}
const TIMEFACTOR = 10000.0;
const MAX_DT = 1.0/Math.max(width, height);
const MAX_DT = Math.min(1.0/width, 1.0/height)*0.2;
let t = 0;
let firstDraw = true;
@ -202,7 +202,7 @@ import { EulerUniverse, Universe, default as init, set_panic_hook as setPanicHoo
};
chosenField.cycle();
universe.init(10, 10);
universe.init(0, 0);
/**
* Integrates and draws the next iteration
@ -236,11 +236,11 @@ import { EulerUniverse, Universe, default as init, set_panic_hook as setPanicHoo
}
if (UPWIND) {
universe.advance_upwind(dt/2);
universe.advance_upwind(dt/2);
universe.advance_upwind(MAX_DT);
universe.advance_upwind(MAX_DT);
} else {
universe.advance(dt/2);
universe.advance(dt/2);
universe.advance(MAX_DT);
universe.advance(MAX_DT);
}
window.requestAnimationFrame(drawMe);

View File

@ -54,13 +54,13 @@ criterion_group!(benches, performance_benchmark);
fn advance_euler_system<SBP: SbpOperator>(universe: &mut EulerSystem<SBP>, n: usize) {
for _ in 0..n {
universe.advance(0.01);
universe.advance(1.0 / 40.0 * 0.2);
}
}
fn advance_euler_system_upwind<UO: UpwindOperator>(universe: &mut EulerSystem<UO>, n: usize) {
for _ in 0..n {
universe.advance_upwind(0.01);
universe.advance_upwind(1.0 / 40.0 * 0.2);
}
}
@ -79,7 +79,7 @@ fn euler_performance_benchmark(c: &mut Criterion) {
group.bench_function("advance_euler", |b| {
b.iter(|| {
universe.vortex(0.0, 0.0);
advance_euler_system(&mut universe, black_box(10))
advance_euler_system(&mut universe, black_box(20))
})
});
@ -87,7 +87,7 @@ fn euler_performance_benchmark(c: &mut Criterion) {
group.bench_function("advance_euler_upwind", |b| {
b.iter(|| {
universe.vortex(0.0, 0.0);
advance_euler_system_upwind(&mut universe, black_box(10))
advance_euler_system_upwind(&mut universe, black_box(20))
})
});
@ -95,7 +95,7 @@ fn euler_performance_benchmark(c: &mut Criterion) {
group.bench_function("advance_euler_trad4", |b| {
b.iter(|| {
universe.vortex(0.0, 0.0);
advance_euler_system(&mut universe, black_box(10))
advance_euler_system(&mut universe, black_box(20))
})
});