Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Sep 11, 2023
1 parent 21d29f8 commit 29bd213
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 83 deletions.
10 changes: 6 additions & 4 deletions src/callbacks_step/amr_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ function refine!(u_ode::AbstractVector, adaptor, mesh::Union{TreeMesh{2}, TreeMe

# Sanity check
if mesh isa TreeMesh && isperiodic(mesh.tree) && nmortars(cache.mortars) == 0 &&
!mpi_isparallel()
@assert ninterfaces(cache_parabolic.interfaces)==ndims(mesh) * nelements(dg, cache_parabolic) ("For $(ndims(mesh))D and periodic domains and conforming elements, the number of interfaces must be $(ndims(mesh)) times the number of elements")
!mpi_isparallel()
@assert ninterfaces(cache_parabolic.interfaces)==ndims(mesh) *
nelements(dg, cache_parabolic) ("For $(ndims(mesh))D and periodic domains and conforming elements, the number of interfaces must be $(ndims(mesh)) times the number of elements")
end

return nothing
Expand Down Expand Up @@ -312,8 +313,9 @@ function coarsen!(u_ode::AbstractVector, adaptor, mesh::Union{TreeMesh{2}, TreeM

# Sanity check
if mesh isa TreeMesh && isperiodic(mesh.tree) && nmortars(cache.mortars) == 0 &&
!mpi_isparallel()
@assert ninterfaces(cache_parabolic.interfaces)==ndims(mesh) * nelements(dg, cache_parabolic) ("For $(ndims(mesh))D and periodic domains and conforming elements, the number of interfaces must be $(ndims(mesh)) times the number of elements")
!mpi_isparallel()
@assert ninterfaces(cache_parabolic.interfaces)==ndims(mesh) *
nelements(dg, cache_parabolic) ("For $(ndims(mesh))D and periodic domains and conforming elements, the number of interfaces must be $(ndims(mesh)) times the number of elements")
end

return nothing
Expand Down
2 changes: 1 addition & 1 deletion src/equations/compressible_euler_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ end

@inline function v1(u, equations::CompressibleEulerEquations1D)
rho, rho_v1, _ = u
return rho_v1/rho
return rho_v1 / rho
end

# Calculate thermodynamic entropy for a conservative state `cons`
Expand Down
4 changes: 2 additions & 2 deletions src/equations/compressible_euler_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1430,12 +1430,12 @@ end

@inline function v1(u, equations::CompressibleEulerEquations2D)
rho, rho_v1, _, _ = u
return rho_v1/rho
return rho_v1 / rho
end

@inline function v2(u, equations::CompressibleEulerEquations2D)
rho, _, rho_v2, _ = u
return rho_v2/rho
return rho_v2 / rho
end

# Calculates the entropy flux in direction "orientation" and the entropy variables for a state cons
Expand Down
6 changes: 3 additions & 3 deletions src/equations/compressible_euler_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1516,17 +1516,17 @@ end

@inline function v1(u, equations::CompressibleEulerEquations3D)
rho, rho_v1, _, _, _ = u
return rho_v1/rho
return rho_v1 / rho
end

@inline function v2(u, equations::CompressibleEulerEquations3D)
rho, _, rho_v2, _, _ = u
return rho_v2/rho
return rho_v2 / rho
end

@inline function v3(u, equations::CompressibleEulerEquations3D)
rho, _, _, rho_v3, _ = u
return rho_v3/rho
return rho_v3 / rho
end

# Calculate thermodynamic entropy for a conservative state `u`
Expand Down
4 changes: 2 additions & 2 deletions src/solvers/dgsem_tree/container_viscous_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mutable struct ViscousContainer1D{uEltype <: Real}
end

function init_viscous_container_1d(n_vars::Integer, n_nodes::Integer,
n_elements::Integer,
::Type{uEltype}) where {uEltype <: Real}
n_elements::Integer,
::Type{uEltype}) where {uEltype <: Real}
return ViscousContainer1D{uEltype}(n_vars, n_nodes, n_elements)
end

Expand Down
55 changes: 28 additions & 27 deletions src/solvers/dgsem_tree/container_viscous_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ mutable struct ViscousContainer2D{uEltype <: Real}
_gradients::Vector{Vector{uEltype}}
_flux_viscous::Vector{Vector{uEltype}}

function ViscousContainer2D{uEltype}(n_vars::Integer, n_nodes::Integer, n_elements::Integer) where {uEltype <: Real}
function ViscousContainer2D{uEltype}(n_vars::Integer, n_nodes::Integer,
n_elements::Integer) where {uEltype <: Real}
new(Array{uEltype, 4}(undef, n_vars, n_nodes, n_nodes, n_elements),
[Array{uEltype, 4}(undef, n_vars, n_nodes, n_nodes, n_elements) for _ in 1:2],
[Array{uEltype, 4}(undef, n_vars, n_nodes, n_nodes, n_elements) for _ in 1:2],
Vector{uEltype}(undef, n_vars * n_nodes^2 * n_elements),
[Vector{uEltype}(undef, n_vars * n_nodes^2 * n_elements) for _ in 1:2],
[Vector{uEltype}(undef, n_vars * n_nodes^2 * n_elements) for _ in 1:2])
end
end
end

function init_viscous_container_2d(n_vars::Integer, n_nodes::Integer,
Expand All @@ -31,31 +32,31 @@ end
# `unsafe_wrap`ping multi-dimensional `Array`s around the
# internal storage.
function Base.resize!(viscous_container::ViscousContainer2D, equations, dg, cache)
capacity = nvariables(equations) * nnodes(dg) * nnodes(dg) * nelements(dg, cache)
resize!(viscous_container._u_transformed, capacity)
for dim in 1:2
resize!(viscous_container._gradients[dim], capacity)
resize!(viscous_container._flux_viscous[dim], capacity)
end
capacity = nvariables(equations) * nnodes(dg) * nnodes(dg) * nelements(dg, cache)
resize!(viscous_container._u_transformed, capacity)
for dim in 1:2
resize!(viscous_container._gradients[dim], capacity)
resize!(viscous_container._flux_viscous[dim], capacity)
end

viscous_container.u_transformed = unsafe_wrap(Array,
pointer(viscous_container._u_transformed),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nelements(dg, cache)))
viscous_container.u_transformed = unsafe_wrap(Array,
pointer(viscous_container._u_transformed),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nelements(dg, cache)))

for dim in 1:2
viscous_container.gradients[dim] = unsafe_wrap(Array,
pointer(viscous_container._gradients[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nelements(dg, cache)))
for dim in 1:2
viscous_container.gradients[dim] = unsafe_wrap(Array,
pointer(viscous_container._gradients[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nelements(dg, cache)))

viscous_container.flux_viscous[dim] = unsafe_wrap(Array,
pointer(viscous_container._flux_viscous[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nelements(dg, cache)))
end
return nothing
end
viscous_container.flux_viscous[dim] = unsafe_wrap(Array,
pointer(viscous_container._flux_viscous[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nelements(dg, cache)))
end
return nothing
end
86 changes: 45 additions & 41 deletions src/solvers/dgsem_tree/container_viscous_3d.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
mutable struct ViscousContainer3D{uEltype <: Real}
u_transformed::Array{uEltype, 5}
# IDEA: Use SVector for fixed sized vectors?
gradients::Vector{Array{uEltype, 5}}
flux_viscous::Vector{Array{uEltype, 5}}
u_transformed::Array{uEltype, 5}
# IDEA: Use SVector for fixed sized vectors?
gradients::Vector{Array{uEltype, 5}}
flux_viscous::Vector{Array{uEltype, 5}}

# internal `resize!`able storage
_u_transformed::Vector{uEltype}
_gradients::Vector{Vector{uEltype}}
_flux_viscous::Vector{Vector{uEltype}}
# internal `resize!`able storage
_u_transformed::Vector{uEltype}
_gradients::Vector{Vector{uEltype}}
_flux_viscous::Vector{Vector{uEltype}}

function ViscousContainer3D{uEltype}(n_vars::Integer, n_nodes::Integer, n_elements::Integer) where {uEltype <: Real}
new(Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements),
[Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements) for _ in 1:3],
[Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements) for _ in 1:3],
Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),
[Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements) for _ in 1:3],
[Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements) for _ in 1:3])
end
function ViscousContainer3D{uEltype}(n_vars::Integer, n_nodes::Integer,
n_elements::Integer) where {uEltype <: Real}
new(Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements),
[Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements)
for _ in 1:3],
[Array{uEltype, 5}(undef, n_vars, n_nodes, n_nodes, n_nodes, n_elements)
for _ in 1:3],
Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements),
[Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements) for _ in 1:3],
[Vector{uEltype}(undef, n_vars * n_nodes^3 * n_elements) for _ in 1:3])
end
end


