Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Finite difference discretization order for UpwindDifference #308

@archermarx

Description

@archermarx

Hi all, I'm loving the DiffEq ecosystem a lot and I wanted to thank yall for implementing Neumann and Robin BCs this week. I was running some tests on basic linear advection and was testing out higher order finite differences and found that specifying an order above 1 when applying the MOLFiniteDifference function made no difference to the approximation.

low_order

problem

Investigating the code, I found this in the discretize_2 function:

 if deriv_order == 0
      expr = :(u[:,$j])
  elseif deriv_order == 1
      # TODO: approx_order and forward/backward should be

      #       input parameters of each derivative
      approx_order = 1
      L = UpwindDifference(deriv_order,approx_order,dx[i],len_of_indep_vars[i]-2,-1)
      expr = :(-1*($L*Q[$j]*u[:,$j]))
  elseif deriv_order == 2
      L = CenteredDifference(deriv_order,approx_order,dx[i],len_of_indep_vars[i]-2)
      expr = :($L*Q[$j]*u[:,$j])
  end

If I understand this correctly, first derivatives are always discretized using a first order upwind finite difference, which would explain what I saw. Is there a reason that the UpwindDifference doesn't support higher derivatives at this time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions