RipleySystemMatrix.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2014-2017 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014 by Centre for Geoscience Computing (GeoComp)
*
*****************************************************************************/
#ifndef __RIPLEY_SYSTEMMATRIX_H__
#define __RIPLEY_SYSTEMMATRIX_H__
#include <escript/AbstractSystemMatrix.h>
#include <escript/FunctionSpace.h>
#include <ripley/Ripley.h>
namespace escript {
class SolverBuddy;
}
#include <cusp/cds_matrix.h>
namespace ripley {
typedef cusp::cds_matrix<int, double, cusp::host_memory> HostMatrixType;
typedef cusp::cds_matrix<int, double, cusp::device_memory> DeviceMatrixType;
typedef cusp::array1d<double, cusp::host_memory> HostVectorType;
typedef cusp::array1d<double, cusp::device_memory> DeviceVectorType;
class SystemMatrix : public escript::AbstractSystemMatrix
{
public:
SystemMatrix(escript::JMPI mpiInfo, int blocksize,
const escript::FunctionSpace& fs, int nRows,
const IndexVector& diagonalOffsets, bool symmetric);
virtual ~SystemMatrix() {}
virtual void nullifyRowsAndCols(escript::Data& row_q,
escript::Data& col_q,
double mdv);
virtual void saveMM(const std::string& filename) const;
virtual void saveHB(const std::string& filename) const;
virtual void resetValues(bool preserveSolverData = false);
void add(const IndexVector& rowIndex, const std::vector<double>& array);
inline int getBlockSize() const { return getRowBlockSize(); }
private:
template<class LinearOperator, class Vector, class Preconditioner>
void runSolver(LinearOperator& A, Vector& x, Vector& b, Preconditioner& M,
escript::SolverBuddy& sb) const;
void copyMatrixToDevice(bool verbose=false) const;
virtual void setToSolution(escript::Data& out, escript::Data& in,
boost::python::object& options) const;
virtual void ypAx(escript::Data& y, escript::Data& x) const;
static void checkCUDA();
static std::vector<int> cudaDevices;
escript::JMPI m_mpiInfo;
HostMatrixType mat;
mutable DeviceMatrixType dmat;
mutable bool matrixAltered;
bool symmetric;
};
} // namespace ripley
#endif // __RIPLEY_SYSTEMMATRIX_H__
ripley::SystemMatrix::~SystemMatrix
virtual ~SystemMatrix()
Definition: RipleySystemMatrix.h:45
escript::FunctionSpace
Definition: FunctionSpace.h:34
escript::SolverBuddy
Definition: SolverOptions.h:184
ripley::SystemMatrix::cudaDevices
static std::vector< int > cudaDevices
GPU device IDs supporting CUDA.
Definition: RipleySystemMatrix.h:77
ripley::HostVectorType
cusp::array1d< double, cusp::host_memory > HostVectorType
Definition: RipleySystemMatrix.h:35
escript
Definition: AbstractContinuousDomain.cpp:22
ripley::HostMatrixType
cusp::cds_matrix< int, double, cusp::host_memory > HostMatrixType
Definition: RipleySystemMatrix.h:33
ripley::DeviceVectorType
cusp::array1d< double, cusp::device_memory > DeviceVectorType
Definition: RipleySystemMatrix.h:36
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:71
ripley::SystemMatrix
Definition: RipleySystemMatrix.h:38
paso::M
static dim_t M
Definition: SparseMatrix_saveHB.cpp:37
ripley::SystemMatrix::dmat
DeviceMatrixType dmat
Definition: RipleySystemMatrix.h:81
escript::symmetric
void symmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2
Definition: DataVectorOps.h:102
ripley::SystemMatrix::symmetric
bool symmetric
Definition: RipleySystemMatrix.h:83
ripley::IndexVector
std::vector< index_t > IndexVector
Definition: Ripley.h:43
ripley::DeviceMatrixType
cusp::cds_matrix< int, double, cusp::device_memory > DeviceMatrixType
Definition: RipleySystemMatrix.h:34
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:63
ripley::SystemMatrix::m_mpiInfo
escript::JMPI m_mpiInfo
Definition: RipleySystemMatrix.h:79
escript::Vector
Data Vector(double value, const FunctionSpace &what, bool expanded)
Return a Data object containing vector data-points. ie: rank 1 data-points.
Definition: DataFactory.cpp:84
ripley::SystemMatrix::mat
HostMatrixType mat
Definition: RipleySystemMatrix.h:80
ripley::SystemMatrix::matrixAltered
bool matrixAltered
Definition: RipleySystemMatrix.h:82
escript::AbstractSystemMatrix
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:42
ripley
Definition: ripley/src/AbstractAssembler.h:25
ripley::SystemMatrix::getBlockSize
int getBlockSize() const
Definition: RipleySystemMatrix.h:59