2#ifndef DUNE_PDELAB_BACKEND_COMMON_UNCACHEDMATRIXVIEW_HH
3#define DUNE_PDELAB_BACKEND_COMMON_UNCACHEDMATRIXVIEW_HH
11 template<
typename M_,
typename RowCache,
typename ColCache>
12 class ConstUncachedMatrixView
17 typedef typename std::remove_const<M_>::type Container;
21 typename RowCache::LocalFunctionSpace::Traits::GridFunctionSpace,
22 typename Container::TestGridFunctionSpace
24 "The RowCache passed to LocalView must belong to the underlying GFSV"
29 typename ColCache::LocalFunctionSpace::Traits::GridFunctionSpace,
30 typename Container::TrialGridFunctionSpace
32 "The ColCache passed to LocalView must belong to the underlying GFSU"
37 typedef typename Container::field_type E;
38 typedef typename Container::size_type size_type;
40 typedef E ElementType;
42 typedef RowCache RowIndexCache;
43 typedef ColCache ColIndexCache;
45 typedef typename RowCache::LocalFunctionSpace LFSV;
46 typedef typename ColCache::LocalFunctionSpace LFSU;
48 typedef typename LFSV::Traits::DOFIndex RowDOFIndex;
49 typedef typename LFSV::Traits::GridFunctionSpace::Ordering::Traits::ContainerIndex RowContainerIndex;
51 typedef typename LFSU::Traits::DOFIndex ColDOFIndex;
52 typedef typename LFSU::Traits::GridFunctionSpace::Ordering::Traits::ContainerIndex ColContainerIndex;
54 ConstUncachedMatrixView()
60 ConstUncachedMatrixView(M_& container)
61 : _container(&container)
66 const RowIndexCache& rowIndexCache()
const
72 const ColIndexCache& colIndexCache()
const
78 void attach(M_& container)
80 _container = &container;
88 void bind(
const RowCache& row_cache,
const ColCache& col_cache)
90 _row_cache = &row_cache;
91 _col_cache = &col_cache;
99 return rowIndexCache().size();
104 return colIndexCache().size();
107 template<
typename LC>
108 void read(LC& local_container)
const
110 for (size_type i = 0; i < N(); ++i)
111 for (size_type j = 0; j < M(); ++j)
112 local_container.getEntry(i,j) = container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j));
117 const ElementType& operator()(size_type i, size_type j)
const
119 return container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j));
124 template<
typename RDI,
typename CDI>
126 (std::is_same<RDI,RowDOFIndex>{} and std::is_same<CDI,ColDOFIndex>{} and not
127 (std::is_same<RDI,RowContainerIndex>{} and std::is_same<CDI,ColContainerIndex>{})),
130 operator()(
const RDI& i,
const CDI& j)
const
132 return container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j));
135 const ElementType& operator()(
const RowContainerIndex& i,
const ColContainerIndex& j)
const
137 return container()(i,j);
140 const ElementType& operator()(
const RowContainerIndex& i, size_type j)
const
142 return container()(i,colIndexCache().containerIndex(j));
145 const ElementType& operator()(size_type i,
const ColContainerIndex& j)
const
147 return container()(rowIndexCache().containerIndex(i),j);
150 const Container& container()
const
158 const RowCache* _row_cache;
159 const ColCache* _col_cache;
164 template<
typename M_,
typename RowCache,
typename ColCache>
165 class UncachedMatrixView
166 :
public ConstUncachedMatrixView<M_,RowCache,ColCache>
169 typedef ConstUncachedMatrixView<M_,RowCache,ColCache> BaseT;
173 typedef M_ Container;
174 typedef typename Container::ElementType ElementType;
175 typedef typename Container::size_type size_type;
177 typedef RowCache RowIndexCache;
178 typedef ColCache ColIndexCache;
180 typedef typename RowCache::LocalFunctionSpace LFSV;
181 typedef typename ColCache::LocalFunctionSpace LFSU;
183 typedef typename LFSV::Traits::DOFIndex RowDOFIndex;
184 typedef typename LFSV::Traits::GridFunctionSpace::Ordering::Traits::ContainerIndex RowContainerIndex;
186 typedef typename LFSU::Traits::DOFIndex ColDOFIndex;
187 typedef typename LFSU::Traits::GridFunctionSpace::Ordering::Traits::ContainerIndex ColContainerIndex;
189 using BaseT::rowIndexCache;
190 using BaseT::colIndexCache;
196 using BaseT::operator();
201 UncachedMatrixView(Container& container)
208 template<
typename LC>
209 void write(
const LC& local_container)
211 for (size_type i = 0; i < N(); ++i)
212 for (size_type j = 0; j < M(); ++j)
213 container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j)) = local_container.getEntry(i,j);
216 template<
typename LC>
217 void add(
const LC& local_container)
219 for (size_type i = 0; i < N(); ++i)
220 for (size_type j = 0; j < M(); ++j)
221 container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j)) += local_container.getEntry(i,j);
226 ElementType& operator()(size_type i, size_type j)
228 return container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j));
233 template<
typename RDI,
typename CDI>
235 (std::is_same<RDI,RowDOFIndex>{} and std::is_same<CDI,ColDOFIndex>{} and not
236 (std::is_same<RDI,RowContainerIndex>{} and std::is_same<CDI,ColContainerIndex>{})),
239 operator()(
const RDI& i,
const CDI& j)
241 return container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j));
244 ElementType& operator()(
const RowContainerIndex& i,
const ColContainerIndex& j)
246 return container()(i,j);
249 ElementType& operator()(
const RowContainerIndex& i, size_type j)
251 return container()(i,colIndexCache().containerIndex(j));
254 ElementType& operator()(size_type i,
const ColContainerIndex& j)
256 return container()(rowIndexCache().containerIndex(i),j);
259 void add(size_type i, size_type j,
const ElementType& v)
261 container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j)) += v;
266 template<
typename RDI,
typename CDI>
268 (std::is_same<RDI,RowDOFIndex>{} and std::is_same<CDI,ColDOFIndex>{} and not
269 (std::is_same<RDI,RowContainerIndex>{} and std::is_same<CDI,ColContainerIndex>{}))
271 add(
const RDI& i,
const CDI& j,
const ElementType& v)
273 container()(rowIndexCache().containerIndex(i),colIndexCache().containerIndex(j)) += v;
276 void add(
const RowContainerIndex& i,
const ColContainerIndex& j,
const ElementType& v)
278 container()(i,j) += v;
281 void add(
const RowContainerIndex& i, size_type j,
const ElementType& v)
283 container()(i,colIndexCache().containerIndex(j)) += v;
286 void add(size_type i,
const ColContainerIndex& j,
const ElementType& v)
288 container()(rowIndexCache().containerIndex(i),j) += v;
291 Container& container()
293 return *(this->_container);
Dune namespace.
Definition: alignedallocator.hh:13