-
Notifications
You must be signed in to change notification settings - Fork 159
Support for purely parabolic PDEs via SemidiscretizationParabolic
#2874
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
Merged
Merged
Changes from 83 commits
Commits
Show all changes
105 commits
Select commit
Hold shift + click to select a range
21a572d
rename viscous to parabolic in non-fluid contexts
tristanmontoya f6da116
rename files
tristanmontoya 159bd64
first step to parabolic solver
tristanmontoya 015fd25
remove hyperbolic part from parabolic solver
tristanmontoya e42ea22
rename advective/diffusive cfl to hyperbolic/parabolic
tristanmontoya 1e231fd
revert NEWS.md
tristanmontoya 52fef85
add change to NEWS.md
tristanmontoya 91cd9a2
Merge branch 'main' into tm/rename_viscous_to_parabolic
tristanmontoya 60c0e8f
Merge branch 'main' into tm/rename_viscous_to_parabolic
tristanmontoya 20bdc28
Apply suggestion from code review
tristanmontoya a453842
Apply suggestion from code review
tristanmontoya 96234c7
Apply suggestion from code review
tristanmontoya d7f03f2
Apply suggestion from code review
tristanmontoya b98459a
Apply suggestion from code review
tristanmontoya ae21945
Apply suggestion from code review
tristanmontoya e3eda0d
Apply suggestion from code review
tristanmontoya ff5d77d
Apply suggestion from code review
tristanmontoya 9f8f0b7
Apply suggestion from code review
tristanmontoya 64a16c6
Apply suggestion from code review
tristanmontoya c2e5371
Apply formatter suggestion
tristanmontoya fa9f0c5
Merge branch 'tm/rename_viscous_to_parabolic' into tm/parabolic_solver
tristanmontoya 023c7b0
remove hyperbolic stuff from parabolic solver
tristanmontoya 4c07db8
allow specifying parabolic solver
tristanmontoya ef9af66
revise tests
tristanmontoya bfda3a7
rename elixirs
tristanmontoya 221a491
Merge branch 'main' into tm/parabolic_solver
DanielDoehring f5b1d92
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 96cd60d
Apply suggestions from code review
tristanmontoya e928cc2
Apply formatting changes
tristanmontoya c57779d
Apply formatting changes
tristanmontoya 805b65b
Apply formatting changes
tristanmontoya 7d507dc
Merge branch 'main' into tm/rename_viscous_to_parabolic
tristanmontoya d18b43f
Update NEWS.md
tristanmontoya 13162f8
add amr
tristanmontoya 85dbe16
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya 606574a
Merge branch 'main' into tm/rename_viscous_to_parabolic
tristanmontoya eb9914c
fix amr examples/tests
tristanmontoya 73600a2
Merge branch 'main' into tm/rename_viscous_to_parabolic
tristanmontoya e731e81
make old fake diffusion tests use real diffusion equation
tristanmontoya 6be1261
consolidate tests/examples and add LinearDiffusionEquation2D
tristanmontoya b61f861
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 6aa8f34
update comments/relax tols
tristanmontoya dff9b8e
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya 701ec40
Merge branch 'main' into tm/rename_viscous_to_parabolic
ranocha 8a7da97
Merge branch 'main' into tm/rename_viscous_to_parabolic
ranocha 6a17f94
Merge branch 'main' into tm/rename_viscous_to_parabolic
ranocha 6aabdb0
add myself to authors
tristanmontoya da83367
Merge branch 'tm/rename_viscous_to_parabolic' into tm/parabolic_solver
tristanmontoya 906ede5
add diffusion equation to readme
tristanmontoya 836231b
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 09a0e18
add consistency check
tristanmontoya 08ed789
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya 243601f
update tests
tristanmontoya 54597db
separate caches
tristanmontoya e8ad240
dispatch for parabolic linear structure
tristanmontoya bcf02c0
specialize extra node variables and update tests
tristanmontoya 2e65bb5
fix outdir issue in tests
tristanmontoya 20a067d
remove check + variable naming consistency in stepsize.jl
tristanmontoya c38e0aa
remove unneeded restrictions, add missing dispatches, and update tests
tristanmontoya 95abb83
cleanup
tristanmontoya 6905853
spacing
tristanmontoya 6b1463f
line breaks
tristanmontoya 3f514be
consistency
tristanmontoya 8ea291a
add comment
tristanmontoya 145466f
Trixi.ndofsglobal needed in test
tristanmontoya 102684a
Merge branch 'main' into tm/parabolic_solver
tristanmontoya d51be88
clarify standalone diffusion equations in docstrings
tristanmontoya 2b61a04
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya 6dc51f6
Apply suggestions from code review
tristanmontoya 9701813
add parabolic linear_structure docstring
tristanmontoya f15fd10
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya 477bd1f
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 13a5bcb
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 1ffcff2
add note about non-public API
tristanmontoya d18ee95
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya cf28a33
clarify non-public API note
tristanmontoya 2aa51a6
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 9d47e69
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 4bb1888
Update NEWS.md
tristanmontoya 377889a
Add PR reference to NEWS.md
tristanmontoya 9440ae5
Merge branch 'main' into tm/parabolic_solver
tristanmontoya ae1fef2
Merge branch 'main' into tm/parabolic_solver
DanielDoehring 2b7d7cc
Merge branch 'main' into tm/parabolic_solver
ranocha ab926a5
Update examples/tree_1d_dgsem/elixir_diffusion_ldg_amr_boundary_layer.jl
tristanmontoya 01fdce6
Merge branch 'main' into tm/parabolic_solver
tristanmontoya f39f03c
update docstrings for LaplaceDiffusion1D/2D
tristanmontoya 8b52028
separate bullet point in README.md for diffusion
tristanmontoya d8ca7eb
make laplace_diffusion 1d docstring consistent with 2d
tristanmontoya d1f2b25
Merge branch 'main' into tm/parabolic_solver
tristanmontoya ce750f5
dispatch rhs! to rhs_parabolic
tristanmontoya 45e8a4e
update docs to include heat equation
tristanmontoya c1f8d15
add proper dispatch using default_rhs(semi)
tristanmontoya 27c638b
make timer output consistent with other use of parabolic rhs
tristanmontoya 5a416d3
use @trixi_timeit_ext backend
tristanmontoya 6fb5165
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 60f3c7a
Merge branch 'main' into tm/parabolic_solver
DanielDoehring 522933d
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 0ecb3b5
revert test values
tristanmontoya 4e4da24
slightly relax tol on elixir_diffusion_ldg_newton_krylov
tristanmontoya 9f483c4
add intermediate linear_diffusion_equation.jl file
tristanmontoya e93982f
Merge branch 'main' into tm/parabolic_solver
DanielDoehring 6d0009a
Merge branch 'main' into tm/parabolic_solver
tristanmontoya 17908e7
Merge branch 'main' into tm/parabolic_solver
ranocha b5107df
retrigger CI
tristanmontoya fe6f24b
Merge remote-tracking branch 'origin/tm/parabolic_solver' into tm/par…
tristanmontoya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
examples/tree_1d_dgsem/elixir_diffusion_ldg_amr_boundary_layer.jl
This file contains hidden or 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,89 @@ | ||
| using OrdinaryDiffEqLowStorageRK | ||
| using Trixi | ||
|
|
||
| ############################################################################### | ||
| # Adaptive semidiscretization of the pure diffusion equation with mixed | ||
| # Dirichlet-Neumann BCs and an initial condition with a boundary layer. | ||
|
|
||
| diffusivity = 0.25 | ||
| amplitude = 1.0 | ||
| boundary_layer_thickness = 0.01 | ||
|
|
||
| equations = LinearDiffusionEquation1D(diffusivity) | ||
|
|
||
| solver = DGSEM(polydeg = 3) | ||
| solver_parabolic = ParabolicFormulationLocalDG() | ||
|
|
||
| mesh = TreeMesh((0.0,), (1.0,), | ||
| initial_refinement_level = 0, | ||
| periodicity = false, | ||
| n_cells_max = 30_000) | ||
|
|
||
| function initial_condition_boundary_layer(x, t, equations) | ||
| return SVector(amplitude * (1 - exp(-x[1] / boundary_layer_thickness)) / | ||
| (1 - exp(-1 / boundary_layer_thickness))) | ||
| end | ||
|
tristanmontoya marked this conversation as resolved.
Outdated
|
||
|
|
||
| initial_condition = initial_condition_boundary_layer | ||
| boundary_condition_dirichlet = BoundaryConditionDirichlet((x, t, equations) -> SVector(0.0)) | ||
| boundary_condition_neumann = BoundaryConditionNeumann((x, t, equations) -> SVector(0.0)) | ||
|
|
||
| boundary_conditions = (; x_neg = boundary_condition_dirichlet, | ||
| x_pos = boundary_condition_neumann) | ||
|
|
||
| semi = SemidiscretizationParabolic(mesh, equations, initial_condition, solver; | ||
| solver_parabolic = solver_parabolic, | ||
| boundary_conditions = boundary_conditions) | ||
|
|
||
| ############################################################################### | ||
| # ODE solvers, callbacks etc. | ||
|
|
||
| tspan = (0.0, 1.0) | ||
| ode = semidiscretize(semi, tspan) | ||
|
|
||
| summary_callback = SummaryCallback() | ||
|
|
||
| analysis_callback = AnalysisCallback(semi, interval = 200) | ||
|
|
||
| alive_callback = AliveCallback(analysis_interval = 200) | ||
|
|
||
| amr_indicator = IndicatorLöhner(semi, variable = first) | ||
| amr_controller = ControllerThreeLevel(semi, amr_indicator, | ||
| base_level = 0, | ||
| med_level = 3, | ||
| med_threshold = 0.01, | ||
| max_level = 6, max_threshold = 0.175) | ||
| amr_callback = AMRCallback(semi, amr_controller, | ||
| interval = 200, | ||
| adapt_initial_condition = true, | ||
| adapt_initial_condition_only_refine = false) | ||
|
|
||
| stepsize_callback = StepsizeCallback(cfl_parabolic = 0.05) | ||
|
|
||
| # specify extra node variables to be saved in the `SaveSolutionCallback` | ||
| extra_node_variables = (:dudx,) | ||
|
|
||
| # note that using `get_node_variable` to access the gradient exposes Trixi.jl internals | ||
| # that are not part of the public API, so this usage is not guaranteed to be stable across | ||
| # releases | ||
| function Trixi.get_node_variable(::Val{:dudx}, u, mesh, equations, dg, cache, | ||
| cache_parabolic) | ||
| return copy(@view cache_parabolic.parabolic_container.gradients[1, :, :]) | ||
| end | ||
|
tristanmontoya marked this conversation as resolved.
|
||
|
|
||
| # save the solution at the last time step, including the extra node variables | ||
| save_solution = SaveSolutionCallback(dt = 2.0, | ||
| save_initial_solution = false, | ||
| save_final_solution = true, | ||
| solution_variables = cons2cons, | ||
| extra_node_variables = extra_node_variables) | ||
|
|
||
| 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 = stepsize_callback(ode), adaptive = false, | ||
| ode_default_options()..., callback = callbacks, maxiters = 500_000) | ||
This file contains hidden or 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,60 @@ | ||
| using OrdinaryDiffEqLowStorageRK | ||
| using Trixi | ||
|
|
||
| ############################################################################### | ||
| # semidiscretization of the pure diffusion equation | ||
|
|
||
| diffusivity() = 0.5 | ||
| equations = LinearDiffusionEquation1D(diffusivity()) | ||
|
|
||
| # Create DG solver with polynomial degree = 3 | ||
| solver = DGSEM(polydeg = 3) | ||
| solver_parabolic = ParabolicFormulationLocalDG() | ||
|
|
||
| # Create a uniformly refined mesh with nonperiodic boundaries | ||
| mesh = TreeMesh(0.0, 1.0, | ||
| initial_refinement_level = 4, | ||
| n_cells_max = 30_000, # set maximum capacity of tree data structure | ||
| periodicity = false) | ||
|
|
||
| function analytical_solution(x, t, equations) | ||
| scalar = sinpi(x[1]) * exp(-diffusivity() * pi^2 * t) | ||
| return SVector(scalar) | ||
| end | ||
| initial_condition = analytical_solution | ||
|
|
||
| boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition), | ||
| x_pos = BoundaryConditionDirichlet(initial_condition)) | ||
|
|
||
| # A semidiscretization collects data structures and functions for the spatial discretization | ||
| semi = SemidiscretizationParabolic(mesh, equations, initial_condition, solver; | ||
| solver_parabolic = solver_parabolic, | ||
| boundary_conditions = boundary_conditions) | ||
|
|
||
| ############################################################################### | ||
| # ODE solvers, callbacks etc. | ||
|
|
||
| # Create ODE problem with time span from 0.0 to 1.0 | ||
| tspan = (0.0, 1.0) | ||
| 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_callback = AnalysisCallback(semi, interval = 100) | ||
|
|
||
| # The AliveCallback prints short status information in regular intervals | ||
| alive_callback = AliveCallback(analysis_interval = 100) | ||
|
|
||
| # 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 | ||
| # For CI purposes, we use fixed time-stepping for this elixir. | ||
| sol = solve(ode, RDPK3SpFSAL35(); dt = 1.0e-4, adaptive = false, | ||
| ode_default_options()..., callback = callbacks) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.