Skip to content

Commit

Permalink
Added boundary profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
kapple19 committed Aug 6, 2024
1 parent ea4787a commit 4cfbbf6
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 13 deletions.
Empty file added scripts/readme.md
Empty file.
8 changes: 4 additions & 4 deletions src/99_postliminary/00_preliminary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export Atmosphere
export Ocean
export Seabed

abstract type Medium end
abstract type AcousticMedium end

abstract type Atmosphere <: Medium end
abstract type Ocean <: Medium end
abstract type Seabed <: Medium end
abstract type Atmosphere <: AcousticMedium end
abstract type Ocean <: AcousticMedium end
abstract type Seabed <: AcousticMedium end
8 changes: 8 additions & 0 deletions src/99_postliminary/01_functors/boundary/00_preliminary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export Surface
export Bottom

abstract type OceanInterface end
abstract type Surface <: OceanInterface end
abstract type Bottom <: OceanInterface end

struct BoundaryProfileFunctionType{BoundaryType <: OceanInterface} <: ModellingFunction{2} end
5 changes: 5 additions & 0 deletions src/99_postliminary/01_functors/boundary/01_altimetry.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export altimetry_profile

const altimetry_profile = BoundaryProfileFunctionType{Surface}()

altimetry_profile(::ModelName{:Flat}, x::Real, y::Real; z::Real = 0.0)::Float64 = z
19 changes: 19 additions & 0 deletions src/99_postliminary/01_functors/boundary/01_bathymetry.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export bathymetry_profile

const bathymetry_profile = BoundaryProfileFunctionType{Bottom}()

bathymetry_profile(::ModelName{:Flat}, x::Real, y::Real; z::Real)::Float64 = z

bathymetry_profile(::ModelName{:Epipelagic}, x::Real, y::Real)::Float64 = 100.0
bathymetry_profile(::ModelName{:Mesopelagic}, x::Real, y::Real)::Float64 = 1e3
bathymetry_profile(::ModelName{:Bathypelagic}, x::Real, y::Real)::Float64 = 4e3
bathymetry_profile(::ModelName{:Abyssopelagic}, x::Real, y::Real)::Float64 = 6e3

bathymetry_profile(::ModelName{:Bottomless}, x::Real, y::Real)::Float64 = Inf

function bathymetry_profile(::ModelName{:Parabolic}, x::Real, y::Real;
b = 250e3, c = 250.0
)::Float64
r = hypot(x, y)
2e-3b * sqrt(1 + r/c)
end
15 changes: 15 additions & 0 deletions src/99_postliminary/01_functors/boundary/99_postliminary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export BoundaryProfile

struct BoundaryProfile{InterfaceType <: OceanInterface, ProfileFunctionType <: Function} <: ModellingFunctor{2}
profile::ProfileFunctionType

function BoundaryProfile{InterfaceType}(model::ModelName; pars...) where {InterfaceType <: OceanInterface}
boundary_profile = BoundaryProfileFunctionType{InterfaceType}()
profile(x::Real, y::Real) = boundary_profile(model, x, y; pars...)
new{InterfaceType, profile |> typeof}(profile)
end
end

function (bnd::BoundaryProfile{<:OceanInterface, <:Function})(x::Real, y::Real)
bnd.profile(x, y)
end
1 change: 1 addition & 0 deletions src/99_postliminary/01_functors/celerity/00_preliminary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
struct CelerityProfileFunctionType{MediumType <: AcousticMedium} <: ModellingFunction{3} end
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export CelerityProfile

struct CelerityProfile{MediumType <: Medium, ProfileFunctionType <: Function} <: ModellingFunctor{3}
struct CelerityProfile{MediumType <: AcousticMedium, ProfileFunctionType <: Function} <: ModellingFunctor{3}
profile::ProfileFunctionType

function CelerityProfile{MediumType}(model::ModelName; pars...) where {MediumType <: Medium}
function CelerityProfile{MediumType}(model::ModelName; pars...) where {MediumType <: AcousticMedium}
celerity_profile = CelerityProfileFunctionType{MediumType}()
profile(x::Real, y::Real, z::Real) = celerity_profile(model, x, y, z; pars...)
new{MediumType, profile |> typeof}(profile)
end
end

function (cel::CelerityProfile{<:Medium, <:Function})(x::Real, y::Real, z::Real)
function (cel::CelerityProfile{<:AcousticMedium, <:Function})(x::Real, y::Real, z::Real)
cel.profile(x, y, z)
end
end
1 change: 1 addition & 0 deletions src/99_postliminary/01_functors/density/00_preliminary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
struct DensityProfileFunctionType{MediumType <: AcousticMedium} <: ModellingFunction{3} end
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export DensityProfile

struct DensityProfile{MediumType <: Medium, ProfileFunctionType <: Function} <: ModellingFunctor{3}
struct DensityProfile{MediumType <: AcousticMedium, ProfileFunctionType <: Function} <: ModellingFunctor{3}
profile::ProfileFunctionType

function DensityProfile{MediumType}(model::ModelName; pars...) where {MediumType <: Medium}
function DensityProfile{MediumType}(model::ModelName; pars...) where {MediumType <: AcousticMedium}
density_profile = DensityProfileFunctionType{MediumType}()
profile(x::Real, y::Real, z::Real) = density_profile(model, x, y, z; pars...)
new{MediumType, profile |> typeof}(profile)
end
end

function (den::DensityProfile{<:Medium, <:Function})(x::Real, y::Real, z::Real)
function (den::DensityProfile{<:AcousticMedium, <:Function})(x::Real, y::Real, z::Real)
den.profile(x, y, z)
end
1 change: 0 additions & 1 deletion src/99_postliminary/01_profiles/celerity/01_preliminary.jl

This file was deleted.

1 change: 0 additions & 1 deletion src/99_postliminary/01_profiles/density/01_preliminary.jl

This file was deleted.

0 comments on commit 4cfbbf6

Please sign in to comment.