diff --git a/src/Geometry/Polytopal.jl b/src/Geometry/Polytopal.jl index 2e260e9ef..20a908e00 100644 --- a/src/Geometry/Polytopal.jl +++ b/src/Geometry/Polytopal.jl @@ -138,19 +138,18 @@ function compute_face_own_nodes(model::PolytopalDiscreteModel,d::Integer) end end -function Grid(::Type{ReferenceFE{1}},model::PolytopalDiscreteModel{Dc}) where {Dc} - node_coordinates = get_node_coordinates(model) - face_to_nodes = Table(get_face_nodes(model,1)) - reffes = [LagrangianRefFE(Float64,SEGMENT,1)] - face_to_ftype = fill(Int8(1),num_faces(get_grid_topology(model),1)) - UnstructuredGrid(node_coordinates, face_to_nodes, reffes, face_to_ftype) -end - function Grid(::Type{ReferenceFE{Df}},model::PolytopalDiscreteModel{Dc}) where {Df,Dc} node_coordinates = get_node_coordinates(model) face_to_nodes = Table(get_face_nodes(model,Df)) - face_to_polytopes = get_reffaces(Polytope{Df},get_grid_topology(model)) - PolytopalGrid(node_coordinates, face_to_nodes, face_to_polytopes) + if iszero(Df) || isone(Df) + reffes = [ifelse(iszero(Df), VERTEX1, SEG2)] + face_to_ftype = fill(Int8(1),num_faces(get_grid_topology(model),Df)) + grid = UnstructuredGrid(node_coordinates, face_to_nodes, reffes, face_to_ftype) + else + face_to_polytopes = get_reffaces(Polytope{Df},get_grid_topology(model)) + grid = PolytopalGrid(node_coordinates, face_to_nodes, face_to_polytopes) + end + return grid end function Grid(::Type{ReferenceFE{Dc}},model::PolytopalDiscreteModel{Dc}) where {Dc} diff --git a/test/GeometryTests/PolytopalGridsTests.jl b/test/GeometryTests/PolytopalGridsTests.jl index ad3321728..b25b3bb68 100644 --- a/test/GeometryTests/PolytopalGridsTests.jl +++ b/test/GeometryTests/PolytopalGridsTests.jl @@ -7,12 +7,26 @@ using FillArrays using Meshes: viz using CairoMakie +# TODO: Add support for GridapMakie, which is what Meshes.jl uses for plotting underneath +# using GridapMakie +# using Makie +# using GridapMakie: PlotGridMesh, PlotGrid +# Makie.plottype(::Grid) = PlotGridMesh +# function Makie.convert_arguments(::Type{PlotGridMesh}, grid::Grid) +# (PlotGrid(grid), ) +# end +# function Makie.convert_arguments(t::Type{<:Union{Makie.Wireframe, Makie.Scatter}}, grid::Grid) +# Makie.convert_arguments(t, PlotGrid(grid)) +# end +# Makie.args_preferred_axis(pg::PlotGrid)= num_point_dims(pg.grid)<=2 ? Makie.Axis : Makie.LScene + model = CartesianDiscreteModel((0,1,0,1),(4,4)) pmodel = Geometry.PolytopalDiscreteModel(model) vmodel = Geometry.voronoi(simplexify(model)) polys = get_polytopes(vmodel) -# viz(vmodel;color=1:num_cells(vmodel),showpoints=true,showsegments=true) + +viz(vmodel;color=1:num_cells(vmodel),showpoints=true,showsegments=true) Ω = Triangulation(vmodel) Γ = Boundary(vmodel)