forked from trixi-framework/Trixi.jl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'subcell-limiting' into subcell-limiting-p4est-all
- Loading branch information
Showing
28 changed files
with
1,373 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Trixi" | ||
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb" | ||
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"] | ||
version = "0.6.2-pre" | ||
version = "0.6.3-pre" | ||
|
||
[deps] | ||
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2" | ||
|
@@ -66,7 +66,7 @@ Makie = "0.19" | |
MuladdMacro = "0.2.2" | ||
Octavian = "0.3.5" | ||
OffsetArrays = "1.3" | ||
P4est = "0.4" | ||
P4est = "0.4.9" | ||
Polyester = "0.7.5" | ||
PrecompileTools = "1.1" | ||
Printf = "1" | ||
|
@@ -84,7 +84,7 @@ StaticArrays = "1" | |
StrideArrays = "0.1.18" | ||
StructArrays = "0.6" | ||
SummationByPartsOperators = "0.5.41" | ||
T8code = "0.4.1" | ||
T8code = "0.4.3" | ||
TimerOutputs = "0.5" | ||
Triangulate = "2.0" | ||
TriplotBase = "0.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
examples/p4est_2d_dgsem/elixir_advection_diffusion_nonperiodic_amr.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the linear advection-diffusion equation | ||
|
||
diffusivity() = 5.0e-2 | ||
advection_velocity = (1.0, 0.0) | ||
equations = LinearScalarAdvectionEquation2D(advection_velocity) | ||
equations_parabolic = LaplaceDiffusion2D(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) # minimum coordinates (min(x), min(y)) | ||
coordinates_max = (0.0, 0.5) # maximum coordinates (max(x), max(y)) | ||
|
||
trees_per_dimension = (4, 4) | ||
mesh = P4estMesh(trees_per_dimension, | ||
polydeg = 3, initial_refinement_level = 2, | ||
coordinates_min = coordinates_min, coordinates_max = coordinates_max, | ||
periodicity = false) | ||
|
||
# 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 = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition), | ||
:y_neg => BoundaryConditionDirichlet(initial_condition), | ||
:y_pos => BoundaryConditionDirichlet(initial_condition), | ||
:x_pos => boundary_condition_do_nothing) | ||
|
||
boundary_conditions_parabolic = Dict(:x_neg => BoundaryConditionDirichlet(initial_condition), | ||
:x_pos => BoundaryConditionDirichlet(initial_condition), | ||
:y_neg => BoundaryConditionDirichlet(initial_condition), | ||
:y_pos => 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 = 1000 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
# The AliveCallback prints short status information in regular intervals | ||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), | ||
base_level = 1, | ||
med_level = 2, med_threshold = 0.9, | ||
max_level = 3, max_threshold = 1.0) | ||
|
||
amr_callback = AMRCallback(semi, amr_controller, | ||
interval = 50) | ||
|
||
# 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, amr_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, dt = 1e-7, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, | ||
ode_default_options()..., callback = callbacks) | ||
|
||
# Print the timer summary | ||
summary_callback() |
83 changes: 83 additions & 0 deletions
83
examples/p4est_2d_dgsem/elixir_advection_diffusion_periodic_amr.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the linear advection-diffusion equation | ||
|
||
advection_velocity = (1.5, 1.0) | ||
equations = LinearScalarAdvectionEquation2D(advection_velocity) | ||
diffusivity() = 5.0e-2 | ||
equations_parabolic = LaplaceDiffusion2D(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, -1.0) # minimum coordinates (min(x), min(y)) | ||
coordinates_max = (1.0, 1.0) # maximum coordinates (max(x), max(y)) | ||
|
||
trees_per_dimension = (4, 4) | ||
mesh = P4estMesh(trees_per_dimension, | ||
polydeg = 3, initial_refinement_level = 1, | ||
coordinates_min = coordinates_min, coordinates_max = coordinates_max) | ||
|
||
# Define initial condition | ||
function initial_condition_diffusive_convergence_test(x, t, | ||
equation::LinearScalarAdvectionEquation2D) | ||
# 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 | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolicParabolic(mesh, | ||
(equations, equations_parabolic), | ||
initial_condition, solver) | ||
|
||
############################################################################### | ||
# 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) | ||
|
||
amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), | ||
base_level = 1, | ||
med_level = 2, med_threshold = 1.25, | ||
max_level = 3, max_threshold = 1.45) | ||
|
||
amr_callback = AMRCallback(semi, amr_controller, | ||
interval = 20) | ||
|
||
# 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, amr_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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.