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

MOR_RythmosSnapshotCollectionObserver.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_RythmosSnapshotCollectionObserver.hpp"
00007 
00008 #include "MOR_RythmosUtils.hpp"
00009 
00010 #include "Epetra_Vector.h"
00011 #include "Epetra_Map.h"
00012 #include "Epetra_Comm.h"
00013 
00014 #include "Thyra_EpetraThyraWrappers.hpp"
00015 
00016 #include "Teuchos_RCP.hpp"
00017 
00018 namespace MOR {
00019 
00020 using ::Teuchos::RCP;
00021 using ::Teuchos::ParameterList;
00022 
00023 RythmosSnapshotCollectionObserver::RythmosSnapshotCollectionObserver(
00024     int period,
00025     Teuchos::RCP<MultiVectorOutputFile> snapshotFile) :
00026   snapshotCollector_(period, snapshotFile)
00027 {
00028   // Nothing to do
00029 }
00030 
00031 RCP<Rythmos::IntegrationObserverBase<double> > RythmosSnapshotCollectionObserver::cloneIntegrationObserver() const {
00032   return Teuchos::null; // TODO
00033 }
00034 
00035 void RythmosSnapshotCollectionObserver::resetIntegrationObserver(const Rythmos::TimeRange<double> &/*integrationTimeDomain*/) {
00036   // Not implemented
00037 }
00038 
00039 void RythmosSnapshotCollectionObserver::observeTimeStep(
00040     const Rythmos::StepperBase<double> &stepper) {
00041   const Rythmos::StepStatus<double> stepStatus = stepper.getStepStatus();
00042 
00043   const Teuchos::RCP<const Thyra::VectorBase<double> > stepperSolution = stepStatus.solution;
00044   const Teuchos::RCP<const Thyra::VectorBase<double> > stepperState = getRythmosState(stepperSolution);
00045   const Teuchos::RCP<const Thyra::VectorSpaceBase<double> > stateSpace = stepperState->space();
00046   const Teuchos::RCP<const Teuchos::Comm<Thyra::Ordinal> > stateSpaceComm = getComm(*stateSpace);
00047 
00048   const Teuchos::RCP<const Epetra_Comm> stateComm = Thyra::get_Epetra_Comm(*stateSpaceComm);
00049   const Teuchos::RCP<const Epetra_Map> stateMap = Thyra::get_Epetra_Map(*stateSpace, stateComm);
00050   const Teuchos::RCP<const Epetra_Vector> state = Thyra::get_Epetra_Vector(*stateMap, stepperState);
00051 
00052   const double stamp = stepStatus.time;
00053 
00054   snapshotCollector_.addVector(stamp, *state);
00055 }
00056 
00057 void RythmosSnapshotCollectionObserver::observeStartTimeIntegration(
00058     const Rythmos::StepperBase<double> &stepper) {
00059   this->observeTimeStep(stepper);
00060 }
00061 
00062 void RythmosSnapshotCollectionObserver::observeCompletedTimeStep(
00063     const Rythmos::StepperBase<double> &stepper,
00064     const Rythmos::StepControlInfo<double> &/*stepCtrlInfo*/,
00065     const int /*timeStepIter*/) {
00066   this->observeTimeStep(stepper);
00067 }
00068 
00069 } // namespace MOR

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