Skip to content
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

User defined schemes - FunctionalScheme #247

Merged
merged 27 commits into from
Mar 21, 2023
Merged

Conversation

xtalax
Copy link
Member

@xtalax xtalax commented Mar 2, 2023

User Defined Schemes

Allows advection_scheme to be defined at the top level, and fed in to the package. Defines the type FunctionalScheme with a predefined application method to allow this. The docstring for this is reproduced below.

Redefines WENO in terms of this new scheme type as an example.

This will allow for experiments with optimized schemes, as well as making schemes conform to a standard interface.

FunctionalScheme

    F = FunctionalScheme{interior_points, boundary_points}(interior, lower, upper, is_nonuniform, parameters; name)

A user definable scheme that takes a set of functions as input. The functions define the derivative at the interior, lower boundary, and upper boundary.

lower and upper should be vectors of functions. In general, upper and lower must be at least floor(interior_points/2) long. Where you have no good approximation for a derivative at the boundary, you can use nothing as a placeholder. MethodOfLines will then attempt to use an extrapolation here where nessesary. Be warned that this can lead to instability.

The boundary functions define the derivative at their index in the function vector, numbering from the boundary. For example, if boundary_points = 3, the first function in the vector will define the derivative at the boundary, the second at the boundary plus one step, and the third at the boundary plus two steps.

The functions making up the scheme take the following inputs:

Functions must be of the form f(u, p, t, deriv_iv, d_iv).

For the interior, u takes a vector of dependent variable values in the direction of the derivative
of length interior_points. interior_points must be odd, as this function defines the derivative at the center of the input points.

For the lower and upper boundaries, u takes a vector of dependent variable values of length boundary_points. This will be the boundary_points number of points closest to the lower and upper boundary respectively.
p will take all parameter values in the order specified in the PDESystem, with the scheme's parameters prepended to the list.

deriv_iv takes a vector of independent variable values of the same support as for u, for the independent variable in the direction of the derivative.

If is_nonuniform is false, d_iv will take a scalar value of the stepsize between the points used to call the function in u and deriv_iv.

If is_nonuniform is true, the scheme must be able to accept d_iv as a vector of stepsizes between the points used to call the function in u and deriv_iv, therefore of length length(u)-1. A method should also be defined for the case where d_iv is a scalar, in which case the stepsizes are assumed to be uniform.

@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Merging #247 (0b6350d) into master (61e635e) will decrease coverage by 4.40%.
The diff coverage is 76.64%.

❗ Current head 0b6350d differs from pull request most recent head 4a496ff. Consider uploading reports for the commit 4a496ff to get more accurate results

@@            Coverage Diff             @@
##           master     #247      +/-   ##
==========================================
- Coverage   77.24%   72.85%   -4.40%     
==========================================
  Files          39       40       +1     
  Lines        1991     2037      +46     
==========================================
- Hits         1538     1484      -54     
- Misses        453      553     +100     
Impacted Files Coverage Δ
...schemes/spherical_laplacian/spherical_laplacian.jl 92.30% <ø> (ø)
src/interface/solution/timedep.jl 85.29% <ø> (ø)
src/interface/solution/timeindep.jl 100.00% <ø> (ø)
src/interface/scheme_types.jl 36.84% <33.33%> (-63.16%) ⬇️
src/MOL_discretization.jl 63.97% <50.00%> (ø)
src/MOL_utils.jl 52.94% <62.50%> (-26.33%) ⬇️
...ization/schemes/function_scheme/function_scheme.jl 73.68% <73.68%> (ø)
src/system_parsing/variable_map.jl 75.00% <83.33%> (ø)
src/discretization/discretize_vars.jl 81.31% <84.61%> (-4.24%) ⬇️
src/discretization/generate_bc_eqs.jl 70.58% <90.00%> (-9.29%) ⬇️
... and 9 more

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xtalax xtalax merged commit 85eb979 into SciML:master Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant