DOLFIN
DOLFIN C++ interface
PETScLinearOperator.h
1 // Copyright (C) 2005-2012 Anders Logg and Garth N. Wells
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 // Modified by Andy R. Terrel 2005
19 //
20 // First added: 2005-01-17
21 // Last changed: 2012-12-11
22 
23 #ifndef __PETSC_LINEAR_OPERATOR_H
24 #define __PETSC_LINEAR_OPERATOR_H
25 
26 #ifdef HAS_PETSC
27 
28 #include <string>
29 #include <dolfin/common/types.h>
30 #include "PETScBaseMatrix.h"
31 #include "GenericLinearOperator.h"
32 
33 namespace dolfin
34 {
35 
36  class PETScVector;
37 
39 
46  {
47  public:
48 
50  explicit PETScLinearOperator(MPI_Comm comm);
51 
52  //--- Implementation of the GenericLinearOperator interface ---
53 
55  virtual std::size_t size(std::size_t dim) const;
56 
58  virtual void mult(const GenericVector& x, GenericVector& y) const;
59 
61  virtual MPI_Comm mpi_comm() const
62  { return PETScBaseMatrix::mpi_comm(); }
63 
65  virtual std::string str(bool verbose) const;
66 
67  //--- Special functions ---
68 
70  virtual const GenericLinearOperator* wrapper() const;
71 
73  virtual GenericLinearOperator* wrapper();
74 
75  protected:
76 
77  // Initialization
78  void init_layout(const GenericVector& x,
79  const GenericVector& y,
80  GenericLinearOperator* wrapper);
81 
82  // Pointer to wrapper
83  GenericLinearOperator* _wrapper;
84 
85  };
86 
87 }
88 
89 #endif
90 
91 #endif
void init_layout(const GenericVector &x, const GenericVector &y, GenericLinearOperator *wrapper)
Definition: PETScLinearOperator.cpp:110
Definition: adapt.h:29
virtual const GenericLinearOperator * wrapper() const
Return pointer to wrapper (const version)
Definition: PETScLinearOperator.cpp:100
virtual void mult(const GenericVector &x, GenericVector &y) const
Compute matrix-vector product y = Ax.
Definition: PETScLinearOperator.cpp:76
Definition: GenericLinearOperator.h:42
PETScLinearOperator(MPI_Comm comm)
Constructor.
Definition: PETScLinearOperator.cpp:63
virtual MPI_Comm mpi_comm() const
Return MPI communicator.
Definition: PETScLinearOperator.h:61
Definition: PETScBaseMatrix.h:49
virtual std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: PETScLinearOperator.cpp:81
MPI_Comm mpi_comm() const
Return the MPI communicator.
Definition: PETScBaseMatrix.cpp:141
std::pair< std::int64_t, std::int64_t > size() const
Definition: PETScBaseMatrix.cpp:79
This class defines a common interface for vectors.
Definition: GenericVector.h:47
PETSc version of the GenericLinearOperator.
Definition: PETScLinearOperator.h:44