findiff_sparse_elements_realonly: Get sparse matrix elements for 1st order differentiation (no...

View source: R/flownet_finitedifferences.R

findiff_sparse_elements_realonlyR Documentation

Get sparse matrix elements for 1st order differentiation (no ghost nodes)

Description

Function generates rows, column and values for sparse matrix to get a first order approximation of values for all real nodes in a regularly spaced, rectangular grid in either the x or y direction.

The function assumes a regular, square grid where nodes are numbered row-first. The grid does not contain any ghost nodes. The grid has a size 1*1.

For a 4*3 grid, the numbering is:

ix=1 ix=2 ix=3 ix=4
iy=3 9 10 11 12
iy=2 5 6 7 8
iy=1 1 2 3 4

The finite difference approximation is of the second order (central differences). When only real nodes are used and the node lies on an edge, a second order approximation is used (forwards or backwards, depending on the position)

Usage

findiff_sparse_elements_realonly(
  nx,
  ny,
  direction,
  i0 = 0,
  multiplier = 1,
  ...
)

Arguments

nx, ny

number of real nodes in x and y-directions. There need to be at least 3 (real or ghost) nodes in the direction of differentiation, or 4 in case 2nd order differentiation is requested with real_only == TRUE

direction

direction of differentiation

  • direction = "x": 1st order in x-direction (d/dx)

  • direction = "y": 1st order in y-direction (d/dy)

i0

optional index offset for node offset

multiplier

optional multipliers for all values in the finite difference matrix to differentiate real nodes

...

potential extra arguments

Value

a tibble with node indices for row (row), column (col) and value (val) columns of non-zero entries in the matrix

Examples

findiff_sparse_elements_realonly(9, 5, "y")

GJMeijer/soilmech documentation built on May 22, 2022, 10:39 a.m.