Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# [1.17.0] - 2026-04-15
- new kwargs `not_in_domain_value = nothing` and `check_if_not_in_domain = isnothing(not_in_domain_value)` for grid interpolation.
This enables the user to interpolate values between grids which do not share the same domain. The value _outside_ the target domain has to be provided by the user.
- Allow to read simplexgrid data from TetGen .ele file sets

## [1.16.0] - 2026-01-21
- Allow to read/write WIAS-TeSCA dom files

## [1.15.0] - 2026-01-14
- add and export `explode` function that produces a grid with all adjacencies removed
Expand Down
90 changes: 90 additions & 0 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ $(TYPEDSIGNATURES)
- format version 2.1: shortened version only with cells, cellnodes, cellregions, bfacenodes, bfaceregions
- format version 2.2: like 2.1, but additional info on cell and node partitioning. Edge partitioning
is not stored in the file and may be re-established by [`induce_edge_partitioning!`](@ref).
- "*.ele": TetGen output format (requires presence of *.ele, *.node and *.face file)
- "*.geo": gmsh geometry description (requires `using Gmsh`)
- "*.msh": gmsh mesh (requires `using Gmsh`)
- "*.dom": WIAS-TeSCA dom format
Expand Down Expand Up @@ -265,6 +266,95 @@ function writegrid(fname::String, g::ExtendableGrid, ::Type{Val{:sg}}; version =
return nothing
end

########################################################
## TetGen ele format
#######################################################
function simplexgrid(file::String, ::Type{Val{:ele}}; kwargs...)
Ti = Cint
fname, fext = splitext(file)
tks_ele = TokenStream(fname * ".ele")
tks_face = TokenStream(fname * ".face")
tks_node = TokenStream(fname * ".node")


npoints = parse(Ti, gettoken(tks_node))
dim = parse(Ti, gettoken(tks_node))
if dim != 3
throw(ErrorException("Dimension $dim not supported so far for .ele format"))
end
npointboundarymarkers = parse(Ti, gettoken(tks_node))
if npointboundarymarkers > 0
@warn "ignoring point boundary markers"
end
npointattributes = parse(Ti, gettoken(tks_node))
if npointattributes > 0
@warn "ignoring point attributes"
end
coord = Array{Float64, 2}(undef, dim, npoints)
for ipoint in 1:npoints
idx = parse(Ti, gettoken(tks_node)) + 1
for idim in 1:dim
coord[idim, idx] = parse(Float64, gettoken(tks_node))
end
for i in 1:npointboundarymarkers
gettoken(tks_node)
end
for i in 1:npointattributes
gettoken(tks_node)
end
end


ncells = parse(Ti, gettoken(tks_ele))
ncellnodes = parse(Ti, gettoken(tks_ele))
ncellattributes = parse(Ti, gettoken(tks_ele))
cells = Array{Ti, 2}(undef, ncellnodes, ncells)
regions = Array{Ti, 1}(undef, ncells)
if ncellattributes > 1
@warn "ignoring more than one cell attribute"
end
for icell in 1:ncells
idx = parse(Ti, gettoken(tks_ele)) + 1
for inode in 1:ncellnodes
cells[inode, idx] = parse(Ti, gettoken(tks_ele)) + 1
end
if ncellattributes == 0
regions[idx] = 1
else
regions[idx] = parse(Ti, gettoken(tks_ele))
for i in 2:ncellattributes
gettoken(tks_ele)
end
end
end

nfaces = parse(Ti, gettoken(tks_face))
nfaceattributes = parse(Ti, gettoken(tks_face))
nfacenodes = 3
if nfaceattributes > 1
@warn "ignoring more than one face attribute"
end
faces = Array{Ti, 2}(undef, dim, nfaces)
bregions = Array{Ti, 1}(undef, nfaces)
for iface in 1:nfaces
idx = parse(Ti, gettoken(tks_face)) + 1
for inode in 1:nfacenodes
faces[inode, idx] = parse(Ti, gettoken(tks_face)) + 1
end
if nfaceattributes == 0
bregions[idx] = 1
else
bregions[idx] = parse(Ti, gettoken(tks_face))
for i in 2:nfaceattributes
gettoken(tks_face)
end
end
end
g = simplexgrid(coord, cells, regions, faces, bregions)
return g
end


########################################################
## WIAS-TeSCA dom format
#######################################################
Expand Down
50 changes: 50 additions & 0 deletions test/cube.1.edge
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
48 1
0 22 42 -1
1 15 66 -1
2 6 41 -1
3 57 130 -1
4 5 74 -1
5 25 150 -1
6 1 83 -1
7 0 126 -1
8 38 6 -1
9 21 38 -1
10 16 112 -1
11 3 129 -1
12 3 154 -1
13 39 75 -1
14 7 82 -1
15 11 114 -1
16 4 149 -1
17 23 139 -1
18 17 87 -1
19 2 117 -1
20 19 51 -1
21 1 72 -1
22 2 98 -1
23 20 76 -1
24 41 19 -1
25 42 6 -1
26 51 7 -1
27 4 134 -1
28 66 7 -1
29 72 25 -1
30 74 22 -1
31 75 3 -1
32 76 4 -1
33 82 20 -1
34 83 57 -1
35 87 1 -1
36 98 39 -1
37 112 0 -1
38 114 0 -1
39 117 21 -1
40 126 17 -1
41 129 15 -1
42 130 2 -1
43 134 16 -1
44 139 5 -1
45 149 23 -1
46 150 5 -1
47 154 11 -1
# Generated by /home/fuhrmann/Wias/work/tetgen/codeberg/TestingDrafts/src/../tetgen-v161/build/tetgen -pqa0.005 /home/fuhrmann/Wias/work/tetgen/codeberg/TestingDrafts/src/../quarry/cube.smesh
Loading
Loading