matrixops.hpp
Go to the documentation of this file.
1 //==============================================================================
11 //==============================================================================
12 #ifndef MATRIXOPS_HPP_
13 #define MATRIXOPS_HPP_
14 
15 #include <dune/common/fmatrix.hh>
16 #include <dune/common/dynmatrix.hh>
17 #include <dune/istl/bcrsmatrix.hh>
18 
19 namespace Opm {
20 namespace Elasticity {
21 
23 typedef Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > Matrix;
24 
26 typedef std::vector< std::set<int> > AdjacencyPattern;
27 
29 typedef Dune::BlockVector<Dune::FieldVector<double,1> > Vector;
30 
32 class MatrixOps {
33  public:
39  static void fromAdjacency(Matrix& A, const AdjacencyPattern& adj,
40  int rows, int cols);
41 
45  static Matrix fromDense(const Dune::DynamicMatrix<double>& T);
46 
49  static void print(const Matrix& A);
50 
56  static Matrix Axpy(const Matrix& A, const Matrix& B, double alpha);
57 
64  static Matrix augment(const Matrix& A, const Matrix& B,
65  size_t r0, size_t c0, bool symmetric);
66 
70  static Matrix extractDiagonal(const Matrix& A);
71 
74  static Matrix diagonal(size_t N);
75 
79  static Matrix extractBlock(const Matrix& A,
80  size_t r0, size_t N, size_t c0, size_t M);
81 
86  static void saveAsc(const Matrix& A, const std::string& file);
87 };
88 
89 }
90 }
91 
92 #endif
static Matrix Axpy(const Matrix &A, const Matrix &B, double alpha)
axpy like operation - returns A+alpha*B
static Matrix diagonal(size_t N)
Returns a diagonal matrix.
Definition: applier.hpp:18
static Matrix fromDense(const Dune::DynamicMatrix< double > &T)
Create a sparse matrix from a dense matrix.
std::vector< std::set< int > > AdjacencyPattern
For storing matrix adjacency/sparsity patterns.
Definition: matrixops.hpp:26
static void saveAsc(const Matrix &A, const std::string &file)
Save a matrix as a dense asc file.
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition: matrixops.hpp:23
static Matrix extractDiagonal(const Matrix &A)
Extract the diagonal of a matrix into a new matrix.
static void fromAdjacency(Matrix &A, const AdjacencyPattern &adj, int rows, int cols)
Create a sparse matrix from a given adjacency pattern.
Helper class with some matrix operations.
Definition: matrixops.hpp:32
static void print(const Matrix &A)
Print a matrix to stdout.
static Matrix augment(const Matrix &A, const Matrix &B, size_t r0, size_t c0, bool symmetric)
Augment a matrix with another.
static Matrix extractBlock(const Matrix &A, size_t r0, size_t N, size_t c0, size_t M)
Extract a subblock of a matrix into a new matrix.
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:29