Skip to content

Commit

Permalink
Start
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyuxie committed Oct 16, 2024
1 parent cdd552f commit 810cd8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/solvers/dgmulti/dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ mul_by_accum!(A::UniformScaling) = MulByAccumUniformScaling()
StructArrays.foreachfield(f, args...)
end

# Matrix{<:SVector} fallback
@inline function apply_to_each_field(f::F, args::Vararg{Any, N}) where {F, N}
f(args...)
end

# specialize for UniformScaling types: works for either StructArray{SVector} or Matrix{SVector}
# solution storage formats.
@inline apply_to_each_field(f::MulByUniformScaling, out, x, args...) = copy!(out, x)
Expand Down Expand Up @@ -138,10 +143,8 @@ end

# Allocate nested array type for DGMulti solution storage.
function allocate_nested_array(uEltype, nvars, array_dimensions, dg)
# store components as separate arrays, combine via StructArrays
return StructArray{SVector{nvars, uEltype}}(ntuple(_ -> zeros(uEltype,
array_dimensions...),
nvars))
# store components as separate arrays, combine them into Matrix{SVector}
return zeros(SVector{nvars, uEltype}, array_dimensions...)
end

function reset_du!(du, dg::DGMulti, other_args...)
Expand Down
6 changes: 0 additions & 6 deletions src/solvers/dgmulti/flux_differencing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,6 @@ function compute_flux_differencing_SBP_matrices(dg::DGMultiFluxDiffSBP,
return Qrst_skew
end

# For flux differencing SBP-type approximations, store solutions in Matrix{SVector{nvars}}.
# This results in a slight speedup for `calc_volume_integral!`.
function allocate_nested_array(uEltype, nvars, array_dimensions, dg::DGMultiFluxDiffSBP)
return zeros(SVector{nvars, uEltype}, array_dimensions...)
end

function create_cache(mesh::DGMultiMesh, equations, dg::DGMultiFluxDiffSBP, RealT,
uEltype)
rd = dg.basis
Expand Down

0 comments on commit 810cd8e

Please sign in to comment.