Skip to content

Commit

Permalink
test centers for stationary PDE
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed Oct 26, 2024
1 parent b85eb01 commit 2e0ce6b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions examples/PDEs/anisotropic_elliptic_2d_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ n = 10
nodeset_inner = homogeneous_hypercube(n, (0.1, 0.1), (0.9, 0.9); dim = 2)
n_boundary = 3
nodeset_boundary = homogeneous_hypercube_boundary(n_boundary; dim = 2)
centers = homogeneous_hypercube(8; dim = 2)
# Dirichlet boundary condition (here taken from analytical solution)
g(x) = u(x, pde)

kernel = WendlandKernel{2}(3, shape_parameter = 0.8)
sd = SpatialDiscretization(pde, nodeset_inner, g, nodeset_boundary, kernel)
kernel = WendlandKernel{2}(3, shape_parameter = 0.4)
sd = SpatialDiscretization(pde, nodeset_inner, g, nodeset_boundary, centers, kernel)
itp = solve_stationary(sd)

many_nodes = homogeneous_hypercube(20; dim = 2)
Expand Down
4 changes: 2 additions & 2 deletions test/test_examples_pde.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ end

@testitem "anisotropic_elliptic_2d_basic.jl" setup=[Setup, AdditionalImports, PDEExamples] begin
@test_include_example(joinpath(EXAMPLES_DIR, "anisotropic_elliptic_2d_basic.jl"),
l2=0.3680733486177618, linf=0.09329545570900866,
pde_test=true)
l2=0.6820834994466024, linf=0.10747754142379007,
pde_test=true, least_square_test=true)
end

@testitem "heat_2d_basic.jl" setup=[Setup, AdditionalImports, PDEExamples] begin
Expand Down
18 changes: 11 additions & 7 deletions test/test_util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ macro test_include_example(example, args...)
# assumes `many_nodes`, `nodes_inner` and `nodeset_boundary` are defined in the example
# if `u` is defined, it is used to compare the solution (analytical solution or initial condition) using the l2 and linf norms
if pde isa KernelInterpolation.AbstractStationaryEquation
rhs_values = KernelInterpolation.rhs(nodeset_inner, pde)
for i in eachindex(nodeset_inner)
@test isapprox(pde(itp, nodeset_inner[i]), rhs_values[i],
atol = $atol, rtol = $rtol)
if !$least_square_test
rhs_values = KernelInterpolation.rhs(nodeset_inner, pde)
for i in eachindex(nodeset_inner)
@test isapprox(pde(itp, nodeset_inner[i]), rhs_values[i],
atol = $atol, rtol = $rtol)
end
values_boundary = g.(nodeset_boundary)
end
values_boundary = g.(nodeset_boundary)
# Because of some namespace issues
itp2 = itp

Expand All @@ -95,8 +97,10 @@ macro test_include_example(example, args...)
error("Unknown PDE type")
end

for (node, value) in zip(nodeset_boundary, values_boundary)
@test isapprox(itp2(node), value, atol = $atol, rtol = $rtol)
if !$least_square_test
for (node, value) in zip(nodeset_inner, values_inner)
@test isapprox(itp2(node), value, atol = $atol, rtol = $rtol)
end
end

if @isdefined many_values
Expand Down

0 comments on commit 2e0ce6b

Please sign in to comment.