function init_viscous_container_3d(n_vars::Integer, n_nodes::Integer,
n_elements::Integer,
::Type{uEltype}) where {uEltype <: Real}
Expand All @@ -32,31 +34,33 @@ end
# `unsafe_wrap`ping multi-dimensional `Array`s around the
# internal storage.
function Base.resize!(viscous_container::ViscousContainer3D, equations, dg, cache)
capacity = nvariables(equations) * nnodes(dg) * nnodes(dg) * nnodes(dg) * nelements(dg, cache)
resize!(viscous_container._u_transformed, capacity)
for dim in 1:3
resize!(viscous_container._gradients[dim], capacity)
resize!(viscous_container._flux_viscous[dim], capacity)
end

viscous_container.u_transformed = unsafe_wrap(Array,
pointer(viscous_container._u_transformed),
(nvariables(equations),
nnodes(dg), nnodes(dg), nnodes(dg),
nelements(dg, cache)))
capacity = nvariables(equations) * nnodes(dg) * nnodes(dg) * nnodes(dg) *
nelements(dg, cache)
resize!(viscous_container._u_transformed, capacity)
for dim in 1:3
resize!(viscous_container._gradients[dim], capacity)
resize!(viscous_container._flux_viscous[dim], capacity)
end

for dim in 1:3
viscous_container.gradients[dim] = unsafe_wrap(Array,
pointer(viscous_container._gradients[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg), nnodes(dg),
nelements(dg, cache)))
viscous_container.u_transformed = unsafe_wrap(Array,
pointer(viscous_container._u_transformed),
(nvariables(equations),
nnodes(dg), nnodes(dg), nnodes(dg),
nelements(dg, cache)))

