keep tests up to date
This commit is contained in:
parent
650f7f204a
commit
1ee8dc5e9a
|
@ -3,7 +3,7 @@ use ndarray::prelude::*;
|
||||||
use sbp::euler::*;
|
use sbp::euler::*;
|
||||||
use sbp::Float;
|
use sbp::Float;
|
||||||
|
|
||||||
fn run_with_size<SBP: sbp::operators::UpwindOperator>(size: usize) -> Float {
|
fn run_with_size(size: usize, op: impl sbp::operators::UpwindOperator2d + Copy) -> Float {
|
||||||
let nx = size;
|
let nx = size;
|
||||||
let ny = size;
|
let ny = size;
|
||||||
let x = Array1::linspace(-5.0, 5.0, nx);
|
let x = Array1::linspace(-5.0, 5.0, nx);
|
||||||
|
@ -18,15 +18,21 @@ fn run_with_size<SBP: sbp::operators::UpwindOperator>(size: usize) -> Float {
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
let vortex_params = VortexParameters {
|
let vortex_params = VortexParameters {
|
||||||
|
vortices: {
|
||||||
|
let mut v = ArrayVec::new();
|
||||||
|
v.push(Vortice {
|
||||||
x0: -1.0,
|
x0: -1.0,
|
||||||
y0: 0.0,
|
y0: 0.0,
|
||||||
mach: 0.5,
|
|
||||||
rstar: 0.5,
|
rstar: 0.5,
|
||||||
eps: 1.0,
|
eps: 1.0,
|
||||||
|
});
|
||||||
|
v
|
||||||
|
},
|
||||||
|
mach: 0.5,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut sys = System::<SBP>::new(x, y);
|
let mut sys = System::new(x, y, op);
|
||||||
sys.vortex(0.0, vortex_params);
|
sys.vortex(0.0, vortex_params.clone());
|
||||||
|
|
||||||
let time = 0.2;
|
let time = 0.2;
|
||||||
let dt = 0.2 * Float::min(1.0 / (nx - 1) as Float, 1.0 / (ny - 1) as Float);
|
let dt = 0.2 * Float::min(1.0 / (nx - 1) as Float, 1.0 / (ny - 1) as Float);
|
||||||
|
@ -37,18 +43,18 @@ fn run_with_size<SBP: sbp::operators::UpwindOperator>(size: usize) -> Float {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut verifield = Field::new(ny, nx);
|
let mut verifield = Field::new(ny, nx);
|
||||||
verifield.vortex(sys.x(), sys.y(), nsteps as Float * dt, vortex_params);
|
verifield.vortex(sys.x(), sys.y(), nsteps as Float * dt, &vortex_params);
|
||||||
|
|
||||||
verifield.h2_err::<SBP>(sys.field())
|
verifield.h2_err(sys.field(), &op)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convergence<SBP: sbp::operators::UpwindOperator>() {
|
fn convergence(op: impl sbp::operators::UpwindOperator2d + Copy) {
|
||||||
let sizes = [25, 35, 50, 71, 100, 150, 200];
|
let sizes = [25, 35, 50, 71, 100, 150, 200];
|
||||||
let mut prev: Option<(usize, Float)> = None;
|
let mut prev: Option<(usize, Float)> = None;
|
||||||
println!("Size\tError(h2)\tq");
|
println!("Size\tError(h2)\tq");
|
||||||
for size in &sizes {
|
for size in &sizes {
|
||||||
print!("{:3}x{:3}", size, size);
|
print!("{:3}x{:3}", size, size);
|
||||||
let e = run_with_size::<SBP>(*size);
|
let e = run_with_size(*size, op);
|
||||||
print!("\t{:.10}", e);
|
print!("\t{:.10}", e);
|
||||||
if let Some(prev) = prev.take() {
|
if let Some(prev) = prev.take() {
|
||||||
let m0 = size * size;
|
let m0 = size * size;
|
||||||
|
@ -68,10 +74,10 @@ fn convergence<SBP: sbp::operators::UpwindOperator>() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn convergence_upwind4() {
|
fn convergence_upwind4() {
|
||||||
convergence::<sbp::operators::Upwind4>();
|
convergence(sbp::operators::Upwind4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn convergence_upwind9() {
|
fn convergence_upwind9() {
|
||||||
convergence::<sbp::operators::Upwind9>();
|
convergence(sbp::operators::Upwind9);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,21 @@ fn single_period_upwind4() {
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
let vortex_params = VortexParameters {
|
let vortex_params = VortexParameters {
|
||||||
|
vortices: {
|
||||||
|
let mut v = ArrayVec::new();
|
||||||
|
v.push(Vortice {
|
||||||
x0: -1.0,
|
x0: -1.0,
|
||||||
y0: 0.0,
|
y0: 0.0,
|
||||||
mach: 0.5,
|
|
||||||
rstar: 0.5,
|
rstar: 0.5,
|
||||||
eps: 1.0,
|
eps: 1.0,
|
||||||
|
});
|
||||||
|
v
|
||||||
|
},
|
||||||
|
mach: 0.5,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut sys = System::<sbp::operators::Upwind4>::new(x, y);
|
let mut sys = System::new(x, y, sbp::operators::Upwind4);
|
||||||
sys.vortex(0.0, vortex_params);
|
sys.vortex(0.0, vortex_params.clone());
|
||||||
|
|
||||||
let time = 10.0;
|
let time = 10.0;
|
||||||
let dt = 0.2 * Float::min(1.0 / (nx - 1) as Float, 1.0 / (ny - 1) as Float);
|
let dt = 0.2 * Float::min(1.0 / (nx - 1) as Float, 1.0 / (ny - 1) as Float);
|
||||||
|
@ -40,8 +46,13 @@ fn single_period_upwind4() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut verifield = Field::new(ny, nx);
|
let mut verifield = Field::new(ny, nx);
|
||||||
verifield.vortex(sys.x(), sys.y(), nsteps as Float * dt - 10.0, vortex_params);
|
verifield.vortex(
|
||||||
|
sys.x(),
|
||||||
|
sys.y(),
|
||||||
|
nsteps as Float * dt - 10.0,
|
||||||
|
&vortex_params,
|
||||||
|
);
|
||||||
|
|
||||||
let err = verifield.h2_err::<sbp::operators::Upwind4>(sys.field());
|
let err = verifield.h2_err(sys.field(), &sbp::operators::Upwind4);
|
||||||
panic!("{}", err);
|
panic!("{}", err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue