Skip to content

Commit

Permalink
Merge #175
Browse files Browse the repository at this point in the history
175: Add bcs to interpf2c r=charleskawczynski a=charleskawczynski



Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski committed Aug 29, 2021
2 parents a6bea13 + 10a1fae commit 8f4cb00
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration_tests/utils/Cases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ function initialize_surface(self::CasesBase{LES_driven_SCM}, Gr::Grid, Ref::Refe
self.Sur.Gr = Gr
self.Sur.Tsurface = mean(data.group["timeseries"]["surface_temperature"][:][imin:imax], dims = 1)[1]
# get surface value of q
mean_qt_prof = mean(data.group["profiles"]["qt_mean"][:][:, imin:imax], dims = 2)
mean_qt_prof = mean(data.group["profiles"]["qt_mean"][:][:, imin:imax], dims = 2)[:]
self.Sur.qsurface = TC.interpf2c(mean_qt_prof, Gr, TC.kc_surface(Gr))
self.Sur.lhf = mean(data.group["timeseries"]["lhf_surface_mean"][:][imin:imax], dims = 1)[1]
self.Sur.shf = mean(data.group["timeseries"]["shf_surface_mean"][:][imin:imax], dims = 1)[1]
Expand Down
23 changes: 18 additions & 5 deletions src/Operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,26 @@ interpc2f(f::SVector, grid::Grid, ::InteriorTag) = (f[1] + f[2]) / 2
interpc2f(f::SVector, grid::Grid, ::TopBCTag, bc::SetValue) = bc.value
interpc2f(f::SVector, grid::Grid, ::BottomBCTag, bc::SetValue) = bc.value

function interpf2c(f, grid::Grid, k::Int)
return 0.5 * (f[k] + f[k - 1])
end
# Used when traversing cell centers
interpf2c(f, grid::Grid, k::Int; bottom = UseBoundaryValue(), top = UseBoundaryValue()) =
interpf2c(dual_faces(f, grid, k), grid, k, bottom, top)

interpf2c(f, grid::Grid, k::Int, i_up::Int; bottom = UseBoundaryValue(), top = UseBoundaryValue()) =
interpf2c(dual_faces(f, grid, k, i_up), grid, k, bottom, top)

function interpf2c(f, grid::Grid, k::Int, i_up::Int)
return 0.5 * (f[i_up, k] + f[i_up, k - 1])
function interpf2c(f_dual::SVector, grid::Grid, k::Int, bottom::AbstractBC, top::AbstractBC)
if is_surface_center(grid, k)
return interpf2c(f_dual, grid, BottomBCTag(), bottom)
elseif is_toa_center(grid, k)
return interpf2c(f_dual, grid, TopBCTag(), top)
else
return interpf2c(f_dual, grid, InteriorTag())
end
end
interpf2c(f::SVector, grid::Grid, ::Int, ::UseBoundaryValue, top::UseBoundaryValue) = interpf2c(f, grid, InteriorTag())
interpf2c(f::SVector, grid::Grid, ::InteriorTag) = (f[1] + f[2]) / 2
interpf2c(f::SVector, grid::Grid, ::TopBCTag, bc::SetValue) = (f[1] + bc.value) / 2
interpf2c(f::SVector, grid::Grid, ::BottomBCTag, bc::SetValue) = (bc.value + f[2]) / 2

#####
##### ∇(center data)
Expand Down

0 comments on commit 8f4cb00

Please sign in to comment.