Skip to content

Commit

Permalink
adding cut cell hybridized SBP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlchan committed May 10, 2024
1 parent a2bcc55 commit fa6c6b8
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions test/cut_mesh_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,41 @@ end
cells_per_dimension = 2
circle = PresetGeometries.Circle(R=0.66, x0=.1, y0=0)

rd = RefElemData(Quad(), N=3)
rd = RefElemData(Quad(), N=2)

md = MeshData(rd, (circle, ), cells_per_dimension;
precompute_operators=true)

mt = md.mesh_type
(; wJf) = md.mesh_type.cut_cell_data
wf = wJf ./ md.Jf

for (e, elem) in enumerate(mt.physical_frame_elements)
xq, yq, wq = md.xq.cut[:,e], md.yq.cut[:,e], md.wJq.cut[:,e]

Vq, Vxq, Vyq = basis(elem, rd.N, xq, yq)
face_ids = mt.cut_face_nodes[e]
Vf = vandermonde(elem, rd.N, md.xf.cut[face_ids], md.yf.cut[face_ids])
Qx, Qy = Vq' * diagm(wq) * Vxq, Vq' * diagm(wq) * Vyq

Bx = Diagonal(wf.cut[face_ids] .* md.nxJ.cut[face_ids])
By = Diagonal(wf.cut[face_ids] .* md.nyJ.cut[face_ids])

# represent constant vector in basis
ee = Vq \ ones(size(Vq, 1))
@test norm(ee' * Qx - ee' * Vf' * Bx * Vf) < 100 * eps()
@test norm(ee' * Qy - ee' * Vf' * By * Vf) < 100 * eps()
mt = md.mesh_type

(; x, y, xq, yq) = md
u = @. x^2 + x * y + y^2
uq = @. xq^2 + xq * yq + yq^2

(; volume_interpolation_matrices, differentiation_matrices) = md.mesh_type.cut_cell_operators
Qxyh, hybridized_project_interp_matrices,
hybridized_projection_matrices, hybridized_interp_matrices =
hybridized_SBP_operators(md)

for e in eachindex(Qxyh)
Qxh, Qyh = Qxyh[e]
Dx, Dy = differentiation_matrices[e]
Vq = volume_interpolation_matrices[e]
M = Vq' * diagm(md.wJq.cut[:,e]) * Vq
Pq = M \ (Vq' * diagm(md.wJq.cut[:,e]))

# test exactness of interpolation, projection
@test norm(Vq * u.cut[:,e] - uq.cut[:,e]) < 100 * eps()
@test norm(Pq * uq.cut[:,e] - u.cut[:,e]) < 100 * eps()

# test weak SBP property
@test norm(sum(Qxh, dims=2)) + norm(sum(Qyh, dims=2)) < 100 * eps()

# test accuracy of hybridized SBP operators when rd::RefElemData uses
# full accuracy quadrature.
Ph = hybridized_projection_matrices[e]
Vh = hybridized_interp_matrices[e]
@test norm(Ph * Qxh * Vh - Dx) +
norm(Ph * Qyh * Vh - Dy) < 1e3 * eps()
end
end

0 comments on commit fa6c6b8

Please sign in to comment.