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

MOR_GeneralizedCoordinatesOutput.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 #include "MOR_GeneralizedCoordinatesOutput.hpp"
00007 
00008 #include "MOR_EpetraLocalMapMVMatrixMarketUtils.hpp"
00009 
00010 #include "Epetra_LocalMap.h"
00011 
00012 #include "Teuchos_as.hpp"
00013 
00014 namespace MOR {
00015 
00016 GeneralizedCoordinatesOutput::GeneralizedCoordinatesOutput(
00017     const std::string &filename,
00018     const std::string &stampsFilename) :
00019   filename_(filename),
00020   stampsFilename_(stampsFilename),
00021   projectionComponents_(),
00022   stamps_()
00023 {}
00024 
00025 int
00026 GeneralizedCoordinatesOutput::vectorCount() const
00027 {
00028   return projectionComponents_.size();
00029 }
00030 
00031 void
00032 GeneralizedCoordinatesOutput::vectorAdd(const Epetra_Vector &v)
00033 {
00034   const double defaultStamp = static_cast<double>(this->vectorCount());
00035   this->stampedVectorAdd(defaultStamp, v);
00036 }
00037 
00038 void
00039 GeneralizedCoordinatesOutput::stampedVectorAdd(double stamp, const Epetra_Vector &v)
00040 {
00041   stamps_.push_back(stamp);
00042   projectionComponents_.push_back(v);
00043 }
00044 
00045 GeneralizedCoordinatesOutput::~GeneralizedCoordinatesOutput()
00046 {
00047   // Warning: Destructor performs actual work and might fail !
00048   // Avoding such heresy without killing performance would require
00049   // to modify the EpetraExt Matrix Market I/O code.
00050 
00051   if (!projectionComponents_.empty()) {
00052     const Epetra_BlockMap commonMap = projectionComponents_.front().Map();
00053     Epetra_MultiVector allComponents(commonMap, projectionComponents_.size(), false);
00054     for (int i = 0; i < allComponents.NumVectors(); ++i) {
00055       *allComponents(i) = projectionComponents_[i];
00056     }
00057     writeLocalMapMultiVectorToMatrixMarket(filename_, allComponents);
00058 
00059     const Epetra_LocalMap scalarMap(1, 0, commonMap.Comm());
00060     Epetra_MultiVector allStamps(View, scalarMap, stamps_.getRawPtr(), 1, Teuchos::as<int>(stamps_.size()));
00061     writeLocalMapMultiVectorToMatrixMarket(stampsFilename_, allStamps);
00062   }
00063 }
00064 
00065 } // end namespace MOR

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