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

Main_RomPostProcess.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 "Albany_DataTypes.hpp"
00008 #include "Albany_Utils.hpp"
00009 
00010 #include "Albany_Application.hpp"
00011 #include "Albany_MORFacadeImpl.hpp"
00012 #include "Albany_ObserverImpl.hpp"
00013 
00014 #include "MOR_EpetraLocalMapMVMatrixMarketUtils.hpp"
00015 #include "MOR_ReducedSpace.hpp"
00016 
00017 #include "Epetra_Comm.h"
00018 #include "Epetra_Vector.h"
00019 
00020 #include "Teuchos_RCP.hpp"
00021 #include "Teuchos_GlobalMPISession.hpp"
00022 #include "Teuchos_Comm.hpp"
00023 #include "Teuchos_FancyOStream.hpp"
00024 #include "Teuchos_VerboseObject.hpp"
00025 #include "Teuchos_ParameterList.hpp"
00026 #include "Teuchos_XMLParameterListHelpers.hpp"
00027 
00028 #include <string>
00029 #include <iostream>
00030 
00031 int main(int argc, char *argv[]) {
00032   using Teuchos::RCP;
00033 
00034   // Communicators
00035   Teuchos::GlobalMPISession mpiSession(&argc, &argv);
00036   const Albany_MPI_Comm nativeComm = Albany_MPI_COMM_WORLD;
00037   const RCP<const Teuchos::Comm<int> > teuchosComm = Albany::createTeuchosCommFromMpiComm(nativeComm);
00038   const RCP<const Epetra_Comm> epetraComm = Albany::createEpetraCommFromMpiComm(nativeComm);
00039 
00040   // Standard output
00041   const RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
00042 
00043   // Parse command-line argument for input file
00044   const std::string firstArg = (argc > 1) ? argv[1] : "";
00045   if (firstArg.empty() || firstArg == "--help") {
00046     *out << "AlbanyRomPostProcess input-file-path\n";
00047     return 0;
00048   }
00049   const std::string inputFileName = argv[1];
00050 
00051   // Parse XML input file
00052   const RCP<Teuchos::ParameterList> topLevelParams = Teuchos::createParameterList("Albany Parameters");
00053   Teuchos::updateParametersFromXmlFileAndBroadcast(inputFileName, topLevelParams.ptr(), *teuchosComm);
00054   (void) Teuchos::sublist(topLevelParams, "Debug Output");
00055 
00056   const RCP<Albany::Application> application(new Albany::Application(epetraComm, topLevelParams));
00057 
00058   const RCP<Teuchos::ParameterList> postParams = Teuchos::sublist(topLevelParams, "Post Processing");
00059 
00060   const RCP<Teuchos::ParameterList> spaceParams = Teuchos::sublist(postParams, "Reduced Space");
00061   const RCP<Albany::MORFacadeImpl> morFacade =
00062     Teuchos::rcp_dynamic_cast<Albany::MORFacadeImpl>(application->getMorFacade());
00063   const RCP<const MOR::ReducedSpace> reducedSpace = morFacade->spaceFactory().create(spaceParams);
00064 
00065   const std::string generalizedCoordsFilename =
00066     postParams->get("Generalized Coordinates Input File Name", "generalized_coordinates.mtx");
00067   const RCP<const Epetra_MultiVector> reducedSolutions = MOR::readLocalMapMultiVectorFromMatrixMarket(
00068       generalizedCoordsFilename, reducedSpace->comm(), reducedSpace->basisSize());
00069 
00070   const std::string stampsFilename =
00071     postParams->get("Generalized Coordinates Stamps Input File Name", "stamps_" + generalizedCoordsFilename);
00072   const RCP<const Epetra_MultiVector> stamps = MOR::readLocalMapMultiVectorFromMatrixMarket(
00073       stampsFilename, reducedSpace->comm(), 1);
00074 
00075   Albany::ObserverImpl observer(application);
00076 
00077   Epetra_Vector fullSolution(reducedSpace->basisMap(), /*zeroOut =*/ false);
00078   const Teuchos::RCP<const Epetra_Vector> fullSolution_dot = Teuchos::null; // Time derivative not handled
00079   for (int step = 0; step < reducedSolutions->NumVectors(); ++step) {
00080     reducedSpace->expansion(*(*reducedSolutions)(step), fullSolution);
00081     const double stamp = (*stamps)[step][0];
00082     observer.observeSolution(stamp, fullSolution, fullSolution_dot.ptr());
00083   }
00084 }

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