Mercurial > repos > public > sbplib_julia
comparison grid.jl @ 41:3d8bfb695497
Fix plotting issues in 2d
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 10 Jan 2019 16:48:49 +0100 |
parents | 5ec57ec148ef |
children | 50c6c252d954 |
comparison
equal
deleted
inserted
replaced
39:5ec57ec148ef | 41:3d8bfb695497 |
---|---|
1 module grid | 1 module grid |
2 using PyPlot | 2 using Plots |
3 pyplot() | |
3 | 4 |
4 abstract type Grid end | 5 abstract type Grid end |
5 | 6 |
6 function numberOfDimensions(grid::Grid) | 7 function numberOfDimensions(grid::Grid) |
7 error("Not implemented for abstact type Grid") | 8 error("Not implemented for abstact type Grid") |
121 elseif numberOfDimensions(grid) == 2 | 122 elseif numberOfDimensions(grid) == 2 |
122 x = pointsalongdim(grid,1) | 123 x = pointsalongdim(grid,1) |
123 X = repeat(x,1,grid.numberOfPointsPerDim[2]) | 124 X = repeat(x,1,grid.numberOfPointsPerDim[2]) |
124 y = pointsalongdim(grid,2) | 125 y = pointsalongdim(grid,2) |
125 Y = repeat(y,1,grid.numberOfPointsPerDim[1])' | 126 Y = repeat(y,1,grid.numberOfPointsPerDim[1])' |
127 surface(X,Y,reshape(gridfunction)) | |
126 elseif numberOfDimensions(grid) == 3 | 128 elseif numberOfDimensions(grid) == 3 |
127 x = pointsalongdim(grid,1) | 129 x = pointsalongdim(grid,1) |
128 X = repeat(x,1,grid.numberOfPointsPerDim[2]) | 130 X = repeat(x,1,grid.numberOfPointsPerDim[2]) |
129 y = pointsalongdim(grid,2) | 131 y = pointsalongdim(grid,2) |
130 Y = repeat(y,1,grid.numberOfPointsPerDim[1])' | 132 Y = repeat(y,1,grid.numberOfPointsPerDim[1])' |
133 y = pointsalongdim(grid,2) | |
134 Y = repeat(y,1,grid.numberOfPointsPerDim[1])' | |
135 surface(X,Y,gridfunction) | |
131 else | 136 else |
132 error(string("Plot not implemented for dimension =", string(dim))) | 137 error(string("Plot not implemented for dimension ", string(dim))) |
133 end | 138 end |
134 end | 139 end |
135 | 140 |
136 # Evaluate function f on the grid g | 141 # Evaluate function f on the grid g |
137 function evalOn(g::Grid, f::Function) | 142 function evalOn(g::Grid, f::Function) |