Skip to content

Commit

Permalink
Added mean operator on the skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
fverdugo committed Sep 11, 2019
1 parent d1f95b8 commit 83798b4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/Integration/SkeletonCellFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export SkeletonCellVector
export SkeletonCellMatrix

export jump
export mean
import Gridap: restrict
import Gridap: gradient
import Gridap: inner
Expand Down Expand Up @@ -50,6 +51,19 @@ function jump(sp::SkeletonPair{Z,T,2}) where {Z,T}
SkeletonCellBasis(cf1, -cf2)
end

function mean(sp::SkeletonPair{Z,T,1}) where {Z,T}
cf1 = sp.cellfield1
cf2 = sp.cellfield2
0.5*(cf1 + cf2)
end

function mean(sp::SkeletonPair{Z,T,2}) where {Z,T}
cf1 = sp.cellfield1
cf2 = sp.cellfield2
SkeletonCellBasis(0.5*cf1, 0.5*cf2)
end


struct SkeletonCellBasis{Z,T}
cellbasis1::CellBasis{Z,T}
cellbasis2::CellBasis{Z,T}
Expand Down
34 changes: 32 additions & 2 deletions test/IntegrationTests/SkeletonCellFieldsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,30 @@ suh = restrict(uh,strian)
jsu = jump(su)
jsu_s = evaluate(jsu,s)

msu = mean(su)
msu_s = evaluate(msu,s)

jsuh = jump(suh)
jsuh_s = evaluate(jsuh,s)

msuh = mean(suh)
msuh_s = evaluate(msuh,s)

jsu_grad = jump((su))
jsu_grad_s = evaluate(jsu_grad,s)

msu_grad = mean((su))
msu_grad_s = evaluate(msu_grad,s)

jsuh_grad = jump((suh))
jsuh_grad_s = evaluate(jsuh_grad,s)

msuh_grad = mean((suh))
msuh_grad_s = evaluate(msuh_grad,s)

#writevtk(strian,"strian",cellfields=[
# "jumpu"=>jsu,"jumpu_grad"=>jsu_grad,
# "jumph"=>jsuh,"jumpuh_grad"=>jsuh_grad ])
# "jumpu"=>jsu,"meanu"=>msu,"jumpu_grad"=>jsu_grad,"meanu_grad"=>msu_grad,
# "jumph"=>jsuh,"meanh"=>msuh,"jumpuh_grad"=>jsuh_grad,"meanh_grad"=>msuh_grad ])

v = CellBasis(trian)
du = v
Expand All @@ -58,6 +70,12 @@ cv = integrate(cm,strian,squad)
_ = collect(cv.cellvector1)
_ = collect(cv.cellvector2)

cm = inner(mean(v_Γ),jump(u_Γ))

cv = integrate(cm,strian,squad)
_ = collect(cv.cellvector1)
_ = collect(cv.cellvector2)

cm = inner(jump(v_Γ),jump(du_Γ))

cv = integrate(cm,strian,squad)
Expand All @@ -66,6 +84,14 @@ _ = collect(cv.cellmatrix12)
_ = collect(cv.cellmatrix21)
_ = collect(cv.cellmatrix22)

cm = inner(mean(v_Γ),jump(du_Γ))

cv = integrate(cm,strian,squad)
_ = collect(cv.cellmatrix11)
_ = collect(cv.cellmatrix12)
_ = collect(cv.cellmatrix21)
_ = collect(cv.cellmatrix22)

cm = inner(jump(u_Γ),jump(u_Γ))
cv = integrate(cm,strian,squad)
_ = collect(cv)
Expand All @@ -78,4 +104,8 @@ z = Point(0.0,0.0,0.0)
zs = fill(z,4)
@test all([ xi .+ 1 zs .+ 1 for xi in x ])

x = evaluate(mean(phi_Γ),s)
x2 = evaluate(phi_Γ.cellfield1,s)
@test x x2

end # module

0 comments on commit 83798b4

Please sign in to comment.