Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot on rectangular mesh #67

Closed
MaryamMghz opened this issue Jul 22, 2023 · 2 comments
Closed

plot on rectangular mesh #67

MaryamMghz opened this issue Jul 22, 2023 · 2 comments

Comments

@MaryamMghz
Copy link

hi every one. I want to plot the out put in cairomakie and gridap. I use the code triangular mesh easily but when i have changed the mesh to rectangular one it gives me error. can anyone help me?

using CairoMakie, GridapMakie
p0 = p_opt
pf_vec = pf_p0(p0; r, fem_params)
pfh = FEFunction(fem_params.Pf, pf_vec)
pth = (pf -> Threshold(pf; β, η)) ∘ pfh

fig, ax, plt = plot(fem_params.Ω, pth, colormap = :binary)
Colorbar(fig[1,2], plt)
ax.aspect = AxisAspect(6)
ax.title = "Design Shape"
limits!(ax, -6, 6, 0, 2)
save("shapeocmb.png", fig)

error

BoundsError: attempt to access 9600-element Array{RGBA{Float32},1} with eltype ColorTypes.RGBA{Float32} at index [TriangleFace(GeometryBasics.OffsetInteger{-1, UInt32}(0x00002580), GeometryBasics.OffsetInteger{-1, UInt32}(0x00002581), GeometryBasics.OffsetInteger{-1, UInt32}(0x00002582))]

Stacktrace:
  [1] throw_boundserror(A::Vector{ColorTypes.RGBA{Float32}}, I::Tuple{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}})
    @ Base .\abstractarray.jl:703
  [2] checkbounds
    @ .\abstractarray.jl:668 [inlined]
  [3] _getindex
    @ .\multidimensional.jl:874 [inlined]
  [4] getindex
    @ .\abstractarray.jl:1241 [inlined]
  [5] getindex(fi::CairoMakie.FaceIterator{:PerVert, Vector{ColorTypes.RGBA{Float32}}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}, Tuple{ColorTypes.RGBA{Float32}, ColorTypes.RGBA{Float32}, ColorTypes.RGBA{Float32}}}, i::Int64)
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\utils.jl:188
  [6] iterate
    @ .\abstractarray.jl:1167 [inlined]
  [7] _zip_iterate_some
    @ .\iterators.jl:382 [inlined]
  [8] _zip_iterate_some
    @ .\iterators.jl:384 [inlined]
  [9] _zip_iterate_all
    @ .\iterators.jl:374 [inlined]
 [10] iterate
    @ .\iterators.jl:365 [inlined]
 [11] draw_mesh2D(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, per_face_cols::CairoMakie.FaceIterator{:PerVert, Vector{ColorTypes.RGBA{Float32}}, Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}, Tuple{ColorTypes.RGBA{Float32}, ColorTypes.RGBA{Float32}, ColorTypes.RGBA{Float32}}}, space::Symbol, vs::Vector{GeometryBasics.Point{2, Float32}}, fs::Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}, model::StaticArraysCore.SMatrix{4, 4, Float32, 16})
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\primitives.jl:669
 [12] draw_mesh2D(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, plot::Any, mesh::Any)
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\primitives.jl:645
 [13] draw_atomic(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, primitive::Mesh)
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\primitives.jl:616
 [14] draw_plot(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, primitive::Mesh{Tuple{GeometryBasics.Mesh{2, Float32, GeometryBasics.Ngon{2, Float32, 3, GeometryBasics.Point{2, Float32}}, GeometryBasics.SimpleFaceView{2, Float32, 3, GeometryBasics.OffsetInteger{-1, UInt32}, GeometryBasics.Point{2, Float32}, GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}})
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\infrastructure.jl:251
 [15] draw_plot(scene::Scene, screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, primitive::Mesh{Tuple{GridapMakie.PlotGrid{Gridap.Visualization.VisualizationGrid{2, 2}}}}) (repeats 2 times)
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\infrastructure.jl:255
 [16] cairo_draw(screen::CairoMakie.CairoScreen{Cairo.CairoSurfaceBase{UInt32}}, scene::Scene)
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\infrastructure.jl:192
 [17] backend_show(x::CairoMakie.CairoBackend, io::IOContext{IOStream}, #unused#::MIME{Symbol("image/png")}, scene::Scene)
    @ CairoMakie C:\Users\marya\.julia\packages\CairoMakie\keP4X\src\infrastructure.jl:396
 [18] show(io::IOContext{IOStream}, m::MIME{Symbol("image/png")}, figlike::Figure)
    @ Makie C:\Users\marya\.julia\packages\Makie\Ppzqh\src\display.jl:117
 [19] (::Makie.var"#939#940"{Float64, Float64, Figure, DataType})(s::IOStream)
    @ Makie C:\Users\marya\.julia\packages\Makie\Ppzqh\src\display.jl:250
 [20] open(::Makie.var"#939#940"{Float64, Float64, Figure, DataType}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base .\io.jl:384
 [21] open
    @ .\io.jl:381 [inlined]
 [22] #save#938
    @ C:\Users\marya\.julia\packages\Makie\Ppzqh\src\display.jl:244 [inlined]
 [23] save(file::FileIO.File{FileIO.DataFormat{:PNG}, String}, fig::Figure)
    @ Makie C:\Users\marya\.julia\packages\Makie\Ppzqh\src\display.jl:223
 [24] save(filename::String, fig::Figure; args::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\marya\.julia\packages\Makie\Ppzqh\src\display.jl:220
 [25] save(filename::String, fig::Figure)
    @ Makie C:\Users\marya\.julia\packages\Makie\Ppzqh\src\display.jl:217
 [26] top-level scope
    @ In[27]:12

thanks

@ericneiva
Copy link
Member

Hello, @MaryamMghz, visualization in rectangular meshes is, as far as I know, not supported, please see #33.

I am closing this issue, since it is a duplicate of #33.

If you have any other questions, please do not hesitate to comment in #33 :)

Also, for further enquiries, please remember to provide an example that we can easily run as a script such that we can help you. We cannot run the script you provided in your comment, we miss the instantiation of some local variables (e.g. p_opt).

@Kevin-Mattheus-Moerman
Copy link

@ericneiva @MaryamMghz if this is still of interest, I've done quadrilateral visualisations here: https://github.com/Kevin-Mattheus-Moerman/JuliaAdventures/blob/main/gridap_makie_visualisation_01.jl. It requires Makie's flexible poly function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants