ug4
Loading...
Searching...
No Matches
local_algebra.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3 * Author: Andreas Vogel
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 __H__UG__LIB_DISC__COMMON__LOCAL_ALGEBRA__
34#define __H__UG__LIB_DISC__COMMON__LOCAL_ALGEBRA__
35
36//#define UG_LOCALALGEBRA_ASSERT(cond, exp)
37// include define below to assert arrays used in stabilization
38#define UG_LOCALALGEBRA_ASSERT(cond, exp) UG_ASSERT((cond), exp)
39
40#include <vector>
41
42#include "./multi_index.h"
43#include "./function_group.h"
45
46namespace ug{
47
48
50{
51 public:
53 typedef size_t index_type;
54
57
58 public:
61
63 void resize_fct(size_t numFct)
64 {
65 m_vvIndex.resize(numFct);
66 m_vLFEID.resize(numFct);
67 }
68
70 void set_lfeID(size_t fct, const LFEID& lfeID)
71 {
72 UG_ASSERT(fct < m_vLFEID.size(), "Invalid index: "<<fct);
73 m_vLFEID[fct] = lfeID;
74 }
75
77 const LFEID& local_finite_element_id(size_t fct) const
78 {
79 UG_ASSERT(fct < m_vLFEID.size(), "Invalid index: "<<fct);
80 return m_vLFEID[fct];
81 }
82
84 void resize_dof(size_t fct, size_t numDoF)
85 {
86 check_fct(fct);
87 m_vvIndex[fct].resize(numDoF);
88 }
89
91 void clear_dof(size_t fct) {resize_dof(fct, 0);}
92
94 void reserve_dof(size_t fct, size_t numDoF)
95 {
96 check_fct(fct);
97 m_vvIndex[fct].reserve(numDoF);
98 }
99
101 void push_back_index(size_t fct, size_t index) {push_back_multi_index(fct,index,0);}
102
104 void push_back_multi_index(size_t fct, size_t index, size_t comp)
105 {
106 check_fct(fct);
107 m_vvIndex[fct].push_back(DoFIndex(index,comp));
108 }
109
111 void clear() {m_vvIndex.clear();}
112
114 size_t num_fct() const {return m_vvIndex.size();}
115
117 size_t num_dof(size_t fct) const
118 {
119 check_fct(fct);
120 return m_vvIndex[fct].size();
121 }
122
124 size_t num_dof() const
125 {
126 size_t num = 0;
127 for(size_t fct = 0; fct < num_fct(); ++fct) num += num_dof(fct);
128 return num;
129 }
130
132 const DoFIndex& multi_index(size_t fct, size_t dof) const
133 {
134 check_dof(fct, dof);
135 return m_vvIndex[fct][dof];
136 }
137
139 index_type index(size_t fct, size_t dof) const
140 {
141 check_dof(fct, dof);
142 return m_vvIndex[fct][dof][0];
143 }
144
146 index_type& index(size_t fct, size_t dof)
147 {
148 check_dof(fct, dof);
149 return m_vvIndex[fct][dof][0];
150 }
151
153 comp_type comp(size_t fct, size_t dof) const
154 {
155 check_dof(fct, dof);
156 return m_vvIndex[fct][dof][1];
157 }
158
160 comp_type& comp(size_t fct, size_t dof)
161 {
162 check_dof(fct, dof);
163 return m_vvIndex[fct][dof][1];
164 }
165
168 {
169 for(size_t fct = 0; fct < num_fct(); fct++)
170 for(size_t dof = 0; dof < num_dof(fct); dof++)
171 if(m_vvIndex[fct][dof][0] == ind)
172 return true;
173 return false;
174 }
175
176 protected:
178 inline void check_fct(size_t fct) const
179 {
180 UG_LOCALALGEBRA_ASSERT(fct < num_fct(), "Wrong index.");
181 }
183 inline void check_dof(size_t fct, size_t dof) const
184 {
185 check_fct(fct);
186 UG_LOCALALGEBRA_ASSERT(dof < num_dof(fct), "Wrong index.");
187 }
188
189 protected:
190 // Mapping (fct, dof) -> local index
191 std::vector<std::vector<DoFIndex> > m_vvIndex;
192
193 // Local finite element ids
194 std::vector<LFEID> m_vLFEID;
195};
196
198{
199 public:
202
205
206 public:
209
211 LocalVector(const LocalIndices& ind) {resize(ind);}
212
214 void resize(const LocalIndices& ind)
215 {
216 m_pIndex = &ind;
217 m_vvValue.resize(ind.num_fct());
218 m_vvValueAcc.resize(m_vvValue.size());
219 for(size_t fct = 0; fct < m_vvValue.size(); ++fct)
220 m_vvValue[fct].resize(ind.num_dof(fct));
221 access_all();
222 }
223
225 const LocalIndices& get_indices() const {return *m_pIndex;}
226
228 // vector functions
230
232 {
233 m_pIndex = other.m_pIndex;
234 const size_t numFcts = m_pIndex->num_fct();
235 m_vvValue.resize(numFcts);
236 for (size_t fct = 0; fct < numFcts; ++fct)
237 m_vvValue[fct].resize(m_pIndex->num_dof(fct));
238 m_vvValueAcc.resize(numFcts);
239 if (other.m_pFuncMap)
241 else
242 access_all();
243
244 return *this;
245 }
246
249 {
250 for(size_t fct = 0; fct < m_vvValue.size(); ++fct)
251 for(size_t dof = 0; dof < m_vvValue[fct].size(); ++dof)
252 m_vvValue[fct][dof] = val;
253 return *this;
254 }
255
258 {
259 return this->operator*=(val);
260 }
261
264 {
265 for(size_t fct = 0; fct < m_vvValue.size(); ++fct)
266 for(size_t dof = 0; dof < m_vvValue[fct].size(); ++dof)
267 m_vvValue[fct][dof] *= val;
268 return *this;
269 }
270
273 {
274 UG_LOCALALGEBRA_ASSERT(m_pIndex==rhs.m_pIndex, "Not same indices.");
275 for(size_t fct = 0; fct < m_vvValue.size(); ++fct)
276 for(size_t dof = 0; dof < m_vvValue[fct].size(); ++dof)
277 m_vvValue[fct][dof] += rhs.m_vvValue[fct][dof];
278 return *this;
279 }
280
283 {
284 UG_LOCALALGEBRA_ASSERT(m_pIndex==rhs.m_pIndex, "Not same indices.");
285 for(size_t fct = 0; fct < m_vvValue.size(); ++fct)
286 for(size_t dof = 0; dof < m_vvValue[fct].size(); ++dof)
287 m_vvValue[fct][dof] -= rhs.m_vvValue[fct][dof];
288 return *this;
289 }
290
293 {
294 UG_LOCALALGEBRA_ASSERT(m_pIndex==rhs.m_pIndex, "Not same indices.");
295 for(size_t fct = 0; fct < m_vvValue.size(); ++fct)
296 for(size_t dof = 0; dof < m_vvValue[fct].size(); ++dof)
297 m_vvValue[fct][dof] += s * rhs.m_vvValue[fct][dof];
298 return *this;
299 }
300
302 // restricted DoF access
304
307 {
308 m_pFuncMap = &funcMap;
309 for(size_t i = 0; i < funcMap.num_fct(); ++i)
310 {
311 const size_t mapFct = funcMap[i];
312 m_vvValueAcc[i] = &(m_vvValue[mapFct][0]);
313 }
314 }
315
318 {
319 m_pFuncMap = NULL;
320
321 if(m_pIndex==NULL) {m_vvValueAcc.clear(); return;}
322
323 for(size_t i = 0; i < m_pIndex->num_fct(); ++i)
324 m_vvValueAcc[i] = &(m_vvValue[i][0]);
325 }
326
328 size_t num_fct() const
329 {
330 if(m_pFuncMap == NULL) return m_vvValue.size();
331 return m_pFuncMap->num_fct();
332 }
333
335 const LFEID& local_finite_element_id(size_t fct) const
336 {
337 UG_ASSERT(m_pIndex != NULL, "No indices present");
338 check_fct(fct);
339 if(m_pFuncMap == NULL) return m_pIndex->local_finite_element_id(fct);
340 else return m_pIndex->local_finite_element_id((*m_pFuncMap)[fct]);
341 }
342
344 size_t num_dof(size_t fct) const
345 {
346 check_fct(fct);
347 if(m_pFuncMap == NULL) return m_vvValue[fct].size();
348 else return m_vvValue[ (*m_pFuncMap)[fct] ].size();
349 }
350
352 number& operator()(size_t fct, size_t dof)
353 {
354 check_dof(fct,dof);
355 return m_vvValueAcc[fct][dof];
356 }
357
359 number operator()(size_t fct, size_t dof) const
360 {
361 check_dof(fct,dof);
362 return m_vvValueAcc[fct][dof];
363 }
364
366 // all DoF access
368
370 size_t num_all_fct() const {return m_vvValue.size();}
371
373 size_t num_all_dof(size_t fct) const {check_all_fct(fct); return m_vvValue[fct].size();}
374
376 number& value(size_t fct, size_t dof){check_all_dof(fct,dof);return m_vvValue[fct][dof];}
377
379 const number& value(size_t fct, size_t dof) const{check_all_dof(fct,dof);return m_vvValue[fct][dof];}
380
381 protected:
383 inline void check_fct(size_t fct) const
384 {
385 UG_LOCALALGEBRA_ASSERT(fct < num_fct(), "Wrong index: fct: "<<fct<<
386 " of num_fct: "<<num_fct());
387 }
389 inline void check_dof(size_t fct, size_t dof) const
390 {
391 check_fct(fct);
392 UG_LOCALALGEBRA_ASSERT(dof < num_dof(fct), "Wrong index: dof: "
393 <<dof<<", num_dof: "<<num_dof(fct)<<" of fct: "<<fct);
394 }
396 inline void check_all_fct(size_t fct) const
397 {
398 UG_LOCALALGEBRA_ASSERT(fct < num_all_fct(), "Wrong index.");
399 }
401 inline void check_all_dof(size_t fct, size_t dof) const
402 {
403 check_all_fct(fct);
404 UG_LOCALALGEBRA_ASSERT(dof < num_all_dof(fct), "Wrong index.");
405 }
406
407 protected:
410
413
415 std::vector<value_type*> m_vvValueAcc;
416
418 std::vector<std::vector<value_type> > m_vvValue;
419};
420
422{
423 public:
426
429
430 public:
433 m_pRowIndex(NULL), m_pColIndex(NULL) ,
434 m_pRowFuncMap(NULL), m_pColFuncMap(NULL)
435 {}
436
438 LocalMatrix(const LocalIndices& rowInd, const LocalIndices& colInd)
439 : m_pRowFuncMap(NULL), m_pColFuncMap(NULL)
440 {
441 resize(rowInd, colInd);
442 }
443
445 void resize(const LocalIndices& ind) {resize(ind, ind);}
446
448 void resize(const LocalIndices& rowInd, const LocalIndices& colInd)
449 {
450 m_pRowIndex = &rowInd;
451 m_pColIndex = &colInd;
452
453 m_CplMat.resize(rowInd.num_fct(), colInd.num_fct());
454 m_CplMatAcc.resize(rowInd.num_fct(), colInd.num_fct());
455
456 for(size_t fct1 = 0; fct1 < m_CplMat.num_rows(); ++fct1)
457 for(size_t fct2 = 0; fct2 < m_CplMat.num_cols(); ++fct2)
458 {
459 m_CplMat(fct1, fct2).resize(colInd.num_dof(fct1),
460 rowInd.num_dof(fct2));
461 }
462
463 access_all();
464 }
465
467 const LocalIndices& get_row_indices() const {return *m_pRowIndex;}
468
470 const LocalIndices& get_col_indices() const {return *m_pColIndex;}
471
473 // Matrix functions
475
478 {
479 for(size_t fct1=0; fct1 < m_CplMat.num_rows(); ++fct1)
480 for(size_t fct2=0; fct2 < m_CplMat.num_cols(); ++fct2)
481 m_CplMat(fct1,fct2) = val;
482 return *this;
483 }
484
487 {
488 return this->operator*=(val);
489 }
490
493 {
494 for(size_t fct1=0; fct1 < m_CplMat.num_rows(); ++fct1)
495 for(size_t fct2=0; fct2 < m_CplMat.num_cols(); ++fct2)
496 m_CplMat(fct1,fct2) *= val;
497 return *this;
498 }
499
502 {
504 m_pColIndex==rhs.m_pColIndex, "Not same indices.");
505 for(size_t fct1=0; fct1 < m_CplMat.num_rows(); ++fct1)
506 for(size_t fct2=0; fct2 < m_CplMat.num_cols(); ++fct2)
507 m_CplMat(fct1,fct2) += rhs.m_CplMat(fct1,fct2);
508 return *this;
509 }
510
513 {
515 m_pColIndex==rhs.m_pColIndex, "Not same indices.");
516 for(size_t fct1=0; fct1 < m_CplMat.num_rows(); ++fct1)
517 for(size_t fct2=0; fct2 < m_CplMat.num_cols(); ++fct2)
518 m_CplMat(fct1,fct2) -= rhs.m_CplMat(fct1,fct2);
519 return *this;
520 }
521
524 {
526 m_pColIndex==rhs.m_pColIndex, "Not same indices.");
527 for(size_t fct1=0; fct1 < m_CplMat.num_rows(); ++fct1)
528 for(size_t fct2=0; fct2 < m_CplMat.num_cols(); ++fct2)
529 MatScaleAppend(m_CplMat(fct1,fct2), s, rhs.m_CplMat(fct1,fct2));
530 return *this;
531 }
532
534 // restricted DoF access
536
539 {
540 access_by_map(funcMap, funcMap);
541 }
542
544 void access_by_map(const FunctionIndexMapping& rowFuncMap,
545 const FunctionIndexMapping& colFuncMap)
546 {
547 m_pRowFuncMap = &rowFuncMap;
548 m_pColFuncMap = &colFuncMap;
549
550 for(size_t i = 0; i < m_pRowFuncMap->num_fct(); ++i)
551 for(size_t j = 0; j < m_pColFuncMap->num_fct(); ++j)
552 {
553 const size_t rowMapFct = rowFuncMap[i];
554 const size_t colMapFct = colFuncMap[j];
555
556 m_CplMatAcc(i,j) = &(m_CplMat(rowMapFct, colMapFct));
557 }
558 }
559
562 {
563 m_pRowFuncMap = NULL;
564 m_pColFuncMap = NULL;
565
566 if(m_pRowIndex==NULL) {m_CplMatAcc.resize(0,0); return;}
567
568 for(size_t i = 0; i < m_pRowIndex->num_fct(); ++i)
569 for(size_t j = 0; j < m_pColIndex->num_fct(); ++j)
570 m_CplMatAcc(i,j) = &(m_CplMat(i,j));
571 }
572
574 size_t num_row_fct() const
575 {
576 if(m_pRowFuncMap != NULL) return m_pRowFuncMap->num_fct();
577 return m_CplMatAcc.num_rows();
578 }
579
581 size_t num_col_fct() const
582 {
583 if(m_pColFuncMap != NULL) return m_pColFuncMap->num_fct();
584 return m_CplMatAcc.num_cols();
585 }
586
588 size_t num_row_dof(size_t fct) const
589 {
590 if(m_CplMat.num_rows()==0) return 0;
591 if(m_pRowFuncMap == NULL) return m_CplMat(fct, 0).num_rows();
592 else return m_CplMat( (*m_pRowFuncMap)[fct], 0).num_rows();
593 }
594
596 size_t num_col_dof(size_t fct) const
597 {
598 if(m_CplMat.num_cols()==0) return 0;
599 if(m_pRowFuncMap == NULL) return m_CplMat(0, fct).num_cols();
600 else return m_CplMat( 0, (*m_pColFuncMap)[fct]).num_cols();
601 }
602
604 number& operator()(size_t rowFct, size_t rowDoF,
605 size_t colFct, size_t colDoF)
606 {
607 check_dof(rowFct, rowDoF, colFct, colDoF);
608 return (*m_CplMatAcc(rowFct,colFct))(rowDoF, colDoF);
609 }
610
612 number operator()(size_t rowFct, size_t rowDoF,
613 size_t colFct, size_t colDoF) const
614 {
615 check_dof(rowFct, rowDoF, colFct, colDoF);
616 return (*m_CplMatAcc(rowFct,colFct))(rowDoF, colDoF);
617 }
618
620 // all DoF access
622
624 size_t num_all_row_fct() const{ return m_CplMat.num_rows();}
625
627 size_t num_all_col_fct() const{return m_CplMat.num_cols();}
628
630 size_t num_all_row_dof(size_t fct) const {return m_CplMat(fct, 0).num_rows();}
631
633 size_t num_all_col_dof(size_t fct) const {return m_CplMat(0, fct).num_cols();}
634
636 number& value(size_t rowFct, size_t rowDoF,
637 size_t colFct, size_t colDoF)
638 {
639 check_all_dof(rowFct, rowDoF, colFct, colDoF);
640 return (m_CplMat(rowFct,colFct))(rowDoF, colDoF);
641 }
642
644 number value(size_t rowFct, size_t rowDoF,
645 size_t colFct, size_t colDoF) const
646 {
647 check_all_dof(rowFct, rowDoF, colFct, colDoF);
648 return (m_CplMat(rowFct,colFct))(rowDoF, colDoF);
649 }
650
651 protected:
653 inline void check_fct(size_t rowFct, size_t colFct) const
654 {
655 UG_LOCALALGEBRA_ASSERT(rowFct < num_row_fct(), "Wrong index.");
656 UG_LOCALALGEBRA_ASSERT(colFct < num_col_fct(), "Wrong index.");
657 }
659 inline void check_dof(size_t rowFct, size_t rowDoF,
660 size_t colFct, size_t colDoF) const
661 {
662 check_fct(rowFct, colFct);
663 UG_LOCALALGEBRA_ASSERT(rowDoF < num_row_dof(rowFct), "Wrong index.");
664 UG_LOCALALGEBRA_ASSERT(colDoF < num_col_dof(colFct), "Wrong index.");
665 }
667 inline void check_all_fct(size_t rowFct, size_t colFct) const
668 {
669 UG_LOCALALGEBRA_ASSERT(rowFct < num_all_row_fct(), "Wrong index.");
670 UG_LOCALALGEBRA_ASSERT(colFct < num_all_col_fct(), "Wrong index.");
671 }
673 inline void check_all_dof(size_t rowFct, size_t rowDoF,
674 size_t colFct, size_t colDoF) const
675 {
676 check_all_fct(rowFct, colFct);
677 UG_LOCALALGEBRA_ASSERT(rowDoF < num_all_row_dof(rowFct), "Wrong index.");
678 UG_LOCALALGEBRA_ASSERT(colDoF < num_all_col_dof(colFct), "Wrong index.");
679 }
680
681 protected:
682 // Row indices
684
685 // Column indices
687
690
693
694 // \todo: Think of a better (faster) storage (one plain array?)
695
696 // type of cpl matrices between two functions
698
699 // type of Func-Coupling matrices
701
702 // type of Func-Coupling pointer matrices
704
705 // Entries (fct1, fct2, dof1, dof2)
707
708 // Entries (fct1, fct2, dof1, dof2)
710};
711
712inline
713std::ostream& operator<< (std::ostream& outStream, const ug::LocalMatrix& mat)
714{
715 for(size_t fct1 = 0; fct1 < mat.num_row_fct(); ++fct1)
716 for(size_t fct2 = 0; fct2 < mat.num_col_fct(); ++fct2)
717 for(size_t dof1 = 0; dof1 < mat.num_row_dof(fct1); ++dof1)
718 for(size_t dof2 = 0; dof2 < mat.num_col_dof(fct2); ++dof2)
719 {
720 outStream << "[("<< fct1 << "," << dof1 << ") x ("
721 << fct2 << "," << dof2 << ")]: "
722 << mat(fct1, dof1, fct2, dof2) << "\n";
723 }
724 return outStream;
725}
726
727inline
728std::ostream& operator<< (std::ostream& outStream, const ug::LocalVector& vec)
729{
730 for(size_t fct = 0; fct < vec.num_fct(); ++fct)
731 for(size_t dof = 0; dof < vec.num_dof(fct); ++dof)
732 {
733 outStream << "["<<fct<<","<<dof<<"]:" << vec(fct, dof) << "\n";
734 }
735 return outStream;
736}
737
738template <typename TVector>
739void GetLocalVector(LocalVector& lvec, const TVector& vec)
740{
741 const LocalIndices& ind = lvec.get_indices();
742
743 for(size_t fct=0; fct < lvec.num_all_fct(); ++fct)
744 for(size_t dof=0; dof < lvec.num_all_dof(fct); ++dof)
745 {
746 const size_t index = ind.index(fct,dof);
747 const size_t comp = ind.comp(fct,dof);
748 lvec.value(fct,dof) = BlockRef(vec[index], comp);
749 }
750}
751
752template <typename TVector>
753void AddLocalVector(TVector& vec, const LocalVector& lvec)
754{
755 const LocalIndices& ind = lvec.get_indices();
756
757 for(size_t fct=0; fct < lvec.num_all_fct(); ++fct)
758 for(size_t dof=0; dof < lvec.num_all_dof(fct); ++dof)
759 {
760 const size_t index = ind.index(fct,dof);
761 const size_t comp = ind.comp(fct,dof);
762 BlockRef(vec[index], comp) += lvec.value(fct,dof);
763 }
764}
765
766template <typename TMatrix>
767void AddLocalMatrixToGlobal(TMatrix& mat, const LocalMatrix& lmat)
768{
769 //PROFILE_FUNC_GROUP("algebra")
770 const LocalIndices& rowInd = lmat.get_row_indices();
771 const LocalIndices& colInd = lmat.get_col_indices();
772
773 for(size_t fct1=0; fct1 < lmat.num_all_row_fct(); ++fct1)
774 for(size_t dof1=0; dof1 < lmat.num_all_row_dof(fct1); ++dof1)
775 {
776 const size_t rowIndex = rowInd.index(fct1,dof1);
777 const size_t rowComp = rowInd.comp(fct1,dof1);
778
779 for(size_t fct2=0; fct2 < lmat.num_all_col_fct(); ++fct2)
780 for(size_t dof2=0; dof2 < lmat.num_all_col_dof(fct2); ++dof2)
781 {
782 const size_t colIndex = colInd.index(fct2,dof2);
783 const size_t colComp = colInd.comp(fct2,dof2);
784
785 BlockRef(mat(rowIndex, colIndex), rowComp, colComp)
786 += lmat.value(fct1,dof1,fct2,dof2);
787 }
788 }
789}
790
791} // end namespace ug
792
793#endif /* __H__UG__LIB_DISC__COMMON__LOCAL_ALGEBRA__ */
parameterString s
Definition densematrix.h:57
describes a mapping between two local index sets
Definition function_group.h:186
size_t num_fct() const
returns the number of indices that are mapped
Definition function_group.h:195
void clear()
removes all connections
Definition function_group.h:189
Identifier for Local Finite Elements.
Definition local_finite_element_id.h:98
Definition local_algebra.h:50
const DoFIndex & multi_index(size_t fct, size_t dof) const
global algebra multi-index for (fct, dof)
Definition local_algebra.h:132
const LFEID & local_finite_element_id(size_t fct) const
returns the local finite element id of a function
Definition local_algebra.h:77
size_t num_dof(size_t fct) const
number of dofs for accessible function
Definition local_algebra.h:117
size_t num_dof() const
number of dofs of all accessible (sum)
Definition local_algebra.h:124
void push_back_index(size_t fct, size_t index)
adds an index (increases size)
Definition local_algebra.h:101
void reserve_dof(size_t fct, size_t numDoF)
reserves memory for the number of dofs
Definition local_algebra.h:94
void clear_dof(size_t fct)
clears the dofs of a function
Definition local_algebra.h:91
index_type index(size_t fct, size_t dof) const
global algebra index for (fct, dof)
Definition local_algebra.h:139
std::vector< LFEID > m_vLFEID
Definition local_algebra.h:194
size_t index_type
Index type used by algebra.
Definition local_algebra.h:53
void clear()
clears all fct
Definition local_algebra.h:111
void resize_dof(size_t fct, size_t numDoF)
sets the number of dofs of a function
Definition local_algebra.h:84
void check_dof(size_t fct, size_t dof) const
checks correct dof index in debug mode
Definition local_algebra.h:183
void set_lfeID(size_t fct, const LFEID &lfeID)
sets the local finite element id for a function
Definition local_algebra.h:70
bool contains_index(index_type ind)
checks if the local index object references a given index
Definition local_algebra.h:167
LocalIndices()
Default Constructor.
Definition local_algebra.h:60
size_t num_fct() const
number of functions
Definition local_algebra.h:114
void resize_fct(size_t numFct)
sets the number of functions
Definition local_algebra.h:63
std::vector< std::vector< DoFIndex > > m_vvIndex
Definition local_algebra.h:191
void check_fct(size_t fct) const
checks correct fct index in debug mode
Definition local_algebra.h:178
comp_type comp(size_t fct, size_t dof) const
algebra comp for (fct, dof)
Definition local_algebra.h:153
index_type & index(size_t fct, size_t dof)
global algebra index for (fct, dof)
Definition local_algebra.h:146
index_type comp_type
Component type used by algebra.
Definition local_algebra.h:56
void push_back_multi_index(size_t fct, size_t index, size_t comp)
adds an index (increases size)
Definition local_algebra.h:104
comp_type & comp(size_t fct, size_t dof)
algebra comp for (fct, dof)
Definition local_algebra.h:160
Definition local_algebra.h:422
number value(size_t rowFct, size_t rowDoF, size_t colFct, size_t colDoF) const
const access to coupling (rowFct, rowDoF) x (colFct, colDoF)
Definition local_algebra.h:644
const FunctionIndexMapping * m_pRowFuncMap
Row Access Mapping.
Definition local_algebra.h:689
this_type & scale_append(number s, const this_type &rhs)
add scaled matrix
Definition local_algebra.h:523
size_t num_all_col_fct() const
returns the number of all functions
Definition local_algebra.h:627
size_t num_col_fct() const
returns the number of currently accessible (restricted) functions
Definition local_algebra.h:581
DenseMatrix< VariableArray2< value_type > > LocalCplMatrix
Definition local_algebra.h:697
size_t num_row_fct() const
returns the number of currently accessible (restricted) functions
Definition local_algebra.h:574
const LocalIndices & get_row_indices() const
get current local indices
Definition local_algebra.h:467
this_type & operator*(number val)
multiply all entries
Definition local_algebra.h:486
this_type & operator=(number val)
set all entries
Definition local_algebra.h:477
DenseMatrix< VariableArray2< LocalCplMatrix * > > FctCplAccMatrix
Definition local_algebra.h:703
number operator()(size_t rowFct, size_t rowDoF, size_t colFct, size_t colDoF) const
const access to (restricted) coupling (rowFct, rowDoF) x (colFct, colDoF)
Definition local_algebra.h:612
void check_dof(size_t rowFct, size_t rowDoF, size_t colFct, size_t colDoF) const
checks correct (dof1,dof2) index in debug mode
Definition local_algebra.h:659
this_type & operator*=(number val)
multiply matrix
Definition local_algebra.h:492
size_t num_all_row_fct() const
returns the number of all functions
Definition local_algebra.h:624
size_t num_all_col_dof(size_t fct) const
returns the number of dofs for a function
Definition local_algebra.h:633
number value_type
Entry type used by algebra.
Definition local_algebra.h:428
void resize(const LocalIndices &rowInd, const LocalIndices &colInd)
resize for current local indices
Definition local_algebra.h:448
void check_all_dof(size_t rowFct, size_t rowDoF, size_t colFct, size_t colDoF) const
checks correct (dof1,dof2) index in debug mode
Definition local_algebra.h:673
LocalMatrix(const LocalIndices &rowInd, const LocalIndices &colInd)
Constructor.
Definition local_algebra.h:438
const LocalIndices & get_col_indices() const
get current local indices
Definition local_algebra.h:470
DenseMatrix< VariableArray2< LocalCplMatrix > > FctCplMatrix
Definition local_algebra.h:700
void check_fct(size_t rowFct, size_t colFct) const
checks correct (fct1,fct2) index in debug mode
Definition local_algebra.h:653
size_t num_all_row_dof(size_t fct) const
returns the number of dofs for a function
Definition local_algebra.h:630
void access_by_map(const FunctionIndexMapping &funcMap)
access only part of the functions using mapping (restrict functions)
Definition local_algebra.h:538
const LocalIndices * m_pColIndex
Definition local_algebra.h:686
const FunctionIndexMapping * m_pColFuncMap
Column Access Mapping.
Definition local_algebra.h:692
this_type & operator+=(const this_type &rhs)
add matrix
Definition local_algebra.h:501
LocalMatrix()
Constructor.
Definition local_algebra.h:432
void access_by_map(const FunctionIndexMapping &rowFuncMap, const FunctionIndexMapping &colFuncMap)
access only part of the functions using mapping (restrict functions)
Definition local_algebra.h:544
number & value(size_t rowFct, size_t rowDoF, size_t colFct, size_t colDoF)
access to coupling (rowFct, rowDoF) x (colFct, colDoF)
Definition local_algebra.h:636
void resize(const LocalIndices &ind)
resize for same ind in row and column
Definition local_algebra.h:445
FctCplMatrix m_CplMat
Definition local_algebra.h:706
number & operator()(size_t rowFct, size_t rowDoF, size_t colFct, size_t colDoF)
access to (restricted) coupling (rowFct, rowDoF) x (colFct, colDoF)
Definition local_algebra.h:604
LocalMatrix this_type
own type
Definition local_algebra.h:425
size_t num_col_dof(size_t fct) const
returns the number of dofs for the currently accessible (restricted) function
Definition local_algebra.h:596
const LocalIndices * m_pRowIndex
Definition local_algebra.h:683
this_type & operator-=(const this_type &rhs)
subtract matrix
Definition local_algebra.h:512
FctCplAccMatrix m_CplMatAcc
Definition local_algebra.h:709
size_t num_row_dof(size_t fct) const
returns the number of dofs for the currently accessible (restricted) function
Definition local_algebra.h:588
void check_all_fct(size_t rowFct, size_t colFct) const
checks correct (fct1,fct2) index in debug mode
Definition local_algebra.h:667
void access_all()
access all functions
Definition local_algebra.h:561
Definition local_algebra.h:198
const LFEID & local_finite_element_id(size_t fct) const
returns the local finite element id of a function
Definition local_algebra.h:335
std::vector< std::vector< value_type > > m_vvValue
Entries (fct, dof)
Definition local_algebra.h:418
this_type & operator*=(number val)
multiply all components of the vector
Definition local_algebra.h:263
void check_all_fct(size_t fct) const
checks correct fct index in debug mode
Definition local_algebra.h:396
number & operator()(size_t fct, size_t dof)
access to dof of currently accessible function fct
Definition local_algebra.h:352
size_t num_dof(size_t fct) const
returns the number of dofs for the currently accessible function
Definition local_algebra.h:344
const LocalIndices * m_pIndex
Indices.
Definition local_algebra.h:409
LocalVector()
default Constructor
Definition local_algebra.h:208
void check_fct(size_t fct) const
checks correct fct index in debug mode
Definition local_algebra.h:383
this_type & operator=(number val)
set all components of the vector
Definition local_algebra.h:248
number value_type
Type to store DoF values.
Definition local_algebra.h:204
size_t num_all_fct() const
returns the number of all functions
Definition local_algebra.h:370
number operator()(size_t fct, size_t dof) const
const access to dof of currently accessible function fct
Definition local_algebra.h:359
this_type & operator*(number val)
multiply all components of the vector
Definition local_algebra.h:257
void check_all_dof(size_t fct, size_t dof) const
checks correct dof index in debug mode
Definition local_algebra.h:401
LocalVector this_type
own type
Definition local_algebra.h:201
const FunctionIndexMapping * m_pFuncMap
Access Mapping.
Definition local_algebra.h:412
const LocalIndices & get_indices() const
get current local indices
Definition local_algebra.h:225
size_t num_fct() const
returns the number of currently accessible functions
Definition local_algebra.h:328
number & value(size_t fct, size_t dof)
access to dof of a fct (unrestricted functions)
Definition local_algebra.h:376
void access_all()
access all functions
Definition local_algebra.h:317
this_type & operator+=(const this_type &rhs)
add a local vector
Definition local_algebra.h:272
this_type & operator=(const this_type &other)
Definition local_algebra.h:231
void access_by_map(const FunctionIndexMapping &funcMap)
access only part of the functions using mapping (restrict functions)
Definition local_algebra.h:306
std::vector< value_type * > m_vvValueAcc
Entries (fct, dof)
Definition local_algebra.h:415
void resize(const LocalIndices &ind)
resize for current local indices
Definition local_algebra.h:214
this_type & scale_append(number s, const this_type &rhs)
add a scaled vector
Definition local_algebra.h:292
void check_dof(size_t fct, size_t dof) const
checks correct dof index in debug mode
Definition local_algebra.h:389
this_type & operator-=(const this_type &rhs)
subtract a local vector
Definition local_algebra.h:282
const number & value(size_t fct, size_t dof) const
const access to dof of a fct (unrestricted functions)
Definition local_algebra.h:379
size_t num_all_dof(size_t fct) const
returns the number of dofs for a function (unrestricted functions)
Definition local_algebra.h:373
LocalVector(const LocalIndices &ind)
Constructor.
Definition local_algebra.h:211
Definition multi_index.h:50
bool resize(size_type newRows, size_type newCols, bool bCopyValues=true)
Definition variable_array_impl.h:237
size_type num_rows() const
Definition variable_array_impl.h:222
size_type num_cols() const
Definition variable_array_impl.h:229
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition math_matrix.cpp:38
void MatScaleAppend(matrix_t &mOut, typename matrix_t::value_type s, const matrix_t &m)
scales a matrix_t and adds to result to a second matrix
Definition math_matrix_functions_common_impl.hpp:329
#define UG_ASSERT(expr, msg)
Definition assert.h:70
double number
Definition types.h:124
#define UG_LOCALALGEBRA_ASSERT(cond, exp)
Definition local_algebra.h:38
the ug namespace
double & BlockRef(T &vec, size_t i)
Definition blocks.h:66
MultiIndex< 2 > DoFIndex
type of DoF-Index used to identify an DoF in the Algebra
Definition multi_index.h:272
void GetLocalVector(LocalVector &lvec, const TVector &vec)
Definition local_algebra.h:739
void AddLocalVector(TVector &vec, const LocalVector &lvec)
Definition local_algebra.h:753
void AddLocalMatrixToGlobal(TMatrix &mat, const LocalMatrix &lmat)
Definition local_algebra.h:767