Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/makieplotting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand All @@ -193,17 +193,17 @@ 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])
end
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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down