Mercurial > repos > public > sbplib_julia
comparison grid.jl @ 14:b11b67c02d1a
Started implementing grids
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 17 Dec 2018 14:45:10 +0100 |
parents | b714e341a0ba |
children | 3d032081832d |
comparison
equal
deleted
inserted
replaced
0:b714e341a0ba | 14:b11b67c02d1a |
---|---|
1 module grid | |
2 | |
3 abstract type Grid end | |
4 | |
5 function numberOfDimensions(grid::Grid) | |
6 error("Not yet implemented"); | |
7 end | |
8 | |
9 function numberOfPoints(grid::Grid) | |
10 error("Not yet implemented"); | |
11 end | |
12 | |
13 function points(grid::Grid) | |
14 error("Not yet implemented"); | |
15 end | |
16 | |
17 abstract type BoundaryId end | |
18 | |
19 # Move to seperate file. | |
20 struct EquidistantGrid <: Grid | |
21 numberOfDimensions::UInt; | |
22 numberOfPoints::Vector(UInt); | |
23 limits::Vector{Pair{Real, Real}}; | |
24 function EquidistantGrid(nDims, nPoints, lims) | |
25 @assert nDims == size(nPoints); | |
26 return new(nDims, nPoints, lims); | |
27 end | |
28 end | |
29 | |
30 # Getter functions for public properties? | |
31 function numberOfDimensions(grid::EquidistantGrid) | |
32 return grid.numberOfDimensions; | |
33 end | |
34 | |
35 function numberOfPoints(grid::EquidistantGrid) | |
36 return grid.numberOfPoints; | |
37 end | |
38 | |
39 | |
40 function points(grid::EquidistantGrid) | |
41 points::Array{Real,3}(undef, numberOfPoints(grid)); | |
42 # for i ∈ eachindex(points) | |
43 # points(i) = i/ | |
44 # end | |
45 return points; | |
46 end | |
47 | |
48 function limitsForDimension(grid::EquidistantGrid, dim::UInt) | |
49 @assert dim <= 3 | |
50 @assert dim >= 1 | |
51 return grid.limits(dim); | |
52 end |