From 4cfbbf6c957e5d029abf891a4e2a7dae6dc5590a Mon Sep 17 00:00:00 2001 From: Aaron Kaw Date: Wed, 7 Aug 2024 00:49:21 +1000 Subject: [PATCH] Added boundary profiles --- scripts/readme.md | 0 src/99_postliminary/00_preliminary.jl | 8 ++++---- .../01_functors/boundary/00_preliminary.jl | 8 ++++++++ .../01_functors/boundary/01_altimetry.jl | 5 +++++ .../01_functors/boundary/01_bathymetry.jl | 19 +++++++++++++++++++ .../01_functors/boundary/99_postliminary.jl | 15 +++++++++++++++ .../01_functors/celerity/00_preliminary.jl | 1 + .../celerity/01_atmosphere.jl} | 0 .../celerity/01_ocean.jl} | 0 .../celerity/01_seabed.jl} | 0 .../celerity/99_postliminary.jl | 8 ++++---- .../01_functors/density/00_preliminary.jl | 1 + .../density/01_atmosphere.jl} | 0 .../density/01_ocean.jl} | 0 .../density/01_seabed.jl} | 0 .../density/99_postliminary.jl | 6 +++--- .../01_profiles/celerity/01_preliminary.jl | 1 - .../01_profiles/density/01_preliminary.jl | 1 - 18 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 scripts/readme.md create mode 100644 src/99_postliminary/01_functors/boundary/00_preliminary.jl create mode 100644 src/99_postliminary/01_functors/boundary/01_altimetry.jl create mode 100644 src/99_postliminary/01_functors/boundary/01_bathymetry.jl create mode 100644 src/99_postliminary/01_functors/boundary/99_postliminary.jl create mode 100644 src/99_postliminary/01_functors/celerity/00_preliminary.jl rename src/99_postliminary/{01_profiles/celerity/02_atmosphere.jl => 01_functors/celerity/01_atmosphere.jl} (100%) rename src/99_postliminary/{01_profiles/celerity/02_ocean.jl => 01_functors/celerity/01_ocean.jl} (100%) rename src/99_postliminary/{01_profiles/celerity/02_seabed.jl => 01_functors/celerity/01_seabed.jl} (100%) rename src/99_postliminary/{01_profiles => 01_functors}/celerity/99_postliminary.jl (60%) create mode 100644 src/99_postliminary/01_functors/density/00_preliminary.jl rename src/99_postliminary/{01_profiles/density/02_atmosphere.jl => 01_functors/density/01_atmosphere.jl} (100%) rename src/99_postliminary/{01_profiles/density/02_ocean.jl => 01_functors/density/01_ocean.jl} (100%) rename src/99_postliminary/{01_profiles/density/02_seabed.jl => 01_functors/density/01_seabed.jl} (100%) rename src/99_postliminary/{01_profiles => 01_functors}/density/99_postliminary.jl (60%) delete mode 100644 src/99_postliminary/01_profiles/celerity/01_preliminary.jl delete mode 100644 src/99_postliminary/01_profiles/density/01_preliminary.jl diff --git a/scripts/readme.md b/scripts/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/src/99_postliminary/00_preliminary.jl b/src/99_postliminary/00_preliminary.jl index c17ba17..e41258a 100644 --- a/src/99_postliminary/00_preliminary.jl +++ b/src/99_postliminary/00_preliminary.jl @@ -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 diff --git a/src/99_postliminary/01_functors/boundary/00_preliminary.jl b/src/99_postliminary/01_functors/boundary/00_preliminary.jl new file mode 100644 index 0000000..41ff71d --- /dev/null +++ b/src/99_postliminary/01_functors/boundary/00_preliminary.jl @@ -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 diff --git a/src/99_postliminary/01_functors/boundary/01_altimetry.jl b/src/99_postliminary/01_functors/boundary/01_altimetry.jl new file mode 100644 index 0000000..9112e3c --- /dev/null +++ b/src/99_postliminary/01_functors/boundary/01_altimetry.jl @@ -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 diff --git a/src/99_postliminary/01_functors/boundary/01_bathymetry.jl b/src/99_postliminary/01_functors/boundary/01_bathymetry.jl new file mode 100644 index 0000000..a64a902 --- /dev/null +++ b/src/99_postliminary/01_functors/boundary/01_bathymetry.jl @@ -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 diff --git a/src/99_postliminary/01_functors/boundary/99_postliminary.jl b/src/99_postliminary/01_functors/boundary/99_postliminary.jl new file mode 100644 index 0000000..297cf30 --- /dev/null +++ b/src/99_postliminary/01_functors/boundary/99_postliminary.jl @@ -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 diff --git a/src/99_postliminary/01_functors/celerity/00_preliminary.jl b/src/99_postliminary/01_functors/celerity/00_preliminary.jl new file mode 100644 index 0000000..4094cc2 --- /dev/null +++ b/src/99_postliminary/01_functors/celerity/00_preliminary.jl @@ -0,0 +1 @@ +struct CelerityProfileFunctionType{MediumType <: AcousticMedium} <: ModellingFunction{3} end diff --git a/src/99_postliminary/01_profiles/celerity/02_atmosphere.jl b/src/99_postliminary/01_functors/celerity/01_atmosphere.jl similarity index 100% rename from src/99_postliminary/01_profiles/celerity/02_atmosphere.jl rename to src/99_postliminary/01_functors/celerity/01_atmosphere.jl diff --git a/src/99_postliminary/01_profiles/celerity/02_ocean.jl b/src/99_postliminary/01_functors/celerity/01_ocean.jl similarity index 100% rename from src/99_postliminary/01_profiles/celerity/02_ocean.jl rename to src/99_postliminary/01_functors/celerity/01_ocean.jl diff --git a/src/99_postliminary/01_profiles/celerity/02_seabed.jl b/src/99_postliminary/01_functors/celerity/01_seabed.jl similarity index 100% rename from src/99_postliminary/01_profiles/celerity/02_seabed.jl rename to src/99_postliminary/01_functors/celerity/01_seabed.jl diff --git a/src/99_postliminary/01_profiles/celerity/99_postliminary.jl b/src/99_postliminary/01_functors/celerity/99_postliminary.jl similarity index 60% rename from src/99_postliminary/01_profiles/celerity/99_postliminary.jl rename to src/99_postliminary/01_functors/celerity/99_postliminary.jl index c74c9ea..7365d89 100644 --- a/src/99_postliminary/01_profiles/celerity/99_postliminary.jl +++ b/src/99_postliminary/01_functors/celerity/99_postliminary.jl @@ -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 \ No newline at end of file +end diff --git a/src/99_postliminary/01_functors/density/00_preliminary.jl b/src/99_postliminary/01_functors/density/00_preliminary.jl new file mode 100644 index 0000000..1140667 --- /dev/null +++ b/src/99_postliminary/01_functors/density/00_preliminary.jl @@ -0,0 +1 @@ +struct DensityProfileFunctionType{MediumType <: AcousticMedium} <: ModellingFunction{3} end diff --git a/src/99_postliminary/01_profiles/density/02_atmosphere.jl b/src/99_postliminary/01_functors/density/01_atmosphere.jl similarity index 100% rename from src/99_postliminary/01_profiles/density/02_atmosphere.jl rename to src/99_postliminary/01_functors/density/01_atmosphere.jl diff --git a/src/99_postliminary/01_profiles/density/02_ocean.jl b/src/99_postliminary/01_functors/density/01_ocean.jl similarity index 100% rename from src/99_postliminary/01_profiles/density/02_ocean.jl rename to src/99_postliminary/01_functors/density/01_ocean.jl diff --git a/src/99_postliminary/01_profiles/density/02_seabed.jl b/src/99_postliminary/01_functors/density/01_seabed.jl similarity index 100% rename from src/99_postliminary/01_profiles/density/02_seabed.jl rename to src/99_postliminary/01_functors/density/01_seabed.jl diff --git a/src/99_postliminary/01_profiles/density/99_postliminary.jl b/src/99_postliminary/01_functors/density/99_postliminary.jl similarity index 60% rename from src/99_postliminary/01_profiles/density/99_postliminary.jl rename to src/99_postliminary/01_functors/density/99_postliminary.jl index 3ab9f68..d302751 100644 --- a/src/99_postliminary/01_profiles/density/99_postliminary.jl +++ b/src/99_postliminary/01_functors/density/99_postliminary.jl @@ -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 \ No newline at end of file diff --git a/src/99_postliminary/01_profiles/celerity/01_preliminary.jl b/src/99_postliminary/01_profiles/celerity/01_preliminary.jl deleted file mode 100644 index 706e6cd..0000000 --- a/src/99_postliminary/01_profiles/celerity/01_preliminary.jl +++ /dev/null @@ -1 +0,0 @@ -struct CelerityProfileFunctionType{MediumType <: Medium} <: ModellingFunction{3} end diff --git a/src/99_postliminary/01_profiles/density/01_preliminary.jl b/src/99_postliminary/01_profiles/density/01_preliminary.jl deleted file mode 100644 index de48198..0000000 --- a/src/99_postliminary/01_profiles/density/01_preliminary.jl +++ /dev/null @@ -1 +0,0 @@ -struct DensityProfileFunctionType{MediumType <: Medium} <: ModellingFunction{3} end