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

fix cosmetic stuff

parent f6c2db7e
Branches
Tags
No related merge requests found
...@@ -13,7 +13,6 @@ ndofs(::P1) = 3 ...@@ -13,7 +13,6 @@ ndofs(::P1) = 3
ndofs(::DP0) = 1 ndofs(::DP0) = 1
ndofs(::DP1) = 3 ndofs(::DP1) = 3
# FIXME: should be static vectors
# evaluate all (1-dim) local basis functions against x # evaluate all (1-dim) local basis functions against x
evaluate_basis(::P1, x) = SA[1 - x[1] - x[2], x[1], x[2]] evaluate_basis(::P1, x) = SA[1 - x[1] - x[2], x[1], x[2]]
evaluate_basis(::DP0, x) = SA[1] evaluate_basis(::DP0, x) = SA[1]
...@@ -29,6 +28,8 @@ struct FeSpace{M, Fe, S} ...@@ -29,6 +28,8 @@ struct FeSpace{M, Fe, S}
ndofs::Int # = maximum(dofmap) ndofs::Int # = maximum(dofmap)
end end
# TODO: size should probably be a type argument to make the constructor type
# safe
function FeSpace(mesh, el::P1, size_=(1,)) function FeSpace(mesh, el::P1, size_=(1,))
# special case for P1: dofs correspond to vertices # special case for P1: dofs correspond to vertices
rdims = prod(size_) rdims = prod(size_)
...@@ -321,6 +322,7 @@ end ...@@ -321,6 +322,7 @@ end
bind!(f::FacetDivergence, cell) = f.cell[] = cell bind!(f::FacetDivergence, cell) = f.cell[] = cell
# TODO: get rid of this hack as soon as we use size=() for scalar functions
function sample(f::FeFunction) function sample(f::FeFunction)
out = _sample(f) out = _sample(f)
return f.space.size == (1,) ? return f.space.size == (1,) ?
...@@ -444,14 +446,15 @@ function save_csv(path, f::FeFunction) ...@@ -444,14 +446,15 @@ function save_csv(path, f::FeFunction)
throw(ArgumentError("non-scalar functions unsupported")) throw(ArgumentError("non-scalar functions unsupported"))
mesh = f.space.mesh mesh = f.space.mesh
df = DataFrame() df = DataFrame()
X = SA[0 1 0; 0 0 1] X = SA[0 1 0; 0 0 1] # corners in local coordinates
for cell in cells(mesh) for cell in cells(mesh)
bind!(f, cell) bind!(f, cell)
A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}( A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}(
view(mesh.vertices, :, view(mesh.cells, :, cell))) view(mesh.vertices, :, view(mesh.cells, :, cell)))
for k in axes(A, 2) for k in axes(A, 2)
push!(df, (x = A[1, k], y = A[2, k], c = evaluate(f, X[:, k])[1])) push!(df, (x = A[1, k], y = A[2, k],
f_xy = evaluate(f, X[:, k])[1]))
end end
end end
CSV.write(path, df) CSV.write(path, df)
......
...@@ -2,6 +2,7 @@ export interpolate_bilinear, halve, warp_backwards ...@@ -2,6 +2,7 @@ export interpolate_bilinear, halve, warp_backwards
eval_neumann(img, x) = img[clamp.(Tuple(x), axes(img))...] eval_neumann(img, x) = img[clamp.(Tuple(x), axes(img))...]
# uses native array indexing, i.e. 1:n
function interpolate_bilinear(img, x) function interpolate_bilinear(img, x)
x0 = floor.(Int, x) x0 = floor.(Int, x)
x1 = x0 .+ 1 x1 = x0 .+ 1
......
...@@ -261,7 +261,7 @@ function project_img2!(u::FeFunction, img) ...@@ -261,7 +261,7 @@ function project_img2!(u::FeFunction, img)
# size: nrdims # size: nrdims
value = evaluate(f, xhat) value = evaluate(f, xhat)
# size: nldofs # size: nldofs
phix = evaluate_basis(space.element, SVector{d}(view(qx, :, k))) phix = evaluate_basis(space.element, xhat)
# size: nrdims × nldofs # size: nrdims × nldofs
gdofs = u.space.dofmap[:, :, cell] gdofs = u.space.dofmap[:, :, cell]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment