Added Forward, Backward and Central Difference Option. #1
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.
TLDR: I added a forward, central, and backward difference option for all of the finite difference methods.
Problem:
There are many cases in PDEs where we need to use the backward difference method. For example, any advection PDE requires a backwards finite difference scheme otherwise the solution blows up (e.g. 12 steps NS). Currently in the package, the package only implements the central difference except in the special case where the central difference stencil was too small for the input size). However, the package is able to generate the offsets for all 3 schemes. I think having the option to choose which finite difference scheme would be extremely advantageous for all users. I myself needed it write away for some of the code I am using (e.g. 1d linear convection)
Solution:
difference
function which is callable via amethod="central"|"forward"|"backward"
. I also added this option to all of the subsequent functions that depend on the difference function, i.e. the rest of them."central"
) is still the default for all methods.Potential Improvements
fgrad
function. This might be helpful for some people in the future.grad
,divergence
, etc. I can see this being potentially useful in the future.