BiCGSTAB_solver.h
Go to the documentation of this file.
1 //
2 // This file is part of the FFEA simulation package
3 //
4 // Copyright (c) by the Theory and Development FFEA teams,
5 // as they appear in the README.md file.
6 //
7 // FFEA is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // FFEA is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with FFEA. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // To help us fund FFEA development, we humbly ask that you cite
21 // the research papers on the package.
22 //
23 
24 #ifndef BICGSTAB_SOLVER_H_INCLUDED
25 #define BICGSTAB_SOLVER_H_INCLUDED
26 
27 #include <stdlib.h>
28 #include <stdio.h>
29 
30 #include "FFEA_return_codes.h"
31 #include "mat_vec_types.h"
33 
35 public:
37 
39 
40  int init(int N, scalar tol, int max_num_iterations);
41 
43 
44  int solve(SparseMatrixUnknownPattern *A, scalar *x, scalar *b, int num_iterations);
45 
46 private:
47 
49  int N;
50 
53 
56 
59 
61  scalar *r, *r_hat;
64 
66  scalar *p, *p_hat, *q, *s, *s_hat, *t;
69 
72 
74  void copy_vector(scalar *a, scalar *b, int N);
75 
77  scalar dot(scalar *a, scalar *b, int N);
78 
80  void apply_diagonal_matrix(scalar *y, scalar *M, scalar *x, int N);
81 
83  void zero(scalar *x, int N);
84 
86  void scalar_vector_add(scalar *x, scalar *y, scalar c, scalar *z, int N);
87 
89  // p = r + beta(p - omega * v)
90  void complicated_machine(scalar *w, scalar *x, scalar a, scalar *y, scalar b, scalar *z, int N);
91 };
92 
93 #endif
scalar * p
Other necessary vectors.
Definition: BiCGSTAB_solver.h:67
Definition: BiCGSTAB_solver.h:34
static const int z
Definition: rod_math_v9.h:54
~BiCGSTAB_solver()
Definition: BiCGSTAB_solver.cpp:42
scalar * p_hat
Definition: BiCGSTAB_solver.h:67
scalar * r_hat
Definition: BiCGSTAB_solver.h:62
scalar tol
The convergence tolerance threshold.
Definition: BiCGSTAB_solver.h:52
int N
The number of unknowns.
Definition: BiCGSTAB_solver.h:49
int init(int N, scalar tol, int max_num_iterations)
Definition: BiCGSTAB_solver.cpp:68
static const int y
Definition: rod_math_v9.h:53
static const int x
Definition: rod_math_v9.h:52
void copy_vector(scalar *a, scalar *b, int N)
Definition: BiCGSTAB_solver.cpp:264
Definition: SparseMatrixUnknownPattern.h:35
scalar * s
Definition: BiCGSTAB_solver.h:67
void zero(scalar *x, int N)
Definition: BiCGSTAB_solver.cpp:288
scalar dot(scalar *a, scalar *b, int N)
Definition: BiCGSTAB_solver.cpp:271
int max_num_iterations
Maximum number of iterations before giving up.
Definition: BiCGSTAB_solver.h:55
scalar * q
Definition: BiCGSTAB_solver.h:67
void get_residual_vector(scalar *r, scalar *b, SparseMatrixUnknownPattern *A, scalar *x, int N)
Definition: BiCGSTAB_solver.cpp:253
BiCGSTAB_solver()
Definition: BiCGSTAB_solver.cpp:26
scalar * inv_M
The inverse of the preconditioner matrix.
Definition: BiCGSTAB_solver.h:58
void complicated_machine(scalar *w, scalar *x, scalar a, scalar *y, scalar b, scalar *z, int N)
Definition: BiCGSTAB_solver.cpp:304
scalar * t
Definition: BiCGSTAB_solver.h:67
scalar * r
The residual vectors.
Definition: BiCGSTAB_solver.h:62
void apply_diagonal_matrix(scalar *y, scalar *M, scalar *x, int N)
Definition: BiCGSTAB_solver.cpp:281
int solve(SparseMatrixUnknownPattern *A, scalar *x, scalar *b)
Definition: BiCGSTAB_solver.cpp:111
double scalar
Definition: mat_vec_types.h:36
scalar * s_hat
Definition: BiCGSTAB_solver.h:67
void scalar_vector_add(scalar *x, scalar *y, scalar c, scalar *z, int N)
Definition: BiCGSTAB_solver.cpp:295