|
Layers
Diffusion in heterogeneous environments
|
Function for calculating the Laplacian of the concentration in cylindrical coordinates via convolutions. More...
#include <stdio.h>#include <stdlib.h>
Go to the source code of this file.
Macros | |
| #define | A(i, j) a[((i)*N+(j))] |
| Retrieves the appropriate element from the 1D 'a' array given pseudo-2D indices i (z index) and j (r index), for the convolutions; uses column-major ordering. | |
| #define | OUT(i, j) out[((i)*N+(j))] |
| Retrieves the appropriate element from the 1D 'out' array given pseudo-2D indices i (z index) and j (r index); uses column-major ordering. | |
Functions | |
| void | convolve3 (int M, int N, double *a, double scale1, double scale2, double *invr, double *out) |
Calculates updates to the concentration in a layer by applying the Laplacian in cylindrical coordinates; also scales by . More... | |
Function for calculating the Laplacian of the concentration in cylindrical coordinates via convolutions.
The change in the concentration with time depends on the Laplacian of the concentration. In cylindrical coordinates, the Laplacian of
is
Because of circular symmetry,
.
Note that in this program
, which simplifies the kernels below.
The first 2 terms in the equation for the Laplacian are implemented numerically as if they were a 2D Laplacian in cartesian coordinates, by convolving the concentration array
with the Laplacian kernel
and dividing by
(via a scaling factor).
The first derivative with respect to
in the third term is implemented numerically by convolving the
array with the derivative kernel
and dividing by
(via another scaling factor). Rows of the concentration array correspond to
and columns correspond to
.
In the third term,
is a problem numerically for
. But by L'Hopital's Rule,
So for the case
we use
which is implemented by convolving
with the kernel
Also the Laplacian is scaled by
via the scaling factors.
Definition in file convo.c.
| void convolve3 | ( | int | M, |
| int | N, | ||
| double * | a, | ||
| double | scale1, | ||
| double | scale2, | ||
| double * | invr, | ||
| double * | out | ||
| ) |
Calculates updates to the concentration in a layer by applying the Laplacian in cylindrical coordinates; also scales by
.
Calculates the update terms
or
where
= output array
= scaling factors
= input array (concentration)
means convolution
= 3x3 Laplace operator (see above)
= 3x3 Laplace operator modified for 
= 3x3 derivative operator for 
Note that the index
corresponds to
.
| [in] | M | Number of columns of input matrix (z) |
| [in] | N | Number of rows of input matrix (r) |
| [in] | a | Input matrix (concentration, c) |
| [in] | scale1 | Scaling factor #1 |
| [in] | scale2 | Scaling factor #2 |
| [in] | invr | Vector of 1/r values |
| [out] | out | Output matrix |
1.8.11