-
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
hyperbolic Serre-Green-Naghdi equations #139
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
==========================================
+ Coverage 97.57% 97.75% +0.18%
==========================================
Files 20 22 +2
Lines 1569 1741 +172
==========================================
+ Hits 1531 1702 +171
- Misses 38 39 +1 ☔ View full report in Codecov by Sentry. |
# TODO: There is another name clash. For the SerreGreenNaghdiEquations1D, | ||
# the corresponding function is called initial_condition_convergence_test | ||
# However, we cannot use that name since it's not an analytical solution. | ||
# How shall we handle this? | ||
""" | ||
initial_condition_soliton(x, t, equations::HyperbolicSerreGreenNaghdiEquations1D, mesh) | ||
|
||
A soliton solution of the [`SerreGreenNaghdiEquations1D`](@ref) | ||
used for convergence tests in a periodic domain. | ||
|
||
See also [`initial_condition_convergence_test`](@ref). | ||
""" |
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.
Another name clash
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.
Good question. I would be fine keeping it like it is now (maybe with a bit more explanations in the docstring that this function is the same as initial_condition_convergence_test
for SerreGreenNaghdiEquations1D
, but is not an analytical solution of HyperbolicSerreGreenNaghdiEquations1D
). I think it's not too bad that these two initial conditions are not called the same.
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, they represent the same physics, so it's a bit annoying but I don't know a better solution right now 🤷
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.
Yeah, it' not perfect, but I can live with in (at least for now). The name initial_condition_convergence_test
doesn't describe the physics, but rather the fact of it being an analytical solution of some equations, so it's not that confusing, I think.
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.
Thanks! A preliminary review regarding your comments/questions.
I saw some non-ASCII code characters in executable code. Could you replace them by ASCII code characters, please?
How to initialize variables? Ideally, I would like to use w = -(D1 * v) instead of having to specify a value manually in the initial condition.
I also thought about that. I agree that this would be really nice. I think it would be ideal if both would be possible, i.e., defining an initial condition consisting of three variables with defaults for compute_coefficients
by adding some dispatching on HyperbolicSerreGreenNaghdiEquations1D
and some branching whether the output of initial_condition
is three or five elements long?
# TODO: There is another name clash. For the SerreGreenNaghdiEquations1D, | ||
# the corresponding function is called initial_condition_convergence_test | ||
# However, we cannot use that name since it's not an analytical solution. | ||
# How shall we handle this? | ||
""" | ||
initial_condition_soliton(x, t, equations::HyperbolicSerreGreenNaghdiEquations1D, mesh) | ||
|
||
A soliton solution of the [`SerreGreenNaghdiEquations1D`](@ref) | ||
used for convergence tests in a periodic domain. | ||
|
||
See also [`initial_condition_convergence_test`](@ref). | ||
""" |
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.
Good question. I would be fine keeping it like it is now (maybe with a bit more explanations in the docstring that this function is the same as initial_condition_convergence_test
for SerreGreenNaghdiEquations1D
, but is not an analytical solution of HyperbolicSerreGreenNaghdiEquations1D
). I think it's not too bad that these two initial conditions are not called the same.
Co-authored-by: Joshua Lampert <[email protected]>
I used them on purpose to make it easier to search and replace stuff after deciding how to call the new variables |
julia> convergence_test("examples/hyperbolic_serre_green_naghdi_1d/hyperbolic_serre_green_naghdi_manufactured.jl", 4);
[...]
####################################################################################################
l2
η v D w H
N error EOC N error EOC N error EOC N error EOC N error EOC
50 5.65e-02 - 50 3.46e-02 - 50 0.00e+00 - 50 1.17e+00 - 50 5.85e-02 -
100 3.61e-03 3.97 100 2.25e-03 3.94 100 0.00e+00 NaN 100 7.51e-02 3.96 100 3.73e-03 3.97
200 2.26e-04 4.00 200 1.42e-04 3.99 200 0.00e+00 NaN 200 4.71e-03 3.99 200 2.34e-04 4.00
400 1.42e-05 4.00 400 1.02e-05 3.79 400 0.00e+00 NaN 400 2.95e-04 4.00 400 1.46e-05 4.00
mean 3.99 mean 3.91 mean NaN mean 3.99 mean 3.99
----------------------------------------------------------------------------------------------------
linf
η v D w H
N error EOC N error EOC N error EOC N error EOC N error EOC
50 1.21e-01 - 50 5.21e-02 - 50 0.00e+00 - 50 2.19e+00 - 50 1.27e-01 -
100 7.81e-03 3.95 100 3.36e-03 3.95 100 0.00e+00 NaN 100 1.41e-01 3.96 100 8.59e-03 3.88
200 4.91e-04 3.99 200 2.16e-04 3.96 200 0.00e+00 NaN 200 8.83e-03 3.99 200 5.38e-04 4.00
400 3.15e-05 3.96 400 2.33e-05 3.21 400 0.00e+00 NaN 400 5.51e-04 4.00 400 3.37e-05 4.00
mean 3.97 mean 3.71 mean NaN mean 3.98 mean 3.96
----------------------------------------------------------------------------------------------------
|
Including some optimizations for flat bathymetry: julia> q = copy(ode.u0); dq = similar(q); @benchmark $(ode.f)($dq, $q, $(ode.p), $0.0)
BenchmarkTools.Trial: 10000 samples with 4 evaluations.
Range (min … max): 7.864 μs … 13.969 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 7.927 μs ┊ GC (median): 0.00%
Time (mean ± σ): 8.165 μs ± 647.504 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▇▆▂▂▃▃ ▂▁▂▁▂ ▁ ▂
█████████▅▅▄▅▁▄▃█████████▇▆▅▅▆▃▆▆▆▇██▇▇▇▇▆▇▇███▇▅▅▄▆▆▅▅▃▅▆▆ █
7.86 μs Histogram: log(frequency) by time 11 μs <
Memory estimate: 304 bytes, allocs estimate: 5.
julia> redirect_stdio(stdout = devnull, stderr = devnull) do
trixi_include("examples/hyperbolic_serre_green_naghdi_1d/hyperbolic_serre_green_naghdi_soliton.jl", interval = 1000, bathymetry_type = bathymetry_mild_slope);
end;
julia> q = copy(ode.u0); dq = similar(q); @benchmark $(ode.f)($dq, $q, $(ode.p), $0.0)
BenchmarkTools.Trial: 10000 samples with 3 evaluations.
Range (min … max): 8.597 μs … 17.208 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 8.917 μs ┊ GC (median): 0.00%
Time (mean ± σ): 9.159 μs ± 774.910 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▇▇▂ █▇▇▇▂ ▁▁▁▁▁▁ ▁ ▁ ▂
███▆██████▇███▇▇█▇█▇██████████████▇█▇▇▇▆██▇███▇▇▇▆▆▆▅▆▅▆▅▅▅ █
8.6 μs Histogram: log(frequency) by time 12.2 μs <
Memory estimate: 16 bytes, allocs estimate: 2. |
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.
This looks already really nice! I think we are not far from merging this. I especially like your trait system to allow all or only a reduced set of variables in the initial condition. I knew you would come up with a very nice idea for implementing that what was very fuzzy in my head 🙂
The convergence test and benchmark look nice. Thanks! |
Co-authored-by: Joshua Lampert <[email protected]>
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.
Looks mostly good! I have only some minor comments/suggestions/questions.
examples/hyperbolic_serre_green_naghdi_1d/hyperbolic_serre_green_naghdi_manufactured.jl
Show resolved
Hide resolved
Co-authored-by: Joshua Lampert <[email protected]>
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.
Thanks a lot! Once my final two suggestions are resolved, this is ready to merge.
Co-authored-by: Joshua Lampert <[email protected]>
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.
Thanks!
Next step of #129
TODO
w = -(D1 * v)
instead of having to specify a value manually in the initial condition.