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

rework image projection

parent e40cc4c0
Branches
Tags
No related merge requests found
...@@ -132,7 +132,7 @@ function quadrature_composite_lagrange_midpoint(p) ...@@ -132,7 +132,7 @@ function quadrature_composite_lagrange_midpoint(p)
for I in Iterators.product(ntuple(_ -> 0:p, d_)...) for I in Iterators.product(ntuple(_ -> 0:p, d_)...)
sum(Tuple(I)) > p && continue sum(Tuple(I)) > p && continue
k += 1 k += 1
weights[k] = 1 / n weights[k] = 1 / n / factorial(d_)
points[1, k] = I[1] / p points[1, k] = I[1] / p
points[2, k] = I[2] / p points[2, k] = I[2] / p
end end
...@@ -237,25 +237,20 @@ function project_img2!(u::FeFunction, img) ...@@ -237,25 +237,20 @@ function project_img2!(u::FeFunction, img)
space = u.space space = u.space
mesh = space.mesh mesh = space.mesh
f = ImageFunction(mesh, img) f = ImageFunction(mesh, img)
nrdims = prod(space.size)
# number of element dofs (i.e. local dofs not counting range dimensions)
nldofs = ndofs(space.element)
u.data .= 0
# count contributions to respective dof for subsequent averaging # count contributions to respective dof for subsequent averaging
gdofcount = zeros(Int, size(u.data)) gdofcount = zeros(Int, size(u.data))
area_refel = 0.5
# mesh cells u.data .= zero(eltype(u.data))
for cell in cells(mesh) for cell in cells(mesh)
bind!(f, cell) bind!(f, cell)
# size: nrdims × nldofs
# TODO: should be statically sized
gdofs = u.space.dofmap[:, :, cell]
p = ceil(Int, diam(mesh, cell)) p = ceil(Int, diam(mesh, cell))
# we actually only use the lagrange lattice points
qw, qx = quadrature_composite_lagrange_midpoint(p) qw, qx = quadrature_composite_lagrange_midpoint(p)
nqpts = length(qw) # number of quadrature points
qphi = zeros(nldofs, nqpts)
for k in axes(qx, 2) for k in axes(qx, 2)
xhat = SVector{d}(view(qx, :, k)) xhat = SVector{d}(view(qx, :, k))
x = elmap(mesh, cell)(xhat) x = elmap(mesh, cell)(xhat)
...@@ -265,11 +260,11 @@ function project_img2!(u::FeFunction, img) ...@@ -265,11 +260,11 @@ function project_img2!(u::FeFunction, img)
# size: nldofs # size: nldofs
phix = evaluate_basis(space.element, xhat) phix = evaluate_basis(space.element, xhat)
# size: nrdims × nldofs # no integration element used
gdofs = u.space.dofmap[:, :, cell] u.data[gdofs] .+= qw[k] ./ area_refel .* 3 .* value * phix'
u.data[gdofs] .+= value * (12 .* phix' .- 3) #u.data[gdofs] .+= qw[k] ./ area_refel * value * (12 .* phix' .- 3)
gdofcount[gdofs] .+= 1
end end
gdofcount[gdofs] .+= 1
end end
u.data ./= gdofcount u.data ./= gdofcount
return u return u
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment