Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Try #2174:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Apr 12, 2021
2 parents 432de81 + 4053233 commit 71da7c7
Show file tree
Hide file tree
Showing 17 changed files with 936 additions and 26 deletions.
19 changes: 19 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,15 @@ steps:
queue: central
slurm_ntasks: 1

- label: "cpu_land_overland_flow_vcatchment"
key: "cpu_land_overland_flow_vcatchment"
command:
- "mpiexec julia --color=yes --project test/Land/Model/test_overland_flow_vcatchment.jl"
agents:
config: cpu
queue: central
slurm_ntasks: 1

- label: "gpu_thermodynamics"
key: "gpu_thermodynamics"
command:
Expand Down Expand Up @@ -1992,6 +2001,16 @@ steps:
slurm_ntasks: 1
slurm_gres: "gpu:1"

- label: "gpu_land_overland_flow_vcatchment"
key: "gpu_land_overland_flow_vcatchment"
command:
- "mpiexec julia --color=yes --project test/Land/Model/test_overland_flow_vcatchment.jl"
agents:
config: gpu
queue: central
slurm_ntasks: 1
slurm_gres: "gpu:1"

- label: "gpu_unittests"
key: "gpu_unittests"
command:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.jl.*.cov
*.jl.mem
*.DS_Store
*.vscode
*~
TAGS

