Skip to content

Commit

Permalink
Add 'convert' for 'GeometrySet' (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliascarv authored Feb 19, 2024
1 parent 6a50bfc commit 7e61398
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/domains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,15 @@ end
include("sets.jl")
include("mesh.jl")
include("trajectories.jl")

# ------------
# CONVERSIONS
# ------------

Base.convert(::Type{GeometrySet}, d::Domain) = GeometrySet(collect(d))

Base.convert(::Type{SimpleMesh}, m::Mesh) = SimpleMesh(vertices(m), topology(m))

Base.convert(::Type{StructuredGrid}, g::Grid) = StructuredGrid(XYZ(g))

Base.convert(::Type{RectilinearGrid}, g::CartesianGrid) = RectilinearGrid(xyz(g))
10 changes: 0 additions & 10 deletions src/mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,3 @@ include("mesh/rectilineargrid.jl")
include("mesh/structuredgrid.jl")
include("mesh/simplemesh.jl")
include("mesh/transformedmesh.jl")

# ------------
# CONVERSIONS
# ------------

Base.convert(::Type{<:SimpleMesh}, m::Mesh) = SimpleMesh(vertices(m), topology(m))

Base.convert(::Type{<:StructuredGrid}, g::Grid) = StructuredGrid(XYZ(g))

Base.convert(::Type{<:RectilinearGrid}, g::CartesianGrid) = RectilinearGrid(xyz(g))
7 changes: 7 additions & 0 deletions test/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
push!(geoms, Segment(P2(1, 1), P2(0, 0)))
gset = GeometrySet(geoms)
@test eltype(gset) <: Segment{2,T}

# conversion
grid = CartesianGrid{T}(10, 10)
gset = convert(GeometrySet, grid)
@test gset isa GeometrySet
@test nelements(gset) == 100
@test eltype(gset) <: Quadrangle
end

@testset "PointSet" begin
Expand Down

0 comments on commit 7e61398

Please sign in to comment.