Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "Albany_RythmosObserver.hpp"
00008
00009 #include "Rythmos_StepperBase.hpp"
00010
00011 #include "Thyra_DefaultProductVector.hpp"
00012 #include "Thyra_VectorBase.hpp"
00013 #include "Thyra_EpetraThyraWrappers.hpp"
00014
00015 #include "Epetra_Vector.h"
00016
00017 #include "Teuchos_Ptr.hpp"
00018
00019 Albany_RythmosObserver::Albany_RythmosObserver(
00020 const Teuchos::RCP<Albany::Application> &app_) :
00021 impl(app_),
00022 initial_step(true)
00023 {
00024
00025 }
00026
00027 void Albany_RythmosObserver::observeStartTimeStep(
00028 const Rythmos::StepperBase<ScalarType> &stepper,
00029 const Rythmos::StepControlInfo<ScalarType> &stepCtrlInfo,
00030 const int timeStepIter
00031 )
00032 {
00033
00034 if(initial_step)
00035
00036 initial_step = false;
00037
00038 else
00039
00040 return;
00041
00042
00043
00044 Teuchos::RCP<const Thyra::DefaultProductVector<ScalarType> > solnandsens =
00045 Teuchos::rcp_dynamic_cast<const Thyra::DefaultProductVector<ScalarType> >
00046 (stepper.getStepStatus().solution);
00047 Teuchos::RCP<const Thyra::DefaultProductVector<ScalarType> > solnandsens_dot =
00048 Teuchos::rcp_dynamic_cast<const Thyra::DefaultProductVector<ScalarType> >
00049 (stepper.getStepStatus().solutionDot);
00050
00051 Teuchos::RCP<const Thyra::VectorBase<ScalarType> > solution;
00052 Teuchos::RCP<const Thyra::VectorBase<ScalarType> > solution_dot;
00053 if (solnandsens != Teuchos::null) {
00054 solution = solnandsens->getVectorBlock(0);
00055 solution_dot = solnandsens_dot->getVectorBlock(0);
00056 }
00057 else {
00058 solution = stepper.getStepStatus().solution;
00059 solution_dot = stepper.getStepStatus().solutionDot;
00060 }
00061
00062
00063 const ScalarType time = impl.getTimeParamValueOrDefault(stepper.getStepStatus().time);
00064
00065 const Epetra_Vector soln= *(Thyra::get_Epetra_Vector(impl.getNonOverlappedMap(), solution));
00066
00067 if(solution_dot != Teuchos::null){
00068 const Epetra_Vector soln_dot= *(Thyra::get_Epetra_Vector(impl.getNonOverlappedMap(), solution_dot));
00069 impl.observeSolution(time, soln, Teuchos::constOptInArg(soln_dot));
00070 }
00071 else {
00072 impl.observeSolution(time, soln, Teuchos::null);
00073 }
00074
00075 }
00076
00077 void Albany_RythmosObserver::observeCompletedTimeStep(
00078 const Rythmos::StepperBase<ScalarType> &stepper,
00079 const Rythmos::StepControlInfo<ScalarType> &stepCtrlInfo,
00080 const int timeStepIter
00081 )
00082 {
00083
00084
00085
00086 Teuchos::RCP<const Thyra::DefaultProductVector<ScalarType> > solnandsens =
00087 Teuchos::rcp_dynamic_cast<const Thyra::DefaultProductVector<ScalarType> >
00088 (stepper.getStepStatus().solution);
00089 Teuchos::RCP<const Thyra::DefaultProductVector<ScalarType> > solnandsens_dot =
00090 Teuchos::rcp_dynamic_cast<const Thyra::DefaultProductVector<ScalarType> >
00091 (stepper.getStepStatus().solutionDot);
00092
00093 Teuchos::RCP<const Thyra::VectorBase<ScalarType> > solution;
00094 Teuchos::RCP<const Thyra::VectorBase<ScalarType> > solution_dot;
00095 if (solnandsens != Teuchos::null) {
00096 solution = solnandsens->getVectorBlock(0);
00097 solution_dot = solnandsens_dot->getVectorBlock(0);
00098 }
00099 else {
00100 solution = stepper.getStepStatus().solution;
00101 solution_dot = stepper.getStepStatus().solutionDot;
00102 }
00103
00104 const ScalarType time = impl.getTimeParamValueOrDefault(stepper.getStepStatus().time);
00105
00106 const Epetra_Vector soln= *(Thyra::get_Epetra_Vector(impl.getNonOverlappedMap(), solution));
00107
00108 if(solution_dot != Teuchos::null){
00109 const Epetra_Vector soln_dot= *(Thyra::get_Epetra_Vector(impl.getNonOverlappedMap(), solution_dot));
00110 impl.observeSolution(time, soln, Teuchos::constOptInArg(soln_dot));
00111 }
00112 else {
00113 impl.observeSolution(time, soln, Teuchos::null);
00114 }
00115
00116 }