-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathdistributed_incompressible_model.jl
51 lines (39 loc) · 1.67 KB
/
distributed_incompressible_model.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
using Oceananigans.Grids
using Oceananigans.Fields
#####
##### Distributed incompressible model constructor
#####
function DistributedIncompressibleModel(; architecture, grid, model_kwargs...)
i, j, k = architecture.local_index
Rx, Ry, Rz = architecture.ranks
my_connectivity = architecture.connectivity
Nx, Ny, Nz = size(grid)
Lx, Ly, Lz = length(grid)
# Pull out endpoints for full grid.
xL, xR = grid.xF[1], grid.xF[Nx+1]
yL, yR = grid.yF[1], grid.yF[Ny+1]
zL, zR = grid.zF[1], grid.zF[Nz+1]
# Make sure we can put an integer number of grid points in each rank.
# Will generalize in the future.
# TODO: Check that we have enough grid points on each rank to fit the halos!
@assert isinteger(Nx / Rx)
@assert isinteger(Ny / Ry)
@assert isinteger(Nz / Rz)
nx, ny, nz = Nx÷Rx, Ny÷Ry, Nz÷Rz
lx, ly, lz = Lx/Rx, Ly/Ry, Lz/Rz
x₁, x₂ = xL + (i-1)*lx, xL + i*lx
y₁, y₂ = yL + (j-1)*ly, yL + j*ly
z₁, z₂ = zL + (k-1)*lz, zL + k*lz
# FIXME? local grid might have different topology!
my_grid = RegularRectilinearGrid(topology=topology(grid), size=(nx, ny, nz), x=(x₁, x₂), y=(y₁, y₂), z=(z₁, z₂), halo=halo_size(grid))
## Construct local model
pressure_solver = haskey(model_kwargs, :pressure_solver) ? Dict(model_kwargs)[:pressure_solver] :
DistributedFFTBasedPoissonSolver(architecture, grid, my_grid)
my_model = IncompressibleModel(;
architecture = architecture,
grid = my_grid,
pressure_solver = pressure_solver,
model_kwargs...
)
return my_model
end