From 17d251e9e896a74f93c62fc1a466c0d013bd409c Mon Sep 17 00:00:00 2001 From: Brian Groenke <brian.groenke@awi.de> Date: Thu, 9 Dec 2021 10:29:21 +0100 Subject: [PATCH] Rename more LandModel -> Tile stuff missed before --- src/Land/Land.jl | 4 ++-- src/Land/state.jl | 16 ++++++++-------- src/Land/{model.jl => tile.jl} | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) rename src/Land/{model.jl => tile.jl} (98%) diff --git a/src/Land/Land.jl b/src/Land/Land.jl index aac3c6da..4eaed980 100644 --- a/src/Land/Land.jl +++ b/src/Land/Land.jl @@ -32,11 +32,11 @@ export StratComponent, componentname, copmonenttypes, components, boundaries export top, bottom, subsurface include("stratigraphy.jl") -export LandModelState, LayerState +export TileState, LayerState include("state.jl") export Tile, withaxes, getstate -include("model.jl") +include("tile.jl") export ParameterVector, LinearTrend, parameters include("params.jl") diff --git a/src/Land/state.jl b/src/Land/state.jl index e9a9d8ca..81af7154 100644 --- a/src/Land/state.jl +++ b/src/Land/state.jl @@ -36,32 +36,32 @@ end end """ - LandModelState{iip,TGrid,TStates,Tt,names} + TileState{iip,TGrid,TStates,Tt,names} Represents the instantaneous state of a CryoGrid `Tile`. """ -struct LandModelState{iip,TGrid,TStates,Tt,names} +struct TileState{iip,TGrid,TStates,Tt,names} grid::TGrid states::NamedTuple{names,TStates} t::Tt - LandModelState(grid::TGrid, states::NamedTuple{names,TS}, t::Tt, ::Val{iip}=Val{inplace}()) where + TileState(grid::TGrid, states::NamedTuple{names,TS}, t::Tt, ::Val{iip}=Val{inplace}()) where {TGrid<:Numerics.AbstractDiscretization,TS<:Tuple{Vararg{<:LayerState}},Tt,names,iip} = new{iip,TGrid,TS,Tt,names}(grid, states, t) end -Base.getindex(state::LandModelState, sym::Symbol) = Base.getproperty(state, sym) -Base.getindex(state::LandModelState, i::Int) = state.states[i] -function Base.getproperty(state::LandModelState, sym::Symbol) +Base.getindex(state::TileState, sym::Symbol) = Base.getproperty(state, sym) +Base.getindex(state::TileState, i::Int) = state.states[i] +function Base.getproperty(state::TileState, sym::Symbol) return if sym ∈ (:grid,:states,:t) getfield(state, sym) else getproperty(getfield(state, :states), sym) end end -@inline @generated function LandModelState(vs::VarStates{names}, zs::NTuple, u=copy(vs.uproto), du=similar(vs.uproto), t=0.0, ::Val{iip}=Val{inplace}()) where {names,iip} +@inline @generated function TileState(vs::VarStates{names}, zs::NTuple, u=copy(vs.uproto), du=similar(vs.uproto), t=0.0, ::Val{iip}=Val{inplace}()) where {names,iip} layerstates = (:(LayerState(vs, (ustrip(bounds[$i][1]), ustrip(bounds[$i][2])), u, du, t, Val{$(QuoteNode(names[i]))}(), Val{iip}())) for i in 1:length(names)) quote bounds = boundaryintervals(zs, vs.grid[end]) - return LandModelState( + return TileState( vs.grid, NamedTuple{tuple($(map(QuoteNode,names)...))}(tuple($(layerstates...))), t, diff --git a/src/Land/model.jl b/src/Land/tile.jl similarity index 98% rename from src/Land/model.jl rename to src/Land/tile.jl index 476fdf3a..2cb52b1b 100644 --- a/src/Land/model.jl +++ b/src/Land/tile.jl @@ -130,7 +130,7 @@ is only executed during compilation and will not appear in the compiled version. _du .= zero(eltype(_du)) du = ComponentArray(_du, getaxes(model.state.uproto)) u = ComponentArray(_u, getaxes(model.state.uproto)) - state = LandModelState(model.state, boundaries(strat), u, du, t, Val{inplace}()) + state = TileState(model.state, boundaries(strat), u, du, t, Val{inplace}()) end push!(expr.args) # Initialize variables for all layers for i in 1:N @@ -208,7 +208,7 @@ initialcondition!(model::Tile, tspan::NTuple{2,DateTime}, p::AbstractVector, arg du = zero(similar(model.state.uproto, eltype(p))) u = zero(similar(model.state.uproto, eltype(p))) strat = Flatten.reconstruct(model.strat, p, ModelParameters.SELECT, ModelParameters.IGNORE) - state = LandModelState(model.state, boundaries(strat), u, du, tspan[1], Val{iip}()) + state = TileState(model.state, boundaries(strat), u, du, tspan[1], Val{iip}()) end push!(expr.args) # Call initializers for i in 1:N @@ -315,7 +315,7 @@ Gets the function getstate(model::Tile{TStrat,TGrid,TStates,iip}, _u, _du, t) where {TStrat,TGrid,TStates,iip} du = ComponentArray(_du, getaxes(model.state.uproto)) u = ComponentArray(_u, getaxes(model.state.uproto)) - return LandModelState(model.strat, model.state, u, du, t, Val{iip}()) + return TileState(model.strat, model.state, u, du, t, Val{iip}()) end """ Collects and validates all declared variables (`Var`s) for the given strat component. -- GitLab