Skip to content

Commit

Permalink
Saved progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Dec 13, 2024
1 parent f933240 commit 9144878
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/FESpaces/Pullbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end
function get_cell_pushforward_arguments(
::CoVariantPiolaMap, model::DiscreteModel, cell_reffe, conformity
)
cell_map = get_cell_map(get_grid(model))
cell_map = get_cell_map(get_grid(model))
Jt = lazy_map(Broadcasting(∇),cell_map)
return Jt
end
Expand Down
11 changes: 6 additions & 5 deletions src/ReferenceFEs/Pullbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,12 @@ Arrays.inverse_map(pb::Pullback) = InversePullback(pb.pushforward)
Arrays.inverse_map(ipb::InversePullback) = Pullback(ipb.pushforward)

function Arrays.lazy_map(
::typeof(evaluate),k::LazyArray{<:Fill{<:InversePullback}},phys_cell_fields::AbstractArray
::typeof(evaluate), k::LazyArray{<:Fill{<:InversePullback}}, phys_cell_fields::AbstractArray
)
println("InversePullback dispatch")
pb = inverse_map(k.maps.value)
ref_cell_dofs, pf_args... = k.args
ref_cell_fields = lazy_map(inverse_map(pb.pushforward),phys_cell_fields,pf_args...)
ref_cell_fields = lazy_map(inverse_map(pb.pushforward), phys_cell_fields, pf_args...)
return lazy_map(evaluate,ref_cell_dofs,ref_cell_fields)
end

Expand All @@ -251,7 +252,7 @@ function evaluate!(
)
sign = (-1)^sign_flip
idetJ = 1. / meas(Jt)
return sign * idetJ * (v_refJt)
return (sign * v_ref) (idetJ * Jt)
end

function return_cache(
Expand All @@ -263,9 +264,9 @@ end
function evaluate!(
cache, ::InversePushforward{ContraVariantPiolaMap}, v_phys::Number, Jt::Number, sign_flip::Bool
)
sign = (-1)^sign_flip
sign = (-1)^sign_flip
detJ = meas(Jt)
return sign * detJ * (inv(Jt)v_phys)
return (sign * v_phys) (detJ * pinvJt(Jt))
end

# TODO: Should this be here? Probably not...
Expand Down
46 changes: 21 additions & 25 deletions test/FESpacesTests/DivConformingFESpacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,65 +10,62 @@ using Gridap.Fields
using Gridap.Io

function test_div_v_q_equiv(U,V,P,Q,Ω)
v=get_fe_basis(V)
u=get_trial_fe_basis(U)
v = get_fe_basis(V)
u = get_trial_fe_basis(U)

q=get_fe_basis(Q)
p=get_trial_fe_basis(P)
q = get_fe_basis(Q)
p = get_trial_fe_basis(P)

=Measure(Ω,1)
dΩᵣ=Measure(Ω,1,integration_domain_style=ReferenceDomain())
= Measure(Ω,1)
dΩᵣ = Measure(Ω,1,integration_domain_style = ReferenceDomain())

a1(p,v)=(divergence(v)*p)dΩ
a2(p,v)=(DIV(v)*p)dΩᵣ
a1(p,v) = (divergence(v)*p)dΩ
a2(p,v) = (DIV(v)*p)dΩᵣ

tol=1.0e-12
tol = 1.0e-12
assem = SparseMatrixAssembler(P,V)
data = collect_cell_matrix(P,V,a1(p,v))
A1 = assemble_matrix(assem,data)
data = collect_cell_matrix(P,V,a2(p,v))
A2 = assemble_matrix(assem,data)
@test norm(A1-A2) < tol

a3(u,q)=(q*divergence(u))dΩ
a4(u,q)=(q*DIV(u))dΩᵣ
a3(u,q) = (q*divergence(u))dΩ
a4(u,q) = (q*DIV(u))dΩᵣ
assem = SparseMatrixAssembler(U,Q)
data = collect_cell_matrix(U,Q,a3(u,q))
A3 = assemble_matrix(assem,data)
data = collect_cell_matrix(U,Q,a4(u,q))
A4 = assemble_matrix(assem,data)
@test norm(A3-A4) < tol

uh=FEFunction(U,rand(num_free_dofs(U)))
l1(q)=(q*divergence(uh))dΩ
l2(q)=(q*DIV(uh))dΩᵣ
v1=assemble_vector(l1,Q)
v2=assemble_vector(l2,Q)
uh = FEFunction(U,rand(num_free_dofs(U)))
l1(q) = (q*divergence(uh))dΩ
l2(q) = (q*DIV(uh))dΩᵣ
v1 = assemble_vector(l1,Q)
v2 = assemble_vector(l2,Q)
@test norm(v1-v2) < tol
end

@testset "Test Raviart-Thomas" begin
#@testset "Test Raviart-Thomas" begin

domain =(0,1,0,1)
domain = (0,1,0,1)
partition = (3,3)
model = CartesianDiscreteModel(domain,partition)

order = 1

u(x) = x

reffe = ReferenceFE(raviart_thomas,order)

V = TestFESpace(model,reffe,dirichlet_tags = [1,6])
test_single_field_fe_space(V)
U = TrialFESpace(V,u)

reffe = ReferenceFE(lagrangian,Float64,order)
Q = TestFESpace(model,reffe,conformity=:L2)
reffe_p = ReferenceFE(lagrangian,Float64,order)
Q = TestFESpace(model,reffe_p,conformity=:L2)
P = TrialFESpace(Q)

uh = interpolate(u,U)

e = u - uh

Ω = Triangulation(model)
Expand Down Expand Up @@ -103,7 +100,6 @@ end

v(x) = VectorValue(-0.5*x[1]+1.0,-0.5*x[2],-0.5*x[3])
vh = interpolate(v,V)

e = v - vh

Ω = Triangulation(model)
Expand Down Expand Up @@ -150,7 +146,7 @@ end

test_div_v_q_equiv(U,V,P,Q,Ω)

end
#end

@testset "Test BDM" begin

Expand Down

0 comments on commit 9144878

Please sign in to comment.