Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMR for parabolic terms in 2D & 3D on TreeMeshes #1629

Merged
merged 100 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
b33cbc2
Clean branch
DanielDoehring Aug 14, 2023
7e32e24
Un-Comment
DanielDoehring Aug 14, 2023
5e1997b
un-comment
DanielDoehring Aug 14, 2023
54e328e
test coarsen
DanielDoehring Aug 14, 2023
a9e4cb7
remove redundancy
DanielDoehring Aug 14, 2023
ebb5865
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 15, 2023
4f72a09
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 15, 2023
70568f5
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 16, 2023
ebc9cc8
Remove support for passive terms
DanielDoehring Aug 18, 2023
9c766b9
expand resize
DanielDoehring Aug 18, 2023
c63e8b7
Merge branch 'Parabolic_AMR_1D' of github.com:DanielDoehring/Trixi.jl…
DanielDoehring Aug 18, 2023
82894d7
comments
DanielDoehring Aug 18, 2023
6ef88ca
format
DanielDoehring Aug 18, 2023
7e4a450
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 19, 2023
53f5991
Avoid code duplication
DanielDoehring Aug 20, 2023
daf6fc4
Merge branch 'Parabolic_AMR_1D' of github.com:DanielDoehring/Trixi.jl…
DanielDoehring Aug 20, 2023
cdfe93b
Update src/callbacks_step/amr_dg1d.jl
DanielDoehring Aug 22, 2023
0f2b779
comment
DanielDoehring Aug 22, 2023
376f99e
comment & format
DanielDoehring Aug 22, 2023
1dcfed4
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 22, 2023
baec78f
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 22, 2023
8526d16
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 22, 2023
826553f
Try to increase coverage
DanielDoehring Aug 28, 2023
9363b52
Merge branch 'Parabolic_AMR_1D' of github.com:DanielDoehring/Trixi.jl…
DanielDoehring Aug 28, 2023
d209629
Slightly more expressive names
DanielDoehring Aug 29, 2023
abce5ae
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Aug 31, 2023
a7d56a1
Apply suggestions from code review
sloede Sep 1, 2023
133c6a6
Merge branch 'main' into Parabolic_AMR_1D
sloede Sep 1, 2023
d348b82
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Sep 6, 2023
f87046d
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Sep 6, 2023
0c7dcb0
Merge branch 'main' into Parabolic_AMR_1D
DanielDoehring Sep 7, 2023
abb6dfb
add specifier for 1d
DanielDoehring Sep 11, 2023
bfa3a24
Structs for resizing parabolic helpers
DanielDoehring Sep 11, 2023
40ad266
check if mortars are present
DanielDoehring Sep 11, 2023
4d1914b
reuse `reinitialize_containers!`
DanielDoehring Sep 11, 2023
70c8e66
resize calls for parabolic helpers
DanielDoehring Sep 11, 2023
a5db7d0
update analysis callbacks
DanielDoehring Sep 11, 2023
c9d98a2
Velocities for compr euler
DanielDoehring Sep 11, 2023
694e6bc
Init container
DanielDoehring Sep 11, 2023
07655a4
correct copy-paste error
DanielDoehring Sep 11, 2023
edd82ce
resize each dim
DanielDoehring Sep 11, 2023
ba1ef1b
add dispatch
DanielDoehring Sep 11, 2023
7d351e5
Add AMR for shear layer
DanielDoehring Sep 11, 2023
e608174
USe only amr shear layer
DanielDoehring Sep 11, 2023
6574bf5
first steps towards p4est parabolic amr
DanielDoehring Sep 11, 2023
4c35430
Add tests
DanielDoehring Sep 11, 2023
21d29f8
remove plots
DanielDoehring Sep 11, 2023
29bd213
Format
DanielDoehring Sep 11, 2023
cb3eac8
remove redundant line
DanielDoehring Sep 11, 2023
7e68d94
platform independent tests
DanielDoehring Sep 11, 2023
0eadf49
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 12, 2023
5c20c4f
No need for different flux_viscous comps after adding container_visco…
DanielDoehring Sep 12, 2023
a0b6e3a
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Sep 12, 2023
21ccff4
Laplace 3d
DanielDoehring Sep 12, 2023
06a7811
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 15, 2023
591132b
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 18, 2023
d1b8316
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 20, 2023
07cf0ba
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 20, 2023
8df117b
Longer times to allow converage to hit coarsen!
DanielDoehring Sep 20, 2023
ff77769
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Sep 20, 2023
cdaa865
Increase testing of Laplace 3D
DanielDoehring Sep 20, 2023
4699a10
Add tests for velocities
DanielDoehring Sep 20, 2023
306c9b0
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 20, 2023
0129b5e
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 22, 2023
ac1c1ca
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Sep 22, 2023
5f0051c
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
jlchan Oct 4, 2023
389d89c
remove comment
DanielDoehring Oct 5, 2023
03be339
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Oct 5, 2023
1d4486a
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 5, 2023
a79a2f6
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
jlchan Oct 10, 2023
a5ddabe
Add comments
DanielDoehring Oct 11, 2023
ed2c95d
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 11, 2023
bc34831
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
jlchan Oct 11, 2023
2d960fc
Remove some specializations
DanielDoehring Oct 11, 2023
22eeb18
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Oct 11, 2023
9435d4e
Add comments
DanielDoehring Oct 11, 2023
77b3b02
Use tuple for outer, fixed size datastruct for internal quantities
DanielDoehring Oct 12, 2023
2297486
Format
DanielDoehring Oct 12, 2023
230b083
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
jlchan Oct 12, 2023
3079153
Add comments
DanielDoehring Oct 18, 2023
825ff34
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Oct 18, 2023
0484fb9
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 18, 2023
1d50359
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 19, 2023
a6f21c5
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 21, 2023
e2e287a
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
jlchan Oct 21, 2023
e8f2a66
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
jlchan Oct 21, 2023
9c32ae2
Update examples/tree_2d_dgsem/elixir_navierstokes_shearlayer_amr.jl
DanielDoehring Oct 22, 2023
1a42c15
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 22, 2023
67c1027
Update src/Trixi.jl
DanielDoehring Oct 22, 2023
09f1e85
Move velocity into elixir
DanielDoehring Oct 22, 2023
67647b4
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Oct 22, 2023
00a827d
remove tests
DanielDoehring Oct 22, 2023
fa893cb
Remove deprecated comments
DanielDoehring Oct 23, 2023
2272cda
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 23, 2023
827f6e1
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 23, 2023
d452930
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 23, 2023
202106b
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 24, 2023
b8a010d
Add news
DanielDoehring Oct 24, 2023
0353488
Merge branch 'AMR_Parabolic_2D3D_Tree' of github.com:DanielDoehring/T…
DanielDoehring Oct 24, 2023
5877e7a
Merge branch 'main' into AMR_Parabolic_2D3D_Tree
DanielDoehring Oct 25, 2023
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ for human readability.
- Wetting and drying feature and examples for 1D and 2D shallow water equations
- Implementation of the polytropic Euler equations in 2D
- Subcell positivity limiting support for conservative variables in 2D for `TreeMesh`
- AMR for hyperbolic-parabolic equations on 2D/3D `TreeMesh`

#### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ using Trixi

# TODO: parabolic; unify names of these accessor functions
prandtl_number() = 0.72
mu() = 1.0/3.0 * 10^(-3) # equivalent to Re = 3000
mu() = 1.0/3.0 * 10^(-5) # equivalent to Re = 30,000

equations = CompressibleEulerEquations2D(1.4)
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu=mu(),
Prandtl=prandtl_number())

"""
A compressible version of the double shear layer initial condition. Adapted from
Brown and Minion (1995).

- David L. Brown and Michael L. Minion (1995)
Performance of Under-resolved Two-Dimensional Incompressible Flow Simulations.
[DOI: 10.1006/jcph.1995.1205](https://doi.org/10.1006/jcph.1995.1205)
"""
function initial_condition_shear_layer(x, t, equations::CompressibleEulerEquations2D)
# Shear layer parameters
k = 80
Expand All @@ -22,8 +30,8 @@ function initial_condition_shear_layer(x, t, equations::CompressibleEulerEquatio
Ms = 0.1 # maximum Mach number

rho = 1.0
v1 = x[2] <= 0.5 ? u0 * tanh(k*(x[2]*0.5 - 0.25)) : u0 * tanh(k*(0.75 -x[2]*0.5))
v2 = u0 * delta * sin(2*pi*(x[1]*0.5 + 0.25))
v1 = x[2] <= 0.5 ? u0 * tanh(k*(x[2] - 0.25)) : u0 * tanh(k*(0.75 -x[2]))
v2 = u0 * delta * sin(2*pi*(x[1]+ 0.25))
sloede marked this conversation as resolved.
Show resolved Hide resolved
p = (u0 / Ms)^2 * rho / equations.gamma # scaling to get Ms

return prim2cons(SVector(rho, v1, v2, p), equations)
Expand All @@ -47,27 +55,43 @@ semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabol
###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 2.0)
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 50
analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true,
extra_analysis_integrals=(energy_kinetic,
energy_internal,
enstrophy))
analysis_interval = 2000
analysis_callback = AnalysisCallback(semi, interval=analysis_interval)

