Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Jan 6, 2025
1 parent d695e26 commit e5e4728
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/Geometry/Polytopal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
16 changes: 15 additions & 1 deletion test/GeometryTests/PolytopalGridsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e5e4728

Please sign in to comment.