Skip to content

Commit 9d96bd2

Browse files
authored
Merge pull request #65 from WIAS-PDELib/feature/broken-plots
plot broken scalar FE Types in broken plots
2 parents af2c83a + 4706017 commit 9d96bd2

3 files changed

Lines changed: 51 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGES
22

3+
## v1.3.0
4+
5+
### Added
6+
- `plot` for broken FE Spaces are now plotted discontinuously to avoid averaging of values at the grid nodes.
7+
This can be disabled by passing the kwarg `average_broken_plots = true` to the `plot` call.
8+
39
## v1.2.0 June 4, 2025
410

511
### Changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableFEM"
22
uuid = "a722555e-65e0-4074-a036-ca7ce79a4aed"
3+
version = "1.3.0"
34
authors = ["Christian Merdon <merdon@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
4-
version = "1.2"
55

66
[deps]
77
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"

src/plots.jl

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ function plot!(p::GridVisualizer, ops, sol; kwargs...)
1919
Plots the operator evaluations ops of blocks in sol into the GridVisualizer.
2020
2121
"""
22-
function plot!(p::GridVisualizer, ops, sol; rasterpoints = 10, linewidth = 1, keep = [], ncols = size(p.subplots, 2), do_abs = true, do_vector_plots = true, title_add = "", kwargs...)
22+
function plot!(
23+
p::GridVisualizer,
24+
ops,
25+
sol;
26+
rasterpoints = 10,
27+
linewidth = 1,
28+
keep = [],
29+
ncols = size(p.subplots, 2),
30+
do_abs = true,
31+
do_vector_plots = true,
32+
title_add = "",
33+
average_broken_plots = false,
34+
kwargs...
35+
)
2336
col, row, id = 0, 1, 0
2437
for op in ops
2538
col += 1
@@ -48,7 +61,11 @@ function plot!(p::GridVisualizer, ops, sol; rasterpoints = 10, linewidth = 1, ke
4861
title = op[2] == Identity ? "$(sol[op[1]].name)" : "$(op[2])($(sol[op[1]].name))"
4962
end
5063
if resultdim == 1
51-
GridVisualize.scalarplot!(p[row, col], sol[op[1]].FES.dofgrid, view(nodevalues(sol[op[1]], op[2]; abs = false), 1, :), title = title * title_add; kwargs...)
64+
if !average_broken_plots && ExtendableFEMBase.broken(sol[op[1]].FES)
65+
broken_scalarplot!(p[row, col], sol[op[1]], op[2]; title = title * title_add, kwargs...)
66+
else
67+
GridVisualize.scalarplot!(p[row, col], sol[op[1]].FES.dofgrid, view(nodevalues(sol[op[1]], op[2]; abs = false), 1, :), title = title * title_add; kwargs...)
68+
end
5269
elseif do_abs == true
5370
GridVisualize.scalarplot!(p[row, col], sol[op[1]].FES.dofgrid, view(nodevalues(sol[op[1]], op[2]; abs = true), 1, :), title = "|" * title * "|" * title_add; kwargs...)
5471
else
@@ -72,6 +89,31 @@ function plot!(p::GridVisualizer, ops, sol; rasterpoints = 10, linewidth = 1, ke
7289
end
7390

7491

92+
"""
93+
broken_scalarplot!(vis, feVectorBlock::FEVectorBlock, operator = Identity; kwargs...)
94+
95+
A "broken" scalarplot of a broken finite element vector.
96+
Instead of averaging the discontinuous values on the grid nodes, each grid cell is plotted
97+
independently. Thus, a discontinuous plot is generated.
98+
99+
All kwargs of the calling method are transferred to the scalarplot in this method.
100+
"""
101+
function broken_scalarplot!(vis, feVectorBlock::FEVectorBlock, operator = Identity; kwargs...)
102+
103+
dofgrid = feVectorBlock.FES.dofgrid
104+
cell_nodes = dofgrid[CellNodes]
105+
coords = dofgrid[Coordinates]
106+
107+
all_values = nodevalues(feVectorBlock, operator; cellwise = true) # cellwise evaluation of the FE
108+
all_coords = @views coords[:, cell_nodes[:]]
109+
all_cells = reshape(1:length(all_values), size(all_values))
110+
111+
GridVisualize.scalarplot!(vis, all_coords, all_cells, view(all_values, :); kwargs...)
112+
113+
return nothing
114+
end
115+
116+
75117
"""
76118
````
77119
function plot!(p::GridVisualizer, ops, sol; Plotter = nothing, kwargs...)

0 commit comments

Comments
 (0)