DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
BlockVector.h
1// Copyright (C) 2008 Kent-Andre Mardal
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 Anders Logg, 2008.
19// Modified by Garth N. Wells, 2011.
20//
21// First added: 2008-08-25
22// Last changed: 2011-01-22
23//
24
25#ifndef __BLOCKVECTOR_H
26#define __BLOCKVECTOR_H
27
28#include <string>
29#include <vector>
30#include <memory>
31#include <dolfin/common/types.h>
32
33namespace dolfin
34{
35
37 class GenericVector;
38
40
42 {
43 public:
44
46 BlockVector(std::size_t n = 0);
47
49 virtual ~BlockVector();
50
52 virtual BlockVector* copy() const;
53
55 void set_block(std::size_t i, std::shared_ptr<GenericVector> v);
56
58 std::shared_ptr<const GenericVector> get_block(std::size_t i) const;
59
61 std::shared_ptr<GenericVector> get_block(std::size_t);
62
64 void axpy(double a, const BlockVector& x);
65
67 double inner(const BlockVector& x) const;
68
70 double norm(std::string norm_type) const;
71
73 double min() const;
74
76 double max() const;
77
79 const BlockVector& operator*= (double a);
80
82 const BlockVector& operator/= (double a);
83
85 const BlockVector& operator+= (const BlockVector& x);
86
88 const BlockVector& operator-= (const BlockVector& x);
89
91 const BlockVector& operator= (const BlockVector& x);
92
94 const BlockVector& operator= (double a);
95
97 virtual bool empty() const;
98
100 std::size_t size() const;
101
103 std::string str(bool verbose) const;
104
105 private:
106
107 std::vector<std::shared_ptr<GenericVector>> vectors;
108
109 };
110
111}
112
113#endif
Block vector.
Definition BlockVector.h:42
virtual bool empty() const
Return true if empty.
Definition BlockVector.cpp:75
double inner(const BlockVector &x) const
Return inner product with given vector.
Definition BlockVector.cpp:91
const BlockVector & operator=(const BlockVector &x)
Assignment operator.
Definition BlockVector.cpp:167
const BlockVector & operator+=(const BlockVector &x)
Add given vector.
Definition BlockVector.cpp:155
void set_block(std::size_t i, std::shared_ptr< GenericVector > v)
Set function.
Definition BlockVector.cpp:56
double max() const
Return maximum value of vector.
Definition BlockVector.cpp:132
virtual ~BlockVector()
Destructor.
Definition BlockVector.cpp:43
const BlockVector & operator-=(const BlockVector &x)
Subtract given vector.
Definition BlockVector.cpp:161
double norm(std::string norm_type) const
Return norm of vector.
Definition BlockVector.cpp:99
std::shared_ptr< const GenericVector > get_block(std::size_t i) const
Get sub-vector (const)
Definition BlockVector.cpp:63
void axpy(double a, const BlockVector &x)
Add multiple of given vector (AXPY operation)
Definition BlockVector.cpp:85
const BlockVector & operator/=(double a)
Divide vector by given number.
Definition BlockVector.cpp:148
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition BlockVector.cpp:181
std::size_t size() const
Number of vectors.
Definition BlockVector.cpp:80
const BlockVector & operator*=(double a)
Multiply vector by given number.
Definition BlockVector.cpp:141
virtual BlockVector * copy() const
Return copy of tensor.
Definition BlockVector.cpp:48
double min() const
Return minimum value of vector.
Definition BlockVector.cpp:123
Definition adapt.h:30