diff --git a/src/amr.jl b/src/amr.jl new file mode 100644 index 0000000000000000000000000000000000000000..81bcb5c001ccd65dd68353d54a4973218e5ecdc0 --- /dev/null +++ b/src/amr.jl @@ -0,0 +1,46 @@ +struct AdaptiveMesh{TMesh<:Mesh} <: AbstractMesh + mesh::TMesh +end + + +const AMesh{T} where T = AdaptiveMesh{T} + + +regrid!(mesh, cache, evolution) = nothing + + +function regrid!(amesh::AMesh{Mesh1d}, cache, evolution::Evolution) + # compute new tree layout + newtree = compute_tree_layout(amesh.mesh, cache, evolution) + # legalize new tree layout + # set up new mesh for new tree layout + # resize evolution.stages and use them as caches for interpolation (could also use any + # of the static variables from the cache) + # interpolate data from old mesh to new mesh + # resize all caches +end + + +function compute_tree_layout(mesh::Mesh1d, cache, evolution) + # dummy method + nc = n_cells(mesh.tree) + flags = rand((-1,0,1), nc) + legalize!(flags, mesh.tree.cells) + # setup refined tree?? +end + + +function legalize!(flags, cells) + # search all -1s and check their neighbors + for (i,f) in zip(flags) + f == -1 || continue + c = cells[i] + il, ir = c.neighbors + if has_neighbor(c, Cart1d.Xmin) && flags[il] == 1 + flags[il] = 0 + end + if has_neighbor(c, Cart1d.Xmax) && flags[ir] == 1 + flags[il] = 0 + end + end +end