1 /**********************************************************************\
2 ______ __ __ _______ _______ __ __ __ __ __ ___
3 / || | | | | ____|| ____|| | | | | \ | | | |/ /
4 | ,----'| | | | | |__ | |__ | | | | | \| | | ' /
5 | | | | | | | __| | __| | | | | | . ` | | <
6 | `----.| `--' | | | | | | `----.| | | |\ | | . \
7 \______| \______/ |__| |__| |_______||__| |__| \__| |__|\__\
11 cufflink is a library for linking numerical methods based on Nvidia's
12 Compute Unified Device Architecture (CUDA™) C/C++ programming language
15 Please note that cufflink is not approved or endorsed by ESI-OpenCFD®
16 Limited, the owner of the OpenFOAM® and OpenCFD® trademarks and
17 producer of OpenFOAM® software.
19 The official web-site of OpenCFD® Limited is www.openfoam.com .
21 ------------------------------------------------------------------------
22 This file is part of cufflink.
24 cufflink is free software: you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation, either version 3 of the License, or
27 (at your option) any later version.
29 cufflink is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 GNU General Public License for more details.
34 You should have received a copy of the GNU General Public License
35 along with cufflink. If not, see <http://www.gnu.org/licenses/>.
38 Daniel P. Combest. All rights reserved.
39 Modifications by Dominik Christ, Wikki Ltd.
42 diagonal preconditioned conjugate gradient
43 solver for symmetric Matrices using a CUSP CUDA™ based solver.
45 \**********************************************************************/
47 // Fill in the rest of the diag (rows and col),
48 // upper and upper.rows and upper.cols
49 cusp::coo_matrix<IndexType, ValueType, MemorySpace> A(ces->A);
50 cusp::array1d<ValueType, MemorySpace> X(ces->X);
51 cusp::array1d<ValueType, MemorySpace> B(ces->B);
53 // Determine row indices of diagonal values and fill A COO matrix
54 thrust::sequence(A.row_indices.begin(), A.row_indices.begin() + ces->nCells);
56 // Determine column indices of diagonal values and fill A COO matrix
59 A.column_indices.begin(),
60 A.column_indices.begin() + ces->nCells
63 // Copy values of lower into upper in COO matrix
66 A.values.begin() + ces->nCells,
67 A.values.begin() + ces->nCells + ces->nFaces,
68 A.values.begin() + ces->nCells + ces->nFaces
71 // Copy row indices of lower to columns of upper into A COO matrix
74 A.row_indices.begin() + ces->nCells,
75 A.row_indices.begin() + ces->nCells + ces->nFaces,
76 A.column_indices.begin() + ces->nCells + ces->nFaces
79 // Copy column indices of lower to rows of upper into A COO matrix
82 A.column_indices.begin() + ces->nCells,
83 A.column_indices.begin() + ces->nCells + ces->nFaces,
84 A.row_indices.begin() + ces->nCells + ces->nFaces
87 A.sort_by_row_and_column(); // Speeds code up a little bit more