Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "MOR_ConcatenatedEpetraMVSource.hpp"
00008
00009 #include "Teuchos_TestForException.hpp"
00010
00011 #include <algorithm>
00012
00013 namespace MOR {
00014
00015 ConcatenatedEpetraMVSource::ConcatenatedEpetraMVSource(
00016 const Epetra_Map &vectorMap,
00017 const Teuchos::ArrayView<const Teuchos::RCP<EpetraMVSource> > &sources) :
00018 vectorMap_(vectorMap),
00019 sources_(sources),
00020 vectorCount_(0)
00021 {
00022 for (SourceList::const_iterator it = sources_.begin(), it_end = sources_.end(); it != it_end; ++it) {
00023 const EpetraMVSource &source = **it;
00024 TEUCHOS_TEST_FOR_EXCEPT(!vectorMap_.SameAs(source.vectorMap()));
00025 vectorCount_ += source.vectorCount();
00026 }
00027 }
00028
00029 int
00030 ConcatenatedEpetraMVSource::vectorCount() const
00031 {
00032 return vectorCount_;
00033 }
00034
00035 Epetra_Map
00036 ConcatenatedEpetraMVSource::vectorMap() const
00037 {
00038 return vectorMap_;
00039 }
00040
00041 Teuchos::RCP<Epetra_MultiVector>
00042 ConcatenatedEpetraMVSource::multiVectorNew()
00043 {
00044 const Teuchos::RCP<Epetra_MultiVector> result(
00045 new Epetra_MultiVector(vectorMap_, vectorCount_, false));
00046
00047 int firstVectorRank = 0;
00048 for (SourceList::iterator it = sources_.begin(), it_end = sources_.end(); it != it_end; ++it) {
00049 EpetraMVSource &source = **it;
00050 const int vectorSubcount = source.vectorCount();
00051 Epetra_MultiVector buffer(View, *result, firstVectorRank, vectorSubcount);
00052 source.filledMultiVector(buffer);
00053 firstVectorRank += vectorSubcount;
00054 }
00055
00056 return result;
00057 }
00058
00059 }