gridap / GridapMakie.jl

Makie plotting recipes for Gridap
MIT License
33 stars 8 forks source link

GSOC-Task #1: Visualizing 2D and 3D Grid objects #16

Closed fverdugo closed 3 years ago

fverdugo commented 3 years ago

cc @paurierap @ericneiva @amartinhuertas

This task is to be further defined in the kick-off meeting

Intro

Being able to visualize instances of Gridap.Geometry.Grid is the cornerstone to visualize other Gridap objects. So, it is a good place to start.

Given a 2D Grid object (3D and 1D will be covered in subsequent tasks), we typically want the following kind of visualizations (now they are done with paraview). Here, I am using this code to generate a simple grid of triangles:

using Gridap
using Gridap.ReferenceFEs
using Gridap.Geometry
using Gridap.Visualization

model = CartesianDiscreteModel((0.,1.5,0.,1.),(15,10)) |> simplexify
grid = get_grid(model)
celldata = rand(num_cells(grid))
nodaldata = rand(num_nodes(grid))
write_vtk_file(grid,"grid",celldata=["d1"=>celldata],nodaldata=["d2"=>nodaldata])
fig1 fig2 fig3
surface surface and edges prescribe edge width
fig4 fig7 fig5
set surface and edge color set surface color via a cell field set surface color via a nodal field
fig6 fig8
display colorbar change colormap

TODO (outdated, see below for the updated steps)

Notes

Most of the functionality we need is provided by the Makie function mesh, but it is likely that this does not cover all cases.

fverdugo commented 3 years ago

Steps:

amartinhuertas commented 3 years ago

Some relevant links/info interchanged during 07/06/21 meeting:

Eric Neiva17:41

fverdugo commented 3 years ago

@paurierap perhaps it is better to use convert_single_argument instead of convert_arguments.

fverdugo commented 3 years ago

Some updated steps after the meeting on 2021-06-11:

paurierap commented 3 years ago

Before the meeting on 21/06/2021, the conversions implemented from Gridap types to Makie types allow us to plot:

fig1 fig2 fig3
2D surface + set color (extended to quads too) 2D edges + set color and linewidth (only for simplices) 2D surface color via a nodal field + choice of colormap (and colorbar)
fig4 fig5 fig6
3D surface + set color (extended to quads too) 3D edges + set color and linewidth (only for simplices) 3D surface color via a nodal field + choice of colormap (and colorbar)

So far, we still need to address the drawing of quadrilateral edges in either dimension as well as the plotting of a cell field.

fverdugo commented 3 years ago

Code discussed in meeting 2021-06-21 for visualizing 3D meshes. (i.e., convert volume mesh to boundary mesh of triangles)

using Gridap
using Gridap.Geometry
using Gridap.Visualization

domain = (0,1,0,1,0,1)
cells = (2,2,2)
grid = CartesianGrid(domain,cells)

write_vtk_file(grid,"grid")

topo = GridTopology(grid)

labels = FaceLabeling(topo)

model = DiscreteModel(grid,topo,labels)

face_grid = Grid(ReferenceFE{2},model)

face_to_mask = get_face_mask(labels,"boundary",2)

@show num_cells(face_grid)
@show length(face_to_mask)

write_vtk_file(face_grid,"face_grid",celldata=["mask"=>collect(Int,face_to_mask)])

boundary_grid = GridPortion(face_grid,face_to_mask) |> simplexify

write_vtk_file(boundary_grid,"boundary_grid")
fverdugo commented 3 years ago

TODO steps

fverdugo commented 3 years ago

closed via #18