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
23namespace Opm {
24namespace Elasticity {
25
27typedef Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > Matrix;
28
30typedef std::vector< std::set<int> > AdjacencyPattern;
31
33typedef Dune::BlockVector<Dune::FieldVector<double,1> > Vector;
34
36class 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
Helper class with some matrix operations.
Definition: matrixops.hpp:36
static Matrix Axpy(const Matrix &A, const Matrix &B, double alpha)
axpy like operation - returns A+alpha*B
static Matrix extractDiagonal(const Matrix &A)
Extract the diagonal of a matrix into a new matrix.
static Matrix augment(const Matrix &A, const Matrix &B, size_t r0, size_t c0, bool symmetric)
Augment a matrix with another.
static Matrix diagonal(size_t N)
Returns a diagonal matrix.
static Matrix fromDense(const Dune::DynamicMatrix< double > &T)
Create a sparse matrix from a dense matrix.
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.
static void saveAsc(const Matrix &A, const std::string &file)
Save a matrix as a dense asc file.
static void fromAdjacency(Matrix &A, const AdjacencyPattern &adj, int rows, int cols)
Create a sparse matrix from a given adjacency pattern.
static void print(const Matrix &A)
Print a matrix to stdout.
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition: matrixops.hpp:27
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:33
std::vector< std::set< int > > AdjacencyPattern
For storing matrix adjacency/sparsity patterns.
Definition: matrixops.hpp:30
Definition: ImplicitAssembly.hpp:43