Skip to content

Commit 707f43d

Browse files
committed
fixed L2P1 element and added test
1 parent 3c013e7 commit 707f43d

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

examples/Example281_DiscontinuousPlot.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ function main(; broken = false, nrefs = 3, abs = false, Plotter = nothing)
6161
nodevals4nodes2 = nodevalues(FEFunction[1], Identity; abs = abs, regions = [2], nodes = subnodes2)
6262

6363
## plot
64-
p = GridVisualizer(; Plotter = Plotter, layout = (2, 2), clear = true, resolution = (1000, 500))
65-
gridplot!(p[1,1], xgrid)
66-
scalarplot!(p[1, 2], [subgrid1, subgrid2], xgrid, [view(nodevals4nodes1,:), view(nodevals4nodes2,:)], cellwise = false, levels = 11, title = "u")
64+
if Plotter !== nothing
65+
p = GridVisualizer(; Plotter = Plotter, layout = (2, 2), clear = true, resolution = (1000, 500))
66+
gridplot!(p[1,1], xgrid)
67+
scalarplot!(p[1, 2], [subgrid1, subgrid2], xgrid, [view(nodevals4nodes1,:), view(nodevals4nodes2,:)], cellwise = false, levels = 11, title = "u")
68+
end
6769

6870
return p
6971
end

src/fedefs/l2_p1.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ get_dofmap_pattern(FEType::Type{<:L2P1}, ::Type{CellDofs}, EG::Type{<:AbstractEl
3131

3232
isdefined(FEType::Type{<:L2P1}, ::Type{<:AbstractElementGeometry}) = true
3333

34+
init_interpolator!(FES::FESpace{Tv, Ti, FEType, APT}, ::Type{AT_NODES}) where {Tv, Ti, FEType <: L2P1, APT} = NodalInterpolator(FES)
3435
function ExtendableGrids.interpolate!(Target, FE::FESpace{Tv, Ti, FEType, APT}, ::Type{AT_NODES}, exact_function!; items = [], kwargs...) where {Tv, Ti, FEType <: L2P1, APT}
3536
return get_interpolator(FE, AT_NODES).evaluate!(Target, exact_function!, items; kwargs...)
3637
end
@@ -50,7 +51,7 @@ end
5051
function ExtendableGrids.interpolate!(Target, FE::FESpace{Tv, Ti, FEType, APT}, ::Type{ON_CELLS}, exact_function!; items = [], kwargs...) where {Tv, Ti, FEType <: L2P1, APT}
5152
return if FE.broken == true
5253
# broken interpolation
53-
interpolate!(Target, FE, AT_NODES, exact_function!; items = items, kwargs...)
54+
get_interpolator(FE, AT_NODES).evaluate!(Target, exact_function!, items; kwargs...)
5455
else
5556
# delegate cell nodes to node interpolation
5657
subitems = slice(FE.dofgrid[CellNodes], items)

src/interpolators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function NodalInterpolator(
3434
kwargs...) where {T}
3535
FEType = eltype(FES)
3636
ncomponents = get_ncomponents(FEType)
37-
offset4component = 0:component_offset:(ncomponents * component_offset)
3837
xCoordinates = grid[Coordinates]
3938
xCellRegions = grid[CellRegions]
4039
result = zeros(T, ncomponents)
@@ -59,7 +58,7 @@ function NodalInterpolator(
5958
for n in 1:nnodes_on_cell
6059
j = xCellNodes[n, cell]
6160
QP.x .= view(xCoordinates, :, j)
62-
exact_function(result, QP)
61+
exact_function!(result, QP)
6362
for k in 1:ncomponents
6463
target[xCellDofs[1, cell] + n - 1 + (k - 1) * nnodes_on_cell] = result[k]
6564
end
@@ -69,6 +68,7 @@ function NodalInterpolator(
6968
return NodalInterpolator(evaluate_broken!)
7069
else
7170
## FE space is continuous in node, so only one evaluation is required
71+
offset4component = 0:component_offset:(ncomponents * component_offset)
7272
nnodes = num_nodes(grid)
7373
xNodeCells = atranspose(grid[CellNodes])
7474
function evaluate!(target, exact_function!, items; time = 0, params = [], kwargs...)

test/test_interpolators.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function run_interpolator_tests()
2525
HDIVRTk{2, 3},
2626
HDIVRTk{2, 4},
2727
L2P0{2},
28+
L2P1{2},
2829
H1P1{2},
2930
H1Q1{2},
3031
H1CR{2},
@@ -39,7 +40,7 @@ function run_interpolator_tests()
3940
H1Pk{2, 2, 4},
4041
H1Pk{2, 2, 5},
4142
]
42-
ExpectedOrders2D = [0, 1, 0, 0, 1, 1, 1, 2, 2, 3, 4, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5]
43+
ExpectedOrders2D = [0, 1, 0, 0, 1, 1, 1, 2, 2, 3, 4, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5]
4344

4445
TestCatalog3D = [
4546
HCURLN0{3},

0 commit comments

Comments
 (0)