Skip to content

Commit

Permalink
Merge pull request trilinos#10035 from trilinos/10034-Tempus-Deprecat…
Browse files Browse the repository at this point in the history
…e-Some-Functions

Tempus: Deprecate Some Functions
  • Loading branch information
ccober6 authored Jan 4, 2022
2 parents 3d6b1f4 + 0bb39ec commit e4a8b54
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 47 deletions.
4 changes: 4 additions & 0 deletions packages/tempus/src/Tempus_Integrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ class Integrator
virtual void setStatus(const Tempus::Status st) = 0;
/// Get the stepper
virtual Teuchos::RCP<Stepper<Scalar> > getStepper() const = 0;
#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Return a copy of the Tempus ParameterList
TEMPUS_DEPRECATED
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList() = 0;
TEMPUS_DEPRECATED
virtual void setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl) = 0;
#endif
/// Returns the SolutionHistory for this Integrator
virtual Teuchos::RCP<const SolutionHistory<Scalar> > getSolutionHistory() const = 0;
/// Returns the SolutionHistory for this Integrator
Expand Down
10 changes: 7 additions & 3 deletions packages/tempus/src/Tempus_IntegratorAdjointSensitivity_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class IntegratorAdjointSensitivity :
{
public:

/** \brief Full Constructor with model, and will be fully initialized.
/** \brief Full Constructor with model, and will be fully initialized.
*
* \param[in] model The forward physics ModelEvaluator
* \param[in] state_integrator Forward state Integrator for the forward problem
* \param[in] adjoint_model ModelEvaluator for the adjoint physics/problem
* \param[in] adjoint_aux_model ModelEvaluator for the auxiliary adjoint physics/problem
* \param[in] adjoint_model ModelEvaluator for the adjoint physics/problem
* \param[in] adjoint_aux_model ModelEvaluator for the auxiliary adjoint physics/problem
* \param[in] adjoint_integrator Time integrator for the adjoint problem
* \param[in] solution_history The forward state solution history
* \param[in] p_index Sensitivity parameter index
Expand Down Expand Up @@ -145,9 +145,13 @@ class IntegratorAdjointSensitivity :
virtual void setStatus(const Status st) override;
/// Get the Stepper
virtual Teuchos::RCP<Stepper<Scalar> > getStepper() const override;
#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Return a copy of the Tempus ParameterList
TEMPUS_DEPRECATED
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList() override;
TEMPUS_DEPRECATED
virtual void setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl) override;
#endif
/// Get the SolutionHistory
virtual Teuchos::RCP<const SolutionHistory<Scalar> > getSolutionHistory() const override;
/// Get the SolutionHistory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ getStepper() const
return state_integrator_->getStepper();
}

#ifndef TEMPUS_HIDE_DEPRECATED_CODE
template<class Scalar>
Teuchos::RCP<Teuchos::ParameterList>
IntegratorAdjointSensitivity<Scalar>::
Expand All @@ -354,6 +355,7 @@ setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl)
adjoint_integrator_->setTempusParameterList(pl);
}

#endif
template<class Scalar>
Teuchos::RCP<const SolutionHistory<Scalar> >
IntegratorAdjointSensitivity<Scalar>::
Expand Down
4 changes: 2 additions & 2 deletions packages/tempus/src/Tempus_IntegratorBasicOld_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class IntegratorBasicOld
virtual void endIntegrator();
/// Return a copy of the Tempus ParameterList
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList()
override { return tempusPL_; }
{ return tempusPL_; }
virtual void setTempusParameterList(
Teuchos::RCP<Teuchos::ParameterList> pl) override
Teuchos::RCP<Teuchos::ParameterList> pl)
{
if (tempusPL_==Teuchos::null) tempusPL_=Teuchos::parameterList("Tempus");
if (pl != Teuchos::null) *tempusPL_ = *pl;
Expand Down
5 changes: 5 additions & 0 deletions packages/tempus/src/Tempus_IntegratorBasic_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ class IntegratorBasic : virtual public Tempus::Integrator<Scalar>
virtual void checkTimeStep();
/// Perform tasks after end of integrator.
virtual void endIntegrator();
#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Return a copy of the Tempus ParameterList DEPRECATED!
TEMPUS_DEPRECATED
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList()
override { return Teuchos::rcp_const_cast<Teuchos::ParameterList> (this->getValidParameters()); }

TEMPUS_DEPRECATED
virtual void setTempusParameterList(
Teuchos::RCP<Teuchos::ParameterList> pl) override
{
TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error,
" IntegratorBasic::setTempusParameterList() -- Deprecated!\n");
}
#endif
//@}

/// \name Accessor methods
Expand Down
14 changes: 9 additions & 5 deletions packages/tempus/src/Tempus_IntegratorForwardSensitivity_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class IntegratorForwardSensitivity
{
public:

/** \brief Full Constructor with model, and will be fully initialized.
/** \brief Full Constructor with model, and will be fully initialized.
*
* \param[in] model The forward physics ModelEvaluator
* \param[in] integrator Forward state Integrator
Expand Down Expand Up @@ -123,11 +123,15 @@ class IntegratorForwardSensitivity
/// Perform tasks after end of integrator.
virtual void endIntegrator()
{ integrator_->endIntegrator(); }
#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Return a copy of the Tempus ParameterList
TEMPUS_DEPRECATED
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList() override
{ return integrator_->getTempusParameterList(); }
TEMPUS_DEPRECATED
virtual void setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl) override
{ integrator_->setTempusParameterList(pl); }
#endif
//@}

/// \name Accessor methods
Expand Down Expand Up @@ -208,11 +212,11 @@ class IntegratorForwardSensitivity
* @brief Get the current solution, x, only. If looking for the solution
* vector and the sensitivities, use `SolutionState->getX()` which will return a
* Block MultiVector with the first block containing the current solution, x,
* and the remaining blocks are the forward sensitivities \f$dx/dp\f$.
* and the remaining blocks are the forward sensitivities \f$dx/dp\f$.
*
* Use `getDxDp` to get the forward sensitivities \f$dx/dp\f$ only.
*
* @return The current solution, x, without the sensitivities.
* @return The current solution, x, without the sensitivities.
* */
virtual Teuchos::RCP<const Thyra::VectorBase<Scalar> > getX() const;

Expand All @@ -222,7 +226,7 @@ class IntegratorForwardSensitivity
* @brief Get current the time derivative of the solution, xdot, only. This
* is the first block only and not the full Block MultiVector.
*
* @return Get current the time derivative of the solution, xdot.
* @return Get current the time derivative of the solution, xdot.
* */
virtual Teuchos::RCP<const Thyra::VectorBase<Scalar> > getXDot() const;
virtual Teuchos::RCP<const Thyra::MultiVectorBase<Scalar> > getDXDotDp() const;
Expand All @@ -232,7 +236,7 @@ class IntegratorForwardSensitivity
*
* Use `getDXDotDp` to get the forward sensitivities.
*
* @return Get current the second time derivative of the solution, xdotdot.
* @return Get current the second time derivative of the solution, xdotdot.
* */
virtual Teuchos::RCP<const Thyra::VectorBase<Scalar> > getXDotDot() const;
virtual Teuchos::RCP<const Thyra::MultiVectorBase<Scalar> > getDXDotDotDp() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,13 @@ class IntegratorPseudoTransientAdjointSensitivity
virtual void setStatus(const Status st) override;
/// Get the Stepper
virtual Teuchos::RCP<Stepper<Scalar> > getStepper() const override;
#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Return a copy of the Tempus ParameterList
TEMPUS_DEPRECATED
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList() override;
TEMPUS_DEPRECATED
virtual void setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl) override;
#endif
/// Get the SolutionHistory
virtual Teuchos::RCP<const SolutionHistory<Scalar> > getSolutionHistory() const override;
/// Get the SolutionHistory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ getStepper() const
return state_integrator_->getStepper();
}

