/[escript]/branches/diaplayground/ripley/src/RipleySystemMatrix.h
ViewVC logotype

Contents of /branches/diaplayground/ripley/src/RipleySystemMatrix.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5086 - (show annotations)
Mon Jun 30 02:31:20 2014 UTC (4 years, 10 months ago) by caltinay
File MIME type: text/plain
File size: 2807 byte(s)
tweak to set some flags only to nvcc and move THRUST_*_SYSTEM defs to the
scons file.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #ifndef __RIPLEY_SYSTEMMATRIX_H__
18 #define __RIPLEY_SYSTEMMATRIX_H__
19
20 #include <escript/AbstractSystemMatrix.h>
21 #include <escript/FunctionSpace.h>
22
23 #include <ripley/Ripley.h>
24
25 namespace cusp {
26 template <typename IndexType, typename ValueType, class MemorySpace> class dia_matrix;
27 }
28
29 namespace escript {
30 class SolverBuddy;
31 }
32
33 #include <cusp/dia_matrix.h>
34
35 namespace ripley {
36
37 typedef cusp::dia_matrix<int, double, cusp::host_memory> HostMatrixType;
38 typedef cusp::dia_matrix<int, double, cusp::device_memory> DeviceMatrixType;
39 typedef cusp::array1d<double, cusp::host_memory> HostVectorType;
40 typedef cusp::array1d<double, cusp::device_memory> DeviceVectorType;
41
42 class SystemMatrix : public escript::AbstractSystemMatrix
43 {
44 public:
45 SystemMatrix();
46
47 SystemMatrix(int blocksize, const escript::FunctionSpace& fs,
48 int nRows, const IndexVector& diagonalOffsets);
49
50 virtual ~SystemMatrix() {}
51
52 virtual void nullifyRowsAndCols(escript::Data& row_q,
53 escript::Data& col_q,
54 double mdv);
55
56 virtual void saveMM(const std::string& filename) const;
57
58 virtual void saveHB(const std::string& filename) const;
59
60 virtual void resetValues();
61
62 void add(const IndexVector& rowIndex, const std::vector<double>& array);
63
64 void matrixVector(const double* x, double beta, double* y) const;
65
66 inline int getBlockSize() const { return getRowBlockSize(); }
67
68 private:
69 template<class LinearOperator, class Vector, class Preconditioner>
70 void runSolver(LinearOperator& A, Vector& x, Vector& b, Preconditioner& M,
71 escript::SolverBuddy& sb) const;
72
73 virtual void setToSolution(escript::Data& out, escript::Data& in,
74 boost::python::object& options) const;
75
76 virtual void ypAx(escript::Data& y, escript::Data& x) const;
77
78 void checkCUDA();
79
80 /// GPU device IDs supporting CUDA
81 static std::vector<int> cudaDevices;
82
83 HostMatrixType mat;
84 mutable DeviceMatrixType dmat;
85 mutable bool matrixAltered;
86 //int numRows;
87 //std::vector<int> offsets;
88 //std::vector<double> values;
89 };
90
91 } // namespace ripley
92
93 #endif // __RIPLEY_SYSTEMMATRIX_H__
94

  ViewVC Help
Powered by ViewVC 1.1.26