Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Aug 7, 2024
1 parent 8c29216 commit bd8c530
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
10 changes: 8 additions & 2 deletions test/FESpacesTests/FESpacesWithConstantFixedTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ test_single_field_fe_space(V0)
uh0 = interpolate(V0) do x
sin(4*pi*(x[1]+x[2]^2)) + 3
end
using Gridap.Visualization

#writevtk(trian,"trian",nsubcells=20,cellfields=["uh0"=>uh0])
V1 = FESpaceWithConstantFixed(V,false,rand(1:num_free_dofs(V)))
test_single_field_fe_space(V1)

@test Gridap.FESpaces.ConstantApproach(V1) == Gridap.FESpaces.DoNotFixConstant()

uh1 = interpolate(V1) do x
sin(4*pi*(x[1]+x[2]^2)) + 3
end

end # module
20 changes: 13 additions & 7 deletions test/FESpacesTests/ZeroMeanFESpacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ U = TrialFESpace(V)
test_single_field_fe_space(U,cellmatvec,cellmat,cellvec,trian)
@test isa(U,ZeroMeanFESpace)

fun(x) = sin(4*pi*(x[1]+x[2]^2)) + 3
uh = interpolate(fun, U)

mean1 = sum((uh)*dΩ)

tol = 1.0e-10
@test abs(mean1) < tol
# Interpolate a function with non-zero mean
f(x) = sin(4*pi*(x[1]+x[2]^2)) + 3
uh = interpolate(f, U)
@test abs(sum((uh)*dΩ)) < 1.0e-10

# Interpolate a function with zero mean
(x) = x[1]^2 + x[2]
g_mean = sum((ĝ)*dΩ)/sum((1)*dΩ)
g(x) = (x) - g_mean
vh = interpolate(g, U)
eh = vh - g
@test abs(sum((vh)*dΩ)) < 1.0e-10
@test sum((eh*eh)*dΩ) < 1.0e-10

V = FESpace(model,ReferenceFE(lagrangian,Float64,order);conformity=:L2,constraint=:zeromean)
@test isa(V,ZeroMeanFESpace)
Expand Down

0 comments on commit bd8c530

Please sign in to comment.