alive_callback = AliveCallback(analysis_interval=analysis_interval,)

# This uses velocity-based AMR
@inline function v1(u, equations::CompressibleEulerEquations2D)
rho, rho_v1, _, _ = u
return rho_v1 / rho
end
amr_indicator = IndicatorLöhner(semi, variable=v1)
amr_controller = ControllerThreeLevel(semi, amr_indicator,
base_level = 3,
med_level = 5, med_threshold=0.2,
max_level = 7, max_threshold=0.5)
amr_callback = AMRCallback(semi, amr_controller,
interval=50,
adapt_initial_condition=true,
adapt_initial_condition_only_refine=true)

stepsize_callback = StepsizeCallback(cfl=1.3)

callbacks = CallbackSet(summary_callback,
analysis_callback,
alive_callback)
alive_callback,
amr_callback,
stepsize_callback)

###############################################################################
# run the simulation

time_int_tol = 1e-8
sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol,
ode_default_options()..., callback=callbacks)
sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false),
dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep=false, callback=callbacks);
summary_callback() # print the timer summary
93 changes: 93 additions & 0 deletions examples/tree_3d_dgsem/elixir_advection_diffusion_amr.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the linear advection equation

advection_velocity = (0.2, -0.7, 0.5)
equations = LinearScalarAdvectionEquation3D(advection_velocity)

diffusivity() = 5.0e-4
equations_parabolic = LaplaceDiffusion3D(diffusivity(), equations)

solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs)

coordinates_min = (-1.0, -1.0, -1.0)
coordinates_max = ( 1.0, 1.0, 1.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level=4,
n_cells_max=80_000)

# Define initial condition
function initial_condition_diffusive_convergence_test(x, t, equation::LinearScalarAdvectionEquation3D)
# Store translated coordinate for easy use of exact solution
x_trans = x - equation.advection_velocity * t

nu = diffusivity()
c = 1.0
A = 0.5
L = 2
f = 1/L
omega = 2 * pi * f
scalar = c + A * sin(omega * sum(x_trans)) * exp(-2 * nu * omega^2 * t)
return SVector(scalar)
end
initial_condition = initial_condition_diffusive_convergence_test

# define periodic boundary conditions everywhere
boundary_conditions = boundary_condition_periodic
boundary_conditions_parabolic = boundary_condition_periodic

# A semidiscretization collects data structures and functions for the spatial discretization
semi = SemidiscretizationHyperbolicParabolic(mesh,
(equations, equations_parabolic),
initial_condition, solver;
boundary_conditions=(boundary_conditions,
boundary_conditions_parabolic))


