annotate StencilIndex.jl @ 91:c0f33eccd527 cell_based_test

Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 29 Jan 2019 14:32:28 +0100
parents
children 93df72e2b135
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
1 abstract type StencilIndex end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
2
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
3 function Base.getindex(si::StencilIndex, i::Int)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
4 return si.index[i]
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
5 end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
6
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
7 struct LowerClosureIndex <: StencilIndex
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
8 index::CartesianIndex
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
9 end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
10
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
11 struct UpperClosureIndex <: StencilIndex
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
12 index::CartesianIndex
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
13 end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
14
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
15 struct InteriorIndex <: StencilIndex
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
16 index::CartesianIndex
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
17 end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
19 # TODO: This should take a Stencil or DiffOp so that we can extract all the
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
20 # indices in the closures.
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
21 # TODO: Where to place this function?
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
22 function stencilindices(grid::Grid.EquidistantGrid)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
23 lowerclosure = Vector{LowerClosureIndex}(undef, 0)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
24 upperclosure = Vector{UpperClosureIndex}(undef, 0)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
25 interior = Vector{InteriorIndex}(undef, 0)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
26 # TODO: Fix such that the indices of the entire closure width is included.
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
27 islower = x -> (x == 1)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
28 isupper = x -> (x in grid.numberOfPointsPerDim)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
29 ci = CartesianIndices(grid.numberOfPointsPerDim)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
30 for i ∈ ci
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
31 I = Tuple(i)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
32 if any(islower, I)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
33 push!(lowerclosure, LowerClosureIndex(i))
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
34 # TODO: Corner points should be in both Lower and Upper?
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
35 # Should they have a separate type?
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
36 elseif any(isupper, I)
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
37 push!(upperclosure, UpperClosureIndex(i))
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
38 else
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
39 push!(interior, InteriorIndex(i))
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
40 end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
41 end
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
42 return lowerclosure, upperclosure, interior
c0f33eccd527 Create types StencilIndex, LowerClosureIndex, UpperClosureIndex and InteriorIndex. First attempt at seperating out interior and closure indices from. Not fully implemented.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
43 end