Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
parallel_vector.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3 * Author: Andreas Vogel
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_VECTOR__
34#define __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_VECTOR__
35
36#include "pcl/pcl.h"
40#include "algebra_layouts.h"
41#include "common/assert.h"
42
43namespace ug
44{
45
47
49
58template <typename TVector>
59class ParallelVector : public TVector
60{
61 public:
62 typedef typename TVector::value_type value_type;
63 typedef size_t size_type;
64 typedef typename TVector::vector_type vector_type;
67
68 private:
69 // disallow copy constructor
70 //ParallelVector(const ParallelVector&);
71
73 template<typename T> this_type &operator =(T t);
74
75
76 public:
81
83 ParallelVector(size_t length)
85 {}
86
91
93 // Storage type handling
95
98
101
103
104 void set_storage_type(uint type) {m_type = type;}
105
107
108 void add_storage_type(uint type) {m_type |= type;}
109
111
112 void remove_storage_type(uint type) {m_type &= ~type;}
113
116
118
119 bool has_storage_type(uint type) const
120 {return type == PST_UNDEFINED ? m_type == PST_UNDEFINED : (m_type & type) == type;}
121
123 uint get_storage_mask() const { return m_type; }
125
127 void check_storage_type() const;
128
131
133 // overwritten functions of sequential vector
135
137
142 number norm() const;
143
145 number maxnorm() const;
146
148
153 inline number dotprod(const this_type& v);
154
157
159 void set(number w, ParallelStorageType type);
160
162 void set(number w){return set(w, PST_CONSISTENT);}
163
165 void set_random(number from, number to, ParallelStorageType type);
166 void set_random(number from, number to){return set_random(from, to, PST_CONSISTENT);}
167
170
171
174
177
180
183
184 protected:
186 virtual this_type* virtual_clone() const;
187
190
191 private:
192 // type of storage (i.e. consistent, additive, additive unique)
193 // holds or-combiation of constants enumerated in ug::ParallelStorageType.
195
198};
199
200} // end namespace ug
201
202#include "parallel_vector_impl.h"
203
204#endif /* __H__LIB_ALGEBRA__PARALLELIZATION__PARALLEL_VECTOR__ */
Definition smart_pointer.h:296
Definition smart_pointer.h:108
Extends the HorizontalAlgebraLayouts by vertical layouts.
Definition algebra_layouts.h:121
Definition parallel_vector.h:60
number dotprod(const this_type &v)
dotprod (overwrites TVector::dotprod())
Definition parallel_vector_impl.h:325
ParallelVector(ConstSmartPtr< AlgebraLayouts > layouts)
Constructor setting the Layouts.
Definition parallel_vector.h:88
virtual this_type * virtual_clone() const
virtual clone using covariant return type
Definition parallel_vector_impl.h:550
void check_storage_type() const
checks correctness of storage type
Definition parallel_vector_impl.h:382
void set_random(number from, number to, ParallelStorageType type)
set all entries to a random number (overwrites TVector::set_random(number from, number to))
Definition parallel_vector_impl.h:258
void set(number w)
sets all entries to a value and the storage type to consistent
Definition parallel_vector.h:162
bool has_storage_type(uint type) const
returns if the current storage type has a given representation
Definition parallel_vector.h:119
TVector::value_type value_type
Definition parallel_vector.h:62
this_type & operator=(T t)
catch all other assignments so we don't use copy constructor here
ConstSmartPtr< AlgebraLayouts > m_spAlgebraLayouts
algebra layouts and communicators
Definition parallel_vector.h:197
virtual this_type * virtual_clone_without_values() const
virtual clone using covariant return type excluding values
Definition parallel_vector_impl.h:564
uint get_storage_mask() const
returns storage type mask
Definition parallel_vector.h:123
ParallelStorageType get_storage_type() const
Definition parallel_vector.h:124
TVector::vector_type vector_type
Definition parallel_vector.h:64
void set(number w, ParallelStorageType type)
set all entries to value and the storage type
Definition parallel_vector_impl.h:223
this_type & operator-=(const this_type &v)
subtract a vector
Definition parallel_vector_impl.h:73
size_t size_type
Definition parallel_vector.h:63
SmartPtr< this_type > clone() const
clones the vector (deep-copy) including values
Definition parallel_vector_impl.h:558
void set_random(number from, number to)
Definition parallel_vector.h:166
bool change_storage_type(ParallelStorageType type)
changes to the requested storage type if possible
Definition parallel_vector_impl.h:118
uint m_type
Definition parallel_vector.h:194
void add_storage_type(uint type)
adds a storage type
Definition parallel_vector.h:108
void set_storage_type(uint type)
sets the storage type
Definition parallel_vector.h:104
number maxnorm() const
max norm (overwrites TVector::maxnorm())
Definition parallel_vector_impl.h:298
number norm() const
two norm (overwrites TVector::norm())
Definition parallel_vector_impl.h:271
ParallelVector< TVector > this_type
own type
Definition parallel_vector.h:66
ParallelVector(size_t length)
Resizing constructor.
Definition parallel_vector.h:83
this_type & operator+=(const this_type &v)
add a vector
Definition parallel_vector_impl.h:95
void remove_storage_type(uint type)
removes a storage type
Definition parallel_vector.h:112
ConstSmartPtr< AlgebraLayouts > layouts() const
returns the algebra layouts
Definition parallel_vector.h:97
void set_layouts(ConstSmartPtr< AlgebraLayouts > layouts)
sets the algebra layouts
Definition parallel_vector.h:100
SmartPtr< this_type > clone_without_values() const
clones the vector (deep-copy) excluding values
Definition parallel_vector_impl.h:573
void enforce_consistent_type()
sets storage type to consistent
Definition parallel_vector_impl.h:433
ParallelVector()
Default constructor.
Definition parallel_vector.h:78
ParallelStorageType
Definition parallel_storage_type.h:66
@ PST_UNDEFINED
Definition parallel_storage_type.h:67
@ PST_CONSISTENT
Definition parallel_storage_type.h:68
unsigned int uint
Definition types.h:114
double number
Definition types.h:124
the ug namespace
function ProblemDisc new(problemDesc, dom)