ConjugateGradientSolver.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 CONJUGATEGRADIENTSOLVER_HPP_INCLUDED
25 #define CONJUGATEGRADIENTSOLVER_HPP_INCLUDED
26 
27 
28 #include <stdio.h>
29 
30 #include "FFEA_return_codes.h"
31 #include "mat_vec_types.h"
32 #include "mesh_node.h"
33 #include "tetra_element_linear.h"
34 #include "SimulationParams.h"
35 #include "Solver.h"
37 #include "SparseMatrixTypes.h"
38 
40 public:
43 
46 
48  int init(int num_nodes, int num_elements, mesh_node *node, tetra_element_linear *elem, SimulationParams *params, int num_pinned_nodes, int *pinned_nodes_list, set<int> bsite_pinned_node_list);
49 
51  int solve(vector3 *x);
52 
54  void apply_matrix(scalar *in, scalar *result);
55 
56 private:
57 
60 
62  int i_max;
63 
65  int num_rows;
66 
71 
78  int *key;
79 
82 
84  vector3 *d, *r, *q, *s, *f;
85 
86  /* */
88 
89  /* */
91 
92  void parallel_vector_add_self(vector3 *v1, scalar a, vector3 *v2, int vec_size);
93 
94  void parallel_vector_add(vector3 *v1, scalar a, vector3 *v2, int vec_size);
95 
96  /* */
98 
99  /* */
100  scalar residual2();
101 };
102 
103 #endif
Definition: tetra_element_linear.h:136
int * key
Definition: ConjugateGradientSolver.h:78
void parallel_vector_add_self(vector3 *v1, scalar a, vector3 *v2, int vec_size)
Definition: ConjugateGradientSolver.cpp:292
int solve(vector3 *x)
Definition: ConjugateGradientSolver.cpp:206
vector3 * q
Definition: ConjugateGradientSolver.h:84
sparse_entry * entry
Definition: ConjugateGradientSolver.h:70
scalar parallel_apply_preconditioner()
Definition: ConjugateGradientSolver.cpp:317
int init(int num_nodes, int num_elements, mesh_node *node, tetra_element_linear *elem, SimulationParams *params, int num_pinned_nodes, int *pinned_nodes_list, set< int > bsite_pinned_node_list)
Definition: ConjugateGradientSolver.cpp:62
Definition: SparseMatrixTypes.h:30
scalar epsilon2
Definition: ConjugateGradientSolver.h:59
scalar residual2()
Definition: ConjugateGradientSolver.cpp:334
vector3 * f
Definition: ConjugateGradientSolver.h:84
int i_max
Definition: ConjugateGradientSolver.h:62
static const int x
Definition: rod_math_v9.h:52
void apply_matrix(scalar *in, scalar *result)
Definition: ConjugateGradientSolver.cpp:234
ConjugateGradientSolver()
Definition: ConjugateGradientSolver.cpp:26
scalar parallel_sparse_matrix_apply()
Definition: ConjugateGradientSolver.cpp:270
vector3 * s
Definition: ConjugateGradientSolver.h:84
Definition: ConjugateGradientSolver.h:39
~ConjugateGradientSolver()
Definition: ConjugateGradientSolver.cpp:40
Definition: mesh_node.h:39
scalar conjugate_gradient_residual_assume_x_zero(vector3 *b)
Definition: ConjugateGradientSolver.cpp:244
Definition: SimulationParams.h:75
Definition: Solver.h:30
scalar * preconditioner
Definition: ConjugateGradientSolver.h:81
vector3 * r
Definition: ConjugateGradientSolver.h:84
int num_rows
Definition: ConjugateGradientSolver.h:65
void parallel_vector_add(vector3 *v1, scalar a, vector3 *v2, int vec_size)
Definition: ConjugateGradientSolver.cpp:304
Definition: mat_vec_types.h:90
double scalar
Definition: mat_vec_types.h:36
vector3 * d
Definition: ConjugateGradientSolver.h:84