• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

MOR_MeanSubstractingSnapshotPreprocessor.cpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #include "MOR_MeanSubstractingSnapshotPreprocessor.hpp"
00008 
00009 #include "Teuchos_Assert.hpp"
00010 
00011 namespace MOR {
00012 
00013 MeanSubstractingSnapshotPreprocessor::MeanSubstractingSnapshotPreprocessor() :
00014   modifiedSnapshots_(),
00015   origin_()
00016 {}
00017 
00018 Teuchos::RCP<const Epetra_MultiVector>
00019 MeanSubstractingSnapshotPreprocessor::modifiedSnapshotSet() const
00020 {
00021   return modifiedSnapshots_;
00022 }
00023 
00024 Teuchos::RCP<const Epetra_Vector>
00025 MeanSubstractingSnapshotPreprocessor::origin() const
00026 {
00027   return origin_;
00028 }
00029 
00030 void
00031 MeanSubstractingSnapshotPreprocessor::rawSnapshotSetIs(const Teuchos::RCP<Epetra_MultiVector> &rs)
00032 {
00033   Teuchos::RCP<Epetra_Vector> snapshotMean;
00034 
00035   if (Teuchos::nonnull(rs)) {
00036     const int vecCount = rs->NumVectors();
00037 
00038     snapshotMean = Teuchos::rcp(new Epetra_Vector(rs->Map(), /* zeroOut =*/ true));
00039     for (int iVec = 0; iVec < vecCount; ++iVec) {
00040       snapshotMean->Update(1.0, *(*rs)(iVec), 1.0);
00041     }
00042     if (vecCount > 0) {
00043       snapshotMean->Scale(1.0 / vecCount);
00044     }
00045 
00046     for (int iVec = 0; iVec < vecCount; ++iVec) {
00047       (*rs)(iVec)->Update(-1.0, *snapshotMean, 1.0);
00048     }
00049   }
00050 
00051   origin_ = snapshotMean;
00052   modifiedSnapshots_ = rs;
00053 }
00054 
00055 } // namespace MOR

Generated on Wed Mar 26 2014 18:36:40 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1