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

Commit

Permalink
Add supermodule Ocean around SWModel and HBModel
Browse files Browse the repository at this point in the history
  • Loading branch information
blallen committed Jun 29, 2020
1 parent 978bc60 commit 59959e6
Show file tree
Hide file tree
Showing 18 changed files with 78 additions and 71 deletions.
1 change: 1 addition & 0 deletions docs/src/APIs/BalanceLaws/BalanceLaws.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ transform_post_gradient_laplacian!
```@docs
wavespeed
boundary_state!
nodal_update_auxiliary_state!
update_auxiliary_state!
update_auxiliary_state_gradient!
```
2 changes: 1 addition & 1 deletion experiments/OceanBoxGCM/homogeneous_box.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.BalanceLaws: vars_state_conservative
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.Ocean.HydrostaticBoussinesq

using Test
using CLIMAParameters
Expand Down
2 changes: 1 addition & 1 deletion experiments/OceanBoxGCM/ocean_gyre.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using ClimateMachine.ODESolvers
using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.Ocean.HydrostaticBoussinesq

using Test

Expand Down
9 changes: 6 additions & 3 deletions src/BalanceLaws/BalanceLaws.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ export BalanceLaw,
vars_state_gradient_flux,
init_state_conservative!,
init_state_auxiliary!,
flux_first_order!,
flux_second_order!,
compute_gradient_flux!,
compute_gradient_argument!,
source!,
transform_post_gradient_laplacian!,
flux_first_order!,
flux_second_order!,
source!,
wavespeed,
boundary_state!,
nodal_update_auxiliary_state!,
update_auxiliary_state!,
update_auxiliary_state_gradient!,
vars_integrals,
integral_load_auxiliary_state!,
integral_set_auxiliary_state!,
indefinite_stack_integral!,
vars_reverse_integrals,
reverse_indefinite_stack_integral!,
reverse_integral_load_auxiliary_state!,
reverse_integral_set_auxiliary_state!
Expand Down
3 changes: 3 additions & 0 deletions src/ClimateMachine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ include(joinpath("BalanceLaws", "BalanceLaws.jl"))
include(joinpath("Numerics", "DGMethods", "DGMethods.jl"))
include(joinpath("Common", "Orientations", "Orientations.jl"))
include(joinpath("Utilities", "SingleStackUtils", "SingleStackUtils.jl"))
include(joinpath("Ocean/Ocean.jl"))
#=
include(joinpath("Ocean", "ShallowWater", "ShallowWaterModel.jl"))
include(joinpath(
"Ocean",
"HydrostaticBoussinesq",
"HydrostaticBoussinesqModel.jl",
))
include(joinpath("Ocean", "SplitExplicit", "SplitExplicitModel.jl"))
=#
include(joinpath("Numerics", "SystemSolvers", "SystemSolvers.jl"))
include(joinpath("Numerics", "ODESolvers", "GenericCallbacks.jl"))
include(joinpath("Numerics", "ODESolvers", "ODESolvers.jl"))
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using ..BalanceLaws:
update_auxiliary_state!
using ..DGMethods: remainder_DGModel
using ..DGMethods.NumericalFluxes
using ..HydrostaticBoussinesq
using ..Ocean.HydrostaticBoussinesq
using ..Mesh.Grids
using ..Mesh.Topologies
using ..Thermodynamics
Expand Down
5 changes: 2 additions & 3 deletions src/Ocean/HydrostaticBoussinesq/BoundaryConditions.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using ..DGMethods.NumericalFluxes:
NumericalFluxFirstOrder, NumericalFluxGradient, NumericalFluxSecondOrder
using ...DGMethods.NumericalFluxes

import ..BalanceLaws: boundary_state!
import ...BalanceLaws: boundary_state!

export OceanBC

Expand Down
8 changes: 4 additions & 4 deletions src/Ocean/HydrostaticBoussinesq/Courant.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using Logging, Printf
using LinearAlgebra: norm

using ..Mesh.Grids:
using ...Mesh.Grids:
VerticalDirection, HorizontalDirection, EveryDirection, min_node_distance
using ..DGMethods: courant
using ...DGMethods: courant

import ..Courant:
import ...Courant:
advective_courant, nondiffusive_courant, diffusive_courant, viscous_courant

import ..DGMethods: calculate_dt
import ...DGMethods: calculate_dt