#ifndef TEMPUS_HIDE_DEPRECATED_CODE
template<class Scalar>
Teuchos::RCP<Teuchos::ParameterList>
IntegratorPseudoTransientAdjointSensitivity<Scalar>::
Expand All @@ -193,6 +194,7 @@ setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl)
sens_integrator_->setTempusParameterList(pl);
}

#endif
template<class Scalar>
Teuchos::RCP<const SolutionHistory<Scalar> >
IntegratorPseudoTransientAdjointSensitivity<Scalar>::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ class IntegratorPseudoTransientForwardSensitivity
virtual void setStatus(const Status st) override;
/// Get the Stepper
virtual Teuchos::RCP<Stepper<Scalar> > getStepper() const override;
#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Return a copy of the Tempus ParameterList
TEMPUS_DEPRECATED
virtual Teuchos::RCP<Teuchos::ParameterList> getTempusParameterList() override
{ return state_integrator_->getTempusParameterList(); }
TEMPUS_DEPRECATED
virtual void setTempusParameterList(Teuchos::RCP<Teuchos::ParameterList> pl) override
{ state_integrator_->setTempusParameterList(pl); }
#endif
/// Get the SolutionHistory
virtual Teuchos::RCP<const SolutionHistory<Scalar> > getSolutionHistory() const override;
/// Get the SolutionHistory
Expand Down Expand Up @@ -190,7 +194,7 @@ class IntegratorPseudoTransientForwardSensitivity
* sensitivity model evaluator, and the sensisitivity integrator
* @param model Physics model
*
* @return
* @return
*/
template<class Scalar>
Teuchos::RCP<Tempus::IntegratorPseudoTransientForwardSensitivity<Scalar> >
Expand All @@ -203,7 +207,7 @@ createIntegratorPseudoTransientForwardSensitivity(
* @brief Default ctor
*
* Instantiates a default IntegratorBasic for both the state and the sensitivity
* integrator.
* integrator.
*
* @return IntegratorPseudoTransientForwardSensitivity
*/
Expand Down
7 changes: 5 additions & 2 deletions packages/tempus/src/Tempus_SolutionState_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,23 @@ class SolutionState :
SolutionState();

#ifndef TEMPUS_HIDE_DEPRECATED_CODE
TEMPUS_DEPRECATED
SolutionState(
const Teuchos::RCP<Thyra::VectorBase<Scalar> >& x,
const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xddot = Teuchos::null,
const Teuchos::RCP<StepperState<Scalar> >& stepperState = Teuchos::null,
const Teuchos::RCP<PhysicsState<Scalar> >& physicsState = Teuchos::null);

TEMPUS_DEPRECATED
SolutionState(
const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x,
const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xddot= Teuchos::null,
const Teuchos::RCP<const StepperState<Scalar> >& stepperSt = Teuchos::null,
const Teuchos::RCP<const PhysicsState<Scalar> >& physicsSt = Teuchos::null);
#endif

#endif
SolutionState(
const Teuchos::RCP<SolutionStateMetaData<Scalar> > ssmd,
const Teuchos::RCP<Thyra::VectorBase<Scalar> >& x,
Expand All @@ -99,12 +101,13 @@ class SolutionState :
const Teuchos::RCP<const PhysicsState<Scalar> >& physicsState);

#ifndef TEMPUS_HIDE_DEPRECATED_CODE
TEMPUS_DEPRECATED
SolutionState(
const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
const Teuchos::RCP<StepperState<Scalar> >& stepperState = Teuchos::null,
const Teuchos::RCP<PhysicsState<Scalar> >& physicsState = Teuchos::null);
#endif

#endif
/// This is a shallow copy constructor, use clone for a deep copy constructor
SolutionState(const SolutionState<Scalar>& ss);

Expand Down
4 changes: 2 additions & 2 deletions packages/tempus/src/Tempus_StepperHHTAlpha_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void StepperHHTAlpha<Scalar>::takeStep(
Thyra::put_scalar(0.0, a_init.ptr());
}
wrapperModel->initializeNewmark(v_init,d_init,0.0,time,beta_,gamma_);
const Thyra::SolveStatus<Scalar> sStatus=this->solveImplicitODE(a_init);
const Thyra::SolveStatus<Scalar> sStatus=(*(this->solver_)).solve(&*a_init);

workingState->setSolutionStatus(sStatus); // Converged --> pass.
Thyra::copy(*a_init, a_old.ptr());
Expand Down Expand Up @@ -439,7 +439,7 @@ void StepperHHTAlpha<Scalar>::takeStep(
StepperHHTAlphaAppAction<Scalar>::ACTION_LOCATION::BEFORE_SOLVE);

//Solve for new acceleration
const Thyra::SolveStatus<Scalar> sStatus = this->solveImplicitODE(a_new);
const Thyra::SolveStatus<Scalar> sStatus = (*(this->solver_)).solve(&*a_new);

stepperHHTAlphaAppAction_->execute(solutionHistory, thisStepper,
StepperHHTAlphaAppAction<Scalar>::ACTION_LOCATION::AFTER_SOLVE);
Expand Down
32 changes: 11 additions & 21 deletions packages/tempus/src/Tempus_StepperIMEX_RK_Partition_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ void StepperIMEX_RK_Partition<Scalar>::takeStep(
(this->wrapperModel_);

bool pass = true;
Thyra::SolveStatus<Scalar> sStatus;
Thyra::assign(workingState->getX().ptr(), *(currentState->getX()));
RCP<Thyra::VectorBase<Scalar> > stageY =
wrapperModelPairIMEX->getExplicitOnlyVector(workingState->getX());
Expand Down Expand Up @@ -699,31 +698,22 @@ void StepperIMEX_RK_Partition<Scalar>::takeStep(
Teuchos::rcp(new StepperIMEX_RKPartTimeDerivative<Scalar>(
alpha, xTilde_.getConst()));

// Setup InArgs and OutArgs
typedef Thyra::ModelEvaluatorBase MEB;
//MEB::InArgs<Scalar> inArgs = wrapperModelPairIMEX->getInArgs();
//MEB::OutArgs<Scalar> outArgs = wrapperModelPairIMEX->getOutArgs();
wrapperModelPairIMEX->setUseImplicitModel(true);
MEB::InArgs<Scalar> inArgs = wrapperModelPairIMEX->createInArgs();
MEB::OutArgs<Scalar> outArgs = wrapperModelPairIMEX->createOutArgs();
inArgs.set_x(stageX);
if (wrapperModelPairIMEX->getParameterIndex() >= 0)
inArgs.set_p(wrapperModelPairIMEX->getParameterIndex(), stageY);
if (inArgs.supports(MEB::IN_ARG_x_dot)) inArgs.set_x_dot(stageGx_[i]);
if (inArgs.supports(MEB::IN_ARG_t )) inArgs.set_t (ts);
if (inArgs.supports(MEB::IN_ARG_step_size)) inArgs.set_step_size(dt);
if (inArgs.supports(MEB::IN_ARG_alpha )) inArgs.set_alpha (alpha);
if (inArgs.supports(MEB::IN_ARG_beta )) inArgs.set_beta (beta);
if (inArgs.supports(MEB::IN_ARG_stage_number))
inArgs.set_stage_number(i);

wrapperModelPairIMEX->setForSolve(timeDer, inArgs, outArgs);
auto p = Teuchos::rcp(new ImplicitODEParameters<Scalar>(
timeDer, dt, alpha, beta, SOLVE_FOR_X, i));

this->stepperRKAppAction_->execute(solutionHistory, thisStepper,
StepperRKAppAction<Scalar>::ACTION_LOCATION::BEFORE_SOLVE);

wrapperModelPairIMEX->setUseImplicitModel(true);
this->solver_->setModel(wrapperModelPairIMEX);
sStatus = this->solveImplicitODE(stageX);

Thyra::SolveStatus<Scalar> sStatus;
if (wrapperModelPairIMEX->getParameterIndex() >= 0)
sStatus = this->solveImplicitODE(stageX, stageGx_[i], ts, p,
stageY, wrapperModelPairIMEX->getParameterIndex());
else
sStatus = this->solveImplicitODE(stageX, stageGx_[i], ts, p);

if (sStatus.solveStatus != Thyra::SOLVE_STATUS_CONVERGED) pass = false;

wrapperModelPairIMEX->setUseImplicitModel(false);
Expand Down
7 changes: 6 additions & 1 deletion packages/tempus/src/Tempus_StepperImplicit_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,21 @@ class StepperImplicit : virtual public Tempus::Stepper<Scalar>
/// Return beta = d(x)/dx.
virtual Scalar getBeta (const Scalar dt) const = 0;

#ifndef TEMPUS_HIDE_DEPRECATED_CODE
/// Solve problem using x in-place. (Needs to be deprecated!)
TEMPUS_DEPRECATED
const Thyra::SolveStatus<Scalar> solveImplicitODE(
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & x);

#endif
/// Solve implicit ODE, f(x, xDot, t, p) = 0.
const Thyra::SolveStatus<Scalar> solveImplicitODE(
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & x,
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & xDot,
const Scalar time,
const Teuchos::RCP<ImplicitODEParameters<Scalar> > & p );
const Teuchos::RCP<ImplicitODEParameters<Scalar> > & p,
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & y = Teuchos::null,
const int index = 0 /* index and y are for IMEX_RK_Partition */ );

/// Evaluate implicit ODE residual, f(x, xDot, t, p).
void evaluateImplicitODE(
Expand Down
7 changes: 6 additions & 1 deletion packages/tempus/src/Tempus_StepperImplicit_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ void StepperImplicit<Scalar>::setSolver(
}


#ifndef TEMPUS_HIDE_DEPRECATED_CODE
template<class Scalar>
const Thyra::SolveStatus<Scalar>
StepperImplicit<Scalar>::solveImplicitODE(
Expand All @@ -251,18 +252,22 @@ StepperImplicit<Scalar>::solveImplicitODE(
}


#endif
template<class Scalar>
const Thyra::SolveStatus<Scalar>
StepperImplicit<Scalar>::solveImplicitODE(
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & x,
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & xDot,
const Scalar time,
const Teuchos::RCP<ImplicitODEParameters<Scalar> > & p )
const Teuchos::RCP<ImplicitODEParameters<Scalar> > & p,
const Teuchos::RCP<Thyra::VectorBase<Scalar> > & y,
const int index )
{
typedef Thyra::ModelEvaluatorBase MEB;
MEB::InArgs<Scalar> inArgs = wrapperModel_->getInArgs();
MEB::OutArgs<Scalar> outArgs = wrapperModel_->getOutArgs();
inArgs.set_x(x);
if ( y != Teuchos::null ) inArgs.set_p(index, y);
if (inArgs.supports(MEB::IN_ARG_x_dot )) inArgs.set_x_dot (xDot);
if (inArgs.supports(MEB::IN_ARG_t )) inArgs.set_t (time);
if (inArgs.supports(MEB::IN_ARG_step_size))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void StepperNewmarkImplicitAForm<Scalar>::setInitialConditions(
this->wrapperModel_);

wrapperModel->initializeNewmark(xDot, x, 0.0, time, beta_, gamma_);
const Thyra::SolveStatus<Scalar> sStatus = this->solveImplicitODE(xDotDot);
const Thyra::SolveStatus<Scalar> sStatus = (*(this->solver_)).solve(&*xDotDot);

TEUCHOS_TEST_FOR_EXCEPTION(
sStatus.solveStatus != Thyra::SOLVE_STATUS_CONVERGED, std::logic_error,
Expand Down Expand Up @@ -482,8 +482,11 @@ void StepperNewmarkImplicitAForm<Scalar>::takeStep(
stepperNewmarkImpAppAction_->execute(solutionHistory, thisStepper,
StepperNewmarkImplicitAFormAppAction<Scalar>::ACTION_LOCATION::BEFORE_SOLVE);

if (this->getZeroInitialGuess())
Thyra::assign(a_new.ptr(), Teuchos::ScalarTraits<Scalar>::zero());

// Solve nonlinear system with a_new as initial guess
const Thyra::SolveStatus<Scalar> sStatus = this->solveImplicitODE(a_new);
const Thyra::SolveStatus<Scalar> sStatus = (*(this->solver_)).solve(&*a_new);

stepperNewmarkImpAppAction_->execute(solutionHistory, thisStepper,
StepperNewmarkImplicitAFormAppAction<Scalar>::ACTION_LOCATION::AFTER_SOLVE);
Expand Down
Loading

0 comments on commit e4a8b54

Please sign in to comment.