-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun_MPI_test_startingscript.jl
49 lines (45 loc) · 1.66 KB
/
run_MPI_test_startingscript.jl
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
if abspath(PROGRAM_FILE) == @__FILE__
using Pkg
Pkg.activate(".")
import moment_kinetics
using moment_kinetics.input_structs: grid_input, advection_input
using moment_kinetics.coordinates: define_coordinate
using moment_kinetics.chebyshev: setup_chebyshev_pseudospectral
using moment_kinetics.calculus: derivative!, integral
discretization = "chebyshev_pseudospectral"
etol = 1.0e-15
# define inputs needed for the test
ngrid = 8
nelement = 5
L = 6.0
bc = "periodic"
# fd_option and adv_input not actually used so given values unimportant
fd_option = ""
adv_input = advection_input("default", 1.0, 0.0, 0.0)
# create the 'input' struct containing input info needed to create a
# coordinate
input = grid_input("coord", ngrid, nelement, L,
discretization, fd_option, bc, adv_input)
# create the coordinate struct 'x'
x = define_coordinate(input)
# create arrays needed for Chebyshev pseudospectral treatment in x
# and create the plans for the forward and backward fast Chebyshev
# transforms
spectral = setup_chebyshev_pseudospectral(x)
# create array for the function f(x) to be differentiated/integrated
f = Array{Float64,1}(undef, x.n)
# create array for the derivative df/dx
df = Array{Float64,1}(undef, x.n)
# initialize f
for ix ∈ 1:x.n
f[ix] = ( (cospi(2.0*x.grid[ix]/x.L)+sinpi(2.0*x.grid[ix]/x.L))
* exp(-x.grid[ix]^2) )
end
# differentiate f
derivative!(df, f, x, spectral)
# integrate df/dx
intdf = integral(df, x.wgts)
# Test that error intdf is less than the specified error tolerance etol
#@test abs(intdf) < etol
println( "abs(intdf) = ", abs(intdf), ": etol = ",etol)
end