###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.2)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval=analysis_interval,
extra_analysis_integrals=(entropy,))

alive_callback = AliveCallback(analysis_interval=analysis_interval)

save_solution = SaveSolutionCallback(interval=100,
save_initial_solution=true,
save_final_solution=true,
solution_variables=cons2prim)

amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first),
base_level=3,
med_level=4, med_threshold=1.2,
max_level=5, max_threshold=1.45)
amr_callback = AMRCallback(semi, amr_controller,
interval=5,
adapt_initial_condition=true,
adapt_initial_condition_only_refine=true)

stepsize_callback = StepsizeCallback(cfl=1.0)

callbacks = CallbackSet(summary_callback,
analysis_callback,
alive_callback,
save_solution,
amr_callback,
stepsize_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false),
dt=1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep=false, callback=callbacks);
summary_callback() # print the timer summary
91 changes: 91 additions & 0 deletions examples/tree_3d_dgsem/elixir_advection_diffusion_nonperiodic.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the linear advection-diffusion equation

diffusivity() = 5.0e-2
advection_velocity = (1.0, 0.0, 0.0)
equations = LinearScalarAdvectionEquation3D(advection_velocity)
equations_parabolic = LaplaceDiffusion3D(diffusivity(), equations)

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
solver = DGSEM(polydeg=3, surface_flux=flux_lax_friedrichs)

coordinates_min = (-1.0, -0.5, -0.25) # minimum coordinates (min(x), min(y), min(z))
coordinates_max = ( 0.0, 0.5, 0.25) # maximum coordinates (max(x), max(y), max(z))

# Create a uniformly refined mesh with periodic boundaries
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level=3,
periodicity=false,
n_cells_max=30_000) # set maximum capacity of tree data structure

# Example setup taken from
# - Truman Ellis, Jesse Chan, and Leszek Demkowicz (2016).
# Robust DPG methods for transient convection-diffusion.
# In: Building bridges: connections and challenges in modern approaches
# to numerical partial differential equations.
# [DOI](https://doi.org/10.1007/978-3-319-41640-3_6).
function initial_condition_eriksson_johnson(x, t, equations)
l = 4
epsilon = diffusivity() # TODO: this requires epsilon < .6 due to sqrt
lambda_1 = (-1 + sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon)
lambda_2 = (-1 - sqrt(1 - 4 * epsilon * l)) / (-2 * epsilon)
r1 = (1 + sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon)
s1 = (1 - sqrt(1 + 4 * pi^2 * epsilon^2)) / (2 * epsilon)
u = exp(-l * t) * (exp(lambda_1 * x[1]) - exp(lambda_2 * x[1])) +
cos(pi * x[2]) * (exp(s1 * x[1]) - exp(r1 * x[1])) / (exp(-s1) - exp(-r1))
return SVector{1}(u)
end
initial_condition = initial_condition_eriksson_johnson

boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition),
y_neg = BoundaryConditionDirichlet(initial_condition),
z_neg = boundary_condition_do_nothing,
y_pos = BoundaryConditionDirichlet(initial_condition),
x_pos = boundary_condition_do_nothing,
z_pos = boundary_condition_do_nothing)

boundary_conditions_parabolic = BoundaryConditionDirichlet(initial_condition)

# A semidiscretization collects data structures and functions for the spatial discretization
semi = SemidiscretizationHyperbolicParabolic(mesh,
(equations, equations_parabolic),
initial_condition, solver;
boundary_conditions=(boundary_conditions,
boundary_conditions_parabolic))


###############################################################################
# ODE solvers, callbacks etc.

# Create ODE problem with time span `tspan`
tspan = (0.0, 0.5)
ode = semidiscretize(semi, tspan);

# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
# and resets the timers
summary_callback = SummaryCallback()

# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval=analysis_interval)

# The AliveCallback prints short status information in regular intervals
alive_callback = AliveCallback(analysis_interval=analysis_interval)

# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback)


###############################################################################
# run the simulation

# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
time_int_tol = 1.0e-11
sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol,
ode_default_options()..., callback=callbacks)

# Print the timer summary
summary_callback()
2 changes: 1 addition & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export AcousticPerturbationEquations2D,
LinearizedEulerEquations2D,
PolytropicEulerEquations2D

export LaplaceDiffusion1D, LaplaceDiffusion2D,
export LaplaceDiffusion1D, LaplaceDiffusion2D, LaplaceDiffusion3D,
CompressibleNavierStokesDiffusion1D, CompressibleNavierStokesDiffusion2D,
CompressibleNavierStokesDiffusion3D

Expand Down
43 changes: 6 additions & 37 deletions src/callbacks_step/amr_dg1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,13 @@ function refine!(u_ode::AbstractVector, adaptor, mesh::TreeMesh{1},
# actually transferring the solution to the refined cells
refine!(u_ode, adaptor, mesh, equations, dg, cache, elements_to_refine)

# The remaining function only handles the necessary adaptation of the data structures
# for the parabolic part of the semidiscretization

# Get new list of leaf cells
leaf_cell_ids = local_leaf_cells(mesh.tree)

@unpack elements, viscous_container = cache_parabolic
resize!(elements, length(leaf_cell_ids))
init_elements!(elements, leaf_cell_ids, mesh, dg.basis)

# Resize parabolic helper variables
@unpack viscous_container = cache_parabolic
resize!(viscous_container, equations, dg, cache)

# re-initialize interfaces container
@unpack interfaces = cache_parabolic
resize!(interfaces, count_required_interfaces(mesh, leaf_cell_ids))
init_interfaces!(interfaces, elements, mesh)

# re-initialize boundaries container
@unpack boundaries = cache_parabolic
resize!(boundaries, count_required_boundaries(mesh, leaf_cell_ids))
init_boundaries!(boundaries, elements, mesh)
reinitialize_containers!(mesh, equations, dg, cache_parabolic)
DanielDoehring marked this conversation as resolved.
Show resolved Hide resolved

# Sanity check
@unpack interfaces = cache_parabolic
if isperiodic(mesh.tree)
@assert ninterfaces(interfaces)==1 * nelements(dg, cache_parabolic) ("For 1D and periodic domains, the number of interfaces must be the same as the number of elements")
end
Expand Down Expand Up @@ -246,27 +229,13 @@ function coarsen!(u_ode::AbstractVector, adaptor, mesh::TreeMesh{1},
# actually transferring the solution to the coarsened cells
coarsen!(u_ode, adaptor, mesh, equations, dg, cache, elements_to_remove)

# Get new list of leaf cells
leaf_cell_ids = local_leaf_cells(mesh.tree)

@unpack elements, viscous_container = cache_parabolic
resize!(elements, length(leaf_cell_ids))
init_elements!(elements, leaf_cell_ids, mesh, dg.basis)

# Resize parabolic helper variables
@unpack viscous_container = cache_parabolic
resize!(viscous_container, equations, dg, cache)

# re-initialize interfaces container
@unpack interfaces = cache_parabolic
resize!(interfaces, count_required_interfaces(mesh, leaf_cell_ids))
init_interfaces!(interfaces, elements, mesh)

# re-initialize boundaries container
@unpack boundaries = cache_parabolic
resize!(boundaries, count_required_boundaries(mesh, leaf_cell_ids))
init_boundaries!(boundaries, elements, mesh)
reinitialize_containers!(mesh, equations, dg, cache_parabolic)
jlchan marked this conversation as resolved.
Show resolved Hide resolved

# Sanity check
@unpack interfaces = cache_parabolic
if isperiodic(mesh.tree)
@assert ninterfaces(interfaces)==1 * nelements(dg, cache_parabolic) ("For 1D and periodic domains, the number of interfaces must be the same as the number of elements")
end
Expand Down
Loading
Loading