Skip to content

Commit

Permalink
Merge pull request #49 from vavrines/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vavrines authored Oct 9, 2021
2 parents cb3d125 + c0b6279 commit d5caa50
Show file tree
Hide file tree
Showing 55 changed files with 820 additions and 1,372 deletions.
19 changes: 14 additions & 5 deletions dev/cylinder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ begin
ps = CSpace2D(1.0, 6.0, 30, 0.0, π, 50, 1, 1)
vs = VSpace2D(-10.0, 10.0, 48, -10.0, 10.0, 48)
gas = Gas(5e-2, 3.0, 1.0, 1.0)

prim0 = [1.0, 0.0, 0.0, 1.0]
prim1 = [1.0, gas.Ma * sound_speed(1.0, gas.γ), 0.0, 1.0]
fw = (args...) -> prim_conserve(prim1, gas.γ)
ff = function(args...)
ff = function (args...)
prim = conserve_prim(fw(args...), gas.γ)
h = maxwellian(vs.u, vs.v, prim)
b = h .* gas.K / 2 / prim[end]
return h, b
end
bc = function(x, y)
bc = function (x, y)
if abs(x^2 + y^2 - 1) < 1e-3
return prim0
else
Expand All @@ -48,14 +48,23 @@ dt = timestep(ks, ctr, 0.0)
nt = ks.set.maxTime ÷ dt |> Int
@showprogress for iter = 1:1000#nt
evolve!(ks, ctr, a1face, a2face, dt; bc = [:maxwell, :extra, :mirror, :mirror])
update!(ks, ctr, a1face, a2face, dt, zeros(4); bc = [:maxwell, :extra, :mirror, :mirror])
update!(
ks,
ctr,
a1face,
a2face,
dt,
zeros(4);
bc = [:maxwell, :extra, :mirror, :mirror],
)

for j = ks.ps.÷2+1:ks.ps.
ctr[ks.ps.nr+1, j].w .= ks.ib.fw(6, 0)
ctr[ks.ps.nr+1, j].prim .= conserve_prim(ctr[ks.ps.nr+1, j].w, ks.gas.γ)
ctr[ks.ps.nr+1, j].sw .= 0.0
ctr[ks.ps.nr+1, j].h .= maxwellian(ks.vs.u, ks.vs.v, ctr[ks.ps.nr+1, j].prim)
ctr[ks.ps.nr+1, j].b .= ctr[ks.ps.nr+1, j].h .* ks.gas.K ./ 2 ./ ctr[ks.ps.nr+1, j].prim[end]
ctr[ks.ps.nr+1, j].b .=
ctr[ks.ps.nr+1, j].h .* ks.gas.K ./ 2 ./ ctr[ks.ps.nr+1, j].prim[end]
end

global t += dt
Expand Down
6 changes: 3 additions & 3 deletions dev/reconstruct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nt = ks.set.maxTime ÷ dt |> Int
@inbounds Threads.@threads for i in eachindex(face)
vn = ks.vSpace.u .* face[i].n[1] .+ ks.vSpace.v .* face[i].n[2]
vt = ks.vSpace.v .* face[i].n[1] .- ks.vSpace.u .* face[i].n[2]
if !(-1 in ps.faceCells[i, :])
KitBase.flux_kfvs!(
face[i].fw,
Expand Down Expand Up @@ -94,7 +94,7 @@ nt = ks.set.maxTime ÷ dt |> Int
dt,
face[i].len,
)
face[i].fw .= KitBase.global_frame(face[i].fw, face[i].n[1], face[i].n[2])
end
end
Expand Down Expand Up @@ -140,7 +140,7 @@ nt = ks.set.maxTime ÷ dt |> Int
)
end
end
for i in eachindex(ps.cellType)
if ps.cellType[i] == 3
ids = ps.cellNeighbors[i, :]
Expand Down
2 changes: 1 addition & 1 deletion example/advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ anim = @animate for iter = 1:nt
evolve!(ks, ctr, face, dt)
update!(ks, ctr, face, dt, 0.0)

plot(ks, ctr, ylims=[-1, 1])
plot(ks, ctr, ylims = [-1, 1])
end

