Skip to content

Commit

Permalink
Piro: before adding observer to Tempus, first clear the composite vector
Browse files Browse the repository at this point in the history
also define integrator output in TempusObserver here since the composite
vector is cleared.
  • Loading branch information
Sidafa Conde committed Jan 25, 2018
1 parent 3278344 commit 623a45b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ observeStartIntegrator(const Tempus::Integrator<Scalar>& integrator)
// store off the solution history and time step control
solutionHistory_ = integrator.getSolutionHistory();
timeStepControl_ = integrator.getTimeStepControl();

std::time_t begin = std::time(nullptr);
const Teuchos::RCP<Teuchos::FancyOStream> out = integrator.getOStream();
Teuchos::OSTab ostab(out,0,"ScreenOutput");
*out << "\nTempus - IntegratorBasic\n"
<< std::asctime(std::localtime(&begin)) << "\n"
<< " Stepper = " << integrator.getStepper()->description() << "\n"
<< " Simulation Time Range [" << integrator.getTimeStepControl()->getInitTime()
<< ", " << integrator.getTimeStepControl()->getFinalTime() << "]\n"
<< " Simulation Index Range [" << integrator.getTimeStepControl()->getInitIndex()
<< ", " << integrator.getTimeStepControl()->getFinalIndex() << "]\n"
<< "============================================================================\n"
<< " Step Time dt Abs Error Rel Error Order nFail dCompTime"
<< std::endl;
}

template <typename Scalar>
Expand Down Expand Up @@ -115,18 +129,62 @@ observeAfterTakeStep(const Tempus::Integrator<Scalar>& )
template <typename Scalar>
void
Piro::ObserverToTempusIntegrationObserverAdapter<Scalar>::
observeAcceptedTimeStep(const Tempus::Integrator<Scalar>& )
observeAcceptedTimeStep(const Tempus::Integrator<Scalar>& integrator)
{
//Nothing to do

using Teuchos::RCP;
RCP<Tempus::SolutionStateMetaData<Scalar> > csmd =
integrator.getSolutionHistory()->getCurrentState()->getMetaData();

if ((csmd->getOutputScreen() == true) or
(csmd->getOutput() == true) or
(csmd->getTime() == integrator.getTimeStepControl()->getFinalTime())) {

const Scalar steppertime = integrator.getStepperTimer()->totalElapsedTime();
// reset the stepper timer
integrator.getStepperTimer()->reset();

const Teuchos::RCP<Teuchos::FancyOStream> out = integrator.getOStream();
Teuchos::OSTab ostab(out,0,"ScreenOutput");
*out<<std::scientific<<std::setw( 6)<<std::setprecision(3)<<csmd->getIStep()
<<std::setw(11)<<std::setprecision(3)<<csmd->getTime()
<<std::setw(11)<<std::setprecision(3)<<csmd->getDt()
<<std::setw(11)<<std::setprecision(3)<<csmd->getErrorAbs()
<<std::setw(11)<<std::setprecision(3)<<csmd->getErrorRel()
<<std::fixed <<std::setw( 7)<<std::setprecision(1)<<csmd->getOrder()
<<std::scientific<<std::setw( 7)<<std::setprecision(3)<<csmd->getNFailures()
<<std::setw(11)<<std::setprecision(3)<<steppertime
<<std::endl;
}
}


template <typename Scalar>
void
Piro::ObserverToTempusIntegrationObserverAdapter<Scalar>::
observeEndIntegrator(const Tempus::Integrator<Scalar>& )
observeEndIntegrator(const Tempus::Integrator<Scalar>& integrator)
{
this->observeTimeStep();

std::string exitStatus;
//const Scalar runtime = integrator.getIntegratorTimer()->totalElapsedTime();
if (integrator.getSolutionHistory()->getCurrentState()->getSolutionStatus() ==
Tempus::Status::FAILED or integrator.getStatus() == Tempus::Status::FAILED) {
exitStatus = "Time integration FAILURE!";
} else {
exitStatus = "Time integration complete.";
}
std::time_t end = std::time(nullptr);
const Scalar runtime = integrator.getIntegratorTimer()->totalElapsedTime();
const Teuchos::RCP<Teuchos::FancyOStream> out = integrator.getOStream();
Teuchos::OSTab ostab(out,0,"ScreenOutput");
*out << "============================================================================\n"
<< " Total runtime = " << runtime << " sec = "
<< runtime/60.0 << " min\n"
<< std::asctime(std::localtime(&end))
<< exitStatus << "\n"
<< std::endl;

}

template <typename Scalar>
Expand Down
1 change: 1 addition & 0 deletions packages/piro/src/Piro_TempusSolver_Def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ setObserver()
}
if (Teuchos::nonnull(observer)) {
//Set observer in integrator
fwdStateIntegrator->getObserver()->clearObservers();
fwdStateIntegrator->setObserver(observer);
//Reinitialize everything in integrator class, since we have changed the observer.
fwdStateIntegrator->initialize();
Expand Down

0 comments on commit 623a45b

Please sign in to comment.