-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use BarotropicModel instead of :barotropic etc #176
Conversation
@maximilian-gelbrecht I thought it would be more consistent to use run_speedy(model=ShallowWaterModel) instead of |
Ah same problem as always, we cannot define Parameters without having defined BarotropicModel and vice versa 💩 |
But here we have an abstract type. Shouldn't this just work when defining |
Yeah, but we then also would need a |
Yeah, use in Mh, ... so either introducing all the abstract types, or maybe we just keep it as it is? Long-term, an alternative could also be to do something a bit more akin of the syntax of DiffEq.jl etc: model = ShallowWaterModel(kwargs...)
p, d = solve(model) Edit: when I think about it, this also wouldn't solve this issue, it's basically the same... |
src/define_diffusion.jl
Outdated
@@ -86,14 +86,14 @@ function HorizontalDiffusion( P::Parameters, # Parameter struct | |||
end | |||
end | |||
|
|||
if P.model == :barotropic || P.model == :shallowwater # orographic correction not needed | |||
if P.model <: BarotropicModel || P.model <: ShallowWaterModel # orographic correction not needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume that use of the model types here, would always require the added abstract types. This file needs to be called before the file that defines the models, as it needs HorizontalDiffusion
What about abstract type ModelSetup{D} end
abstract type Barotropic{D} <: ModelSetup end
abstract type ShallowWater{D} <: ModelSetup end
abstract type PrimitiveEquation{D} <: ModelSetup end and then subtype |
My impression is that other libraries also use more parametric types in the struct because of this problem, and specify the types of the fields in the structs less often. This does definitely come as the cost of less readable code though |
Yeah, I guess that's the easiest way to do it. |
Okay that's how it's now! abstract type ModelSetup end
abstract type Barotropic <: ModelSetup end
abstract type ShallowWater <: ModelSetup end
abstract type PrimitiveEquation <: ModelSetup end and struct BarotropicModel <: Barotropic
struct ShallowWaterModel <: ShallowWater
struct PrimitiveEquationModel <: PrimitiveEquation so without |
Same for
ShallowWaterModel
,PrimitiveEquationModel
.