3 #ifndef DUNE_PDELAB_BACKEND_ISTL_BLOCKMATRIXDIAGONAL_HH 4 #define DUNE_PDELAB_BACKEND_ISTL_BLOCKMATRIXDIAGONAL_HH 23 struct matrix_element_vector;
26 template<
typename E,
int n,
int m>
27 struct matrix_element_vector<
31 typedef FieldMatrix<E,n,m> type;
36 template<
typename Block,
typename Allocator>
37 struct matrix_element_vector<
38 Dune::BCRSMatrix<Block,Allocator>
42 typename matrix_element_vector<Block>::type,
50 template<
typename FieldMatrix>
51 void matrix_element_vector_from_matrix(tags::field_matrix, FieldMatrix& c,
const FieldMatrix& matrix)
57 template<
typename BlockVector,
typename BCRSMatrix>
58 void matrix_element_vector_from_matrix(tags::block_vector, BlockVector& c,
const BCRSMatrix& m)
60 const std::size_t rows = m.N();
62 for (std::size_t i = 0; i < rows; ++i)
63 matrix_element_vector_from_matrix(
container_tag(c[i]),c[i],m[i][i]);
69 template<
typename FieldMatrix>
70 void invert_blocks(tags::field_matrix, FieldMatrix& c)
76 template<
typename BlockVector>
77 void invert_blocks(tags::block_vector, BlockVector& c)
79 const std::size_t rows = c.size();
80 for (std::size_t i = 0; i < rows; ++i)
88 template<
typename FieldMatrix,
typename X,
typename Y>
89 void mv(tags::field_matrix,
const FieldMatrix& c,
const X& x, Y& y)
96 template<
typename BlockVector,
typename X,
typename Y>
97 void mv(tags::block_vector,
const BlockVector& c,
const X& x, Y& y)
99 const std::size_t rows = c.size();
100 for (std::size_t i = 0; i < rows; ++i)
115 template<
typename FieldMatrix,
typename CI>
116 std::size_t row_size(tags::field_matrix,
const FieldMatrix& c,
const CI& ci,
int i)
118 return FieldMatrix::cols;
121 template<
typename FieldMatrix>
122 std::size_t row_size(tags::field_matrix,
const FieldMatrix& c)
124 return FieldMatrix::cols;
127 template<
typename BlockVector,
typename CI>
128 std::size_t row_size(tags::block_vector,
const BlockVector& c,
const CI& ci,
int i)
133 template<
typename BlockVector>
134 std::size_t row_size(tags::block_vector,
const BlockVector& c)
141 template<
typename FieldMatrix,
typename CI>
142 typename FieldMatrix::field_type* row_begin(tags::field_matrix_1_any, FieldMatrix& c,
const CI& ci,
int i)
145 return &(*c[0].begin());
148 template<
typename FieldMatrix,
typename CI>
149 typename FieldMatrix::field_type* row_begin(tags::field_matrix_n_any, FieldMatrix& c,
const CI& ci,
int i)
152 return &(*c[ci[0]].begin());
163 template<
typename FieldMatrix,
typename CI>
164 typename FieldMatrix::field_type* row_end(tags::field_matrix_1_1, FieldMatrix& c,
const CI& ci,
int i)
167 return &(*c[0].begin()) + 1;
172 template<
typename FieldMatrix,
typename CI>
173 typename FieldMatrix::field_type* row_end(tags::field_matrix_1_any, FieldMatrix& c,
const CI& ci,
int i)
176 typename FieldMatrix::row_type::iterator it = c[0].end();
182 template<
typename FieldMatrix,
typename CI>
183 typename FieldMatrix::field_type* row_end(tags::field_matrix_n_any, FieldMatrix& c,
const CI& ci,
int i)
186 typename FieldMatrix::row_type::iterator it = c[ci[0]].end();
195 template<
typename BlockVector,
typename CI>
201 template<
typename BlockVector,
typename CI>
222 typedef typename diagonal::matrix_element_vector<Matrix>::type
Container;
235 diagonal::invert_blocks(
container_tag(_container),_container);
238 template<
typename X,
typename Y>
239 void mv(
const X& x, Y& y)
const 244 template<
typename ContainerIndex>
245 std::size_t
row_size(
const ContainerIndex& ci)
const 247 return diagonal::row_size(
container_tag(_container),_container,ci,ci.size()-1);
250 template<
typename ContainerIndex>
253 return diagonal::row_begin(
container_tag(_container),_container,ci,ci.size()-1);
256 template<
typename ContainerIndex>
259 return diagonal::row_end(
container_tag(_container),_container,ci,ci.size()-1);
265 template<
typename GFS>
267 :
public Dune::CommDataHandleIF<AddMatrixElementVectorDataHandle<GFS>,typename Matrix::field_type>
284 return _gfs.dataHandleContains(codim);
290 return _gfs.dataHandleFixedSize(codim);
297 template<
typename Entity>
300 _index_cache.update(e);
303 for (size_type i = 0; i < _index_cache.size(); ++i)
304 s += _v.row_size(_index_cache.containerIndex(i));
309 template<
typename MessageBuffer,
typename Entity>
310 void gather(MessageBuffer& buff,
const Entity&
e)
const 312 _index_cache.update(e);
313 for (size_type i = 0; i < _index_cache.size(); ++i)
315 const CI& ci = _index_cache.containerIndex(i);
316 for (RowIterator it = _v.row_begin(ci),
317 end_it = _v.row_end(ci);
328 template<
typename MessageBuffer,
typename Entity>
329 void scatter(MessageBuffer& buff,
const Entity&
e, size_type n)
331 _index_cache.update(e);
332 for (size_type i = 0; i < _index_cache.size(); ++i)
334 const CI& ci = _index_cache.containerIndex(i);
335 for (RowIterator it = _v.row_begin(ci),
336 end_it = _v.row_end(ci);
354 mutable IndexCache _index_cache;
365 #endif // DUNE_PDELAB_BACKEND_ISTL_BLOCKMATRIXDIAGONAL_HH std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > & >::type native(T &t)
Definition: backend/interface.hh:199
iterator row_begin(const ContainerIndex &ci)
Definition: blockmatrixdiagonal.hh:251
void gather(MessageBuffer &buff, const Entity &e) const
pack data from user to message buffer
Definition: blockmatrixdiagonal.hh:310
std::size_t row_size(const ContainerIndex &ci) const
Definition: blockmatrixdiagonal.hh:245
diagonal::matrix_element_vector< Matrix >::type Container
Definition: blockmatrixdiagonal.hh:222
typename native_type< T >::type Native
Alias of the native container type associated with T or T itself if it is not a backend wrapper...
Definition: backend/interface.hh:183
void mv(const X &x, Y &y) const
Definition: blockmatrixdiagonal.hh:239
Definition: blockmatrixdiagonal.hh:266
static const int dim
Definition: adaptivity.hh:83
Container _container
Definition: blockmatrixdiagonal.hh:226
tags::container< T >::type container_tag(const T &)
Gets instance of container tag associated with T.
Definition: backend/istl/tags.hh:246
GFS::Traits::SizeType size_type
Definition: blockmatrixdiagonal.hh:273
Definition: adaptivity.hh:27
Container::field_type field_type
Definition: istl/vector.hh:37
Ordering::Traits::ContainerIndex ContainerIndex
Definition: entityindexcache.hh:23
Matrix::field_type DataType
Definition: blockmatrixdiagonal.hh:272
Definition: blockmatrixdiagonal.hh:219
const Entity & e
Definition: localfunctionspace.hh:111
AddMatrixElementVectorDataHandle(const GFS &gfs, MatrixElementVector &v)
Definition: blockmatrixdiagonal.hh:275
iterator row_end(const ContainerIndex &ci)
Definition: blockmatrixdiagonal.hh:257
size_type size(Entity &e) const
how many objects of type DataType have to be sent for a given entity
Definition: blockmatrixdiagonal.hh:298
bool fixedsize(int dim, int codim) const
returns true if size per entity of given dim and codim is a constant
Definition: blockmatrixdiagonal.hh:288
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition: blockmatrixdiagonal.hh:282
void invert()
Definition: blockmatrixdiagonal.hh:233
Definition: blockmatrixdiagonal.hh:214
Backend::Native< M > Matrix
Definition: blockmatrixdiagonal.hh:217
field_type * iterator
Definition: blockmatrixdiagonal.hh:224
const std::string s
Definition: function.hh:1102
void scatter(MessageBuffer &buff, const Entity &e, size_type n)
unpack data from message buffer to user
Definition: blockmatrixdiagonal.hh:329
Container::field_type field_type
Definition: blockmatrixdiagonal.hh:223
MatrixElementVector(const M &m)
Definition: blockmatrixdiagonal.hh:228