-
Notifications
You must be signed in to change notification settings - Fork 134
(Linear) Matrix operator for efficient IMEX #2674
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
Open
DanielDoehring
wants to merge
51
commits into
trixi-framework:main
Choose a base branch
from
DanielDoehring:MatrixOperatorIMEX
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+225
−71
Open
Changes from 48 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
c364bc4
Use SciMLOperators for IMEX with linear part
DanielDoehring ebd5b2f
test
DanielDoehring 47dd6a2
bf
DanielDoehring 2b4678b
Merge branch 'main' into MatrixOperatorIMEX
DanielDoehring d467843
cp
DanielDoehring 9c3ba03
Merge branch 'MatrixOperatorIMEX' of github.com:DanielDoehring/Trixi.…
DanielDoehring cf59962
compat
DanielDoehring ecbf0d3
sciml base
DanielDoehring ac63659
cp
DanielDoehring 7fe1660
cp
DanielDoehring bac340c
cp
DanielDoehring 61d375f
revert
DanielDoehring 3ef1310
f
DanielDoehring be88afe
cp
DanielDoehring 83b2dad
cp
DanielDoehring 236c5f8
cp
DanielDoehring 9120892
cp
DanielDoehring 4db9379
cp
DanielDoehring 2ced411
cp
DanielDoehring 006eb6b
Apply suggestions from code review
DanielDoehring 885644f
Update test/Project.toml
DanielDoehring 3897d6c
restrict sciml compact bounds
DanielDoehring 376e451
relieve
DanielDoehring 5bfc670
v
DanielDoehring 66d8cfc
up
DanielDoehring 5da16ce
up
DanielDoehring 33748a3
up
DanielDoehring 585e95d
rev
DanielDoehring 042b1df
1
DanielDoehring 5e1c5e2
cp
DanielDoehring d41294f
add base explicitly
DanielDoehring ad10cfd
Update src/semidiscretization/semidiscretization_hyperbolic_parabolic.jl
DanielDoehring d5cf05c
rev
DanielDoehring 6646b37
rev
DanielDoehring d92804c
compat
DanielDoehring 02d6fb5
Merge branch 'MatrixOperatorIMEX' of github.com:DanielDoehring/Trixi.…
DanielDoehring 2c78429
Merge branch 'main' into MatrixOperatorIMEX
DanielDoehring b903d31
rm
DanielDoehring c3fe575
Merge branch 'MatrixOperatorIMEX' of github.com:DanielDoehring/Trixi.…
DanielDoehring 8917be3
rev
DanielDoehring 5f4d595
cp
DanielDoehring f391536
rev
DanielDoehring 5392ac1
cp
DanielDoehring 46123e1
up
DanielDoehring 68602a0
Update examples/tree_2d_dgsem/elixir_advection_diffusion_imex_operato…
DanielDoehring 6e0264b
Update examples/tree_2d_dgsem/elixir_advection_diffusion_imex_operato…
DanielDoehring dfbe22e
Merge branch 'main' into MatrixOperatorIMEX
DanielDoehring 4c10ef5
Merge branch 'main' into MatrixOperatorIMEX
DanielDoehring d01ac3f
Update test/Project.toml
DanielDoehring a73c0f1
Merge branch 'main' into MatrixOperatorIMEX
DanielDoehring 446f643
Merge branch 'main' into MatrixOperatorIMEX
DanielDoehring 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
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
74 changes: 74 additions & 0 deletions
74
examples/tree_2d_dgsem/elixir_advection_diffusion_imex_operator.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,74 @@ | ||
| using OrdinaryDiffEqSDIRK | ||
| using SciMLBase, SciMLOperators, SparseArrays | ||
| using Trixi | ||
|
|
||
| ############################################################################### | ||
| # semidiscretization of the linear advection-diffusion equation | ||
|
|
||
| advection_velocity = (1.5, 1.0) | ||
| equations = LinearScalarAdvectionEquation2D(advection_velocity) | ||
| diffusivity() = 5.0e-1 | ||
| equations_parabolic = LaplaceDiffusion2D(diffusivity(), equations) | ||
|
|
||
| solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs) | ||
|
|
||
| coordinates_min = (-1.0, -1.0) | ||
| coordinates_max = (1.0, 1.0) | ||
|
|
||
| mesh = TreeMesh(coordinates_min, coordinates_max, | ||
| initial_refinement_level = 4, | ||
| periodicity = true, | ||
| n_cells_max = 30_000) | ||
|
|
||
| function initial_condition_diffusive_convergence_test(x, t, | ||
| equation::LinearScalarAdvectionEquation2D) | ||
| # Store translated coordinate for easy use of exact solution | ||
| RealT = eltype(x) | ||
| x_trans = x - equation.advection_velocity * t | ||
|
|
||
| nu = diffusivity() | ||
| c = 1 | ||
| A = 0.5f0 | ||
| L = 2 | ||
| f = 1.0f0 / L | ||
| omega = 2 * convert(RealT, 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 | ||
|
|
||
| semi = SemidiscretizationHyperbolicParabolic(mesh, | ||
| (equations, equations_parabolic), | ||
| initial_condition, solver) | ||
|
|
||
| ############################################################################### | ||
| # ODE setup | ||
|
|
||
| tspan = (0.0, 0.5) | ||
| ode = semidiscretize(semi, tspan) # For accessing the initial condition u0 only | ||
|
|
||
| D_map, _ = linear_structure_parabolic(semi) | ||
| # Cannot directly construct `MatrixOperator` from `LinearMap`, need detour via sparse matrix | ||
| D_op = MatrixOperator(sparse(D_map)) | ||
|
|
||
| split_func = SplitFunction(D_op, Trixi.rhs!) | ||
| ode_operator = SplitODEProblem{true}(split_func, ode.u0, tspan, semi) | ||
|
|
||
| ############################################################################### | ||
| # Callbacks | ||
|
|
||
| summary_callback = SummaryCallback() | ||
|
|
||
| analysis_interval = 1000 | ||
| analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
|
||
| alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
|
||
| callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) | ||
|
|
||
| ############################################################################### | ||
| # run the simulation | ||
|
|
||
| sol = solve(ode_operator, KenCarp4(); | ||
| adaptive = false, dt = 1e-2, | ||
| 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
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.