From e40ca4ba4779c4cf99eda897cdeb0c92750059a9 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Mon, 27 Jan 2020 21:20:34 +0100 Subject: [PATCH] rename project --- Cargo.toml | 2 +- benches/euler.rs | 4 ++-- benches/maxwell.rs | 19 +++++++++++-------- index.html | 2 +- main.js | 4 ++-- make_wasm.py | 4 ++-- src/lib.rs | 12 ++++++------ 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c29c443..4dd035f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "maxwell" +name = "sbp" version = "0.1.1" authors = ["Magnus Ulimoen "] edition = "2018" diff --git a/benches/euler.rs b/benches/euler.rs index e54ac36..4c8c280 100644 --- a/benches/euler.rs +++ b/benches/euler.rs @@ -1,6 +1,6 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use maxwell::operators::{SbpOperator, Upwind4, UpwindOperator, SBP4}; -use maxwell::EulerSystem; +use sbp::operators::{SbpOperator, Upwind4, UpwindOperator, SBP4}; +use sbp::EulerSystem; fn advance_system(universe: &mut EulerSystem, n: usize) { for _ in 0..n { diff --git a/benches/maxwell.rs b/benches/maxwell.rs index 0d03a19..c819ac0 100644 --- a/benches/maxwell.rs +++ b/benches/maxwell.rs @@ -1,21 +1,21 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use maxwell::operators::{SbpOperator, Upwind4, UpwindOperator, SBP4}; -use maxwell::System; +use sbp::operators::{SbpOperator, Upwind4, UpwindOperator, SBP4}; +use sbp::MaxwellSystem; -fn advance_system(universe: &mut System, n: usize) { +fn advance_system(universe: &mut MaxwellSystem, n: usize) { for _ in 0..n { universe.advance(0.01); } } -fn advance_system_upwind(universe: &mut System, n: usize) { +fn advance_system_upwind(universe: &mut MaxwellSystem, n: usize) { for _ in 0..n { universe.advance_upwind(0.01); } } fn performance_benchmark(c: &mut Criterion) { - let mut group = c.benchmark_group("System"); + let mut group = c.benchmark_group("MaxwellSystem"); group.sample_size(25); let w = 40; @@ -23,7 +23,8 @@ fn performance_benchmark(c: &mut Criterion) { let x = ndarray::Array2::from_shape_fn((h, w), |(_, i)| i as f32 / (w - 1) as f32); let y = ndarray::Array2::from_shape_fn((h, w), |(j, _)| j as f32 / (h - 1) as f32); - let mut universe = System::::new(w, h, x.as_slice().unwrap(), y.as_slice().unwrap()); + let mut universe = + MaxwellSystem::::new(w, h, x.as_slice().unwrap(), y.as_slice().unwrap()); group.bench_function("advance", |b| { b.iter(|| { universe.set_gaussian(0.5, 0.5); @@ -31,7 +32,8 @@ fn performance_benchmark(c: &mut Criterion) { }) }); - let mut universe = System::::new(w, h, x.as_slice().unwrap(), y.as_slice().unwrap()); + let mut universe = + MaxwellSystem::::new(w, h, x.as_slice().unwrap(), y.as_slice().unwrap()); group.bench_function("advance_upwind", |b| { b.iter(|| { universe.set_gaussian(0.5, 0.5); @@ -39,7 +41,8 @@ fn performance_benchmark(c: &mut Criterion) { }) }); - let mut universe = System::::new(w, h, x.as_slice().unwrap(), y.as_slice().unwrap()); + let mut universe = + MaxwellSystem::::new(w, h, x.as_slice().unwrap(), y.as_slice().unwrap()); group.bench_function("advance_trad4", |b| { b.iter(|| { universe.set_gaussian(0.5, 0.5); diff --git a/index.html b/index.html index 26eac1f..01b490a 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - Maxwell waves + SBP waves diff --git a/main.js b/main.js index 4b5f659..52cdda0 100644 --- a/main.js +++ b/main.js @@ -1,11 +1,11 @@ -import { EulerUniverse, Universe, default as init, set_panic_hook as setPanicHook } from "./maxwell.js"; +import { EulerUniverse, MaxwellUniverse, default as init, set_panic_hook as setPanicHook } from "./sbp.js"; /** * Initialises and runs the Maxwell solver, * plotting the solution to a canvas using webgl */ (async function run() { - const wasm = await init("./maxwell_bg.wasm"); + const wasm = await init("./sbp_bg.wasm"); setPanicHook(); const DIAMOND = false; const UPWIND = true; diff --git a/make_wasm.py b/make_wasm.py index 804fedb..4d9c2a9 100755 --- a/make_wasm.py +++ b/make_wasm.py @@ -29,7 +29,7 @@ if __name__ == "__main__": pathlib.Path("target") .joinpath(target_triple) .joinpath("release" if args.release else "debug") - .joinpath("maxwell.wasm") + .joinpath("sbp.wasm") ) if args.release: command.append("--release") @@ -53,7 +53,7 @@ if __name__ == "__main__": try: with tempfile.TemporaryDirectory() as d_: d = pathlib.Path(d_) - wasm_bg = publish.joinpath("maxwell_bg.wasm") + wasm_bg = publish.joinpath("sbp_bg.wasm") wasm_to_opt = d.joinpath("before-wasm-opt.wasm") copyfile(wasm_bg, wasm_to_opt) check_call(["wasm-opt", "-O4", str(wasm_to_opt), "-o", str(wasm_bg)]) diff --git a/src/lib.rs b/src/lib.rs index dbab137..b344a0c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,13 +18,13 @@ pub fn set_panic_hook() { } #[wasm_bindgen] -pub struct Universe(System); +pub struct MaxwellUniverse(MaxwellSystem); #[wasm_bindgen] -impl Universe { +impl MaxwellUniverse { #[wasm_bindgen(constructor)] pub fn new(width: usize, height: usize, x: &[f32], y: &[f32]) -> Self { - Self(System::new(width as usize, height as usize, x, y)) + Self(MaxwellSystem::new(width as usize, height as usize, x, y)) } pub fn init(&mut self, x0: f32, y0: f32) { @@ -52,13 +52,13 @@ impl Universe { } } -pub struct System { +pub struct MaxwellSystem { sys: (Field, Field), wb: WorkBuffers, grid: Grid, } -impl System { +impl MaxwellSystem { pub fn new(width: usize, height: usize, x: &[f32], y: &[f32]) -> Self { assert_eq!((width * height), x.len()); assert_eq!((width * height), y.len()); @@ -97,7 +97,7 @@ impl System { } } -impl System { +impl MaxwellSystem { /// Using artificial dissipation with the upwind operator pub fn advance_upwind(&mut self, dt: f32) { maxwell::advance_upwind(