Skip to content

Commit

Permalink
Added element types, added subhex, tet2hex
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Mattheus-Moerman committed May 20, 2024
1 parent f5aac56 commit a8efd8d
Show file tree
Hide file tree
Showing 11 changed files with 609 additions and 102 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased]

- Implement polyhedron types (`hex8`, `tet4`, etc)
- Removed `wrapindex` function in favour of `mod1`
- Added handling of boundary edges to `subquad` and `subtri`
- Moved excess data from assets folder to dedicated repository


2 changes: 1 addition & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.2"
manifest_format = "2.0"
project_hash = "8f980f252f20c77185d25ab017fcbeabc72c0bbc"
project_hash = "04794bae62f418ff0e74eb0067582ab95ddb0fe4"

[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
XML = "72c71f33-b9b6-44de-8c94-c961784809e2"

Expand Down
21 changes: 21 additions & 0 deletions examples/demo_rhombicdodecahedron.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Comodo
using GLMakie
using GeometryBasics
using Rotations

# Creating faces and vertices for a rhombic dodecahedron
F,V = rhombicdodecahedron(5.0)

## Visualize mesh
markersize = 25
strokewidth = 2
strokecolor = :black
fig = Figure(size = (800,800))

ax1 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Rhombic dodecahedron")

hp1 = poly!(ax1, GeometryBasics.Mesh(V,F), color=:white,transparency=false,strokewidth=strokewidth,strokecolor=strokecolor,shading = FastShading)
hp2 = scatter!(ax1, V,markersize=markersize,color=:red)
hp3 = normalplot(ax1,F,V; color = :green)

fig
53 changes: 53 additions & 0 deletions examples/demo_subhex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Comodo
using GLMakie
using GeometryBasics

#=
This demo shows the use of `subhex` to refine a a hexhedral mesh through splitting.
=#

boxDim = [2.0,3.0,1.0] # Dimensions for the box in each direction
boxEl = [2,3,1] # Number of elements to use in each direction
E,V,F,Fb,CFb_type = hexbox(boxDim,boxEl)

Eh0,Vh0 = subhex(E,V,1;direction=0)
Fh0 = element2faces(Eh0)

Eh1,Vh1 = subhex(E,V,1;direction=1)
Fh1 = element2faces(Eh1)

Eh2,Vh2 = subhex(E,V,1;direction=2)
Fh2 = element2faces(Eh2)

Eh3,Vh3 = subhex(E,V,1;direction=3)
Fh3 = element2faces(Eh3)


# Visualisation
strokewidth = 3
linewidth = 4

fig = Figure(size=(1600,800))

ax0 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined hexahedral mesh, direction=0 (all)")
hp1 = poly!(ax0,GeometryBasics.Mesh(Vh0,Fh0), strokewidth=strokewidth,shading=FastShading,strokecolor=:black, color=:white, transparency=false, overdraw=false)
hp2 = wireframe!(ax0,GeometryBasics.Mesh(V,F), linewidth=linewidth,color=:red, overdraw=false)
# hp3 = normalplot(ax0,Fh0,Vh0;color=:black)

ax1 = Axis3(fig[1, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined hexahedral mesh, direction=1")
hp1 = poly!(ax1,GeometryBasics.Mesh(Vh1,Fh1), strokewidth=strokewidth,shading=FastShading,strokecolor=:black, color=:white, transparency=false, overdraw=false)
hp2 = wireframe!(ax1,GeometryBasics.Mesh(V,F), linewidth=linewidth,color=:red, overdraw=false)
# hp3 = normalplot(ax1,Fh1,Vh1;color=:black)

ax2 = Axis3(fig[2, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined hexahedral mesh, direction=2")
hp1 = poly!(ax2,GeometryBasics.Mesh(Vh2,Fh2), strokewidth=strokewidth,shading=FastShading,strokecolor=:black, color=:white, transparency=false, overdraw=false)
hp2 = wireframe!(ax2,GeometryBasics.Mesh(V,F), linewidth=linewidth,color=:red, overdraw=false)
# hp3 = normalplot(ax2,Fh2,Vh2;color=:black)

ax3 = Axis3(fig[2, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Refined hexahedral mesh, direction=3")
hp1 = poly!(ax3,GeometryBasics.Mesh(Vh3,Fh3), strokewidth=strokewidth,shading=FastShading,strokecolor=:black, color=:white, transparency=false, overdraw=false)
hp2 = wireframe!(ax3,GeometryBasics.Mesh(V,F), linewidth=linewidth,color=:red, overdraw=false)
# hp3 = normalplot(ax3,Fh3,Vh3;color=:black)

fig

1 change: 1 addition & 0 deletions examples/demo_subtri.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Comodo
using GLMakie
using GeometryBasics
using LinearAlgebra

#=
This demo shows the use of `subtri` to refine triangulated meshes. Each
Expand Down
1 change: 1 addition & 0 deletions examples/demo_surface_mesh_smoothing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if testCase == 1 # Triangle mesh bunny
F = faces(M)
V = coordinates(M)
V = topoints(V)
F = tofaces(F)
F,V,ind1,ind2 = mergevertices(F,V; roundVertices=true)
elseif testCase == 2 # Quad mesh sphere
F,V = quadsphere(4,100)
Expand Down
53 changes: 53 additions & 0 deletions examples/demo_tet2hex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Comodo
using GLMakie
using GeometryBasics

#=
This demo shows the use of `tet2hex` to convert tetrahedral elements to hexahedral elements
domain.
=#

testCase = 1

if testCase == 1
E = [tet4{Int64}(1,2,3,4),tet4{Int64}(2,3,4,5),tet4{Int64}(6,7,8,9)]
V = [Point{3,Float64}(-1.0,0.0,0.0),
Point{3,Float64}( 1.0,0.0,0.0),
Point{3,Float64}( 0.0,1.0,0.0),
Point{3,Float64}( 0.0,0.5,1.0),
Point{3,Float64}( 1.0,1.0,1.0),
Point{3,Float64}( 2.0,0.0,0.0),
Point{3,Float64}( 4.0,0.0,0.0),
Point{3,Float64}( 3.0,1.0,0.0),
Point{3,Float64}( 3.0,0.5,1.0),
]
elseif testCase == 2
E = [hex8{Int64}(1,2,3,4,5,6,7,8)]
V = [Point{3,Float64}(0.0,0.0,0.0),
Point{3,Float64}(1.0,0.0,0.0),
Point{3,Float64}(1.0,1.0,0.0),
Point{3,Float64}(0.0,1.0,0.0),
Point{3,Float64}(0.0,0.0,1.0),
Point{3,Float64}(1.0,0.0,1.0),
Point{3,Float64}(1.0,1.0,1.0),
Point{3,Float64}(0.0,1.0,1.0),
]
end
F = element2faces(E)

Eh,Vh = tet2hex(E,V)
Fh = element2faces(Eh)

# Visualisation
markersize = 25

fig = Figure(size=(1600,800))

ax1 = Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Wireframe of hexahedral mesh")
hp1 = poly!(ax1,GeometryBasics.Mesh(V,F), strokewidth=3,shading=FastShading,strokecolor=:black, color=:white, transparency=true, overdraw=false)
hp2 = normalplot(ax1,F,V)

hp1 = poly!(ax1,GeometryBasics.Mesh(Vh,Fh), strokewidth=2,shading=FastShading,strokecolor=:red, color=:red, transparency=true, overdraw=false)
hp2 = normalplot(ax1,Fh,Vh;color=:red)

fig
21 changes: 13 additions & 8 deletions src/Comodo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ import Interpolations # E.g. for resampling curves
import BSplineKit
import QuadGK
import Distances
import DelaunayTriangulation
import DelaunayTriangulation # For regiontrimesh
import StaticArrays # For volumetric mesh definitions

include("functions.jl")

# Export imported packages
export GeometryBasics

# Export types
export Nhedron, tet4, tet10, hex8, hex20, penta6 # Volumetric elements (polyhedra)

# Export types/structs
export ConnectivitySet

# Export functions
export comododir, elements2indices, hexbox, mindist, dist, lerp
export gridpoints, gridpoints_equilateral, interp_biharmonic_spline, interp_biharmonic, nbezier, gunique
Expand All @@ -29,20 +39,15 @@ export con_edge_face, con_edge_edge, con_face_edge, con_face_face, con_face_face
export con_vertex_face, con_vertex_vertex, con_vertex_simplex, meshconnectivity
export simplexcenter, vertex2simplexdata, simplex2vertexdata
export circlepoints, loftlinear, trisurfslice
export wrapindex, edgeangles, count_edge_face, boundaryedges, edges2curve
export edgeangles, count_edge_face, boundaryedges, edges2curve
export pointspacingmean, extrudecurve, meshgroup, ray_triangle_intersect
export distmarch, mesh_curvature_polynomial, curve_length, evenly_sample, evenly_space
export invert_faces, kabsch_rot, sweeploft, loftpoints2surf, revolvecurve
export batman, tridisc, triplate, regiontrimesh, scalesimplex, subcurve, dualclad
export tet2hex, element2faces, subhex, rhombicdodecahedron

# Export functions: Visualization related
export slidercontrol, slider2anim, dirplot, normalplot

# Export types/structs
export ConnectivitySet

# Export imported packages
export GeometryBasics

end # module

Loading

0 comments on commit a8efd8d

Please sign in to comment.