Skip to content

Commit 860fa4a

Browse files
authored
Merge pull request #210 from gaelforget/v0p5p2c
streamline GridSpec_ones a bit, add docs, fix GridLoad_default
2 parents f3b6233 + 4ad833f commit 860fa4a

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/ReadWrite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,4 @@ function write_tiles(fil::String,x::AbstractMeshArray)
267267
close(fid)
268268
end
269269

270-
##
270+
##

src/grids/main.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ function GridSpec(category="default",
2020
GridSpec_default(ID=ID)
2121
elseif category=="ones"&&ID==:unknown
2222
npoints=(isnothing(np) ? 10 : np)
23-
GridSpec_ones("PeriodicDomain",1,npoints)
23+
GridSpec_ones("PeriodicDomain",nP=npoints)
2424
else
2525
GridSpec_MITgcm(category, path; np=np, ID=ID)
2626
end
2727
end
2828

2929
"""
30-
GridSpec_default(xy=NamedTuple(), nFaces=1; ID=:unknown)
30+
GridSpec_default(xy=NamedTuple(); ID=:unknown, ioPrec=Float64, tile=[])
3131
3232
- Select one of the pre-defined grids
3333
- or by providing `xy` parameter (a `NamedTuple` that includes `:xc, :yc, :xg, :yg`)
@@ -304,19 +304,18 @@ import .NEMO_GRID: GridLoad_NEMO, GridSpec_NEMO
304304
MeshArrays.GridSpec_default(ID=:IAP)
305305
```
306306
"""
307-
function GridLoad_default(gr=GridSpec())
308-
xy=(if gr.path=="_default_IAP"
307+
function GridLoad_default(γ=GridSpec())
308+
xy=(if γ.path=="_default_IAP"
309309
Grids_simple.xy_IAP()
310-
elseif gr.path=="_default_Oscar"
310+
elseif γ.path=="_default_Oscar"
311311
Grids_simple.xy_Oscar()
312-
elseif gr.path=="_default_OISST"
312+
elseif γ.path=="_default_OISST"
313313
Grids_simple.xy_OISST()
314314
else
315315
error("unknown grid ID")
316316
end)
317-
(ni,nj)=(length(xy.xc),length(xy.yc)) #still needs fixing ... set according to gr ...
318-
gr=Grids_simple.grid_factors(xy,tile=(ni,nj))
319-
dep=[10 100 1000]; msk=ones(gr[:XC].fSize[1]...,3)
317+
gr=Grids_simple.grid_factors(xy,tile=γ.fSize[1])
318+
dep=[10 100 1000]; msk=ones.ioSize...,3)
320319
gr=Grids_simple.grid_add_z(gr,dep,msk)
321320
end
322321

src/grids/simple.jl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,35 @@ import MeshArrays: gcmgrid, varmeta, MeshArray, Dict_to_NamedTuple
66
import MeshArrays: read_tiles, write_tiles, GridSpec_default
77

88
"""
9-
GridSpec_ones(grTp,nF,nP)
9+
GridSpec_ones(grTp; ioPrec=Float64,nP=10,nF=1)
1010
11-
Define grid where all variables will be set
12-
to one via `GridLoad_ones`.
11+
Define grid where all variables will be set to one via `GridLoad_ones`.
12+
13+
- Possible values for `grTp`` : "LatLonCap","CubeSphere","PeriodicChannel","PeriodicDomain".
14+
- `nP` : number of points at each subdomain edge.
15+
- `nF` (only for "PeriodicChannel", "PeriodicDomain" grids) : number of subdomains.
1316
1417
```
1518
using MeshArrays
16-
γ=MeshArrays.GridSpec_ones("CubeSphere",6,20);
19+
γ=MeshArrays.GridSpec_ones("CubeSphere")
1720
Γ=MeshArrays.GridLoad_ones(γ;option="full")
1821
```
1922
"""
20-
function GridSpec_ones(grTp,nF,nP; ioPrec=Float64)
23+
function GridSpec_ones(grTp; ioPrec=Float64,nP=10,nF=1)
2124
grDir="_ones"
2225
grTopo=grTp
23-
nFaces=nF
2426
if grTopo=="LatLonCap"
25-
ioSize=[nP nP*nF]
27+
nFaces=5
2628
elseif grTopo=="CubeSphere"
27-
ioSize=[nP nP*nF]
29+
nFaces=6
2830
elseif grTopo=="PeriodicChannel"
29-
ioSize=[nP nP]
31+
nFaces=nF
3032
elseif grTopo=="PeriodicDomain"
31-
nFsqrt=Int(sqrt(nF))
32-
ioSize=[nP*nFsqrt nP*nFsqrt]
33+
nFaces=nF
3334
else
3435
error("unknown configuration (grTopo)")
3536
end
37+
ioSize=[nP nP*nFaces]
3638
facesSize=Array{NTuple{2, Int},1}(undef,nFaces)
3739
facesSize[:].=[(nP,nP)]
3840

@@ -154,12 +156,11 @@ isa(Γ.XC,MeshArray)
154156
155157
true
156158
```
157-
158159
"""
159160
function periodic_domain(np::Integer,nq=missing)
160161
ismissing(nq) ? nq=np : nothing
161162

162-
nFaces=1 #still needs fixing ...
163+
nFaces=1
163164
ioSize=[np nq]
164165
facesSize=Array{NTuple{2, Int},1}(undef,nFaces)
165166
facesSize[:].=[(np,nq)]

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ include(joinpath(p,"../examples/Demos.jl"))
2222
elseif nTopo==4; grTopo="PeriodicDomain"; nFaces=1; N=400;
2323
end;
2424
Npt=nFaces*N*N
25-
γ=MeshArrays.GridSpec_ones(grTopo,nFaces,N)
25+
γ=MeshArrays.GridSpec_ones(grTopo,nP=N)
2626
Γ=MeshArrays.GridLoad_ones(γ;option="full")
2727
@test γ.class == grTopo
2828
Rini= 0.; Rend= 0.;
@@ -239,7 +239,7 @@ end
239239
(Γ,γ)=Grids_simple.UnitGrid( (80,90) , (20,30) ; option="full")
240240
@test isa(γ,gcmgrid)
241241

242-
γ=Grids_simple.GridSpec_ones("PeriodicDomain",1,10)
242+
γ=Grids_simple.GridSpec_ones("PeriodicDomain",nP=10)
243243
Γ=Grids_simple.GridLoad_ones(γ,option="full")
244244
@test isa(Γ,NamedTuple)
245245

0 commit comments

Comments
 (0)