Skip to content

Commit

Permalink
Replace field_wrapper with fill
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Aug 3, 2023
1 parent 0223c70 commit a6caf83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
9 changes: 2 additions & 7 deletions test/Operators/finitedifference/column.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1054,15 +1054,10 @@ end
zc = getproperty(Fields.coordinate_field(cs), :z)
zf = getproperty(Fields.coordinate_field(fs), :z)

function field_wrapper(space, nt::NamedTuple)
cmv(z) = nt
return cmv.(Fields.coordinate_field(space))
end

field_vars() = (; y = FT(0))

cfield = field_wrapper(cs, field_vars())
ffield = field_wrapper(fs, field_vars())
cfield = fill(field_vars(), cs)
ffield = fill(field_vars(), fs)

cy = cfield.y
fy = ffield.y
Expand Down
13 changes: 4 additions & 9 deletions test/Operators/finitedifference/column_benchmark_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function get_column_spaces(z_elems, ::Type{FT}) where {FT}
fs = Spaces.FaceFiniteDifferenceSpace(cs)
zc = getproperty(Fields.coordinate_field(cs), :z)
zf = getproperty(Fields.coordinate_field(fs), :z)
cfield = field_wrapper(cs, field_vars(FT))
ffield = field_wrapper(fs, field_vars(FT))
cfield = fill(field_vars(FT), cs)
ffield = fill(field_vars(FT), fs)

return (;cs, fs)
end
Expand All @@ -88,16 +88,11 @@ function get_fields(z_elems, ::Type{FT}, h_space) where {FT}
end
zc = getproperty(Fields.coordinate_field(cs), :z)
zf = getproperty(Fields.coordinate_field(fs), :z)
cfield = field_wrapper(cs, field_vars(FT))
ffield = field_wrapper(fs, field_vars(FT))
cfield = fill(field_vars(FT), cs)
ffield = fill(field_vars(FT), fs)
return (; cfield, ffield)
end

function field_wrapper(space, nt::NamedTuple)
cmv(z) = nt
return cmv.(Fields.coordinate_field(space))
end

#####
##### Second order interpolation / derivatives
#####
Expand Down
13 changes: 4 additions & 9 deletions test/Operators/finitedifference/opt_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ Base.@propagate_inbounds Base.getindex(
a_bcs(::Type{FT}, i::Int) where {FT} =
(; bottom = Operators.SetValue(FT(0)), top = Operators.Extrapolate())

function field_wrapper(space, nt::NamedTuple)
cmv(z) = nt
return cmv.(Fields.coordinate_field(space))
end

function alloc_test_f2c_interp(cfield, ffield)
(; fx, fy, fz, fϕ, fψ) = ffield
(; cx, cy, cz, cϕ, cψ) = cfield
Expand Down Expand Up @@ -462,10 +457,10 @@ end
(; fx = FT(0), fy = FT(0), fz = FT(0), fϕ = FT(0), fψ = FT(0))
cntfield_vars() = (; nt = ntuple(i -> cfield_vars(), n_tuples))
fntfield_vars() = (; nt = ntuple(i -> ffield_vars(), n_tuples))
cfield = field_wrapper(cs, cfield_vars())
ffield = field_wrapper(fs, ffield_vars())
ntcfield = field_wrapper(cs, cntfield_vars())
ntffield = field_wrapper(fs, fntfield_vars())
cfield = fill(cfield_vars(), cs)
ffield = fill(ffield_vars(), fs)
ntcfield = fill(cntfield_vars(), cs)
ntffield = fill(fntfield_vars(), fs)
wvec_glob = Geometry.WVector

alloc_test_f2c_interp(cfield, ffield)
Expand Down

0 comments on commit a6caf83

Please sign in to comment.