"""
advective_courant(::HBModel)
Expand Down
56 changes: 25 additions & 31 deletions src/Ocean/HydrostaticBoussinesq/HydrostaticBoussinesqModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,44 @@ using StaticArrays
using LinearAlgebra: dot, Diagonal
using CLIMAParameters.Planet: grav

using ..VariableTemplates
using ..MPIStateArrays
using ..Mesh.Filters: apply!
using ..Mesh.Grids: VerticalDirection
using ..BalanceLaws: BalanceLaw
import ..BalanceLaws: nodal_update_auxiliary_state!
using ..DGMethods.NumericalFluxes: RusanovNumericalFlux

import ..DGMethods.NumericalFluxes: update_penalty!
import ..DGMethods:
using ...VariableTemplates
using ...MPIStateArrays
using ...Mesh.Filters: apply!
using ...Mesh.Grids: VerticalDirection
using ...Mesh.Geometry
using ...DGMethods: DGModel, copy_stack_field_down!
using ...DGMethods.NumericalFluxes
using ...BalanceLaws

import ...DGMethods.NumericalFluxes: update_penalty!
import ...BalanceLaws:
vars_state_conservative,
vars_state_auxiliary,
vars_state_gradient,
vars_integrals,
vars_state_gradient_flux,
vars_reverse_integrals,
init_state_conservative!,
init_state_auxiliary!,
compute_gradient_argument!,
compute_gradient_flux!,
integral_load_auxiliary_state!,
integral_set_auxiliary_state!,
indefinite_stack_integral!,
reverse_indefinite_stack_integral!,
indefinite_stack_integral!,
reverse_indefinite_stack_integral!,
reverse_integral_load_auxiliary_state!,
reverse_integral_set_auxiliary_state!,
flux_first_order!,
flux_second_order!,
source!,
wavespeed,
boundary_state!,
update_auxiliary_state!,
update_auxiliary_state_gradient!

using ..DGMethods: DGModel, copy_stack_field_down!
using ..Mesh.Geometry: LocalGeometry

using ..DGMethods.NumericalFluxes: RusanovNumericalFlux

import ..DGMethods.NumericalFluxes: update_penalty!
update_auxiliary_state_gradient!,
vars_integrals,
integral_load_auxiliary_state!,
integral_set_auxiliary_state!,
indefinite_stack_integral!,
vars_reverse_integrals,
reverse_indefinite_stack_integral!,
reverse_integral_load_auxiliary_state!,
reverse_integral_set_auxiliary_state!

×(a::SVector, b::SVector) = StaticArrays.cross(a, b)
(a::SVector, b::SVector) = StaticArrays.dot(a, b)
(a::SVector, b::SVector) = a * b'

abstract type AbstractHydrostaticBoussinesqProblem end

Expand Down Expand Up @@ -296,7 +290,7 @@ location to store integrands for bottom up integrals
"""
function vars_integrals(m::HBModel, T)
@vars begin
hu::T
ʰu::T
αᵀθ::T
end
end
Expand All @@ -319,7 +313,7 @@ A -> array of aux variables
Q::Vars,
A::Vars,
)
I.∇hu = A.w # borrow the w value from A...
I.∇ʰu = A.w # borrow the w value from A...
I.αᵀθ = -m.αᵀ * Q.θ # integral will be reversed below

