-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow Fourier and periodic rational derivative operators for BBMBBMEquations1D
and SvaerdKalischEquations1D
#154
Merged
+216
−21
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4c1223f
allow Fourier and periodic rational derivative operators
JoshuaLampert 4570853
format
JoshuaLampert 4114bbb
adjust tolerances
JoshuaLampert 5fd46d6
avoid clutter
JoshuaLampert 8dd383e
fix
JoshuaLampert 950828f
add test for PeriodicRationalDerivativeOperator for BBMEquation1D
JoshuaLampert 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 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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: fourier_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the BBM-BBM equation | ||
|
||
# or bathymetry_variable instead of bathymetry_flat | ||
equations = BBMBBMEquations1D(bathymetry_type = bathymetry_flat, gravity_constant = 9.81) | ||
|
||
# initial_condition_convergence_test needs periodic boundary conditions | ||
initial_condition = initial_condition_convergence_test | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -35.0 | ||
coordinates_max = 35.0 | ||
N = 512 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with Fourier SBP operators | ||
D1 = fourier_derivative_operator(xmin(mesh), xmax(mesh), nnodes(mesh)) | ||
D2 = D1^2 | ||
solver = Solver(D1, D2) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, 30.0) | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 10, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
velocity, entropy)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 100) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
43 changes: 43 additions & 0 deletions
43
examples/svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans_fourier.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,43 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: fourier_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Svärd-Kalisch equations | ||
|
||
equations = SvaerdKalischEquations1D(gravity_constant = 9.81, eta0 = 0.8, alpha = 0.0, | ||
beta = 0.27946992481203003, gamma = 0.0521077694235589) | ||
|
||
initial_condition = initial_condition_dingemans | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -138.0 | ||
coordinates_max = 46.0 | ||
N = 512 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with Fourier SBP operators | ||
D1 = fourier_derivative_operator(xmin(mesh), xmax(mesh), nnodes(mesh)) | ||
D2 = D1^2 | ||
solver = Solver(D1, D2) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, 70.0) | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 10, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
entropy, | ||
entropy_modified)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 500) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go as far as this, it could make sense to add downstream tests to SummationByPartsOperators.jl. I am not sure whether I have documented that
D1^
will necessarily return aPeriodicRationalDerivativeOperator
. It should be pretty stable, but we use some parts that are less clearly described as public API.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I didn't know that
PeriodicRationalDerivativeOperator
is not quite public. Adding tests to SummationByPartsOperators.jl sounds good. But this can be merged anyway, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same also holds for
FourierPolynomialDerivativeOperator
, doesn't it? As far as I can tell, it's also not clearly documented thatD1^
will return aFourierPolynomialDerivativeOperator
ifD1
is aFourierDerivativeOperator
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I have not added any documentation to it, so it is indeed not really public but more like an implementation detail to make
^
etc. work - which is documentedalready in the README.md (see https://github.com/ranocha/SummationByPartsOperators.jl?tab=readme-ov-file#periodic-domains).
But we can go ahead and merge this PR here. We don't need to add downstream tests right now, but it may be nice to keep this in mind for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simpler option would be to add some explicit tests that
^
returns the appropriate types with some comments that DispersiveShallowWater.jl uses this interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes