Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions deprecated/flux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ function calc_flux!(::Val{1}, ::Val{0}, face::Face, AMR_2D::KitAMR_Data_2D, face
# end
@. vs_data.flux[:, 2] += vn * rot * ps_data.ds[dir] * gas.Δt * B
end
function make_face_data(ps_data::PS_Data_2D, nps_data::AbstractPsData, rot::Float64, dir::Int)
function make_face_data(
ps_data::PS_Data_2D,
nps_data::AbstractPsData,
rot::Float64,
dir::Int,
)
vs_data = ps_data.vs_data
midpoint_L = vs_data.midpoint
vs_data_n = nps_data.vs_data
Expand Down Expand Up @@ -328,7 +333,7 @@ function calc_flux!(::Val{0}, ::Val{2}, face::Face, AMR_2D::KitAMR_Data_2D, face
# @show ps_data.neighbor.data[faceid][2].midpoint
# end
fw_test = zeros(DIM + 2)
for i = 1:2^(DIM-1)
for i = 1:(2^(DIM-1))
nps_data = ps_data.neighbor.data[faceid][i]
vs_data_n = nps_data.vs_data
ds = nps_data.ds[dir]
Expand Down
172 changes: 111 additions & 61 deletions deprecated/flux_UGKS.jl

Large diffs are not rendered by default.

50 changes: 34 additions & 16 deletions deprecated/flux_copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,15 @@ function update_face_data_L!(
df_L = @view(vs_data.df[bit_L, :])
end
f_vs_data.midpoint =
Vcat(@view(midpoint_L[bit_L, :]), @view(f_vs_data.midpoint[offset+1:end, :]))
Vcat(@view(midpoint_L[bit_L, :]), @view(f_vs_data.midpoint[(offset+1):end, :]))
f_vs_data.vn = @view(f_vs_data.midpoint[:, DIR])
f_vs_data.df = Vcat(df_L, @view(f_vs_data.df[offset+1:end, :]))
f_vs_data.sdf =
Vcat(@view(vs_data.sdf[bit_L, :, DIR]), @view(f_vs_data.sdf[offset+1:end, :, DIR]))
f_vs_data.df = Vcat(df_L, @view(f_vs_data.df[(offset+1):end, :]))
f_vs_data.sdf = Vcat(
@view(vs_data.sdf[bit_L, :, DIR]),
@view(f_vs_data.sdf[(offset+1):end, :, DIR])
)
f_vs_data.weight =
Vcat(@view(vs_data.weight[bit_L]), @view(f_vs_data.weight[offset+1:end]))
Vcat(@view(vs_data.weight[bit_L]), @view(f_vs_data.weight[(offset+1):end]))
offset = length(df_L)
return (bit_L, offset)
end
Expand All @@ -373,13 +375,15 @@ function update_face_data_L!(
df_L = @view(vs_data.df[bit_L, :])
end
f_vs_data.midpoint =
Vcat(@view(midpoint_L[bit_L, :]), @view(f_vs_data.midpoint[offset+1:end, :]))
Vcat(@view(midpoint_L[bit_L, :]), @view(f_vs_data.midpoint[(offset+1):end, :]))
f_vs_data.vn = @view(f_vs_data.midpoint[:, DIR])
f_vs_data.df = Vcat(df_L, @view(f_vs_data.df[offset+1:end, :]))
f_vs_data.sdf =
Vcat(@view(vs_data.sdf[bit_L, :, DIR]), @view(f_vs_data.sdf[offset+1:end, :, DIR]))
f_vs_data.df = Vcat(df_L, @view(f_vs_data.df[(offset+1):end, :]))
f_vs_data.sdf = Vcat(
@view(vs_data.sdf[bit_L, :, DIR]),
@view(f_vs_data.sdf[(offset+1):end, :, DIR])
)
f_vs_data.weight =
Vcat(@view(vs_data.weight[bit_L]), @view(f_vs_data.weight[offset+1:end]))
Vcat(@view(vs_data.weight[bit_L]), @view(f_vs_data.weight[(offset+1):end]))
offset = length(df_L)
return (bit_L, offset)
end
Expand Down Expand Up @@ -497,7 +501,9 @@ function calc_flux!(::HalfSizeNeighbor, face::Face, amr::KitAMR_Data{3,1})
gas = global_data.config.gas
ds = ps_data.ds[DIR]
vs_data = ps_data.vs_data
f_vs_data = nothing; offset = 0; bit_L = nothing
f_vs_data = nothing;
offset = 0;
bit_L = nothing
for i = 1:4
nps_data = ps_data.neighbor.data[faceid][i]
vs_data_n = nps_data.vs_data
Expand Down Expand Up @@ -560,9 +566,15 @@ function calc_flux!(::DoubleSizeNeighbor, face::Face, amr::KitAMR_Data{2,2})
micro_flux = calc_micro_flux(f_vs_data, F, F⁺, aL, aR, A, Mt, offset, dsf)
update_vs_flux!(micro_flux, bit_L, vs_data, vs_data_n, offset, ROT)
for i in eachindex(face.hanging_data)
(isa(face.hanging_data[i], Ghost_PS_Data)||isa(face.hanging_data[i],MissingHangingQuad)) && continue
(
isa(
face.hanging_data[i],
Ghost_PS_Data,
)||isa(face.hanging_data[i], MissingHangingQuad)
) && continue
ps_data = face.hanging_data[i]
bit_L, offset = update_face_data_L!(ps_data, nps_data, f_vs_data, offset, faceid, ROT, DIR)
bit_L, offset =
update_face_data_L!(ps_data, nps_data, f_vs_data, offset, faceid, ROT, DIR)
reconstruct_vs_L!(f_vs_data, ds, offset, ROT)
w0 = calc_w0(f_vs_data)
prim0 = get_prim(w0, global_data)
Expand Down Expand Up @@ -612,9 +624,15 @@ function calc_flux!(::DoubleSizeNeighbor, face::Face, amr::KitAMR_Data{3,1})
micro_flux = calc_micro_flux(f_vs_data, F, F⁺, aL, aR, A, Mt, offset, dsf)
update_vs_flux!(micro_flux, bit_L, vs_data, vs_data_n, offset, ROT)
for i in eachindex(face.hanging_data)
(isa(face.hanging_data[i], Ghost_PS_Data)||isa(face.hanging_data[i],MissingHangingQuad)) && continue
(
isa(
face.hanging_data[i],
Ghost_PS_Data,
)||isa(face.hanging_data[i], MissingHangingQuad)
) && continue
ps_data = face.hanging_data[i]
bit_L, offset = update_face_data_L!(ps_data, nps_data, f_vs_data, offset, faceid, ROT, DIR)
bit_L, offset =
update_face_data_L!(ps_data, nps_data, f_vs_data, offset, faceid, ROT, DIR)
reconstruct_vs_L!(f_vs_data, ds, offset, ROT)
w0 = calc_w0(f_vs_data)
prim0 = get_prim(w0, global_data)
Expand All @@ -639,4 +657,4 @@ function update_flux!(amr::KitAMR_Data)
face = faces[i]
calc_flux!(Val(face.data.neighbor.state[face.faceid]), face, amr)
end
end
end
38 changes: 29 additions & 9 deletions deprecated/gaussian_weight.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
# In gaussian weighted adaptive method, ps_data.sw and vs_data.flux[:,1] are respectively used to store prims(the aux_pointed (by fluids) one and the interpolated one) and Θ
function gaussian_weight(λ::Float64,midpoint_in::AbstractVector,midpoint_out::AbstractVector) # here, midpoint represents the thermal velocity
exp(-λ*(sum(midpoint_in.^2)-sum(midpoint_out.^2)))
function gaussian_weight(
λ::Float64,
midpoint_in::AbstractVector,
midpoint_out::AbstractVector,
) # here, midpoint represents the thermal velocity
exp(-λ*(sum(midpoint_in .^ 2)-sum(midpoint_out .^ 2)))
end
function df_refine(df::AbstractVector,midpoints::AbstractMatrix,midpoint::AbstractVector,U::AbstractVector,prim::AbstractVector,::PS_Data{DIM,NDF}) where{DIM,NDF}
function df_refine(
df::AbstractVector,
midpoints::AbstractMatrix,
midpoint::AbstractVector,
U::AbstractVector,
prim::AbstractVector,
::PS_Data{DIM,NDF},
) where {DIM,NDF}
λ = prim[end]
weights = [gaussian_weight(λ,x-U,midpoint-U) for x in eachrow(midpoints)]
df_new = [weights[i]*df[j] for i in 1:2^DIM, j in 1:NDF]
weights = [gaussian_weight(λ, x-U, midpoint-U) for x in eachrow(midpoints)]
df_new = [weights[i]*df[j] for i = 1:(2^DIM), j = 1:NDF]
return df_new
end
function df_coarsen(df::AbstractMatrix,midpoint::AbstractVector,midpoints::AbstractMatrix,U::AbstractVector,prim::AbstractVector)
function df_coarsen(
df::AbstractMatrix,
midpoint::AbstractVector,
midpoints::AbstractMatrix,
U::AbstractVector,
prim::AbstractVector,
)
λ = prim[end]
weight = exp(-λ*sum((midpoint-U).^2))/sum([exp(-λ*sum((x-U).^2)) for x in eachrow(midpoints)])
df_new = vec(sum(df;dims=1)*weight)
weight =
exp(
-λ*sum((midpoint-U) .^ 2),
)/sum([exp(-λ*sum((x-U) .^ 2)) for x in eachrow(midpoints)])
df_new = vec(sum(df; dims = 1)*weight)
return df_new
end
# function flux_coarsen_replace!(index,lnflux,::PS_Data{DIM,NDF}) where{DIM,NDF}
Expand All @@ -31,4 +51,4 @@ end
# for _ in 1:(NDF-1)*(2^DIM-1)
# push!(0,lnflux)
# end
# end
# end
Loading