DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
LinearOperator.h
1// Copyright (C) 2012 Anders Logg
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// // You should have received a copy of the GNU Lesser General Public License
15// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
16//
17// First added: 2012-08-20
18// Last changed: 2012-12-12
19
20#ifndef __LINEAR_OPERATOR_H
21#define __LINEAR_OPERATOR_H
22
23#include <memory>
24#include <dolfin/common/MPI.h>
25#include "GenericLinearOperator.h"
26
27namespace dolfin
28{
29
41 {
42 public:
43
46
49 LinearOperator(const GenericVector& x, const GenericVector& y);
50
52 virtual ~LinearOperator() {}
53
55 virtual std::size_t size(std::size_t dim) const = 0;
56
58 virtual void mult(const GenericVector& x, GenericVector& y) const = 0;
59
61 virtual MPI_Comm mpi_comm() const
62 { dolfin_assert(_matA); return _matA->mpi_comm(); }
63
65 std::string str(bool verbose) const;
66
67 //--- Special functions, intended for library use only ---
68
70 virtual const GenericLinearOperator* instance() const;
71
74
76 virtual std::shared_ptr<const LinearAlgebraObject> shared_instance() const;
77
79 virtual std::shared_ptr<LinearAlgebraObject> shared_instance();
80
81 private:
82
83 // Pointer to concrete implementation
84 std::shared_ptr<GenericLinearOperator> _matA;
85
86 };
87
88}
89
90#endif
Definition GenericLinearOperator.h:43
This class defines a common interface for vectors.
Definition GenericVector.h:48
Definition LinearOperator.h:41
virtual std::shared_ptr< const LinearAlgebraObject > shared_instance() const
Return concrete instance / unwrap (const shared pointer version)
Definition LinearOperator.cpp:63
virtual MPI_Comm mpi_comm() const
Return the MPI communicator.
Definition LinearOperator.h:61
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition LinearOperator.cpp:48
LinearOperator()
Create linear operator.
Definition LinearOperator.cpp:28
virtual void mult(const GenericVector &x, GenericVector &y) const =0
Compute matrix-vector product y = Ax.
virtual ~LinearOperator()
Destructor.
Definition LinearOperator.h:52
virtual const GenericLinearOperator * instance() const
Return concrete instance / unwrap (const version)
Definition LinearOperator.cpp:53
virtual std::size_t size(std::size_t dim) const =0
Return size of given dimension.
Definition adapt.h:30