return nothing
Expand All @@ -337,7 +331,7 @@ A -> array of aux variables
I -> array of integrand variables
"""
@inline function integral_set_auxiliary_state!(m::HBModel, A::Vars, I::Vars)
A.w = I.∇hu
A.w = I.∇ʰu
A.pkin = I.αᵀθ

return nothing
Expand Down
8 changes: 8 additions & 0 deletions src/Ocean/Ocean.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Ocean

include("HydrostaticBoussinesq/HydrostaticBoussinesqModel.jl")
include("ShallowWater/ShallowWaterModel.jl")
include("SplitExplicit/SplitExplicitModel.jl")
# include("OceanProblems/SimpleBoxProblem.jl")

end
30 changes: 15 additions & 15 deletions src/Ocean/ShallowWater/ShallowWaterModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ module ShallowWater
export ShallowWaterModel, ShallowWaterProblem

using StaticArrays
using ..VariableTemplates
using LinearAlgebra: Diagonal, dot
using LinearAlgebra: dot, Diagonal
using CLIMAParameters.Planet: grav

import ..BalanceLaws:
BalanceLaw,
vars_state_auxiliary,
using ...VariableTemplates
using ...Mesh.Geometry
using ...DGMethods
using ...DGMethods.NumericalFluxes
using ...BalanceLaws

import ...DGMethods.NumericalFluxes: update_penalty!
import ...BalanceLaws:
vars_state_conservative,
vars_state_auxiliary,
vars_state_gradient,
vars_state_gradient_flux,
vars_integrals,
init_state_conservative!,
init_state_auxiliary!,
compute_gradient_argument!,
compute_gradient_flux!,
flux_first_order!,
flux_second_order!,
source!,
wavespeed,
boundary_state!,
compute_gradient_argument!,
init_state_auxiliary!,
init_state_conservative!,
compute_gradient_flux!

import ...Mesh.Geometry: LocalGeometry

using ..DGMethods.NumericalFluxes
boundary_state!

×(a::SVector, b::SVector) = StaticArrays.cross(a, b)
(a::SVector, b::SVector) = StaticArrays.dot(a, b)
Expand Down
2 changes: 1 addition & 1 deletion src/Ocean/SplitExplicit/SplitExplicitModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module SplitExplicit
using ..HydrostaticBoussinesq
using ..ShallowWater

import ..BalanceLaws:
import ...BalanceLaws:
initialize_states!,
tendency_from_slow_to_fast!,
cummulate_fast_solution!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using ClimateMachine.ODESolvers
using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.Ocean.HydrostaticBoussinesq

using Test

Expand Down
2 changes: 1 addition & 1 deletion test/Ocean/HydrostaticBoussinesq/test_divergence_free.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.BalanceLaws: vars_state_conservative
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.Ocean.HydrostaticBoussinesq

using CLIMAParameters
using CLIMAParameters.Planet: grav
Expand Down
2 changes: 1 addition & 1 deletion test/Ocean/HydrostaticBoussinesq/test_ocean_gyre.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using ClimateMachine.ODESolvers
using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.Ocean.HydrostaticBoussinesq

using CLIMAParameters
using CLIMAParameters.Planet: grav
Expand Down
5 changes: 2 additions & 3 deletions test/Ocean/ShallowWater/2D_hydrostatic_spindown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ using ClimateMachine.ODESolvers
using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.ShallowWater
using ClimateMachine.Ocean.ShallowWater

using ClimateMachine.Mesh.Topologies
using ClimateMachine.Mesh.Grids
Expand All @@ -23,7 +22,7 @@ using LinearAlgebra
using StaticArrays
using Logging, Printf, Dates

import ClimateMachine.ShallowWater: shallow_init_state!, shallow_init_aux!
import ClimateMachine.Ocean.ShallowWater: shallow_init_state!, shallow_init_aux!

using CLIMAParameters
using CLIMAParameters.Planet: grav
Expand Down
4 changes: 2 additions & 2 deletions test/Ocean/ShallowWater/GyreInABox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ using ClimateMachine.MPIStateArrays
using ClimateMachine.ODESolvers
using ClimateMachine.GenericCallbacks
using ClimateMachine.VariableTemplates: flattenednames
using ClimateMachine.ShallowWater
using ClimateMachine.Ocean.ShallowWater
using LinearAlgebra
using StaticArrays
using Logging, Printf, Dates
using ClimateMachine.VTK
import ClimateMachine.ShallowWater:
import ClimateMachine.Ocean.ShallowWater:
shallow_init_state!,
shallow_init_aux!,
vars_state_conservative,
Expand Down
6 changes: 3 additions & 3 deletions test/Ocean/SplitExplicit/hydrostatic_spindown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ using ClimateMachine.ODESolvers
using ClimateMachine.Mesh.Filters
using ClimateMachine.VariableTemplates
using ClimateMachine.Mesh.Grids: polynomialorder
using ClimateMachine.HydrostaticBoussinesq
using ClimateMachine.ShallowWater
using ClimateMachine.Ocean.HydrostaticBoussinesq
using ClimateMachine.Ocean.ShallowWater

using ClimateMachine.Mesh.Topologies
using ClimateMachine.Mesh.Grids
Expand All @@ -23,7 +23,7 @@ using LinearAlgebra
using StaticArrays
using Logging, Printf, Dates

import ClimateMachine.ShallowWater: shallow_init_state!, shallow_init_aux!
import ClimateMachine.Ocean.ShallowWater: shallow_init_state!, shallow_init_aux!

using CLIMAParameters
using CLIMAParameters.Planet: grav
Expand Down

0 comments on commit 59959e6

Please sign in to comment.