-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrop.mx3
executable file
·53 lines (42 loc) · 1.2 KB
/
crop.mx3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Test for crop functionality.
Slice and dice the magnetization and check
for correct averages. Also check that we can save/tabulate
*/
Nx := 160
Ny := 50
Nz := 4
c := 1e-9
setGridSize(Nx, Ny, Nz)
setCellSize(c, c, c)
DefRegion(1, xrange(0, inf))
DefRegion(2, yrange(0, inf))
m.SetRegion(0, uniform(1, 0, 0))
m.SetRegion(1, uniform(0, 1, 0))
m.SetRegion(2, uniform(0, 0, -1))
save(m)
tol := 1e-6
m0 := CropX(m, 0, Nx/2)
expect("m0x", m0.Average()[0], 0.5, tol)
expect("m0y", m0.Average()[1], 0.0, tol)
expect("m0z", m0.Average()[2], -0.5, tol)
m1 := CropX(m, Nx/2, Nx)
expect("m1x", m1.Average()[0], 0.0, tol)
expect("m1y", m1.Average()[1], 0.5, tol)
expect("m1z", m1.Average()[2], -0.5, tol)
m2 := CropY(m, 0, Ny/2)
expect("m2x", m2.Average()[0], 0.5, tol)
expect("m2y", m2.Average()[1], 0.5, tol)
expect("m2z", m2.Average()[2], 0.0, tol)
m3 := CropY(m, Ny/2, Ny)
expect("m3x", m3.Average()[0], 0.0, tol)
expect("m3y", m3.Average()[1], 0.0, tol)
expect("m3z", m3.Average()[2], -1.0, tol)
m4 := CropRegion(m, 2)
expect("m4x", m4.Average()[0], 0.0, tol)
expect("m4y", m4.Average()[1], 0.0, tol)
expect("m4z", m4.Average()[2], -1.0, tol)
tableadd(m0)
save(m0)
tableadd(CropLayer(m.Comp(1), 2))
tablesave()