3 #ifndef DUNE_PDELAB_BACKEND_ISTL_BLOCKMATRIXDIAGONAL_HH 4 #define DUNE_PDELAB_BACKEND_ISTL_BLOCKMATRIXDIAGONAL_HH 26 struct matrix_element_vector;
29 template<
typename E,
int n,
int m>
30 struct matrix_element_vector<
34 typedef FieldMatrix<E,n,m> type;
39 template<
typename Block,
typename Allocator>
40 struct matrix_element_vector<
41 Dune::BCRSMatrix<Block,Allocator>
44 typedef Dune::BlockVector<
45 typename matrix_element_vector<Block>::type,
53 template<
typename FieldMatrix>
54 void matrix_element_vector_from_matrix(tags::field_matrix, FieldMatrix& c,
const FieldMatrix& matrix)
60 template<
typename BlockVector,
typename BCRSMatrix>
61 void matrix_element_vector_from_matrix(tags::block_vector, BlockVector& c,
const BCRSMatrix& m)
63 const std::size_t rows = m.N();
65 for (std::size_t i = 0; i < rows; ++i)
66 matrix_element_vector_from_matrix(
container_tag(c[i]),c[i],m[i][i]);
72 template<
typename FieldMatrix>
73 void invert_blocks(tags::field_matrix, FieldMatrix& c)
79 template<
typename BlockVector>
80 void invert_blocks(tags::block_vector, BlockVector& c)
82 const std::size_t rows = c.size();
83 for (std::size_t i = 0; i < rows; ++i)
91 template<
typename FieldMatrix,
typename X,
typename Y>
92 void mv(tags::field_matrix,
const FieldMatrix& c,
const X& x, Y& y)
99 template<
typename BlockVector,
typename X,
typename Y>
100 void mv(tags::block_vector,
const BlockVector& c,
const X& x, Y& y)
102 const std::size_t rows = c.size();
103 for (std::size_t i = 0; i < rows; ++i)
118 template<
typename FieldMatrix,
typename CI>
119 std::size_t row_size(tags::field_matrix,
const FieldMatrix& c,
const CI& ci,
int i)
121 return FieldMatrix::cols;
124 template<
typename FieldMatrix>
125 std::size_t row_size(tags::field_matrix,
const FieldMatrix& c)
127 return FieldMatrix::cols;
130 template<
typename BlockVector,
typename CI>
131 std::size_t row_size(tags::block_vector,
const BlockVector& c,
const CI& ci,
int i)
136 template<
typename BlockVector>
137 std::size_t row_size(tags::block_vector,
const BlockVector& c)
144 template<
typename FieldMatrix,
typename CI>
145 typename FieldMatrix::field_type* row_begin(tags::field_matrix_1_any, FieldMatrix& c,
const CI& ci,
int i)
148 return &(*c[0].begin());
151 template<
typename FieldMatrix,
typename CI>
152 typename FieldMatrix::field_type* row_begin(tags::field_matrix_n_any, FieldMatrix& c,
const CI& ci,
int i)
155 return &(*c[ci[0]].begin());
166 template<
typename FieldMatrix,
typename CI>
167 typename FieldMatrix::field_type* row_end(tags::field_matrix_1_1, FieldMatrix& c,
const CI& ci,
int i)
170 return &(*c[0].begin()) + 1;
175 template<
typename FieldMatrix,
typename CI>
176 typename FieldMatrix::field_type* row_end(tags::field_matrix_1_any, FieldMatrix& c,
const CI& ci,
int i)
179 typename FieldMatrix::row_type::iterator it = c[0].end();
185 template<
typename FieldMatrix,
typename CI>
186 typename FieldMatrix::field_type* row_end(tags::field_matrix_n_any, FieldMatrix& c,
const CI& ci,
int i)
189 typename FieldMatrix::row_type::iterator it = c[ci[0]].end();
198 template<
typename BlockVector,
typename CI>
204 template<
typename BlockVector,
typename CI>
225 typedef typename diagonal::matrix_element_vector<Matrix>::type
Container;
238 diagonal::invert_blocks(
container_tag(_container),_container);
241 template<
typename X,
typename Y>
242 void mv(
const X& x, Y& y)
const 247 template<
typename ContainerIndex>
248 std::size_t
row_size(
const ContainerIndex& ci)
const 250 return diagonal::row_size(
container_tag(_container),_container,ci,ci.size()-1);
253 template<
typename ContainerIndex>
256 return diagonal::row_begin(
container_tag(_container),_container,ci,ci.size()-1);
259 template<
typename ContainerIndex>
262 return diagonal::row_end(
container_tag(_container),_container,ci,ci.size()-1);
268 template<
typename GFS>
270 :
public Dune::CommDataHandleIF<AddMatrixElementVectorDataHandle<GFS>,typename Matrix::field_type>
287 return _gfs.dataHandleContains(codim);
293 return _gfs.dataHandleFixedSize(codim);
300 template<
typename Entity>
303 _index_cache.update(e);
306 for (size_type i = 0; i < _index_cache.size(); ++i)
307 s += _v.row_size(_index_cache.containerIndex(i));
312 template<
typename MessageBuffer,
typename Entity>
313 void gather(MessageBuffer& buff,
const Entity&
e)
const 315 _index_cache.update(e);
316 for (size_type i = 0; i < _index_cache.size(); ++i)
318 const CI& ci = _index_cache.containerIndex(i);
319 for (RowIterator it = _v.row_begin(ci),
320 end_it = _v.row_end(ci);
331 template<
typename MessageBuffer,
typename Entity>
332 void scatter(MessageBuffer& buff,
const Entity&
e, size_type n)
334 _index_cache.update(e);
335 for (size_type i = 0; i < _index_cache.size(); ++i)
337 const CI& ci = _index_cache.containerIndex(i);
338 for (RowIterator it = _v.row_begin(ci),
339 end_it = _v.row_end(ci);
357 mutable IndexCache _index_cache;
368 #endif // DUNE_PDELAB_BACKEND_ISTL_BLOCKMATRIXDIAGONAL_HH
void scatter(MessageBuffer &buff, const Entity &e, size_type n)
unpack data from message buffer to user
Definition: blockmatrixdiagonal.hh:332
static const int dim
Definition: adaptivity.hh:83
const Entity & e
Definition: localfunctionspace.hh:111
std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > &>::type native(T &t)
Definition: backend/interface.hh:192
const std::string s
Definition: function.hh:830
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:176
Ordering::Traits::ContainerIndex ContainerIndex
Definition: entityindexcache.hh:23
tags::container< T >::type container_tag(const T &)
Gets instance of container tag associated with T.
Definition: backend/istl/tags.hh:249
GFS::Traits::SizeType size_type
Definition: blockmatrixdiagonal.hh:276
std::size_t row_size(const ContainerIndex &ci) const
Definition: blockmatrixdiagonal.hh:248
AddMatrixElementVectorDataHandle(const GFS &gfs, MatrixElementVector &v)
Definition: blockmatrixdiagonal.hh:278
diagonal::matrix_element_vector< Matrix >::type Container
Definition: blockmatrixdiagonal.hh:225
bool fixedsize(int dim, int codim) const
returns true if size per entity of given dim and codim is a constant
Definition: blockmatrixdiagonal.hh:291
void gather(MessageBuffer &buff, const Entity &e) const
pack data from user to message buffer
Definition: blockmatrixdiagonal.hh:313
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
field_type * iterator
Definition: blockmatrixdiagonal.hh:227
Definition: blockmatrixdiagonal.hh:217
Container::field_type field_type
Definition: blockmatrixdiagonal.hh:226
Matrix::field_type DataType
Definition: blockmatrixdiagonal.hh:275
iterator row_begin(const ContainerIndex &ci)
Definition: blockmatrixdiagonal.hh:254
Container::field_type field_type
Definition: istl/vector.hh:39
void invert()
Definition: blockmatrixdiagonal.hh:236
size_type size(Entity &e) const
how many objects of type DataType have to be sent for a given entity
Definition: blockmatrixdiagonal.hh:301
Definition: blockmatrixdiagonal.hh:269
Backend::Native< M > Matrix
Definition: blockmatrixdiagonal.hh:220
iterator row_end(const ContainerIndex &ci)
Definition: blockmatrixdiagonal.hh:260
bool contains(int dim, int codim) const
returns true if data for this codim should be communicated
Definition: blockmatrixdiagonal.hh:285
MatrixElementVector(const M &m)
Definition: blockmatrixdiagonal.hh:231
Definition: blockmatrixdiagonal.hh:222
void mv(const X &x, Y &y) const
Definition: blockmatrixdiagonal.hh:242
Container _container
Definition: blockmatrixdiagonal.hh:229