Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vectorblock.hpp
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Vincent Chabannes <vincent.chabannes@imag.fr>
6  Date: 2012-01-18
7 
8  Copyright (C) 2011 Université Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
30 #ifndef __VectorBlock_H
31 #define __VectorBlock_H 1
32 
33 #include <feel/feelalg/vector.hpp>
34 #include <feel/feelalg/backend.hpp>
35 #include <feel/feelvf/block.hpp>
36 
37 
38 namespace Feel
39 {
40 
41 
42 template<typename T> class Backend;
43 
44 
45 template <typename T=double>
46 class BlocksBaseVector : public vf::BlocksBase<boost::shared_ptr<Vector<T> > >
47 {
48 public :
49  typedef vf::BlocksBase<boost::shared_ptr<Vector<T> > > super_type;
50  typedef BlocksBaseVector<T> self_type;
51  typedef Vector<T> vector_type;
52  typedef boost::shared_ptr<vector_type> vector_ptrtype;
53 
54  BlocksBaseVector(uint16_type nr)
55  :
56  super_type(nr,1)
57  {}
58 
59  BlocksBaseVector(super_type const & b)
60  :
61  super_type(b)
62  {}
63 
67  self_type
68  operator<<( vector_ptrtype const& m ) const
69  {
70  return super_type::operator<<( m );
71  }
72 
76  void localize( vector_ptrtype const& vb )
77  {
78  vb->close();
79 
80  size_type _start_i=0;
81  for ( uint16_type i=0; i<this->nRow(); ++i )
82  {
83  size_type nBlockRow = this->operator()( i,0 )->localSize();
84 
85  for ( size_type k=0; k<nBlockRow; ++k )
86  {
87  this->operator()( i,0 )->set( k, vb->operator()( _start_i+k ) );
88  }
89 
90  this->operator()( i,0 )->close();
91  _start_i += nBlockRow;
92  }
93  }
94 
95 };
96 
97 template <int NR, typename T=double>
98 class BlocksVector : public BlocksBaseVector<T>
99 {
100 public :
101  static const uint16_type NBLOCKROWS = NR;
102  static const uint16_type NBLOCKCOLS = 1;
103 
104  typedef BlocksBaseVector<T> super_type;
105 
106  BlocksVector()
107  :
108  super_type(NBLOCKROWS)
109  {}
110 };
111 
112 
126 template< typename T>
127 class VectorBlockBase
128 {
129  //typedef Vector<T> super;
130 public:
131 
135 
136  typedef VectorBlockBase<T> self_type;
137  typedef T value_type;
138 
139  typedef Backend<value_type> backend_type;
140  typedef boost::shared_ptr<backend_type> backend_ptrtype;
141 
142  typedef Vector<T> vector_type;
143  typedef boost::shared_ptr<vector_type> vector_ptrtype;
144 
146 
150 
151  VectorBlockBase( vf::BlocksBase<vector_ptrtype > const & blockVec,
152  backend_type &backend,
153  bool copy_values=true );
154 
155 
156  VectorBlockBase( VectorBlockBase const & vb )
157  :
158  M_vec( vb.M_vec )
159  {}
160 
161  ~VectorBlockBase()
162  {}
163 
165 
169 
170  VectorBlockBase operator=( VectorBlockBase const& vb )
171  {
172  if ( this != &vb )
173  {
174  M_vec = vb.M_vec;
175  }
176 
177  return *this;
178  }
179 
181 
185  vector_ptrtype getVector()
186  {
187  return M_vec;
188  }
190 
194 
195 
197 
201 
202  void updateBlockVec( vector_ptrtype const & m, size_type start_i );
203 
205 
206 
207 
208 protected:
209 
210 private:
211 
212  vector_ptrtype M_vec;
213 };
214 
215 
216 template<int NR, typename T>
217 class VectorBlock : public VectorBlockBase<T>
218 {
219  typedef VectorBlockBase<T> super_type;
220 
221 public:
222 
223  static const uint16_type NBLOCKROWS = NR;
224 
225  typedef typename super_type::value_type value_type;
226  typedef typename super_type::vector_ptrtype vector_ptrtype;
227  typedef typename super_type::backend_type backend_type;
228  typedef vf::Blocks<NBLOCKROWS,1,vector_ptrtype > blocks_type;
229  typedef vf::BlocksBase<vector_ptrtype> blocksbase_type;
230 
231  VectorBlock( blocksbase_type const & blockVec,
232  backend_type &backend,
233  bool copy_values=true )
234  :
235  super_type( blockVec,backend,copy_values )
236  {}
237 
238  VectorBlock( VectorBlock const & vb )
239  :
240  super_type( vb )
241  {}
242 
243  VectorBlock operator=( VectorBlock const& vb )
244  {
245  super_type::operator=( vb );
246  return *this;
247  }
248 
249  VectorBlock & operator = ( vector_ptrtype const& F )
250  {
252  return *this;
253  }
254 
255 }; // VectorBlock
256 
257 
258 } // Feel
259 
260 #endif /* __VectorBlock_H */
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
Elements & operator=(Elements const &e)
Definition: elements.hpp:335

Generated on Sun Dec 22 2013 13:11:15 for Feel++ by doxygen 1.8.5