29 #ifndef RYTHMOS_FORWARD_RESPONSE_SENSITIVITY_COMPUTER_OBSERVER_HPP
30 #define RYTHMOS_FORWARD_RESPONSE_SENSITIVITY_COMPUTER_OBSERVER_HPP
33 #include "Rythmos_IntegrationObserverBase.hpp"
34 #include "Rythmos_ForwardResponseSensitivityComputer.hpp"
35 #include "Rythmos_ResponseAndFwdSensPoint.hpp"
36 #include "Rythmos_extractStateAndSens.hpp"
47 template<
class Scalar>
61 const RCP<
const Thyra::ModelEvaluator<Scalar> > &responseFunc,
62 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
76 virtual RCP<IntegrationObserverBase<Scalar> >
88 const int timeStepIter
96 Array<ResponseAndFwdSensPoint<Scalar> > responseAndFwdSensPoints_;
98 RCP<Thyra::VectorBase<Scalar> > g_hat_;
99 RCP<Thyra::MultiVectorBase<Scalar> > D_g_hat_D_p_;
108 template<
class Scalar>
109 RCP<ForwardResponseSensitivityComputerObserver<Scalar> >
112 RCP<ForwardResponseSensitivityComputerObserver<Scalar> >
122 template<
class Scalar>
123 RCP<ForwardResponseSensitivityComputerObserver<Scalar> >
125 const RCP<
const Thyra::ModelEvaluator<Scalar> > &responseFunc,
126 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
131 RCP<ForwardResponseSensitivityComputerObserver<Scalar> >
132 frsco = Rythmos::forwardResponseSensitivityComputerObserver<Scalar>();
133 frsco->initialize(responseFunc,basePoint,p_index,g_index);
146 template<
class Scalar>
151 template<
class Scalar>
153 const RCP<
const Thyra::ModelEvaluator<Scalar> > &responseFunc,
154 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &basePoint,
159 forwardResponseSensitivityComputer_.setResponseFunction(
160 responseFunc, basePoint, p_index, g_index );
161 g_hat_ = forwardResponseSensitivityComputer_.create_g_hat();
162 D_g_hat_D_p_ = forwardResponseSensitivityComputer_.create_D_g_hat_D_p();
166 template<
class Scalar>
167 const Array<ResponseAndFwdSensPoint<Scalar> >&
170 return responseAndFwdSensPoints_;
177 template<
class Scalar>
178 RCP<IntegrationObserverBase<Scalar> >
181 TEUCHOS_TEST_FOR_EXCEPT(
true);
182 return Teuchos::null;
186 template<
class Scalar>
191 responseAndFwdSensPoints_.clear();
195 template<
class Scalar>
199 const int timeStepIter
203 using Teuchos::OSTab;
204 using Teuchos::includesVerbLevel;
208 const RCP<FancyOStream> out = this->getOStream();
209 const Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel();
212 ( !is_null(out) && includesVerbLevel(verbLevel,Teuchos::VERB_LOW) );
214 forwardResponseSensitivityComputer_.setOStream(out);
215 forwardResponseSensitivityComputer_.setVerbLevel(verbLevel);
220 *out <<
"\nEntering ForwardResponseSensitivityComputerObserver<Scalar>::observeCompletedTimeStep(...) ...\n";
226 RCP<const Thyra::VectorBase<Scalar> > x_bar, x_bar_dot;
228 get_x_and_x_dot( stepper, t, &x_bar, &x_bar_dot );
230 RCP<const Thyra::VectorBase<Scalar> > x;
231 RCP<const Thyra::MultiVectorBase<Scalar> > S;
232 RCP<const Thyra::VectorBase<Scalar> > x_dot;
233 RCP<const Thyra::MultiVectorBase<Scalar> > S_dot;
235 extractStateAndSens( x_bar, x_bar_dot, &x, &S, &x_dot, &S_dot );
239 forwardResponseSensitivityComputer_.computeResponseAndSensitivity(
240 x_dot.get(), S_dot.get(), *x, *S, t, &*g_hat_, &*D_g_hat_D_p_
245 responseAndFwdSensPoints_.push_back(
247 t, g_hat_->clone_v(), D_g_hat_D_p_->clone_mv()
252 *out <<
"\nEntering ForwardResponseSensitivityComputerObserver<Scalar>::observeCompletedTimeStep(...) ...\n";
260 #endif //RYTHMOS_FORWARD_RESPONSE_SENSITIVITY_COMPUTER_OBSERVER_HPP
Base class for defining stepper functionality.
virtual void resetIntegrationObserver(const TimeRange< Scalar > &integrationTimeDomain)
Observer class that computes sensitivities at the end of each time step.
Simple struct to aggregate integration/stepper control information.
virtual const StepStatus< Scalar > getStepStatus() const =0
Get current stepper status after a step has been taken.
Simple class to combine a response and it's forward sensitivity at a time point.
const Array< ResponseAndFwdSensPoint< Scalar > > & responseAndFwdSensPoints() const
virtual void observeCompletedTimeStep(const StepperBase< Scalar > &stepper, const StepControlInfo< Scalar > &stepCtrlInfo, const int timeStepIter)
RCP< ForwardResponseSensitivityComputerObserver< Scalar > > forwardResponseSensitivityComputerObserver(const RCP< const Thyra::ModelEvaluator< Scalar > > &responseFunc, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &basePoint, const int p_index, const int g_index)
Non-member constructor.
Base class for strategy objects that observe and time integration by observing the stepper object...
void initialize(const RCP< const Thyra::ModelEvaluator< Scalar > > &responseFunc, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &basePoint, const int p_index, const int g_index)
RCP< ForwardResponseSensitivityComputerObserver< Scalar > > forwardResponseSensitivityComputerObserver()
Non-member constructor.
ForwardResponseSensitivityComputerObserver()
Concrete utility class for computing (assembling) forward transient response sensitivities.
virtual RCP< IntegrationObserverBase< Scalar > > cloneIntegrationObserver() const