@@ -11,6 +11,130 @@ common partial differential equations.
1111
1212## Automated Finite Difference Method (FDM) Operators
1313
14+ This library provides lazy operators for finite difference discretizations.
15+ There are two types of ` DerivativeOperator ` s: the ` CenteredDifference ` operator
16+ and the ` UpwindDifference ` operator. The ` CenteredDifference ` operator utilizes
17+ a central difference scheme while the upwind operator requires a coefficient
18+ to be defined to perform an upwinding difference scheme.
19+
20+ ### Operators Constructors
21+
22+ The constructors are as follows:
23+
24+ ``` julia
25+ CenteredDifference {N} (derivative_order:: Int ,
26+ approximation_order:: Int , dx,
27+ len:: Int , coeff_func= nothing )
28+
29+ UpwindDifference {N} (derivative_order:: Int ,
30+ approximation_order:: Int , dx
31+ len:: Int , coeff_func= nothing )
32+ ```
33+
34+ The arguments are:
35+
36+ - ` N ` : The directional dimension of the discretization. If ` N ` is not given,
37+ it is assumed to be 1, i.e. differencing occurs along columns.
38+ - ` derivative_order ` : the order of the derivative to discretize.
39+ - ` approximation_order ` : the order of the discretization in terms of O(dx^order).
40+ - ` dx ` : the spacing of the discretization. If ` dx ` is a ` Number ` , the operator
41+ is a uniform discretization. If ` dx ` is an array, then the operator is a
42+ non-uniform discretization.
43+ - ` len ` : the length of the discretization in the direction of the operator.
44+ - ` coeff_func ` : An operational argument for a coefficient function ` f(du,u,p,t) `
45+ which sets the coefficients of the operator. If ` coeff_func ` is a ` Number `
46+ then the coefficients are set to be constant with that number. If ` coeff_func `
47+ is an ` AbstractArray ` with length matching ` len ` , then the coefficients are
48+ constant but spatially dependent.
49+
50+ ` N ` -dimensional derivative operators need to act against a value of at least
51+ ` N ` dimensions.
52+
53+ ### Example
54+
55+ The 3-dimensional Laplacian is created by:
56+
57+ ``` julia
58+ N = 64
59+ Dxx = CenteredDifference (2 ,2 ,dx,N)
60+ Dyy = CenteredDifference {2} (2 ,2 ,dx,N)
61+ Dzz = CenteredDifference {3} (2 ,2 ,dx,N)
62+ L = Dxx + Dyy + Dzz
63+
64+ u = rand (N,N,N)
65+ L* u
66+ ```
67+
68+ ### Derivative Operator Actions
69+
70+ These operators are lazy, meaning the memory is not allocated. Similarly, the
71+ operator actions ` * ` can be performed without ever building the operator
72+ matrices. Additionally, ` mul!(y,L,x) ` can be performed for non-allocating
73+ applications of the operator.
74+
75+ ### Concretizations
76+
77+ The following concretizations are provided:
78+
79+ - ` Array `
80+ - ` SparseMatrixCSC `
81+ - ` BandedMatrix `
82+ - ` BlockBandedMatrix `
83+
84+ Additionally, the function ` sparse ` is overloaded to give the most efficient
85+ matrix type for a given operator. For one-dimensional derivatives this is a
86+ ` BandedMatrix ` , while for higher dimensional operators this is a ` BlockBandedMatrix `
87+
88+ ## Boundary Value Operators
89+
90+ Boundary conditions are implemented through a ghost node approach. The discretized
91+ values ` u ` should be the interior of the domain so that, for the boundary value
92+ operator ` Q ` , ` Q*u ` is the discretization on the closure of the domain. By
93+ using it like this, ` L*Q*u ` is the ` NxN ` operator which satisfies the boundary
94+ conditions.
95+
96+ ### Periodic Boundary Conditions
97+
98+ The constructor ` PeriodicBC ` provides the periodic boundary condition operator.
99+
100+ ### Robin Boundary Conditions
101+
102+ The variables in l are ` [αl, βl, γl] ` , and correspond to a BC of the form
103+ ` al*u(0) + bl*u'(0) = cl ` , and similarly ` r ` for the right boundary
104+ ` ar*u(N) + br*u'(N) = cl ` .
105+
106+ ``` julia
107+ RobinBC (l:: AbstractArray{T} , r:: AbstractArray{T} , dx:: AbstractArray{T} , order = one (T))
108+ ```
109+
110+ Additionally, the following helpers exist for the Neumann ` u'(0) = α ` and
111+ Dirichlet ` u(0) = α ` cases.
112+
113+ ``` julia
114+ NeumannBC (α:: AbstractVector{T} , dx:: AbstractVector{T} , order = 1 )
115+ DirichletBC (α:: AbstractVector{T} , dx:: AbstractVector{T} , order = 1 )
116+ ```
117+
118+ ### General Boundary Conditions
119+
120+ Implements a generalization of the Robin boundary condition, where α is a vector
121+ of coefficients. Represents a condition of the form
122+ α[ 1] + α[ 2] u[ 0] + α[ 3] u'[ 0] + α[ 4] u''[ 0] +... = 0
123+
124+ ``` julia
125+ GeneralBC (αl:: AbstractArray{T} , αr:: AbstractArray{T} , dx:: AbstractArray{T} , order = 1 )
126+ ```
127+
128+ ### Concretizations
129+
130+ The following concretizations are provided:
131+
132+ - ` Array `
133+ - ` SparseMatrixCSC `
134+
135+ Additionally, the function ` sparse ` is overloaded to give the most efficient
136+ matrix type for a given operator. For these operators it's ` SparseMatrixCSC ` .
137+
14138## Operator Compositions
15139
16140## Matrix-Free Operators
0 commit comments