changeset 169:24ee4def7ffb boundary_conditions

Move NormalDerivative methods to type definition
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 21 May 2019 14:24:28 +0200
parents 45840a8127d6
children 6ba2238a9687
files diffOp.jl
diffstat 1 files changed, 26 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
diff -r 45840a8127d6 -r 24ee4def7ffb diffOp.jl
--- a/diffOp.jl	Tue May 21 14:20:20 2019 +0200
+++ b/diffOp.jl	Tue May 21 14:24:28 2019 +0200
@@ -104,6 +104,32 @@
 	bId::CartesianBoundary
 end
 
+function apply_transpose(d::NormalDerivative, v::AbstractArray, I::Integer)
+	u = selectdim(v,dim(d.bId),I)
+	return apply_d(d.op, h, u, region(d.bId))
+end
+
+# Not correct abstraction level
+# TODO: Not type stable D:<
+function apply(d::NormalDerivative, v::AbstractArray, I::Tuple{Integer,Integer})
+	i = I[dim(d.bId)]
+	j = I[3-dim(d.bId)]
+	N_i = d.grid.size[dim(d.bId)]
+
+	r = getregion(i, closureSize(d.op), N_i)
+
+	if r != region(d.bId)
+		return 0
+	end
+
+	if r == Lower
+		# Note, closures are indexed by offset. Fix this D:<
+		return d.op.dClosure[i-1]*v[j]
+	elseif r == Upper
+		return d.op.dClosure[N_i-j]*v[j]
+	end
+end
+
 struct Laplace{Dim,T<:Real,N,M,K} <: DiffOpCartesian{Dim}
     grid::EquidistantGrid{Dim,T}
     a::T
@@ -155,33 +181,6 @@
 end
 
 
-
-function apply_transpose(d::NormalDerivative, v::AbstractArray, I::Integer)
-	u = selectdim(v,dim(d.bId),I)
-	return apply_d(d.op, h, u, region(d.bId))
-end
-
-# Not correct abstraction level
-# TODO: Not type stable D:<
-function apply(d::NormalDerivative, v::AbstractArray, I::Tuple{Integer,Integer})
-	i = I[dim(d.bId)]
-	j = I[3-dim(d.bId)]
-	N_i = d.grid.size[dim(d.bId)]
-
-	r = getregion(i, closureSize(d.op), N_i)
-
-	if r != region(d.bId)
-		return 0
-	end
-
-	if r == Lower
-		# Note, closures are indexed by offset. Fix this D:<
-		return d.op.dClosure[i-1]*v[j]
-	elseif r == Upper
-		return d.op.dClosure[N_i-j]*v[j]
-	end
-end
-
 """
 A BoundaryCondition should implement the method
     sat(::DiffOp, v::AbstractArray, data::AbstractArray, ...)