From 0e70536c16b8c046ca809ddb03185a46e252986a Mon Sep 17 00:00:00 2001
From: Stephan Hilb <stephan@ecshi.net>
Date: Mon, 22 Nov 2021 11:39:21 +0100
Subject: [PATCH] fix cosmetic stuff
---
src/function.jl | 9 ++++++---
src/image.jl | 1 +
src/operator.jl | 2 +-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/function.jl b/src/function.jl
index 2e001fa..1d00318 100644
--- a/src/function.jl
+++ b/src/function.jl
@@ -13,7 +13,6 @@ ndofs(::P1) = 3
ndofs(::DP0) = 1
ndofs(::DP1) = 3
-# FIXME: should be static vectors
# 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(::DP0, x) = SA[1]
@@ -29,6 +28,8 @@ struct FeSpace{M, Fe, S}
ndofs::Int # = maximum(dofmap)
end
+# TODO: size should probably be a type argument to make the constructor type
+# safe
function FeSpace(mesh, el::P1, size_=(1,))
# special case for P1: dofs correspond to vertices
rdims = prod(size_)
@@ -321,6 +322,7 @@ end
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)
out = _sample(f)
return f.space.size == (1,) ?
@@ -444,14 +446,15 @@ function save_csv(path, f::FeFunction)
throw(ArgumentError("non-scalar functions unsupported"))
mesh = f.space.mesh
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)
bind!(f, cell)
A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}(
view(mesh.vertices, :, view(mesh.cells, :, cell)))
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
CSV.write(path, df)
diff --git a/src/image.jl b/src/image.jl
index 081d5e5..0ea64e5 100644
--- a/src/image.jl
+++ b/src/image.jl
@@ -2,6 +2,7 @@ export interpolate_bilinear, halve, warp_backwards
eval_neumann(img, x) = img[clamp.(Tuple(x), axes(img))...]
+# uses native array indexing, i.e. 1:n
function interpolate_bilinear(img, x)
x0 = floor.(Int, x)
x1 = x0 .+ 1
diff --git a/src/operator.jl b/src/operator.jl
index b86afcd..1a21b05 100644
--- a/src/operator.jl
+++ b/src/operator.jl
@@ -261,7 +261,7 @@ function project_img2!(u::FeFunction, img)
# size: nrdims
value = evaluate(f, xhat)
# size: nldofs
- phix = evaluate_basis(space.element, SVector{d}(view(qx, :, k)))
+ phix = evaluate_basis(space.element, xhat)
# size: nrdims × nldofs
gdofs = u.space.dofmap[:, :, cell]
--
GitLab