All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
matrixops.hpp
Go to the documentation of this file.
1 //==============================================================================
11 //==============================================================================
12 #ifndef MATRIXOPS_HPP_
13 #define MATRIXOPS_HPP_
14 
15 #include <opm/common/utility/platform_dependent/disable_warnings.h>
16 
17 #include <dune/common/fmatrix.hh>
18 #include <dune/common/dynmatrix.hh>
19 #include <dune/istl/bcrsmatrix.hh>
20 
21 #include <opm/common/utility/platform_dependent/reenable_warnings.h>
22 
23 namespace Opm {
24 namespace Elasticity {
25 
27 typedef Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > Matrix;
28 
30 typedef std::vector< std::set<int> > AdjacencyPattern;
31 
33 typedef Dune::BlockVector<Dune::FieldVector<double,1> > Vector;
34 
36 class MatrixOps {
37  public:
43  static void fromAdjacency(Matrix& A, const AdjacencyPattern& adj,
44  int rows, int cols);
45 
49  static Matrix fromDense(const Dune::DynamicMatrix<double>& T);
50 
53  static void print(const Matrix& A);
54 
60  static Matrix Axpy(const Matrix& A, const Matrix& B, double alpha);
61 
68  static Matrix augment(const Matrix& A, const Matrix& B,
69  size_t r0, size_t c0, bool symmetric);
70 
74  static Matrix extractDiagonal(const Matrix& A);
75 
78  static Matrix diagonal(size_t N);
79 
83  static Matrix extractBlock(const Matrix& A,
84  size_t r0, size_t N, size_t c0, size_t M);
85 
90  static void saveAsc(const Matrix& A, const std::string& file);
91 };
92 
93 }
94 }
95 
96 #endif
static Matrix extractDiagonal(const Matrix &A)
Extract the diagonal of a matrix into a new matrix.
Definition: matrixops.cpp:184
static Matrix augment(const Matrix &A, const Matrix &B, size_t r0, size_t c0, bool symmetric)
Augment a matrix with another.
Definition: matrixops.cpp:126
static Matrix fromDense(const Dune::DynamicMatrix< double > &T)
Create a sparse matrix from a dense matrix.
Definition: matrixops.cpp:49
static void print(const Matrix &A)
Print a matrix to stdout.
Definition: matrixops.cpp:73
static void fromAdjacency(Matrix &A, const AdjacencyPattern &adj, int rows, int cols)
Create a sparse matrix from a given adjacency pattern.
Definition: matrixops.cpp:25
static Matrix diagonal(size_t N)
Returns a diagonal matrix.
Definition: matrixops.cpp:198
static void saveAsc(const Matrix &A, const std::string &file)
Save a matrix as a dense asc file.
Definition: matrixops.cpp:210
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.
Definition: matrixops.cpp:240
static Matrix Axpy(const Matrix &A, const Matrix &B, double alpha)
axpy like operation - returns A+alpha*B
Definition: matrixops.cpp:87
Helper class with some matrix operations.
Definition: matrixops.hpp:36