1
- @data Clocks begin
1
+ abstract type AbstractClock end
2
+
3
+ @data Clocks<: AbstractClock begin
2
4
ContinuousClock
3
5
struct PeriodicClock
4
6
dt:: Union{Nothing, Float64, Rational{Int}}
@@ -63,6 +65,7 @@ issolverstepclock(::Any) = false
63
65
iscontinuous (:: Any ) = false
64
66
is_discrete_time_domain (:: Any ) = false
65
67
68
+ # public
66
69
function first_clock_tick_time (c, t0)
67
70
@match c begin
68
71
PeriodicClock (dt) => ceil (t0 / dt) * dt
@@ -71,13 +74,51 @@ function first_clock_tick_time(c, t0)
71
74
end
72
75
end
73
76
74
- struct IndexedClock{I}
75
- clock:: TimeDomain
77
+ # public
78
+ """
79
+ $(TYPEDEF)
80
+
81
+ A struct representing the operation of indexing a clock to obtain a subset of the time
82
+ points at which it ticked. The actual list of time points depends on the time interval
83
+ for which the clock was running, and can be obtained via `canonicalize_indexed_clock`
84
+ by providing a timeseries solution object.
85
+
86
+ For example, `IndexedClock(PeriodicClock(0.1), 3)` refers to the third time that
87
+ `PeriodicClock(0.1)` ticked. If the simulation started at `t = 0`, then this would be
88
+ `t = 0.2`. Similarly, `IndexedClock(PeriodicClock(0.1), [1, 5])` refers to `t = 0.0`
89
+ and `t = 0.4` in this context.
90
+
91
+ # Fields
92
+
93
+ $(TYPEDFIELDS)
94
+ """
95
+ struct IndexedClock{C <: AbstractClock , I}
96
+ """
97
+ The clock being indexed. A subtype of `SciMLBase.AbstractClock`
98
+ """
99
+ clock:: C
100
+ """
101
+ The subset of indexes being referred to. This can be an integer, an array of integers,
102
+ a range or `Colon()` to refer to all the points that the clock ticked.
103
+ """
76
104
idx:: I
77
105
end
78
106
79
- Base. getindex (c:: TimeDomain , idx) = IndexedClock (c, idx)
107
+ # public
108
+ """
109
+ $(TYPEDSIGNATURES)
110
+
111
+ Return a `SciMLBase.IndexedClock` representing the subset of the time points that the clock
112
+ ticked indicated by `idx`.
113
+ """
114
+ Base. getindex (c:: AbstractClock , idx) = IndexedClock (c, idx)
80
115
116
+ # public
117
+ """
118
+ $(TYPEDSIGNATURES)
119
+
120
+ Return the time points in the interval
121
+ """
81
122
function canonicalize_indexed_clock (ic:: IndexedClock , sol:: AbstractTimeseriesSolution )
82
123
c = ic. clock
83
124
0 commit comments