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

Update visualization, part 1 #1071

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions src/visualization/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ struct PlotData2DTriangulated{DataType, NodeType, FaceNodeType, FaceDataType, Va
face_data::FaceDataType
variable_names::VariableNames
end

struct PlotData3DTriangulated{DataType, NodeType, FaceNodeType, FaceDataType, VariableNames, PlottingTriangulation}
x::NodeType # physical nodal coordinates, size (num_plotting_nodes x num_elements)
y::NodeType
z::NodeType
data::DataType
t::PlottingTriangulation
x_face::FaceNodeType
y_face::FaceNodeType
z_face::FaceNodeType
face_data::FaceDataType
variable_names::VariableNames
end

# Show only a truncated output for convenience (the full data does not make sense)
function Base.show(io::IO, pd::PlotData2DTriangulated)
Expand Down
39 changes: 39 additions & 0 deletions src/visualization/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,45 @@ function global_plotting_triangulation_makie(pds::PlotDataSeries{<:PlotData2DTri
plotting_mesh = merge([trimesh...]) # merge meshes on each element into one large mesh
return plotting_mesh
end

# 3D isosurface case for global_plotting_triangulation_makie function
function global_plotting_triangulation_makie(plot_data, level)

xp = plot_data.x
yp = plot_data.y
zp = plot_data.z
func = plot_data.data
connectivity = plot_data.t

plotting_coordinates = zeros(3, size(xp, 1))
num_elements = size(xp, 2)
list_of_meshes = Vector{GeometryBasics.Mesh{3, Float32}}(undef, num_elements)
sk = 1
planes = []

for e in 1:size(func, 2) # for each column
plotting_coordinates[1, :] .= xp[:, e]
plotting_coordinates[2, :] .= yp[:, e]
plotting_coordinates[3, :] .= zp[:, e]

pts, trngls, fvals = GridVisualize.marching_tetrahedra(plotting_coordinates,
connectivity,
func[:, e], planes, level)

#output mesh that encompasses isosurface
if length(pts) > 0
makie_triangles = Makie.to_triangles(hcat((getindex.(trngls,i) for i in 1:3)...))
iso_mesh = GeometryBasics.normal_mesh(Makie.to_vertices(pts), makie_triangles)

# add newly found mesh to list of meshes
list_of_meshes[sk] = iso_mesh
sk += 1
end
end

plotting_mesh = merge(list_of_meshes[1:sk-1])
return plotting_mesh
end

# Returns a list of `Makie.Point`s which can be used to plot the mesh, or a solution "wireframe"
# (e.g., a plot of the mesh lines but with the z-coordinate equal to the value of the solution).
Expand Down