Skip to content
Snippets Groups Projects
Commit 55b9c3aa authored by Stephan Hilb's avatar Stephan Hilb
Browse files

fix bisection algorithm

parent ddc21ec7
No related branches found
No related tags found
No related merge requests found
...@@ -215,12 +215,14 @@ function bisect!(mesh::HMesh, marked_cells::Set) ...@@ -215,12 +215,14 @@ function bisect!(mesh::HMesh, marked_cells::Set)
push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c1)), c1_vs[1] => vbisect))) push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c1)), c1_vs[1] => vbisect)))
push!(mesh.levels, 0) push!(mesh.levels, 0)
c3 = lastindex(mesh.cells) c3 = lastindex(mesh.cells)
@assert(length(setdiff(c1_vs, c1_vs[1])) == 2)
replace!(edgemap[NTuple{2}(setdiff(c1_vs, c1_vs[1]))], c1 => c3) replace!(edgemap[NTuple{2}(setdiff(c1_vs, c1_vs[1]))], c1 => c3)
# take care to produce positively oriented cells # take care to produce positively oriented cells
push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c1)), c1_vs[2] => vbisect))) push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c1)), c1_vs[2] => vbisect)))
push!(mesh.levels, 0) push!(mesh.levels, 0)
c4 = lastindex(mesh.cells) c4 = lastindex(mesh.cells)
@assert(length(setdiff(c1_vs, c1_vs[2])) == 2)
replace!(edgemap[NTuple{2}(setdiff(c1_vs, c1_vs[2]))], c1 => c4) replace!(edgemap[NTuple{2}(setdiff(c1_vs, c1_vs[2]))], c1 => c4)
# flip is correct # flip is correct
...@@ -237,18 +239,20 @@ function bisect!(mesh::HMesh, marked_cells::Set) ...@@ -237,18 +239,20 @@ function bisect!(mesh::HMesh, marked_cells::Set)
push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c2)), c1_vs[1] => vbisect))) # c1_vs is correct push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c2)), c1_vs[1] => vbisect))) # c1_vs is correct
push!(mesh.levels, 0) push!(mesh.levels, 0)
c5 = lastindex(mesh.cells) c5 = lastindex(mesh.cells)
replace!(edgemap[NTuple{2}(setdiff(c2_vs, c1_vs[1]))], c1 => c5) @assert(length(setdiff(c2_vs, c1_vs[1])) == 2)
replace!(edgemap[NTuple{2}(setdiff(c2_vs, c1_vs[1]))], c2 => c5)
# take care to produce positively oriented cells # take care to produce positively oriented cells
push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c2)), c1_vs[2] => vbisect))) # c1_vs is correct push!(mesh.cells, Tuple(replace(SVector(vertices(mesh, c2)), c1_vs[2] => vbisect))) # c1_vs is correct
push!(mesh.levels, 0) push!(mesh.levels, 0)
c6 = lastindex(mesh.cells) c6 = lastindex(mesh.cells)
replace!(edgemap[NTuple{2}(setdiff(c2_vs, c1_vs[2]))], c1 => c6) @assert(length(setdiff(c2_vs, c1_vs[2])) == 2)
replace!(edgemap[NTuple{2}(setdiff(c2_vs, c1_vs[2]))], c2 => c6)
# flip is correct # flip is correct
push!(edgemap[(c1_vs[1], vbisect)], c6) push!(edgemap[(c1_vs[1], vbisect)], c6)
push!(edgemap[(c1_vs[2], vbisect)], c5) push!(edgemap[(c1_vs[2], vbisect)], c5)
edgemap[(c1_vs[3], vbisect)] = [c5, c6] edgemap[(c2_vs[3], vbisect)] = [c5, c6]
mesh.levels[c2] += 1 mesh.levels[c2] += 1
delete!(marked_cells, c2) delete!(marked_cells, c2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment