Mercurial > repos > public > sbplib_julia
comparison EquidistantGrid.jl @ 85:8d505e9bc715 cell_based_test
Merge with default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 25 Jan 2019 15:26:47 +0100 |
parents | a88222fc01de 2be36b38389d |
children | c0f33eccd527 9d53ecca34f7 |
comparison
equal
deleted
inserted
replaced
83:b795ec7f9ca0 | 85:8d505e9bc715 |
---|---|
75 end | 75 end |
76 | 76 |
77 function pointsalongdim(grid::EquidistantGrid, dim::Integer) | 77 function pointsalongdim(grid::EquidistantGrid, dim::Integer) |
78 @assert dim<=numberOfDimensions(grid) | 78 @assert dim<=numberOfDimensions(grid) |
79 @assert dim>0 | 79 @assert dim>0 |
80 points = range(grid.limits[1][dim],stop=grid.limits[2][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 using PyPlot, PyCall | 83 using PyPlot, PyCall |
84 #pygui(:qt) | |
85 #using Plots; pyplot() | |
86 | 84 |
87 function plotgridfunction(grid::EquidistantGrid, gridfunction) | 85 function plotgridfunction(grid::EquidistantGrid, gridfunction) |
88 if numberOfDimensions(grid) == 1 | 86 if numberOfDimensions(grid) == 1 |
89 plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0) | 87 plot(pointsalongdim(grid,1), gridfunction, linewidth=2.0) |
90 elseif numberOfDimensions(grid) == 2 | 88 elseif numberOfDimensions(grid) == 2 |
91 mx = grid.numberOfPointsPerDim[1]; | 89 mx = grid.numberOfPointsPerDim[1] |
92 my = grid.numberOfPointsPerDim[2]; | 90 my = grid.numberOfPointsPerDim[2] |
93 x = pointsalongdim(grid,1) | 91 X = repeat(pointsalongdim(grid,1),1,my) |
94 X = repeat(x,1,my) | 92 Y = permutedims(repeat(pointsalongdim(grid,2),1,mx)) |
95 y = pointsalongdim(grid,2) | 93 plot_surface(X,Y,reshape(gridfunction,mx,my)); |
96 Y = permutedims(repeat(y,1,mx)) | |
97 plot_surface(X,Y,reshape(gridfunction,mx,my)) | |
98 # fig = figure() | |
99 # ax = fig[:add_subplot](1,1,1, projection = "3d") | |
100 # ax[:plot_surface](X,Y,reshape(gridfunction,mx,my)) | |
101 else | 94 else |
102 error(string("Plot not implemented for dimension ", string(numberOfDimensions(grid)))) | 95 error(string("Plot not implemented for dimension ", string(numberOfDimensions(grid)))) |
103 end | 96 end |
104 savefig("gridfunction") | |
105 end | 97 end |