Skip to content

Commit 6349413

Browse files
huiyuxieranocha
andauthored
Fix redundant type conversion in LobattoLegendreBasis (#2239)
* Fix * Fix * Fix * Update src/solvers/dgsem/basis_lobatto_legendre.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Update src/solvers/dgsem/basis_lobatto_legendre.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Update src/solvers/dgsem/basis_lobatto_legendre.jl Co-authored-by: Hendrik Ranocha <[email protected]> * Format --------- Co-authored-by: Hendrik Ranocha <[email protected]>
1 parent fdd22a8 commit 6349413

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/solvers/dgsem/basis_lobatto_legendre.jl

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,27 @@ function LobattoLegendreBasis(RealT, polydeg::Integer)
4040
nodes_, weights_ = gauss_lobatto_nodes_weights(nnodes_, RealT)
4141
inverse_weights_ = inv.(weights_)
4242

43-
_, inverse_vandermonde_legendre_ = vandermonde_legendre(nodes_, RealT)
43+
_, inverse_vandermonde_legendre = vandermonde_legendre(nodes_, RealT)
4444

45-
boundary_interpolation_ = zeros(RealT, nnodes_, 2)
46-
boundary_interpolation_[:, 1] = calc_lhat(-one(RealT), nodes_, weights_)
47-
boundary_interpolation_[:, 2] = calc_lhat(one(RealT), nodes_, weights_)
45+
boundary_interpolation = zeros(RealT, nnodes_, 2)
46+
boundary_interpolation[:, 1] = calc_lhat(-one(RealT), nodes_, weights_)
47+
boundary_interpolation[:, 2] = calc_lhat(one(RealT), nodes_, weights_)
4848

49-
derivative_matrix_ = polynomial_derivative_matrix(nodes_)
50-
derivative_split_ = calc_dsplit(nodes_, weights_)
51-
derivative_split_transpose_ = Matrix(derivative_split_')
52-
derivative_dhat_ = calc_dhat(nodes_, weights_)
49+
derivative_matrix = polynomial_derivative_matrix(nodes_)
50+
derivative_split = calc_dsplit(nodes_, weights_)
51+
derivative_split_transpose = Matrix(derivative_split')
52+
derivative_dhat = calc_dhat(nodes_, weights_)
5353

54-
# type conversions to get the requested real type and enable possible
55-
# optimizations of runtime performance and latency
54+
# Type conversions to enable possible optimizations of runtime performance
55+
# and latency
5656
nodes = SVector{nnodes_, RealT}(nodes_)
5757
weights = SVector{nnodes_, RealT}(weights_)
5858
inverse_weights = SVector{nnodes_, RealT}(inverse_weights_)
5959

60-
inverse_vandermonde_legendre = convert.(RealT, inverse_vandermonde_legendre_)
61-
boundary_interpolation = convert.(RealT, boundary_interpolation_)
62-
63-
# Usually as fast as `SMatrix` (when using `let` in the volume integral/`@threaded`)
64-
derivative_matrix = Matrix{RealT}(derivative_matrix_)
65-
derivative_split = Matrix{RealT}(derivative_split_)
66-
derivative_split_transpose = Matrix{RealT}(derivative_split_transpose_)
67-
derivative_dhat = Matrix{RealT}(derivative_dhat_)
60+
# We keep the matrices above stored using the standard `Matrix` type
61+
# since this is usually as fast as `SMatrix`
62+
# (when using `let` in the volume integral/`@threaded`)
63+
# and reduces latency
6864

6965
return LobattoLegendreBasis{RealT, nnodes_, typeof(nodes),
7066
typeof(inverse_vandermonde_legendre),

0 commit comments

Comments
 (0)