Skip to content

Commit

Permalink
make prim2phys the default for plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha committed Aug 18, 2024
1 parent 40dc766 commit 73a39a0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ for human readability.
- The abstract interface `AbstractShallowWaterEquations` was added to unify several
systems such as the `SerreGreenNaghdiEquations1D`, the `BBMBBMEquations1D`, and the
`SvärdKalischEquations1D` ([#127]).
- A new conversion function `prim2phys` was introduced, defaulting to `prim2prim`. `prim2phys` is the default conversion function for plotting.

## Changes when updating to v0.4 from v0.3.x

Expand Down
2 changes: 1 addition & 1 deletion docs/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ always plot to first subplot) and `plot_initial`. You can also provide a `conver
of the primitive variables `q` at one node, and the `equations` as input and should return an `SVector` of any length as output. For a user defined conversion function,
there should also exist a function `varnames(conversion, equations)` that returns a `Tuple` of the variable names used for labelling. The conversion function can, e.g.,
be [`prim2cons`](@ref) or [`waterheight_total`](@ref) if one only wants to plot the total water height. The resulting plot will have one subplot for each of the returned
variables of the conversion variable. By default, the conversion function is just [`prim2prim`](@ref), i.e. the identity.
variables of the conversion variable. By default, the conversion function is just [`prim2phys`](@ref), i.e., the identity for most equations.

Plotting an animation over time can, e.g., be done by the following command, which uses `step` to plot the solution at a specific time step.

Expand Down
4 changes: 2 additions & 2 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ get_name(equations::AbstractEquations) = equations |> typeof |> nameof |> string
Return the list of variable names when applying `conversion_function` to the
conserved variables associated to `equations`.
Common choices of the `conversion_function` are [`prim2prim`](@ref) and
[`prim2cons`](@ref).
Common choices of the `conversion_function` are [`prim2prim`](@ref),
[`prim2cons`](@ref), and [`prim2phys`](@ref).
"""
function varnames end

Expand Down
8 changes: 4 additions & 4 deletions src/visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,22 @@ end
end

@recipe function f(semisol::Pair{<:Semidiscretization, <:ODESolution}; plot_initial = false,
plot_bathymetry = true, conversion = prim2prim, step = -1)
plot_bathymetry = true, conversion = prim2phys, step = -1)
PlotData(semisol, plot_initial, plot_bathymetry, conversion, step)
end

@recipe function f(semi::Semidiscretization, sol::ODESolution; plot_initial = false,
plot_bathymetry = true, conversion = prim2prim, step = -1)
plot_bathymetry = true, conversion = prim2phys, step = -1)
PlotData(semi => sol, plot_initial, plot_bathymetry, conversion, step)
end

@recipe function f(semisol::Pair{<:Semidiscretization, <:ODESolution}, x_value;
conversion = prim2prim)
conversion = prim2phys)
PlotDataOverTime(semisol, x_value, conversion)
end

@recipe function f(semi::Semidiscretization, sol::ODESolution, x_value;
conversion = prim2prim)
conversion = prim2phys)
PlotDataOverTime(semi => sol, x_value, conversion)
end

Expand Down

0 comments on commit 73a39a0

Please sign in to comment.