-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathTwoD_CircleMPI.jl
More file actions
57 lines (49 loc) · 1.8 KB
/
TwoD_CircleMPI.jl
File metadata and controls
57 lines (49 loc) · 1.8 KB
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
#mpiexecjl --project=. -n 2 julia TwoD_CircleMPI.jl
using WaterLily
using WriteVTK
using MPI
using StaticArrays
# make a writer with some attributes, now we need to apply the BCs when writting
velocity(a::Simulation) = a.flow.u |> Array;
pressure(a::Simulation) = a.flow.p |> Array;
_body(a::Simulation) = (measure_sdf!(a.flow.σ, a.body);
a.flow.σ |> Array;)
vorticity(a::Simulation) = (@inside a.flow.σ[I] =
WaterLily.curl(3,I,a.flow.u)*a.L/a.U;
WaterLily.perBC!(a.flow.σ,());
a.flow.σ |> Array;)
_vbody(a::Simulation) = a.flow.V |> Array;
mu0(a::Simulation) = a.flow.μ₀ |> Array;
ranks(a::Simulation) = (a.flow.σ.=0;
@inside a.flow.σ[I] = me()+1;
WaterLily.perBC!(a.flow.σ,());
a.flow.σ |> Array;)
custom_attrib = Dict(
"u" => velocity,
"p" => pressure,
"d" => _body,
"ω" => vorticity,
"v" => _vbody,
"μ₀" => mu0,
"rank" => ranks
)# this maps what to write to the name in the file
"""Flow around a circle"""
function circle(dims,center,radius;Re=250,U=1,psolver=MultiLevelPoisson,mem=Array)
body = AutoBody((x,t)->√sum(abs2, x .- center) - radius)
Simulation(dims, (U,0), radius; ν=U*radius/Re, body, mem=mem, psolver=psolver)
end
# last one standing...
WaterLily.grid_loc() = mpi_grid().global_loc
# local grid size
L = 2^6
# init the MPI grid and the simulation
r = init_mpi((L,L))
sim = circle((L,L),SA[L/2,L/2+2],L/8;mem=MPIArray) #use MPIArray to use extension
wr = vtkWriter("WaterLily-circle-2";attrib=custom_attrib,dir="vtk_data",
extents=get_extents(sim.flow.p))
for _ in 1:50
sim_step!(sim,sim_time(sim)+1.0,verbose=true)
write!(wr,sim)
end
close(wr)
finalize_mpi()