Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scalar_vector_adapter.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 * Author: Arne Nägel
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 SCALAR_VECTOR_ADAPTER_HH_
34#define SCALAR_VECTOR_ADAPTER_HH_
35
36#include <cstdlib>
37
41
42
43using namespace ug;
44
45// provides an interface for matrix of algebra type B for matrices originally of algebra type A
46// allows to access a CPUBlockAlgebra (AT) as a scalar CPUAlgebra (ST)
47
48template<class AT, class ST>
50
51public:
52 typedef typename AT::vector_type encapsulated_vector_type;
53 typedef typename ST::vector_type::value_type value_type;
54 static const int blockSize = AT::blockSize;
55
56 //typedef typename ST::vector_type::const_row_iterator const_row_iterator;
57
59
60 inline value_type &operator [] (size_t i)
61 { return BlockRef(m_src[i/blockSize], i%blockSize);}
62
63 inline const value_type &operator [] (size_t i) const { return (i);}
64
65 void resize(size_t newSize, bool bCopyValues=true)
66 {
67 m_src.resize_exactly(newSize/blockSize, bCopyValues);
68 }
69 void reserve(size_t newCapacity, bool bCopyValues=true)
70 {
71 m_src.reserve_exactly(newCapacity/blockSize, bCopyValues);
72 }
73 void print(const char * const text = NULL) const
74 {
75 m_src.print(text);
76 }
77
78 size_t size() const {return (m_src.size()*blockSize);}
79private:
81};
82
83
84// partielle Spezialisierung fuer Block Algebra 1,2,3
85template<>
89
90
91
92#endif /* SPARSEMATRIXPROXY_HH_ */
Definition scalar_vector_adapter.hh:49
static const int blockSize
Definition scalar_vector_adapter.hh:54
void print(const char *const text=NULL) const
Definition scalar_vector_adapter.hh:73
void reserve(size_t newCapacity, bool bCopyValues=true)
Definition scalar_vector_adapter.hh:69
encapsulated_vector_type & m_src
Definition scalar_vector_adapter.hh:80
ST::vector_type::value_type value_type
Definition scalar_vector_adapter.hh:53
ScalarVectorAdapter(encapsulated_vector_type &vec)
Definition scalar_vector_adapter.hh:58
value_type & operator[](size_t i)
Definition scalar_vector_adapter.hh:60
AT::vector_type encapsulated_vector_type
Definition scalar_vector_adapter.hh:52
size_t size() const
Definition scalar_vector_adapter.hh:78
void resize(size_t newSize, bool bCopyValues=true)
Definition scalar_vector_adapter.hh:65
the ug namespace
double & BlockRef(T &vec, size_t i)
Definition blocks.h:66