Mercurial > repos > public > sbplib_julia
comparison EquidistantGrid.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 | 8d505e9bc715 |
children | 93df72e2b135 |
comparison
equal
deleted
inserted
replaced
85:8d505e9bc715 | 91:c0f33eccd527 |
---|---|
54 # and lastely the third (if applicable) | 54 # and lastely the third (if applicable) |
55 # | 55 # |
56 # @Input: grid - an EquidistantGrid | 56 # @Input: grid - an EquidistantGrid |
57 # @Return: points - the points of the grid. | 57 # @Return: points - the points of the grid. |
58 function points(grid::EquidistantGrid) | 58 function points(grid::EquidistantGrid) |
59 # Signed grid spacing | |
59 dx̄ = (grid.limit_upper.-grid.limit_lower)./(grid.numberOfPointsPerDim.-1) | 60 dx̄ = (grid.limit_upper.-grid.limit_lower)./(grid.numberOfPointsPerDim.-1) |
60 | |
61 points = Vector{typeof(dx̄)}(undef, numberOfPoints(grid)) | |
62 # Compute the points based on their Cartesian indices and the signed | 61 # Compute the points based on their Cartesian indices and the signed |
63 # grid spacings | 62 # grid spacings |
63 points = Vector{typeof(dx̄)}(undef, numberOfPoints(grid)) | |
64 cartesianIndices = CartesianIndices(grid.numberOfPointsPerDim) | 64 cartesianIndices = CartesianIndices(grid.numberOfPointsPerDim) |
65 for i ∈ 1:numberOfPoints(grid) | 65 for i ∈ 1:numberOfPoints(grid) |
66 ci = Tuple(cartesianIndices[i]) .-1 | 66 ci = Tuple(cartesianIndices[i]) .-1 |
67 points[i] = grid.limit_lower .+ dx̄.*ci | 67 points[i] = grid.limit_lower .+ dx̄.*ci |
68 end | 68 end |
78 @assert dim<=numberOfDimensions(grid) | 78 @assert dim<=numberOfDimensions(grid) |
79 @assert dim>0 | 79 @assert dim>0 |
80 points = range(grid.limit_lower[dim],stop=grid.limit_lower[dim],length=grid.numberOfPointsPerDim[dim]) | 80 points = range(grid.limit_lower[dim],stop=grid.limit_lower[dim],length=grid.numberOfPointsPerDim[dim]) |
81 end | 81 end |
82 | 82 |
83 # TODO: Move to own plotting module. | |
83 using PyPlot, PyCall | 84 using PyPlot, PyCall |
84 | 85 |
85 function plotgridfunction(grid::EquidistantGrid, gridfunction) | 86 function plotgridfunction(grid::EquidistantGrid, gridfunction) |
86 if numberOfDimensions(grid) == 1 | 87 if numberOfDimensions(grid) == 1 |
87 plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0) | 88 plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0) |