From 8e74b09cfc04f96a7dbbf1bf6f49250ab39b2a68 Mon Sep 17 00:00:00 2001 From: Brian Groenke <brian.groenke@awi.de> Date: Fri, 10 Dec 2021 18:38:04 +0100 Subject: [PATCH] Rename z field to bounds in layer state --- docs/src/manual/overview.md | 2 +- src/Strat/state.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/manual/overview.md b/docs/src/manual/overview.md index 809ed1fe..02a51354 100644 --- a/docs/src/manual/overview.md +++ b/docs/src/manual/overview.md @@ -84,4 +84,4 @@ end Prognostic state variables like `H` in the example above **should not be directly modified** in user code. This is especially important when using higher order or implicit integrators as unexpected changes to the underlying state may destroy the accuracy of their internal interpolators. For modleing discontinuities, use [`Callbacks`](@ref) instead. -Note that `state` is of type [`LayerState`](@ref) with fields corresponding to the variables declared by the `variables` function for `Soil` and `Heat`. Additionally, output arrays for the time derivatives are provided (here `dH`), as well as the current timestep, layer boundary depths, and variable grids (accessible via `state.t`, `state.z`, and `state.grids` respectively). Note that `state` will also contain other variables declared on this `Soil` layer by other `SubSurfaceProcess`es, allowing for implicit coupling between processes where appropriate. +Note that `state` is of type [`LayerState`](@ref) with fields corresponding to the variables declared by the `variables` function for `Soil` and `Heat`. Additionally, output arrays for the time derivatives are provided (here `dH`), as well as the current timestep, layer boundary depths, and variable grids (accessible via `state.t`, `state.bounds`, and `state.grids` respectively). Note that `state` will also contain other variables declared on this `Soil` layer by other `SubSurfaceProcess`es, allowing for implicit coupling between processes where appropriate. diff --git a/src/Strat/state.jl b/src/Strat/state.jl index 81af7154..d93c2b76 100644 --- a/src/Strat/state.jl +++ b/src/Strat/state.jl @@ -11,10 +11,10 @@ Represents the state of a single component (layer + processes) in the stratigrap struct LayerState{iip,TStates,TGrids,Tt,Tz,varnames} grids::NamedTuple{varnames,TGrids} states::NamedTuple{varnames,TStates} + bounds::NTuple{2,Tz} t::Tt - z::NTuple{2,Tz} - LayerState(grids::NamedTuple{varnames,TG}, states::NamedTuple{varnames,TS}, t::Tt, z::NTuple{2,Tz}, ::Val{iip}=Val{inplace}()) where - {TG,TS,Tt,Tz,varnames,iip} = new{iip,TS,TG,Tt,Tz,varnames}(grids, states, t, z) + LayerState(grids::NamedTuple{varnames,TG}, states::NamedTuple{varnames,TS}, t::Tt, bounds::NTuple{2,Tz}, ::Val{iip}=Val{inplace}()) where + {TG,TS,Tt,Tz,varnames,iip} = new{iip,TS,TG,Tt,Tz,varnames}(grids, states, bounds, t) end Base.getindex(state::LayerState, sym::Symbol) = getproperty(state, sym) function Base.getproperty(state::LayerState, sym::Symbol) @@ -60,7 +60,7 @@ end @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]) + bounds = boundarypairs(zs, vs.grid[end]) return TileState( vs.grid, NamedTuple{tuple($(map(QuoteNode,names)...))}(tuple($(layerstates...))), -- GitLab