SpM Handbook 1.2.4
|
#include "common.h"
#include "drivers/laplacian.h"
Go to the source code of this file.
Macros | |
#define | laplacian_add_one_edge(_colptr_, _rowptr_, _valptr_, _dest_, _value_) |
Add an edge to the spm matrix. | |
#define | laplacian_add_three_edges(_colptr_, _rowptr_, _valptr_, _dest_, _fcond_, _lcond_, _valone_, _valtwo_) |
Add three edges of the 27 pts stencil. the direct one, and its two diagonal neighboor ones. | |
Functions | |
static spm_int_t | p_spmLaplacian_getnnz (spm_int_t M, spm_int_t N, spm_int_t K, int level, int connexion) |
Return the number of edges in a laplacian of size MxNxK. | |
void | p_spmLaplacian_7points (spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta) |
Generate a laplacian matrix for a 3D 7-points stencil. | |
void | p_spmLaplacian_27points (spmatrix_t *spm, spm_int_t dim1, spm_int_t dim2, spm_int_t dim3, spm_fixdbl_t alpha, spm_fixdbl_t beta) |
Generate an extended laplacian matrix for a 3D 27-points stencil. | |
SParse Matrix package laplacian generator routines.
Definition in file p_spm_laplacian.c.
#define laplacian_add_one_edge | ( | _colptr_, | |
_rowptr_, | |||
_valptr_, | |||
_dest_, | |||
_value_ | |||
) |
Add an edge to the spm matrix.
[in,out] | _colptr_ | Increment the colptr by 1. |
[in,out] | _rowptr_ | Store the edge value and shift to the next array element |
[in,out] | _valptr_ | Store the edge value and shift to the next array element |
[in] | _dest_ | The destination of the edge |
[in] | _value_ | The value of the edge |
Definition at line 55 of file p_spm_laplacian.c.
#define laplacian_add_three_edges | ( | _colptr_, | |
_rowptr_, | |||
_valptr_, | |||
_dest_, | |||
_fcond_, | |||
_lcond_, | |||
_valone_, | |||
_valtwo_ | |||
) |
Add three edges of the 27 pts stencil. the direct one, and its two diagonal neighboor ones.
[in,out] | _colptr_ | Increment the colptr by 1. |
[in,out] | _rowptr_ | Store the edge value and shift to the next array element |
[in,out] | _valptr_ | Store the edge value and shift to the next array element |
[in] | _dest_ | The center destination of the three edges |
[in] | _fcond_ | The condition to add the first diagonal |
[in] | _lcond_ | The condition to add the last diagonal |
[in] | _valone_ | The value on the central edge |
[in] | _valtwo_ | The value on the diagonal edges |
Definition at line 100 of file p_spm_laplacian.c.
|
static |
Return the number of edges in a laplacian of size MxNxK.
[in] | M | The main dimension (the one split among the processes if any) |
[in] | N | The second dimension (Not split) |
[in] | K | The third dimension (Not split) |
[in] | level | The level of the edges to add
|
[in] | connexion | If connexion is true, the edges to connect to another domain along the first dimension (M) are added to the computation. If false, nothing is added. |
Definition at line 150 of file p_spm_laplacian.c.
Referenced by p_spmLaplacian_27points(), and p_spmLaplacian_7points().
void p_spmLaplacian_7points | ( | spmatrix_t * | spm, |
spm_int_t | dim1, | ||
spm_int_t | dim2, | ||
spm_int_t | dim3, | ||
spm_fixdbl_t | alpha, | ||
spm_fixdbl_t | beta | ||
) |
Generate a laplacian matrix for a 3D 7-points stencil.
The generated laplacian matrix is
with D the doagonal matrix of the degrees and A the adjacency matrix with coefficients of 1. for each connexion.
*-------*-------* /| /| /|
----—B----— | /| | /| | /| | ----—-|--—* | | | | —|-|-B—|-|- | |/| | |/ | |/| | B--—|-A--—|-B | |/| | |/| |/| | ----—B----— | | | | —|-|-—|-|-* | |/ | |/ | |/ | --—|-B--—|- |/ |/ |/ ----—----—*
Each element A is only connected to its neigbours B in the stencil.
Example:
3 -1 -1 0 -1 0 0 0 -1 3 0 -1 0 -1 0 0 -1 0 3 -1 0 0 -1 0 0 -1 -1 3 0 0 0 -1 -1 0 0 0 3 -1 -1 0 0 -1 0 0 -1 3 0 -1 0 0 -1 0 -1 0 3 -1 0 0 0 -1 0 -1 -1 3
[in,out] | spm | At start, an allocated spm structure. Contains the size of the laplacian in spm->n. At exit, contains the matrix in csc format. |
[in] | dim1 | contains the first dimension of the grid of the laplacian. |
[in] | dim2 | contains the second dimension of the grid of the laplacian. |
[in] | dim3 | contains the third dimension of the grid of the laplacian. |
[in] | alpha | The alpha coefficient for the degree matrix |
[in] | beta | The beta coefficient for the adjacency matrix |
Definition at line 275 of file p_spm_laplacian.c.
References spmatrix_s::baseval, spmatrix_s::clustnbr, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::dof, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::gN, spmatrix_s::gnnz, laplacian_add_one_edge, spmatrix_s::loc2glob, spmatrix_s::mtxtype, spmatrix_s::n, spmatrix_s::nnz, p_spmLaplacian_getnnz(), spmatrix_s::replicated, spmatrix_s::rowptr, spm_imin(), SpmCSC, SpmPattern, SpmSymmetric, and spmatrix_s::values.
void p_spmLaplacian_27points | ( | spmatrix_t * | spm, |
spm_int_t | dim1, | ||
spm_int_t | dim2, | ||
spm_int_t | dim3, | ||
spm_fixdbl_t | alpha, | ||
spm_fixdbl_t | beta | ||
) |
Generate an extended laplacian matrix for a 3D 27-points stencil.
The generated laplacian is a the matrix
, where D is the matrix of degrees, and A the matrix of adjacency. In the exemple below for each vertex A, the value of the connexions in the adjacency matrix are:
1 / (3) for the connexions with the D vertices (cube diagonal)
D----—X----—D /| /| /| X----—B----—X | /| | /| | /| | D----—X-|--—D | | | | X—|-|-B—|-|-X | |/| | |/ | |/| | B--—|-A--—|-B | |/| | |/| |/| | X----—B----—X | | | | D—|-|-X—|-|-D | |/ | |/ | |/ | X--—|-B--—|-X |/ |/ |/ D----—X----—D
[in,out] | spm | At start, an allocated spm structure. Contains the size of the laplacian in spm->n. At exit, contains the matrix in csc format. |
[in] | dim1 | contains the first dimension of the grid of the laplacian. |
[in] | dim2 | contains the second dimension of the grid of the laplacian. |
[in] | dim3 | contains the third dimension of the grid of the laplacian. |
[in] | alpha | The alpha coefficient for the degree matrix |
[in] | beta | The beta coefficient for the adjacency matrix |
Definition at line 498 of file p_spm_laplacian.c.
References spmatrix_s::baseval, spmatrix_s::clustnbr, spmatrix_s::clustnum, spmatrix_s::colptr, spmatrix_s::dof, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::gN, spmatrix_s::gnnz, laplacian_add_one_edge, laplacian_add_three_edges, spmatrix_s::loc2glob, spmatrix_s::mtxtype, spmatrix_s::n, spmatrix_s::nnz, p_spmLaplacian_getnnz(), spmatrix_s::replicated, spmatrix_s::rowptr, spm_imin(), SpmCSC, SpmPattern, SpmSymmetric, and spmatrix_s::values.