-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_plottools.jl
86 lines (77 loc) · 2.48 KB
/
test_plottools.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# TEST SINGLE VORTEX RING
include("vm2d.jl")
# create circle geometry
center = [0.0,0.0,0.0]
radius = 0.1
refinement = 9
gamma = 0.1
velocity=[0.0,0.0,0.0]
particles = vortexring(radius,center,refinement,gamma;velocity=velocity)
# set simulation variables
name = "vortexrings"
timestart = 0.0
timestep = 0.01
numtimesteps = 150
# plot
## TEST 1: try making 2D x-y plot
# plot_xy(particles)
## TEST 2: try animating
# animate(particles,timestart,timestep,numtimesteps)
# TEST `packVTK`
# particles = vortexring(radius,center,refinement,gamma;velocity=velocity) # primitive
center = [0.0,0.0,0.0]
radius = 0.1
refinement = 150
gamma = -0.002
velocity=[0.0,0.0,0.0]
spacing = 0.05
ring1 = vortexring(radius,center,refinement,gamma;velocity=velocity)
ring2 = vortexring(radius,center.+[0.0,0.0,spacing],refinement,gamma;velocity=velocity)
particles = vcat(ring1,ring2)
filename = "test_plottools"
numtimesteps = 2
timestep = 0.01
# xs = range(center[1] - 2*radius, stop = center[1] + 2*radius, length = 19)
# ys = range(center[1] - 2*radius, stop = center[1] + 2*radius, length = 19)
# zs = [center[3]]
if ~isdir("./vtk")
mkdir("./vtk")
end
margin = 0.2
for i in 1:numtimesteps
## advance timestep
## evaluate velocity field
### get center
xcoordinates = Float64[]
ycoordinates = Float64[]
zcoordinates = Float64[]
for particle in particles
push!(xcoordinates, particle.x[1])
push!(ycoordinates, particle.x[2])
push!(zcoordinates, particle.x[3])
end
# xs = [sum(xcoordinates)/length(xcoordinates) + xoffset]
xhi = maximum(xcoordinates)
xlo = minimum(xcoordinates)
xs = range(xlo-margin, stop = xhi + margin, length = 21)
# ycenter = sum(ycoordinates)/length(ycoordinates)
yhi = maximum(ycoordinates)
ylo = minimum(ycoordinates)
# ys = range(ycenter - 0.2, stop = ycenter + 0.2,length = 20)
ys = range(ylo-margin, stop = yhi + margin, length = 21)
zhi = maximum(zcoordinates)
zlo = minimum(zcoordinates)
zrefinement = Integer(ceil(abs(zhi-zlo) / radius*4))
if zrefinement < 2
zrefinement = 2
end
zs = range(zlo-margin, stop = zhi+margin, length=zrefinement)
zs = range(particles[1].x[3] - 0.07,
stop = particles[1].x[3] + 0.1,
length = 10)
# zs = [sum(zcoordinates)/length(zcoordinates)]
# name = "rings2d_150particles_yz"*"_"*string(i)
packVTK(filename, particles::Array{Particle,1}; xs=xs, ys=ys, zs=zs, num=i)
advance(particles,timestep,Uinf)
# currenttime += timestep
end