DOLFIN
DOLFIN C++ interface
PETScNestMatrix.h
1 // Copyright (C) 2016 Chris Richardson
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef __PETSC_NESTMATRIX_H
20 #define __PETSC_NESTMATRIX_H
21 
22 #ifdef HAS_PETSC
23 
24 #include <petscmat.h>
25 #include <petscsys.h>
26 
27 #include "PETScMatrix.h"
28 
29 namespace dolfin
30 {
31  class GenericMatrix;
32  class GenericVector;
33  class FunctionSpace;
34 
39 
41  {
42  public:
43 
46 
51  explicit PETScNestMatrix
52  (std::vector<std::shared_ptr<GenericMatrix>> mats);
53 
55  virtual ~PETScNestMatrix();
56 
60  virtual void mult(const GenericVector& x, GenericVector& y) const;
61 
65  void init_vectors(GenericVector& z_out,
66  std::vector<std::shared_ptr<GenericVector>> z_in) const;
67 
71  void get_block_dofs(std::vector<dolfin::la_index>& dofs, std::size_t idx) const;
72 
75  std::size_t size(std::size_t dim) const
76  { return PETScBaseMatrix::size(dim); }
77 
80  virtual std::string str(bool verbose) const;
81 
82  };
83 
84 }
85 
86 #endif
87 
88 #endif
dolfin::PETScNestMatrix::PETScNestMatrix
PETScNestMatrix()
Create empty matrix.
Definition: PETScNestMatrix.cpp:36
dolfin::PETScMatrix
Definition: PETScMatrix.h:59
dolfin::PETScNestMatrix::mult
virtual void mult(const GenericVector &x, GenericVector &y) const
Definition: PETScNestMatrix.cpp:118
dolfin::PETScNestMatrix::size
std::size_t size(std::size_t dim) const
Definition: PETScNestMatrix.h:75
dolfin::PETScBaseMatrix::size
std::pair< std::int64_t, std::int64_t > size() const
Definition: PETScBaseMatrix.cpp:79
dolfin::GenericVector
This class defines a common interface for vectors.
Definition: GenericVector.h:48
dolfin::PETScNestMatrix::~PETScNestMatrix
virtual ~PETScNestMatrix()
Destructor.
Definition: PETScNestMatrix.cpp:91
dolfin::PETScNestMatrix::str
virtual std::string str(bool verbose) const
Definition: PETScNestMatrix.cpp:96
dolfin::PETScNestMatrix::get_block_dofs
void get_block_dofs(std::vector< dolfin::la_index > &dofs, std::size_t idx) const
Definition: PETScNestMatrix.cpp:179
dolfin::PETScNestMatrix::init_vectors
void init_vectors(GenericVector &z_out, std::vector< std::shared_ptr< GenericVector >> z_in) const
Definition: PETScNestMatrix.cpp:144
dolfin::PETScNestMatrix
Definition: PETScNestMatrix.h:41
dolfin
Definition: adapt.h:30