Skip to content
Snippets Groups Projects
Commit c1bee02d authored by Florian Atteneder's avatar Florian Atteneder
Browse files

GRHD: add tov symmetrization for all DG rhs' that use the spherical1d...

GRHD: add tov symmetrization for all DG rhs' that use the spherical1d (!195)
parent 51eb4aae
No related branches found
No related tags found
1 merge request!195GRHD: add tov symmetrization for all DG rhs' that use the spherical1d
Pipeline #7113 passed
Showing
with 153 additions and 93 deletions
...@@ -32,49 +32,40 @@ end ...@@ -32,49 +32,40 @@ end
function timestep(mesh, P::Project, hrsc::Maybe{HRSC.AbstractHRSC}) function timestep(mesh, P::Project, hrsc::Maybe{HRSC.AbstractHRSC})
compute_maxspeed(P, P.equation, mesh) compute_maxspeed(P, P.equation, mesh)
vmax = get_maxspeed(mesh, P.equation) vmax = get_maxspeed(mesh, P.equation)
dl = min_grid_spacing(mesh) L, = dg1d.widths(mesh)
dt = dl / (vmax * dtfactor(mesh)) K, = mesh.tree.dims
dL = L/K
dt = dL / (vmax * dtfactor(mesh))
return dt return dt
end end
dtfactor(mesh::Mesh1d{FVElement}) = 2 dtfactor(mesh::Mesh1d{FVElement}) = 2
dtfactor(mesh::Mesh1d{SpectralElement}) = 1 dtfactor(mesh::Mesh1d{SpectralElement}) = 1
function timestep(mesh::Mesh2d{SpectralElement}, P::Project, hrsc::Maybe{HRSC.AbstractHRSC}) function timestep(mesh::Mesh2d{SpectralElement}, P::Project, hrsc::Maybe{HRSC.AbstractHRSC})
compute_maxspeed(P, P.equation, mesh)
vmax = get_maxspeed(mesh, P.equation)
@unpack element = mesh @unpack element = mesh
@unpack N, z = element @unpack N, z = element
dx, dy = dg1d.widths(mesh.boxes[1]) compute_maxspeed(P, P.equation, mesh)
for box in view(mesh.boxes, 2:length(mesh.boxes)) vmax = get_maxspeed(mesh, P.equation)
ddx, ddy = dg1d.widths(box) Lx, Ly = dg1d.widths(mesh.boxes[1])
ddx < dx && (dx = ddx) Kx, Ky = mesh.tree.dims
ddy < dy && (dy = ddy) dL = min(Lx/Kx, Ly/Ky)
end dt = dL / (vmax * dtfactor(mesh))
dz = z[2]-z[1]
dl = min(dx, dy) * dz
dt = dl / (N * vmax)
return dt return dt
end end
function timestep(mesh, P::Project, hrsc::HRSC.AbstractArtificialViscosity) function timestep(mesh, P::Project, hrsc::HRSC.AbstractArtificialViscosity)
@unpack equation = P @unpack equation = P
compute_maxspeed(P, P.equation, mesh)
vmax = get_maxspeed(mesh, P.equation)
# @unpack mu = get_cell_variables(mesh)
# mumax = maximum(abs, mu)
@unpack smoothed_mu = get_static_variables(mesh) @unpack smoothed_mu = get_static_variables(mesh)
mumax = maximum(abs, smoothed_mu)
@unpack element = mesh @unpack element = mesh
@unpack N = element @unpack N = element
compute_maxspeed(P, P.equation, mesh)
vmax = get_maxspeed(mesh, P.equation)
mumax = maximum(abs, smoothed_mu)
L, = dg1d.widths(mesh) L, = dg1d.widths(mesh)
K, = mesh.tree.dims K, = mesh.tree.dims
dL = L/K dL = L/K
dl = min_grid_spacing(mesh) dl = min_grid_spacing(mesh)
dt1 = dl / (vmax * N) dt1 = dl / (vmax * N)
dt2 = dL^2 / (mumax * N^3) dt2 = dL^2 / (mumax * N^3)
dt = min(dt1, dt2) dt = min(dt1, dt2)
...@@ -1260,28 +1251,60 @@ function rhs!(mesh::Mesh1d, P::Project{:spherical1d}, hrsc::Nothing) ...@@ -1260,28 +1251,60 @@ function rhs!(mesh::Mesh1d, P::Project{:spherical1d}, hrsc::Nothing)
broadcast_volume!(flux_source_spherical1d, equation, mesh) broadcast_volume!(flux_source_spherical1d, equation, mesh)
impose_symmetry_sources!(P, mesh) impose_symmetry_sources!(P, mesh)
broadcast_faces!(llf_spherical1d, equation, mesh) broadcast_faces!(llf_spherical1d, equation, mesh)
if P.prms.problem === :bondi id = P.prms.id
broadcast_bdry!(bdryllf_spherical1d_bondi, equation, mesh) bc = P.prms.bc
elseif P.prms.problem === :tov if id == "bondi_accretion" || id == "bondi_accretion_infall"
if ismirrored(mesh) if bc == "from_id"
# already accounts for inflow boundary
broadcast_bdry!(bdryllf_spherical1d_bondi, equation, mesh)
else
TODO("unknown boundary conditions for initial data $id: $bc")
end
elseif id == "tov"
if bc == "tov_symmetric_domain"
# nothing todo, atmosphering should take care of outer bdrys
elseif bc == "tov_reflective_origin"
broadcast_bdry!(bdryllf_spherical1d_tov, equation, mesh) broadcast_bdry!(bdryllf_spherical1d_tov, equation, mesh)
else else
impose_symmetry_bdry_values_spherical1d!(mesh) TODO("unknown boundary conditions for initial data $id: $bc")
broadcast_bdry!(bdryllf_spherical1d_tov_reflected, equation, mesh)
end end
else else
TODO() TODO("unknown boundary conditions for initial data $id: $bc")
end end
compute_rhs_weak_form!(rhs_D, flr_D, src_D, nflr_D, mesh) if :D P.prms.freeze_vars
compute_rhs_weak_form!(rhs_Sr, flr_Sr, src_Sr, nflr_Sr, mesh) compute_rhs_weak_form!(rhs_D, flr_D, src_D, nflr_D, mesh)
compute_rhs_weak_form!(rhs_τ, flr_τ, src_τ, nflr_τ, mesh) end
if :Sr P.prms.freeze_vars
compute_rhs_weak_form!(rhs_Sr, flr_Sr, src_Sr, nflr_Sr, mesh)
end
if :τ P.prms.freeze_vars
compute_rhs_weak_form!(rhs_τ, flr_τ, src_τ, nflr_τ, mesh)
end
if !P.prms.atm_evolve if !P.prms.atm_evolve
broadcast_volume!(determine_atmosphere, P.equation, mesh) broadcast_volume!(determine_atmosphere, P.equation, mesh)
broadcast_volume!(stop_atmosphere_evolution_spherical1d, P.equation, mesh) broadcast_volume!(stop_atmosphere_evolution_spherical1d, P.equation, mesh)
end end
if bc == "tov_symmetric_domain"
# Need to symmetrize data around origin to avoid asymmetries to blow up there.
# This is needed, because near the surface the solution becomes asymmetric,
# and those errors are amplified when propagating inwards.
# Not sure if this is caused by the LDG/AV method or by the DG method itself.
korigin = find_cell_index(0.0, mesh)
for (k,(v_rhs_D, v_rhs_Sr, v_rhs_τ)) in enumerate(zip(eachcell(mesh,rhs_D),
eachcell(mesh,rhs_Sr),
eachcell(mesh,rhs_τ)))
if korigin == k
@views v_rhs_D .= (v_rhs_D .+ v_rhs_D[end:-1:1])./2
@views v_rhs_Sr .= (v_rhs_Sr .- v_rhs_Sr[end:-1:1])./2
@views v_rhs_τ .= (v_rhs_τ .+ v_rhs_τ[end:-1:1])./2
break
end
end
end
return return
end end
...@@ -1448,23 +1471,60 @@ function rhs!(mesh, P::Project{:spherical1d}, hrsc::HRSC.AbstractReconstruction) ...@@ -1448,23 +1471,60 @@ function rhs!(mesh, P::Project{:spherical1d}, hrsc::HRSC.AbstractReconstruction)
broadcast_volume!(flux_source_spherical1d, equation, mesh) broadcast_volume!(flux_source_spherical1d, equation, mesh)
impose_symmetry_sources!(P, mesh) impose_symmetry_sources!(P, mesh)
broadcast_faces!(llf_spherical1d, equation, mesh) broadcast_faces!(llf_spherical1d, equation, mesh)
if P.prms.problem === :bondi id = P.prms.id
broadcast_bdry!(bdryllf_spherical1d_bondi, equation, mesh) bc = P.prms.bc
elseif P.prms.problem === :tov if id == "bondi_accretion" || id == "bondi_accretion_infall"
broadcast_bdry!(bdryllf_spherical1d_tov, equation, mesh) if bc == "from_id"
# already accounts for inflow boundary
broadcast_bdry!(bdryllf_spherical1d_bondi, equation, mesh)
else
TODO("unknown boundary conditions for initial data $id: $bc")
end
elseif id == "tov"
if bc == "tov_symmetric_domain"
# nothing todo, atmosphering should take care of outer bdrys
elseif bc == "tov_reflective_origin"
broadcast_bdry!(bdryllf_spherical1d_tov, equation, mesh)
else
TODO("unknown boundary conditions for initial data $id: $bc")
end
else else
TODO() TODO("unknown boundary conditions for initial data $id: $bc")
end end
compute_rhs_weak_form!(rhs_D, flr_D, src_D, nflr_D, mesh) if :D P.prms.freeze_vars
compute_rhs_weak_form!(rhs_Sr, flr_Sr, src_Sr, nflr_Sr, mesh) compute_rhs_weak_form!(rhs_D, flr_D, src_D, nflr_D, mesh)
compute_rhs_weak_form!(rhs_τ, flr_τ, src_τ, nflr_τ, mesh) end
if :Sr P.prms.freeze_vars
compute_rhs_weak_form!(rhs_Sr, flr_Sr, src_Sr, nflr_Sr, mesh)
end
if :τ P.prms.freeze_vars
compute_rhs_weak_form!(rhs_τ, flr_τ, src_τ, nflr_τ, mesh)
end
if !P.prms.atm_evolve if !P.prms.atm_evolve
broadcast_volume!(determine_atmosphere, P.equation, mesh) broadcast_volume!(determine_atmosphere, P.equation, mesh)
broadcast_volume!(stop_atmosphere_evolution_spherical1d, P.equation, mesh) broadcast_volume!(stop_atmosphere_evolution_spherical1d, P.equation, mesh)
end end
if bc == "tov_symmetric_domain"
# Need to symmetrize data around origin to avoid asymmetries to blow up there.
# This is needed, because near the surface the solution becomes asymmetric,
# and those errors are amplified when propagating inwards.
# Not sure if this is caused by the LDG/AV method or by the DG method itself.
korigin = find_cell_index(0.0, mesh)
for (k,(v_rhs_D, v_rhs_Sr, v_rhs_τ)) in enumerate(zip(eachcell(mesh,rhs_D),
eachcell(mesh,rhs_Sr),
eachcell(mesh,rhs_τ)))
if korigin == k
@views v_rhs_D .= (v_rhs_D .+ v_rhs_D[end:-1:1])./2
@views v_rhs_Sr .= (v_rhs_Sr .- v_rhs_Sr[end:-1:1])./2
@views v_rhs_τ .= (v_rhs_τ .+ v_rhs_τ[end:-1:1])./2
break
end
end
end
return return
end end
......
...@@ -25,5 +25,5 @@ variables1d = [ "D_err", "D", "Sr", "τ", "p", "ρ", "ϵ", "vr" ] ...@@ -25,5 +25,5 @@ variables1d = [ "D_err", "D", "Sr", "τ", "p", "ρ", "ϵ", "vr" ]
aligned_ts = "$(collect(range(0.5,5.0,step=0.5)))" aligned_ts = "$(collect(range(0.5,5.0,step=0.5)))"
[Evolution] [Evolution]
cfl = 0.25 cfl = 0.2
tend = 5.0 tend = 5.0
No preview for this file type
No preview for this file type
[EquationOfState] [EquationOfState]
eos = "polytrope"
polytrope_k = 100.0
polytrope_gamma = 2.0 polytrope_gamma = 2.0
polytrope_k = 100.0
eos = "polytrope"
[Evolution]
cfl = 0.1
tend = 10.0
[Output]
aligned_ts = "$(collect(range(2.5,10.0,step=2.5)))"
variables1d = ["D", "Sx", "τ"]
[GRHD] [GRHD]
bc = "from_id"
id = "tov"
id_filename = "$(joinpath(ROOTDIR,\"initialdata\",\"TOV_stable.h5\"))" id_filename = "$(joinpath(ROOTDIR,\"initialdata\",\"TOV_stable.h5\"))"
atm_factor = 1e-8 atm_factor = 1.0e-8
id = "tov"
formulation = "doublecartoon" formulation = "doublecartoon"
bc = "from_id"
[Mesh] [Mesh]
range = [ 0, 20.0 ] periodic = false
n = 3 range = [0, 20.0]
k = 27 k = 27
basis = "lgl" basis = "lgl"
periodic = false n = 3
[Output]
variables1d = [ "D", "Sx", "τ" ]
aligned_ts = "$(collect(range(2.5,10.0,step=2.5)))"
[Evolution]
cfl = 0.3
tend = 10.0
No preview for this file type
[EquationOfState] [EquationOfState]
eos = "polytrope"
polytrope_k = 100.0
polytrope_gamma = 2.0 polytrope_gamma = 2.0
polytrope_k = 100.0
eos = "polytrope"
[Evolution]
cfl = 0.05
tend = 10.0
[Output]
aligned_ts = "$(collect(range(2.5,10.0,step=2.5)))"
variables1d = ["D", "Sr", "τ"]
[GRHD] [GRHD]
bc = "from_id"
id = "tov"
id_filename = "$(joinpath(ROOTDIR,\"initialdata\",\"TOV_stable.h5\"))"
atm_factor = 1e-8
atm_threshold_factor = 100.0 atm_threshold_factor = 100.0
id_filename = "$(joinpath(ROOTDIR,\"initialdata\",\"TOV_stable.h5\"))"
atm_factor = 1.0e-8
id = "tov"
formulation = "rescaled_spherical1d" formulation = "rescaled_spherical1d"
bc = "from_id"
[Mesh] [Mesh]
range = [ 0.0, 20.0 ] periodic = false
n = 7 range = [0.0, 20.0]
k = 47 k = 47
basis = "lgl" basis = "lgl"
periodic = false n = 5
[Output]
variables1d = [ "D", "Sr", "τ" ]
aligned_ts = "$(collect(range(2.5,10.0,step=2.5)))"
[Evolution]
cfl = 0.3
tend = 10.0
No preview for this file type
[EquationOfState] [EquationOfState]
eos = "polytrope"
polytrope_k = 100.0
polytrope_gamma = 2.0 polytrope_gamma = 2.0
polytrope_k = 100.0
eos = "polytrope"
[Evolution]
cfl = 0.1
tend = 10.0
[Output]
aligned_ts = "$(collect(range(2.5,10.0,step=2.5)))"
variables1d = ["D", "Sr", "τ"]
[GRHD] [GRHD]
bc = "from_id"
id = "tov"
id_filename = "$(joinpath(ROOTDIR,\"initialdata\",\"TOV_stable.h5\"))"
atm_factor = 1e-8
atm_threshold_factor = 100.0 atm_threshold_factor = 100.0
formulation = "spherical1d" id_filename = "$(joinpath(ROOTDIR,\"initialdata\",\"TOV_stable.h5\"))"
atm_factor = 1.0e-8
id = "tov"
c2p_enforce_causal_atm = false c2p_enforce_causal_atm = false
formulation = "spherical1d"
bc = "tov_symmetric_domain"
[Mesh] [Mesh]
range = [ 0.0, 20.0 ]
n = 4
k = 124
basis = "lgl"
periodic = false periodic = false
range = [-20.0, 20.0]
[Output] k = 203
variables1d = [ "D", "Sr", "τ" ] basis = "lgl"
aligned_ts = "$(collect(range(2.5,10.0,step=2.5)))" n = 5
[Evolution]
cfl = 0.4
tend = 10.0
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment