jacobi_C-Style
|
#include "getmatrix.h"
#include "userset.h"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <vector>
Go to the source code of this file.
Functions | |
void | Get_Matrix_Pattern (int const nelem, int const ndof_e, int const *const ia, int &nnz, int *&id, int *&ik, double *&sk) |
void | CalcElem (int const ial[3], double const xc[], double ske[3][3], double fe[3]) |
void | AddElem (int const ial[3], double const ske[3][3], double const fe[3], int const id[], int const ik[], double sk[], double f[]) |
void | DebugMatrix (int const nnode, int const id[], int const ik[], double const sk[]) |
void | DebugVector (int const nnode, double const v[]) |
int | fetch (int const row, int const col, int const id[], int const ik[]) |
void | Defect (double w[], double const f[], double const u[], int const nnode, int const id[], int const ik[], double const sk[]) |
void | CrsMult (double w[], double const u[], int const nnode, int const id[], int const ik[], double const sk[]) |
void | GetDiag (int const nnode, int const id[], int const ik[], double const sk[], double d[]) |
void | GetMatrix (int const nelem, int const ndof_e, int const ia[], int const nnode, double const xc[], int const nnz, int const id[], int const ik[], double sk[], double f[]) |
void | ApplyDirichletBC (int const nx, int const ny, int const neigh[], double const u[], int const id[], int const ik[], double sk[], double f[]) |
void AddElem | ( | int const | ial[3], |
double const | ske[3][3], | ||
double const | fe[3], | ||
int const | id[], | ||
int const | ik[], | ||
double | sk[], | ||
double | f[] | ||
) |
Adds the element stiffness matrix ske
and the element load vector fe
of one triangular element with linear shape functions to the appropriate positions in the symmetric stiffness matrix, stored as CSR matrix K(sk
,id
, ik
)
[in] | ial | node indices of the three element vertices |
[in] | ske | element stiffness matrix |
[in] | fe | element load vector |
[out] | sk | vector non-zero entries of CSR matrix |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[out] | f | distributed local vector storing the right hand side |
Definition at line 97 of file getmatrix.cpp.
void ApplyDirichletBC | ( | int const | nx, |
int const | ny, | ||
int const | neigh[], | ||
double const | u[], | ||
int const | id[], | ||
int const | ik[], | ||
double | sk[], | ||
double | f[] | ||
) |
Applies Dirichlet boundary conditions to symmetric CSR matrix (sk
,id
, ik
) and right hand side f
of a system of equations resulting from a FEM/FDM discretization
[in] | nx | number of discretization intervals in x-direction |
[in] | ny | number of discretization intervals in y-direction |
[in] | neigh | vector of 4 elements containing the ranks of neighbouring processes, -1 indicates a boundary in this direction |
[in] | u | local vector with appropriately initialized b.c. |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[in,out] | sk | vector non-zero entries of CSR matrix |
[in,out] | f | right hand side |
Definition at line 275 of file getmatrix.cpp.
void CalcElem | ( | int const | ial[3], |
double const | xc[], | ||
double | ske[3][3], | ||
double | fe[3] | ||
) |
Calculates the element stiffness matrix ske
and the element load vector fe
of one triangular element with linear shape functions.
[in] | ial | node indices of the three element vertices |
[in] | xc | vector of node coordinates with x(2*k,2*k+1) as coodinates of node k |
[out] | ske | element stiffness matrix |
[out] | fe | element load vector |
Definition at line 68 of file getmatrix.cpp.
void CrsMult | ( | double | w[], |
double const | u[], | ||
int | nnode, | ||
int const | id[], | ||
int const | ik[], | ||
double const | sk[] | ||
) |
Multiplies vector u
with a CSR matrix K(id
, ik
, sk
). w := K*u
[out] | w | distributed local vector. |
[in] | u | accumulated local vector. |
[in] | nnode | number of rows |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[in] | sk | vector non-zero entries of CSR matrix |
Definition at line 206 of file getmatrix.cpp.
void DebugMatrix | ( | int const | nnode, |
int const | id[], | ||
int const | ik[], | ||
double const | sk[] | ||
) |
Print entries of the CSR matrix K(id
, ik
, sk
).
[in] | nnode | number of rows |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[in] | sk | vector non-zero entries of CSR matrix |
Definition at line 132 of file getmatrix.cpp.
void DebugVector | ( | int const | nnode, |
double const | v[] | ||
) |
Print entries of a vector.
[in] | nnode | number of entries |
[in] | v | vector values |
Definition at line 154 of file getmatrix.cpp.
void Defect | ( | double | w[], |
double const | f[], | ||
double const | u[], | ||
int | nnode, | ||
int const | id[], | ||
int const | ik[], | ||
double const | sk[] | ||
) |
Calculates the defect w := f - K*u a CSR matrix K(id
, ik
, sk
).
[out] | w | distributed local vector. |
[in] | f | distributed local vector. |
[in] | u | accumulated local vector. |
[in] | nnode | number of rows |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[in] | sk | vector non-zero entries of CSR matrix |
Definition at line 191 of file getmatrix.cpp.
int fetch | ( | int const | row, |
int const | col, | ||
int const | id[], | ||
int const | ik[] | ||
) |
Finds in a CRS matrix the access index for an entry at row row
and column col
.
[in] | row | row index |
[in] | col | column index |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
row
, col
). If no appropriate entry exists then -1 will be returned.row
, col
) doesn't exist. Definition at line 170 of file getmatrix.cpp.
void Get_Matrix_Pattern | ( | int const | nelem, |
int const | ndof_e, | ||
int const *const | ia, | ||
int & | nnz, | ||
int *& | id, | ||
int *& | ik, | ||
double *& | sk | ||
) |
Determines the matrix graph of an CRS matrix (id
, ik
, sk
) based on the element connectivity ia
.
The memory for arrays id
, ik
, sk
is allocated inside the function.
[in] | nelem | number of triangular elements |
[in] | ndof_e | number of f.e. nodes per element |
[in] | ia | element connectivity array[nelem][ndof_e] for linear triangular elements |
[out] | nnz | number of non-zero elements in matrix |
[out] | id | array[nnode+1] storing indices of first entry of a row (is allocated in function) |
[out] | ik | array[nnz] storing column indices of non-zero entries (is allocated in function) |
[out] | sk | array[nnz] storing values of non-zero entries (is allocated in function) |
Definition at line 14 of file getmatrix.cpp.
void GetDiag | ( | int | nnode, |
int const | id[], | ||
int const | ik[], | ||
double const | sk[], | ||
double | d[] | ||
) |
Copies the diagonal entries of a CSR matrix (sk
,id
, ik
) onto a vector d
.
[in] | nnode | number of rows |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[in] | sk | vector non-zero entries of CSR matrix |
[out] | d | accumulated diagonal entries of CSR matrix |
Definition at line 223 of file getmatrix.cpp.
void GetMatrix | ( | int const | nelem, |
int const | ndof_e, | ||
int const | ia[], | ||
int const | nnode, | ||
double const | xc[], | ||
int const | nnz, | ||
int const | id[], | ||
int const | ik[], | ||
double | sk[], | ||
double | f[] | ||
) |
Computes the stiffness matrix in CRS format(id
, ik
, sk
) and load vector f
for the Poisson problem without incorporating the boundary conditions The matrix pattern has to be generated previously and the memory has to be allocated therein.
[in] | nelem | number of finite elements |
[in] | ndof_e | degrees of freedom per element |
[in] | ia | element connectivity array[nelem][ndof_e] |
[in] | nnode | number of coordinates (== number of unknowns) |
[in] | xc | coordinates[nnode][2] |
[in] | nnz | number of non-zero entries in CRS matrix |
[in] | id | index vector containing the first entry in a CSR row |
[in] | ik | column index vector of CSR matrix |
[out] | sk | vector of non-zero entries of CSR matrix |
[out] | f | distributed local vector storing the right hand side |
Definition at line 243 of file getmatrix.cpp.