viscous_container.flux_viscous[dim] = unsafe_wrap(Array,
pointer(viscous_container._flux_viscous[dim]),
(nvariables(equations),
for dim in 1:3
viscous_container.gradients[dim] = unsafe_wrap(Array,
pointer(viscous_container._gradients[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg), nnodes(dg),
nelements(dg, cache)))
end
return nothing
end

viscous_container.flux_viscous[dim] = unsafe_wrap(Array,
pointer(viscous_container._flux_viscous[dim]),
(nvariables(equations),
nnodes(dg), nnodes(dg),
nnodes(dg),
nelements(dg, cache)))
end
return nothing
end
2 changes: 1 addition & 1 deletion src/solvers/dgsem_tree/containers_viscous.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dimension-specific implementations
include("container_viscous_1d.jl")
include("container_viscous_2d.jl")
include("container_viscous_3d.jl")
include("container_viscous_3d.jl")
2 changes: 1 addition & 1 deletion src/solvers/dgsem_tree/dg_2d_parabolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ function calc_viscous_fluxes!(flux_viscous, gradients, u_transformed,
end
end

function calc_viscous_fluxes!(flux_viscous::Vector{Array{uEltype, 4}},
function calc_viscous_fluxes!(flux_viscous::Vector{Array{uEltype, 4}},
gradients::Vector{Array{uEltype, 4}}, u_transformed,
mesh::TreeMesh{2},
equations_parabolic::AbstractEquationsParabolic,
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/dgsem_tree/dg_3d_parabolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function calc_viscous_fluxes!(flux_viscous, gradients, u_transformed,
end
end

function calc_viscous_fluxes!(flux_viscous::Vector{Array{uEltype, 5}},
function calc_viscous_fluxes!(flux_viscous::Vector{Array{uEltype, 5}},
gradients::Vector{Array{uEltype, 5}}, u_transformed,
mesh::TreeMesh{3},
equations_parabolic::AbstractEquationsParabolic,
Expand Down

0 comments on commit 29bd213

Please sign in to comment.