diff --git a/src/makieplotting.jl b/src/makieplotting.jl index 0cb625b..2cc1a07 100644 --- a/src/makieplotting.jl +++ b/src/makieplotting.jl @@ -148,7 +148,7 @@ function Makie.plot!(WF::Wireframe{<:Tuple{<:MakiePlotter{dim}}}) where dim nodal_u_matrix = @lift($(WF[:deformation_field])===:default ? zeros(0,3) : dof_to_node(plotter.dh, $(WF[1][].u); field=Ferrite.find_field(plotter.dh,$(WF[:deformation_field])), process=identity)) gridnodes = @lift($(WF[:deformation_field])===:default ? plotter.gridnodes : plotter.gridnodes .+ ($(WF[:deformation_scale]) .* $(nodal_u_matrix))) lines = @lift begin - dim > 2 ? (lines = Makie.Point3f0[]) : (lines = Makie.Point2f0[]) + dim > 2 ? (lines = Point3f[]) : (lines = Point2f[]) for cell in Ferrite.getcells(plotter.dh.grid) boundaryentities = dim < 3 ? Ferrite.faces(cell) : Ferrite.edges(cell) append!(lines, [$gridnodes[e,:] for boundary in boundaryentities for e in boundary]) @@ -179,10 +179,10 @@ function Makie.plot!(WF::Wireframe{<:Tuple{<:MakiePlotter{dim}}}) where dim Makie.scatter!(WF,gridnodes,markersize=WF[:markersize], color=WF[:color], visible=WF[:visible]) #set up nodelabels nodelabels = @lift $(WF[:nodelabels]) ? ["$i" for i in 1:size($gridnodes,1)] : [""] - nodepositions = @lift $(WF[:nodelabels]) ? [dim < 3 ? Point2f0(row) : Point3f0(row) for row in eachrow($gridnodes)] : (dim < 3 ? [Point2f0((0,0))] : [Point3f0((0,0,0))]) + nodepositions = @lift $(WF[:nodelabels]) ? [dim < 3 ? Point2f(row) : Point3f(row) for row in eachrow($gridnodes)] : (dim < 3 ? [Point2f((0,0))] : [Point3f((0,0,0))]) #set up celllabels celllabels = @lift $(WF[:celllabels]) ? ["$i" for i in 1:Ferrite.getncells(plotter.dh.grid)] : [""] - cellpositions = @lift $(WF[:celllabels]) ? [midpoint(cell,$gridnodes) for cell in Ferrite.getcells(plotter.dh.grid)] : (dim < 3 ? [Point2f0((0,0))] : [Point3f0((0,0,0))]) + cellpositions = @lift $(WF[:celllabels]) ? [midpoint(cell,$gridnodes) for cell in Ferrite.getcells(plotter.dh.grid)] : (dim < 3 ? [Point2f((0,0))] : [Point3f((0,0,0))]) Makie.text!(WF,nodelabels, position=nodepositions, textsize=WF[:textsize], offset=WF[:offset],color=WF[:nodelabelcolor]) Makie.text!(WF,celllabels, position=cellpositions, textsize=WF[:textsize], color=WF[:celllabelcolor], align=(:center,:center)) #plot edges (3D) /faces (2D) of the mesh @@ -193,7 +193,7 @@ end function Makie.plot!(WF::Wireframe{<:Tuple{<:Ferrite.AbstractGrid{dim}}}) where dim grid = WF[1][] coords = [Ferrite.getcoordinates(node)[i] for node in Ferrite.getnodes(grid), i in 1:dim] - dim > 2 ? (lines = Makie.Point3f0[]) : (lines = Makie.Point2f0[]) + dim > 2 ? (lines = Point3f[]) : (lines = Point2f[]) for cell in Ferrite.getcells(grid) boundaryentities = dim < 3 ? Ferrite.faces(cell) : Ferrite.edges(cell) append!(lines, [coords[e,:] for boundary in boundaryentities for e in boundary]) @@ -201,9 +201,9 @@ function Makie.plot!(WF::Wireframe{<:Tuple{<:Ferrite.AbstractGrid{dim}}}) where nodes = @lift($(WF[:plotnodes]) ? coords : zeros(Float32,0,3)) Makie.scatter!(WF,nodes,markersize=WF[:markersize], color=WF[:color]) nodelabels = @lift $(WF[:nodelabels]) ? ["$i" for i in 1:size(coords,1)] : [""] - nodepositions = @lift $(WF[:nodelabels]) ? [dim < 3 ? Point2f0(row) : Point3f0(row) for row in eachrow(coords)] : (dim < 3 ? [Point2f0((0,0))] : [Point3f0((0,0,0))]) + nodepositions = @lift $(WF[:nodelabels]) ? [dim < 3 ? Point2f(row) : Point3f(row) for row in eachrow(coords)] : (dim < 3 ? [Point2f((0,0))] : [Point3f((0,0,0))]) celllabels = @lift $(WF[:celllabels]) ? ["$i" for i in 1:Ferrite.getncells(grid)] : [""] - cellpositions = @lift $(WF[:celllabels]) ? [midpoint(cell,coords) for cell in Ferrite.getcells(grid)] : (dim < 3 ? [Point2f0((0,0))] : [Point3f0((0,0,0))]) + cellpositions = @lift $(WF[:celllabels]) ? [midpoint(cell,coords) for cell in Ferrite.getcells(grid)] : (dim < 3 ? [Point2f((0,0))] : [Point3f((0,0,0))]) #cellsetsplot dh = Ferrite.DofHandler(grid) cellsets = grid.cellsets @@ -256,7 +256,7 @@ function Makie.plot!(SF::Surface{<:Tuple{<:MakiePlotter{2}}}) plotter = SF[1][] field = @lift($(SF[:field])===:default ? 1 : Ferrite.find_field(plotter.dh,$(SF[:field]))) solution = @lift(reshape(transfer_solution(plotter, $(plotter.u); field_idx=$(field), process=$(SF[:process])), num_vertices(plotter))) - points = @lift([Makie.Point3f0(coord[1], coord[2], $(solution)[idx]) for (idx, coord) in enumerate(eachrow(plotter.physical_coords))]) + points = @lift([Point3f(coord[1], coord[2], $(solution)[idx]) for (idx, coord) in enumerate(eachrow(plotter.physical_coords))]) return Makie.mesh!(SF,points, plotter.triangles, color=solution, scale_plot=SF[:scale_plot], shading=SF[:shading], colormap=SF[:colormap]) end @@ -294,11 +294,11 @@ function Makie.plot!(AR::Arrows{<:Tuple{<:MakiePlotter{dim}}}) where dim @assert Ferrite.getfielddim(plotter.dh,field[]) > 1 solution = @lift(transfer_solution(plotter, $(plotter.u); field_idx=$(field), process=identity)) if dim == 2 - ps = [Point2f0(i) for i in eachrow(plotter.physical_coords)] + ps = [Point2f(i) for i in eachrow(plotter.physical_coords)] ns = @lift([Vec2f(i) for i in eachrow($(solution))]) lengths = @lift($(AR[:color])===:default ? $(AR[:process]).($(ns)) : ones(length($(ns)))*$(AR[:color])) elseif dim == 3 - ps = [Point3f0(i) for i in eachrow(plotter.physical_coords)] + ps = [Point3f(i) for i in eachrow(plotter.physical_coords)] ns = @lift([Vec3f(i) for i in eachrow($(solution))]) lengths = @lift($(AR[:color])===:default ? $(AR[:process]).($(ns)) : ones(length($(ns)))*$(AR[:color])) else