Skip to content

Commit

Permalink
* Using the latest versions of Gridap/GridapDistributed
Browse files Browse the repository at this point in the history
* Temporarily moved Adaptivity module fix to GridapFixes.jl
* Activated the full suite of tests for DarcyNonConforming
  • Loading branch information
amartinhuertas committed Oct 1, 2023
1 parent 701d787 commit dd27010
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 72 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
ArgParse = "1"
FillArrays = "0.8.4, 0.9, 0.10, 0.11, 0.12"
Gridap = "0.17.18"
GridapDistributed = "0.3"
FillArrays = "0.8.4, 0.9, 0.10, 0.11, 0.12, 1"
Gridap = "0.17.20"
GridapDistributed = "0.3.1"
MPI = "0.20"
P4est_wrapper = "0.2.0"
PartitionedArrays = "0.3.3"
Expand Down
18 changes: 18 additions & 0 deletions src/GridapFixes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,22 @@ function Base.map(::typeof(Gridap.Arrays.testitem),
a1=Vector{eltype(eltype(a[1]))}(undef,size(a2,1))
a1.=zero(Gridap.Arrays.testitem(a1))
(a1,a2)
end

# Required to transfer fine-grid VECTOR-VALUED fields into coarse-grid
function Gridap.Adaptivity.FineToCoarseField(fine_fields::AbstractArray{<:Gridap.Fields.Field},
rrule::Gridap.Adaptivity.RefinementRule,
child_ids::AbstractArray{<:Integer})

grid=Gridap.Adaptivity.get_ref_grid(rrule)
D=num_cell_dims(grid)
x=zero(Point{D,Float64})
ffx=lazy_map(evaluate,fine_fields,Fill([x],length(fine_fields)))
ffx=ffx[1]
fields = Vector{Gridap.Fields.Field}(undef,Gridap.Adaptivity.num_subcells(rrule))
fields = fill!(fields,Gridap.Fields.ConstantField(zero(eltype(ffx))))
for (k,id) in enumerate(child_ids)
fields[id] = fine_fields[k]
end
return Gridap.Adaptivity.FineToCoarseField(fields,rrule)
end
109 changes: 40 additions & 69 deletions test/DarcyNonConformingOctreeModelsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,48 +40,48 @@ module DarcyNonConformingOctreeModelsTests
uh,ph=xh
Uh,Ph=Xh

# Ωh = Triangulation(fmodel)
# degree = 2*(order+1)
# dΩh = Measure(Ωh,degree)

# # prolongation via interpolation
# uHh=interpolate(uH,Uh)
# e = uh - uHh
# el2 = sqrt(sum( ∫( e⋅e )*dΩh ))
Ωh = Triangulation(fmodel)
degree = 2*(order+1)
dΩh = Measure(Ωh,degree)

# prolongation via interpolation
uHh=interpolate(uH,Uh)
e = uh - uHh
el2 = sqrt(sum( ( ee )*dΩh ))
tol=1e-6
# println("[INTERPOLATION] el2 < tol: $(el2) < $(tol)")
# @assert el2 < tol

# # prolongation via L2-projection
# # Coarse FEFunction -> Fine FEFunction, by projection
# ahp(u,v) = ∫(v⋅u)*dΩh
# lhp(v) = ∫(v⋅uH)*dΩh
# oph = AffineFEOperator(ahp,lhp,Uh,Uh)
# uHh = solve(oph)
# e = uh - uHh
# el2 = sqrt(sum( ∫( e⋅e )*dΩh ))
# println("[L2 PROJECTION] el2 < tol: $(el2) < $(tol)")
# @assert el2 < tol

# # restriction via interpolation
# uhH=interpolate(uh,UH)
# e = uH - uhH
# el2 = sqrt(sum( ∫( e⋅e )*dΩh ))
# println("[INTERPOLATION] el2 < tol: $(el2) < $(tol)")
# @assert el2 < tol

# # restriction via L2-projection
# ΩH = Triangulation(dmodel)
# degree = 2*(order+1)
# dΩH = Measure(ΩH,degree)
println("[INTERPOLATION] el2 < tol: $(el2) < $(tol)")
@assert el2 < tol

# prolongation via L2-projection
# Coarse FEFunction -> Fine FEFunction, by projection
ahp(u,v) = (vu)*dΩh
lhp(v) = (vuH)*dΩh
oph = AffineFEOperator(ahp,lhp,Uh,Uh)
uHh = solve(oph)
e = uh - uHh
el2 = sqrt(sum( ( ee )*dΩh ))
println("[L2 PROJECTION] el2 < tol: $(el2) < $(tol)")
@assert el2 < tol

# restriction via interpolation
uhH=interpolate(uh,UH)
e = uH - uhH
el2 = sqrt(sum( ( ee )*dΩh ))
println("[INTERPOLATION] el2 < tol: $(el2) < $(tol)")
@assert el2 < tol

# restriction via L2-projection
ΩH = Triangulation(dmodel)
degree = 2*(order+1)
dΩH = Measure(ΩH,degree)

# dΩhH = Measure(ΩH,Ωh,2*order)
# aHp(u,v) = ∫(v⋅u)*dΩH
# lHp(v) = ∫(v⋅uh)*dΩhH
# oph = AffineFEOperator(aHp,lHp,UH,UH)
# uhH = solve(oph)
# e = uH - uhH
# el2 = sqrt(sum( ∫( e⋅e )*dΩH ))
dΩhH = Measure(ΩH,Ωh,2*order)
aHp(u,v) = (vu)*dΩH
lHp(v) = (vuh)*dΩhH
oph = AffineFEOperator(aHp,lHp,UH,UH)
uhH = solve(oph)
e = uH - uhH
el2 = sqrt(sum( ( ee )*dΩH ))

fmodel_red, red_glue=GridapDistributed.redistribute(fmodel);
xh_red,Xh_red=solve_darcy(fmodel_red,order)
Expand Down Expand Up @@ -184,35 +184,6 @@ module DarcyNonConformingOctreeModelsTests

include("CoarseDiscreteModelsTools.jl")

function GridapDistributed.remove_ghost_cells(
trian::Gridap.Adaptivity.AdaptedTriangulation{Dc,Dp,<:Union{SkeletonTriangulation,BoundaryTriangulation}},gids) where {Dc,Dp}
GridapDistributed.remove_ghost_cells(trian.trian,gids)
end

# Required to transfer fine-grid VECTOR-VALUED fields into coarse-grid
function Gridap.Adaptivity.FineToCoarseField(fine_fields::AbstractArray{<:Gridap.Fields.Field},
rrule::Gridap.Adaptivity.RefinementRule,
child_ids::AbstractArray{<:Integer})

grid=Gridap.Adaptivity.get_ref_grid(rrule)
D=num_cell_dims(grid)
x=zero(Point{D,Float64})
ffx=lazy_map(evaluate,fine_fields,Fill([x],length(fine_fields)))
ffx=ffx[1]
fields = Vector{Gridap.Fields.Field}(undef,Gridap.Adaptivity.num_subcells(rrule))
fields = fill!(fields,Gridap.Fields.ConstantField(zero(eltype(ffx))))
for (k,id) in enumerate(child_ids)
fields[id] = fine_fields[k]
end
return Gridap.Adaptivity.FineToCoarseField(fields,rrule)
end

# Required in order to avoid returning the results of get_cell_dof_ids(space)
# in the case of a FESpaceWithLinearConstraints wrapped around a TrialFESpace
function GridapDistributed._get_cell_dof_ids_inner_space(s::TrialFESpace)
GridapDistributed._get_cell_dof_ids_inner_space(s.space)
end

function solve_darcy(model::GridapDistributed.DistributedDiscreteModel{Dc},order) where {Dc}
if (Dc==2)
dirichlet_tags=[5,6]
Expand Down

0 comments on commit dd27010

Please sign in to comment.