Expand Down
3 changes: 3 additions & 0 deletions docs/list_of_apis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ apis = [
"APIs/Land/SoilWaterParameterizations.md",
"Soil Heat Parameterizations" =>
"APIs/Land/SoilHeatParameterizations.md",
"Surface Flow" => "APIs/Land/SurfaceFlow.md",
"Radiative Boundary Conditions" =>
"APIs/Land/RadiativeEnergyFlux.md",
],
"Common" => [
"Orientations" => "APIs/Common/Orientations.md",
Expand Down
17 changes: 17 additions & 0 deletions docs/src/APIs/Land/SurfaceFlow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SurfaceFlow

```@meta
CurrentModule = ClimateMachine.Land.SurfaceFlow
```

## SurfaceFlow types and functions
```@docs
OverlandFlowModel
NoSurfaceFlowModel
surface_boundary_flux!
surface_boundary_state!
calculate_velocity
Precip
VolumeAdvection
SurfaceWaterArea
```
2 changes: 1 addition & 1 deletion src/Driver/driver_configs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ function MultiColumnLandModel(
zmin = zero(FT),
array_type = ClimateMachine.array_type(),
mpicomm = MPI.COMM_WORLD,
boundary = ((3, 3), (3, 3), (1, 2)),
boundary = ((3, 4), (5, 6), (1, 2)),
solver_type = ExplicitSolverType(),
periodicity = (false, false, false),
meshwarp = (x...) -> identity(x),
Expand Down
54 changes: 46 additions & 8 deletions src/Land/Model/LandModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import ..BalanceLaws:
compute_gradient_flux!,
nodal_init_state_auxiliary!,
init_state_prognostic!,
nodal_update_auxiliary_state!
nodal_update_auxiliary_state!,
wavespeed
using ..DGMethods: LocalGeometry, DGModel
export LandModel

Expand All @@ -54,11 +55,13 @@ Users may over-ride prescribed default values for each field.
# Fields
$(DocStringExtensions.FIELDS)
"""
struct LandModel{PS, S, LBC, SRC, SRCDT, IS} <: BalanceLaw
struct LandModel{PS, S, SF, LBC, SRC, SRCDT, IS} <: BalanceLaw
"Parameter set"
param_set::PS
"Soil model"
soil::S
"Surface Flow model"
surface::SF
"struct of boundary conditions"
boundary_conditions::LBC
"Source Terms (Problem specific source terms)"
Expand All @@ -75,6 +78,7 @@ parameter_set(m::LandModel) = m.param_set
LandModel(
param_set::AbstractParameterSet,
soil::BalanceLaw;
surface::BalanceLaw = NoSurfaceFlowModel(),
boundary_conditions::LBC = (),
source::SRC = (),
init_state_prognostic::IS = nothing
Expand All @@ -85,6 +89,7 @@ Constructor for the LandModel structure.
function LandModel(
param_set::AbstractParameterSet,
soil::BalanceLaw;
surface::BalanceLaw = NoSurfaceFlowModel(),
boundary_conditions::LBC = LandDomainBC(),
source::SRC = (),
init_state_prognostic::IS = nothing,
Expand All @@ -94,6 +99,7 @@ function LandModel(
land = (
param_set,
soil,
surface,
boundary_conditions,
source,
source_dt,
Expand All @@ -106,26 +112,32 @@ end
function vars_state(land::LandModel, st::Prognostic, FT)
@vars begin
soil::vars_state(land.soil, st, FT)
surface::vars_state(land.surface, st, FT)
end
end


function vars_state(land::LandModel, st::Auxiliary, FT)
@vars begin
x::FT
y::FT
z::FT
soil::vars_state(land.soil, st, FT)
surface::vars_state(land.surface, st, FT)
end
end

function vars_state(land::LandModel, st::Gradient, FT)
@vars begin
soil::vars_state(land.soil, st, FT)
surface::vars_state(land.surface, st, FT)
end
end

function vars_state(land::LandModel, st::GradientFlux, FT)
@vars begin
soil::vars_state(land.soil, st, FT)
surface::vars_state(land.surface, st, FT)
end
end

Expand All @@ -135,8 +147,11 @@ function nodal_init_state_auxiliary!(
tmp::Vars,
geom::LocalGeometry,
)
aux.x = geom.coord[1]
aux.y = geom.coord[2]
aux.z = geom.coord[3]
land_init_aux!(land, land.soil, aux, geom)
land_init_aux!(land, land.surface, aux, geom)
end

function flux_first_order!(
Expand All @@ -145,8 +160,19 @@ function flux_first_order!(
state::Vars,
aux::Vars,
t::Real,
directions,
) end
direction,
)
tend = Flux{FirstOrder}()
_args = (; state, aux, t, direction)
args = merge(_args, (precomputed = precompute(land, _args, tend),))

map(prognostic_vars(land)) do prog
var, name = get_prog_state(flux, prog)
val = Σfluxes(prog, eq_tends(prog, land, tend), land, args)
setproperty!(var, name, val)
end
nothing
end


function compute_gradient_argument!(
Expand Down Expand Up @@ -210,6 +236,7 @@ function nodal_update_auxiliary_state!(
t::Real,
)
land_nodal_update_auxiliary_state!(land, land.soil, state, aux, t)
land_nodal_update_auxiliary_state!(land, land.surface, state, aux, t)
end


Expand Down Expand Up @@ -246,8 +273,8 @@ function init_state_prognostic!(
land.init_state_prognostic(land, state, aux, coords, t, args...)
end

include("prog_types.jl")

include("prog_types.jl")
include("RadiativeEnergyFlux.jl")
using .RadiativeEnergyFlux
include("SoilWaterParameterizations.jl")
Expand All @@ -260,11 +287,22 @@ include("soil_heat.jl")
include("Runoff.jl")
using .Runoff
include("land_bc.jl")
include("SurfaceFlow.jl")
using .SurfaceFlow
include("soil_bc.jl")

include("prognostic_vars.jl")

include("source.jl")
include("land_tendencies.jl")
include("source.jl")

function wavespeed(m::LandModel, n⁻, state::Vars, aux::Vars, t::Real, direction)
FT = eltype(state)
g = FT(9.8)
width = m.surface.width(aux.x, aux.y)
area = max(eltype(state)(0.0), state.surface.area)
height = area ./ width
v = calculate_velocity(m.surface, aux.x, aux.y, height)
speed = abs(norm(v))
return speed
end

end # Module
Loading

0 comments on commit 71da7c7

Please sign in to comment.