Skip to content

Commit 9dc5de5

Browse files
fix plotting 1d function (#2271)
1 parent 74d5957 commit 9dc5de5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/visualization/recipes_plots.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ end
175175
# We need this recipe in addition to the one above to avoid method ambiguities.
176176
RecipesBase.@recipe function f(func::Function, semi::AbstractSemidiscretization;
177177
solution_variables = nothing)
178-
n_variables = length(func(0.0, semi.equations))
178+
n_variables = length(func(SVector(0.0), semi.equations))
179179
variable_names = SVector(["func[$i]" for i in 1:n_variables]...)
180180
if ndims(semi) == 1
181181
return PlotData1D(func, semi; solution_variables = cons2cons, variable_names)
@@ -210,7 +210,7 @@ RecipesBase.@recipe function f(func::Function,
210210
solution_variables = nothing,
211211
nvisnodes = nothing, slice = :xy,
212212
point = (0.0, 0.0, 0.0), curve = nothing)
213-
n_variables = length(func(0.0, semi.equations))
213+
n_variables = length(func(SVector(0.0), semi.equations))
214214
variable_names = SVector(["func[$i]" for i in 1:n_variables]...)
215215
if ndims(semi) == 1
216216
return PlotData1D(func, semi; solution_variables = cons2cons, nvisnodes, slice,

src/visualization/types.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ plotting. This can be changed by passing an appropriate conversion function to
529529
530530
Alternatively, you can also pass a function `u` with signature `u(x, equations)`
531531
returning a vector. In this case, the `solution_variables` are ignored. This is useful,
532-
e.g., to visualize an analytical solution.
532+
e.g., to visualize an analytical solution. The spatial variable `x` is a vector with one
533+
element.
533534
534535
`nvisnodes` specifies the number of visualization nodes to be used. If it is `nothing`,
535536
twice the number of solution DG nodes are used for visualization, and if set to `0`,
@@ -635,7 +636,7 @@ function PlotData1D(u, mesh::TreeMesh, equations, solver, cache;
635636
orientation_x)
636637
end
637638

638-
# unwrap u if it is VectorOfArray
639+
# unwrap u if it is VectorOfArray
639640
PlotData1D(u::VectorOfArray, mesh, equations, dg::DGMulti{1}, cache; kwargs...) = PlotData1D(parent(u),
640641
mesh,
641642
equations,

0 commit comments

Comments
 (0)