gif(anim, "advection.gif", fps = 45)
4 changes: 2 additions & 2 deletions example/sod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set = Setup(
ps = PSpace1D(0.0, 1.0, 100, 1)
vs = VSpace1D(-5.0, 5.0, 72)
gas = Gas(1e-4, 0.0, 1.0, 2.0)
fw, ff, bc = ib_sod(set, ps, vs, gas)
fw, ff, bc = config_ib(set, ps, vs, gas)
ib = IB1F(fw, ff, bc)

ks = SolverSet(set, ps, vs, gas, ib)
Expand All @@ -32,4 +32,4 @@ for iter = 1:nt
end

plot(ks, ctr)
plot_line(ks, ctr)
plot_line(ks, ctr)
6 changes: 1 addition & 5 deletions src/Boundary/bc_balance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ function bc_balance!(
return nothing
end

function bc_balance!(
ctr::T,
ctr0::T,
ctr1::T,
) where {T<:ControlVolume1D4F}
function bc_balance!(ctr::T, ctr0::T, ctr1::T) where {T<:ControlVolume1D4F}
@. ctr.w = 2.0 * ctr0.w - ctr1.w
@. ctr.prim = 2.0 * ctr0.prim - ctr1.prim
@. ctr.h0 = 2.0 * ctr0.h0 - ctr1.h0
Expand Down
12 changes: 8 additions & 4 deletions src/Boundary/bc_extra.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# ============================================================
# Extrapolation Functions
# ============================================================

function bc_extra!(
ctr::AbstractVector{T},
ng = 1::Integer;
dirc
dirc,
) where {T<:AbstractControlVolume1D}

if Symbol(dirc) in (:xl, :xL)
Expand All @@ -16,13 +20,13 @@ function bc_extra!(
end

return nothing

end

function bc_extra!(
ctr::AbstractMatrix{T},
ng = 1::Integer;
dirc
dirc,
) where {T<:AbstractControlVolume2D}

if Symbol(dirc) in (:xl, :xL)
Expand All @@ -46,5 +50,5 @@ function bc_extra!(
end

return nothing

end
24 changes: 8 additions & 16 deletions src/Boundary/bc_mirror.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# ============================================================
# Mirroring Functions
# ============================================================

function bc_mirror!(
ctr::AbstractMatrix{T},
ng = 1::Integer;
dirc
dirc,
) where {T<:AbstractControlVolume2D}

if Symbol(dirc) in (:xl, :xL)
Expand All @@ -28,11 +32,7 @@ function bc_mirror!(

end

function bc_mirror!(
ctr::ControlVolume2D,
ctr0::ControlVolume2D,
dirc
)
function bc_mirror!(ctr::ControlVolume2D, ctr0::ControlVolume2D, dirc)
copy_ctr!(ctr, ctr0)

if Symbol(dirc) == :x
Expand All @@ -48,11 +48,7 @@ function bc_mirror!(
return nothing
end

function bc_mirror!(
ctr::ControlVolume2D1F,
ctr0::ControlVolume2D1F,
dirc
)
function bc_mirror!(ctr::ControlVolume2D1F, ctr0::ControlVolume2D1F, dirc)
copy_ctr!(ctr, ctr0)

nu = size(ctr.f, 1)
Expand All @@ -79,11 +75,7 @@ function bc_mirror!(
return nothing
end

function bc_mirror!(
ctr::ControlVolume2D2F,
ctr0::ControlVolume2D2F,
dirc
)
function bc_mirror!(ctr::ControlVolume2D2F, ctr0::ControlVolume2D2F, dirc)
copy_ctr!(ctr, ctr0)

nu = size(ctr.h, 1)
Expand Down
6 changes: 3 additions & 3 deletions src/Boundary/bc_period.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ============================================================
# Period Boundary Operations
# Period Functions
# ============================================================

function bc_period!(ctr::AbstractVector, ng = 1)
function bc_period!(ctr::AbstractVector{T}, ng = 1) where {T<:AbstractControlVolume}
nx = length(ctr) - 2 * ng

for i = 1:ng
Expand All @@ -13,7 +13,7 @@ function bc_period!(ctr::AbstractVector, ng = 1)
return nothing
end

function bc_period!(ctr::AbstractMatrix, ng; dirc)
function bc_period!(ctr::AbstractMatrix{T}, ng; dirc) where {T<:AbstractControlVolume}
if dirc == :x
nx = size(ctr, 1) - 2 * ng
for j in axes(ctr, 2), i = 1:ng
Expand Down
2 changes: 1 addition & 1 deletion src/Boundary/boundary.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ============================================================
# Boundary Treatments
# Boundary Methods
# ============================================================

include("bc_extra.jl")
Expand Down
45 changes: 0 additions & 45 deletions src/Config/brio-wu.txt

This file was deleted.

20 changes: 11 additions & 9 deletions src/Config/cfg_briowu.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""
ib_briowu(gam, uspace::T, mi, me) where {T<:AbstractArray{<:AbstractFloat,2}}
ib_briowu(set, ps, vs, gas)
ib_briowu(gam, mi, me, uspace)
ib_briowu(gam, mi, me, uspace, vspace)
Initialize Brio-Wu MHD shock tube
Expand Down Expand Up @@ -52,36 +54,36 @@ function ib_briowu(
BR[2] = -1.0
lorenzR = zeros(3, 2)

fw = function(x)
fw = function (x)
if x <= (ps.x0 + ps.x1) / 2
return wL
else
return wR
end
end
fE = function(x)
fE = function (x)
if x <= (ps.x0 + ps.x1) / 2
return EL
else
return ER
end
end
fB = function(x)
fB = function (x)
if x <= (ps.x0 + ps.x1) / 2
return BL
else
return BR
end
end
fL = function(x)
fL = function (x)
if x <= (ps.x0 + ps.x1) / 2
return lorenzL
else
return lorenzR
end
end

bc = function(x)
bc = function (x)
if x <= (ps.x0 + ps.x1) / 2
return primL
else
Expand Down Expand Up @@ -112,7 +114,7 @@ function ib_briowu(
(primR[3, j]^2 + primR[4, j]^2 + 2.0 / (2.0 * primR[end, j])) .* h0R[:, j]
end

ff = function(x)
ff = function (x)
if x <= (ps.x0 + ps.x1) / 2
return h0L, h1L, h2L, h3L
else
Expand All @@ -138,7 +140,7 @@ function ib_briowu(
h2R[:, :, j] .= (primR[4, j]^2 + 1.0 / (2.0 * primR[end, j])) .* h0R[:, :, j]
end

ff = function(x)
ff = function (x)
if x <= (ps.x0 + ps.x1) / 2
return h0L, h1L, h2L
else
Expand All @@ -153,7 +155,7 @@ function ib_briowu(

end

function ib_briowu(gam, mi, me, uspace::T) where {T<:AbstractArray{<:AbstractFloat,2}}
function ib_briowu(gam, mi, me, uspace::AbstractMatrix{T}) where {T<:AbstractFloat}

# upstream
primL = zeros(5, 2)
Expand Down
12 changes: 5 additions & 7 deletions src/Config/cfg_cavity.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""
2d0f0v: ib_cavity(gam, Um, Vm, Tm) where {T<:AbstractArray{<:AbstractFloat,2}}
2d1f2v: ib_cavity(gam, Um, Vm, Tm, u::T, v::T) where {T<:AbstractArray{<:AbstractFloat,2}}
2d2f2v: ib_cavity(gam, Um, Vm, Tm, u::T, v::T, K) where {T<:AbstractArray{<:AbstractFloat,2}}
ib_cavity(set, ps, vs, gas, Um = 0.15, Vm = 0.0, Tm = 1.0)
Initialize lid-driven cavity
"""
Expand All @@ -27,11 +25,11 @@ function ib_cavity(
primL = deepcopy(prim)
primR = deepcopy(prim)

fw = function(args...)
fw = function (args...)
return w
end

bc = function(x, y)
bc = function (x, y)
if y == ps.y1
return primU
else
Expand All @@ -42,13 +40,13 @@ function ib_cavity(
if set.space[1:4] == "2d0f"
return fw, bc
elseif set.space == "2d1f2v"
ff = function(args...)
ff = function (args...)
return h
end

return fw, ff, bc
elseif set.space == "2d2f2v"
ff = function(args...)
ff = function (args...)
return h, b
end

Expand Down
Loading

2 comments on commit d5caa50

@vavrines
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/46374

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.3 -m "<description of version>" d5caa50fab93eea8d9c451782214ed0aa4e0b087
git push origin v0.7.3

Please sign in to comment.