Skip to content

Commit 85219f9

Browse files
authored
Add area and flowgrow functionality (#54)
1 parent b7a2f5e commit 85219f9

File tree

15 files changed

+331
-113
lines changed

15 files changed

+331
-113
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "CoherentStructures"
22
uuid = "0c1513b4-3a13-56f1-9cd2-8312eaec88c4"
3-
version = "0.3.4"
3+
version = "0.3.5"
44

55
[deps]
66
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
@@ -31,15 +31,15 @@ Arpack = "0.3, 0.4"
3131
AxisArrays = "0.3.3, 0.4"
3232
ColorTypes = "0.10"
3333
DiffEqBase = "6"
34-
Distances = "0.9"
34+
Distances = "0.9, 0.10"
3535
GeometricalPredicates = "0.3, 0.4"
36-
Interpolations = "0.11, 0.12"
36+
Interpolations = "0.11, 0.12, 0.13"
3737
IterativeSolvers = "0.7, 0.8"
3838
LinearMaps = "2"
3939
NearestNeighbors = "0.4.4"
4040
OrdinaryDiffEq = "5.18"
4141
ProgressMeter = "1"
42-
RecipesBase = "0.7, 0.8, 1.0"
42+
RecipesBase = "0.7, 0.8, 1"
4343
StaticArrays = "0.10, 0.11, 0.12"
4444
Tensors = "1.0.1"
4545
VoronoiDelaunay = "0.4"

docs/src/Laplace.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ CurrentModule = CoherentStructures
77
The LCS approaches implemented and described in this section are strongly influenced
88
by ideas developed in the spectral clustering/diffusion maps communities. The
99
general references include:
10-
* [Shi & Malik, Normalized cuts and image segmentation, 2000](https://doi.org/10.1109/34.868688)
11-
* [Coifman & Lafon, Diffusion maps, 2006](https://doi.org/10.1016/j.acha.2006.04.006)
12-
* [Marshall & Hirn, Time coupled diffusion maps, 2018](https://doi.org/10.1016/j.acha.2017.11.003)
10+
11+
* [Shi & Malik, Normalized cuts and image segmentation, 2000](https://doi.org/10.1109/34.868688)
12+
* [Coifman & Lafon, Diffusion maps, 2006](https://doi.org/10.1016/j.acha.2006.04.006)
13+
* [Marshall & Hirn, Time coupled diffusion maps, 2018](https://doi.org/10.1016/j.acha.2017.11.003)
14+
1315
In the LCS context, these ideas have been adopted in the following works:
14-
* somewhat related [Froyland & Padberg-Gehle, 2015](https://doi.org/10.1063/1.4926372)
15-
* [Hadjighasem et al., 2016](https://doi.org/10.1103/PhysRevE.93.063107)
16-
* [Banisch & Koltai, 2017](https://doi.org/10.1063/1.4971788)
17-
* [Rypina et al., 2017](https://doi.org/10.5194/npg-24-189-2017)/[Padberg-Gehle & Schneide, 2018](https://doi.org/10.5194/npg-24-661-2017)
16+
17+
* somewhat related [Froyland & Padberg-Gehle, 2015](https://doi.org/10.1063/1.4926372)
18+
* [Hadjighasem et al., 2016](https://doi.org/10.1103/PhysRevE.93.063107)
19+
* [Banisch & Koltai, 2017](https://doi.org/10.1063/1.4971788)
20+
* [Rypina et al., 2017](https://doi.org/10.5194/npg-24-189-2017)/[Padberg-Gehle & Schneide, 2018](https://doi.org/10.5194/npg-24-661-2017)
1821

1922
For demonstrations on example cases, please consult the page on
2023
[Working with trajectories](@ref).
@@ -25,6 +28,7 @@ For demonstrations on example cases, please consult the page on
2528

2629
Three commonly used sparsification methods are implemented for use with various
2730
graph Laplacian methods.
31+
2832
```@docs
2933
KNN
3034
MutualKNN
@@ -38,16 +42,21 @@ Other sparsification methods can be implemented by defining a
3842

3943
Since the Euclidean heat kernel is ubiquitous in diffusion maps-based computations,
4044
we provide it for convenience.
45+
4146
```@docs
4247
gaussian
4348
gaussiancutoff
4449
```
50+
4551
To compute a sparse distance matrix (or adjacency matrix, depending on the
4652
[sparsification method](@ref sparsification_methods)), use [`spdist`](@ref).
53+
4754
```@docs
4855
spdist
4956
```
57+
5058
The main high-level functions for the above-listed methods are the following.
59+
5160
```@docs
5261
sparse_diff_op_family
5362
sparse_diff_op
@@ -56,9 +65,11 @@ sparse_diff_op
5665
### Normalization functions
5766

5867
In the diffusion maps framework, there are two commonly used normalization steps:
68+
5969
1. kernel-density estimate normalization ([`kde_normalize!`](@ref)), and
6070
2. row normalization ([`row_normalize!`](@ref)), to obtain a diffusion/Markov
6171
operator (w.r.t. right- and left-action, respectively).
72+
6273
```@docs
6374
kde_normalize!
6475
row_normalize!

docs/src/basics.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@
33
```@meta
44
CurrentModule = CoherentStructures
55
```
6+
67
## Definition of vector fields
78

89
`CoherentStructures.jl` is set up for handling two- and three-dimensional dynamical
910
systems only. For such low-dimensional flows it is advantageous (for top
1011
performance) to obey the following syntax:
11-
```
12+
13+
```julia
1214
function vectorfield2d(u, p, t)
1315
du1 = ... # equation for $\dot{x}$
1416
du2 = ... # equation for $\dot{y}$
1517
return StaticArrays.SVector{2}(du1, du2)
1618
end
1719
```
20+
1821
and correspondingly for three-dimensional ODEs:
19-
```
22+
23+
```julia
2024
function vectorfield3d(u, p, t)
2125
du1 = ... # equation for $\dot{x}$
2226
du2 = ... # equation for $\dot{y}$
2327
du3 = ... # equation for $\dot{z}$
2428
return StaticArrays.SVector{3}(du1, du2, du3)
2529
end
2630
```
31+
2732
In a companion package [`StreamMacros.jl`](https://github.com/CoherentStructures/StreamMacros.jl), there are convenience macros to define two-dimensional velocity
2833
and vorticity fields from stream functions.
2934

@@ -70,25 +75,31 @@ tensor_invariants
7075
For computing distances w.r.t. standard metrics, there exists the excellent
7176
[`Distances.jl`](https://github.com/JuliaStats/Distances.jl) package. For example,
7277
the Euclidean distance between two points is computed by any of the last two lines:
73-
```
78+
79+
```julia
7480
using Distances
7581
x, y = rand(3), rand(3)
7682
Euclidean()(x, y)
7783
euclidean(x, y)
7884
```
85+
7986
Other metrics of potential interest include `Haversine(r)`, the geodesic
8087
distance of two points on the sphere with radius `r`, and `PeriodicEuclidean(L)`,
8188
the distance on a torus or cylinder. Here, `L` is a vector containing the period
8289
of each dimension, `Inf` for non-periodic dimensions.
90+
8391
```@docs
8492
Distances.Euclidean
8593
Distances.Haversine
8694
Distances.PeriodicEuclidean
8795
```
96+
8897
In `CoherentStructures.jl`, there is one more metric type implemented:
98+
8999
```@docs
90100
STmetric
91101
```
102+
92103
This is a spatiotemporal metric that operates on trajectories in the format of
93104
vectors of static vectors, i.e., `Vector{<:SVector}`. Each vector element
94105
corresponds to the state vector. The `STmetric` then computes the

docs/src/elliptic.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ CurrentModule = CoherentStructures
77
## Background
88

99
The following functions implement an LCS methodology developed in the following papers:
10-
* [Haller & Beron-Vera, 2012](https://doi.org/10.1016/j.physd.2012.06.012)
11-
* [Haller & Beron-Vera, 2013](https://doi.org/10.1017/jfm.2013.391)
12-
* [Karrasch, Huhn, and Haller, 2015](https://doi.org/10.1098/rspa.2014.0639)
10+
11+
* [Haller & Beron-Vera, 2012](https://doi.org/10.1016/j.physd.2012.06.012)
12+
* [Haller & Beron-Vera, 2013](https://doi.org/10.1017/jfm.2013.391)
13+
* [Karrasch, Huhn, and Haller, 2015](https://doi.org/10.1098/rspa.2014.0639)
14+
1315
Our implementation here follows conceptually [Karrasch, Huhn, and Haller, 2015](https://doi.org/10.1098/rspa.2014.0639),
1416
and is described in detail in the preprint TBD.
1517
Depending on the indefinite metric tensor field used, the functions below yield
1618
the following types of coherent structures:
17-
* black-hole/Lagrangian coherent vortices ([Haller & Beron-Vera, 2012](https://doi.org/10.1017/jfm.2013.391))
18-
* elliptic objective Eulerian coherent structures (OECSs) ([Serra & Haller, 2016](https://doi.org/10.1063/1.4951720))
19-
* material diffusive transport barriers ([Haller, Karrasch, and Kogelbauer, 2018](https://doi.org/10.1073/pnas.1720177115))
19+
20+
* black-hole/Lagrangian coherent vortices ([Haller & Beron-Vera, 2012](https://doi.org/10.1017/jfm.2013.391))
21+
* elliptic objective Eulerian coherent structures (OECSs) ([Serra & Haller, 2016](https://doi.org/10.1063/1.4951720))
22+
* material diffusive transport barriers ([Haller, Karrasch, and Kogelbauer, 2018](https://doi.org/10.1073/pnas.1720177115))
23+
2024
The general procedure is the following. Assume $T$ is the symmetric tensor field
2125
of interest, say, (i) the Cauchy-Green strain tensor field $C$, (ii) the
2226
rate-of-strain tensor field $S$, or (iii) the averaged diffusion-weighted
@@ -38,26 +42,29 @@ rather computes the index for each grid cell and then combines nearby
3842
singularities, i.e., adds non-vanishing indices of nearby grid cells.
3943

4044
In summary, the implementation consists of the following steps:
45+
4146
1. compute the index for each grid cell and combine nearby singular grid cells
4247
to "singularity candidates";
43-
3. look for elliptic singularity candidates (and potentially isolated wedge
48+
2. look for elliptic singularity candidates (and potentially isolated wedge
4449
pairs);
45-
4. place an eastwards oriented Poincaré section at the pair center;
46-
5. for each point on the discretized Poincaré section, scan through the given
50+
3. place an eastwards oriented Poincaré section at the pair center;
51+
4. for each point on the discretized Poincaré section, scan through the given
4752
parameter interval such that the corresponding η-orbit closes at that point;
48-
6. if desired: for each Poincaré section, take the outermost closed orbit as
53+
5. if desired: for each Poincaré section, take the outermost closed orbit as
4954
the coherent vortex barrier (if there exist any).
5055

5156
## Function documentation
5257

5358
### The meta-functions `ellipticLCS` and `constrainedLCS`
5459

5560
The fully automated high-level functions are:
61+
5662
```@docs
5763
ellipticLCS
5864
constrainedLCS
5965
materialbarriers
6066
```
67+
6168
One of their arguments is a list of parameters used in the LCS detection. This
6269
list is combined in a data type called `LCSParameters`. The output is a list of `EllipticBarrier`s and a list of `Singularity`s.
6370
There is an option to retrieve all closed barriers (`outermost=false`), in
@@ -71,12 +78,15 @@ closed orbit computation, cf. [Closed orbit detection](@ref).
7178
### Specific types
7279

7380
These are the specifically introduced types for elliptic LCS computations.
81+
7482
```@docs
7583
LCSParameters
7684
EllipticBarrier
7785
EllipticVortex
7886
```
87+
7988
Another one is `Singularity`, which comes along with some convenience functions.
89+
8090
```@docs
8191
Singularity
8292
getcoords
@@ -88,29 +98,37 @@ getindices
8898
This is performed by [`singularity_detection`](@ref) for line fields
8999
(such as eigenvector fields of symmetric positive-definite tensor fields) and by
90100
[`critical_point_detection`](@ref) for classic vector fields.
101+
91102
```@docs
92103
singularity_detection
93104
critical_point_detection
94105
```
106+
95107
This function takes three steps. The first two are:
108+
96109
```@docs
97110
compute_singularities
98111
combine_singularities
99112
```
113+
100114
The third step is a postprocessing step, in which detected singularities are
101115
merged according to different heuristics.
116+
102117
```@docs
103118
combine_20
104119
combine_20_aggressive
105120
combine_31
106121
```
122+
107123
The function [`compute_singularities`](@ref) requires one of two signed distance
108124
functions for angles. These are [`s1dist`](@ref) for vector fields, and
109125
[`p1dist`](@ref) for line fields.
126+
110127
```@docs
111128
s1dist
112129
p1dist
113130
```
131+
114132
From all virtual/merged singularities those with a suitable index are selected.
115133
Around each elliptic singularity the tensor field is localized and passed on for
116134
closed orbit detection.
@@ -121,3 +139,16 @@ closed orbit detection.
121139
compute_returning_orbit
122140
compute_closed_orbits
123141
```
142+
143+
### Convenience functions
144+
145+
First of all, [`Singularity`](@ref), [`EllipticBarrier`](@ref) and [`EllipticVortex`](@ref)
146+
objects can be passed as initial conditions to the [`flow`](@ref) function, which returns
147+
a (time-resolved) vector of corresponding objects. Moreover, we have advection with
148+
adaptive point insertion (known in oceanography as "Dritschel advection") and an function
149+
to compute the area of [`EllipticBarrier`](@ref) and [`EllipticVortex`](@ref) objects.
150+
151+
```@docs
152+
flowgrow
153+
area
154+
```

0 commit comments

Comments
 (0)