Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus::AdjointSensitivityUtils Namespace Reference

Functions

AdjointResponseType parseResponseType (const std::string &name)
 Convert the "Response Type" parameter value to the enum.
template<class Scalar>
std::vector< Scalar > parseTimeList (const std::string &str)
template<class Scalar>
void evalResponseGradientX (const Thyra::ModelEvaluator< Scalar > &model, const int g_index, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, Thyra::MultiVectorBase< Scalar > &dgdx, const bool dgdx_dot_check, const std::string &caller)
 Evaluate dg/dx^T (gradient form, x_space x num_g) of response g_index at the given inArgs.
template<class Scalar>
void evalResponseGradientP (const Thyra::ModelEvaluator< Scalar > &model, const int g_index, const int p_index, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, Thyra::MultiVectorBase< Scalar > &dgdp)
 Evaluate dg/dp^T (gradient form, p_space x num_g) of response g_index with respect to parameter p_index at the given inArgs.
template<class Scalar>
void applyDfDpTranspose (const Thyra::ModelEvaluator< Scalar > &model, const int p_index, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::MultiVectorBase< Scalar > &v, Thyra::MultiVectorBase< Scalar > &y, const Scalar alpha, const Scalar beta, Teuchos::RCP< Thyra::LinearOpBase< Scalar > > &dfdp_op, Teuchos::RCP< Thyra::MultiVectorBase< Scalar > > &dfdp_mv)
 Compute y = alpha * df/dp^T * v + beta * y.
template<class Scalar>
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > createAdjointLinearOpWithSolve (const Thyra::ModelEvaluator< Scalar > &adjoint_model, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Scalar alpha, const Scalar beta)
 Create a solver for the adjoint model's W = (alpha*df/dx_dot + beta*df/dx)^T at inArgs.
template<class Scalar>
void addResponseTimeEvents (TimeStepControl< Scalar > &tsc, const std::vector< Scalar > &times)
 Add the response times to the time step control as time events on which the time steps land exactly.

Function Documentation

◆ parseResponseType()

AdjointResponseType Tempus::AdjointSensitivityUtils::parseResponseType ( const std::string & name)
inline

Convert the "Response Type" parameter value to the enum.

Definition at line 53 of file Tempus_AdjointSensitivityUtils.hpp.

◆ parseTimeList()

template<class Scalar>
std::vector< Scalar > Tempus::AdjointSensitivityUtils::parseTimeList ( const std::string & str)

Convert a comma-separated list of times (as in "Output Time List") to a sorted vector.

Definition at line 70 of file Tempus_AdjointSensitivityUtils.hpp.

◆ evalResponseGradientX()

template<class Scalar>
void Tempus::AdjointSensitivityUtils::evalResponseGradientX ( const Thyra::ModelEvaluator< Scalar > & model,
const int g_index,
const Thyra::ModelEvaluatorBase::InArgs< Scalar > & inArgs,
Thyra::MultiVectorBase< Scalar > & dgdx,
const bool dgdx_dot_check,
const std::string & caller )

Evaluate dg/dx^T (gradient form, x_space x num_g) of response g_index at the given inArgs.

If dgdx_dot_check is true and the model supports dg/dx_dot in gradient form, dg/dx_dot is evaluated in the same call and an exception is thrown if it is nonzero, since the adjoint formulation requires responses that do not depend on x_dot.

Definition at line 110 of file Tempus_AdjointSensitivityUtils.hpp.

◆ evalResponseGradientP()

template<class Scalar>
void Tempus::AdjointSensitivityUtils::evalResponseGradientP ( const Thyra::ModelEvaluator< Scalar > & model,
const int g_index,
const int p_index,
const Thyra::ModelEvaluatorBase::InArgs< Scalar > & inArgs,
Thyra::MultiVectorBase< Scalar > & dgdp )

Evaluate dg/dp^T (gradient form, p_space x num_g) of response g_index with respect to parameter p_index at the given inArgs.

Models that only provide the Jacobian form are supported by transposing, as done for the final-time response.

Definition at line 157 of file Tempus_AdjointSensitivityUtils.hpp.

◆ applyDfDpTranspose()

template<class Scalar>
void Tempus::AdjointSensitivityUtils::applyDfDpTranspose ( const Thyra::ModelEvaluator< Scalar > & model,
const int p_index,
const Thyra::ModelEvaluatorBase::InArgs< Scalar > & inArgs,
const Thyra::MultiVectorBase< Scalar > & v,
Thyra::MultiVectorBase< Scalar > & y,
const Scalar alpha,
const Scalar beta,
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > & dfdp_op,
Teuchos::RCP< Thyra::MultiVectorBase< Scalar > > & dfdp_mv )

Compute y = alpha * df/dp^T * v + beta * y.

v is a multivector in the residual (f) space and y a multivector in the space of parameter p_index, with the same number of columns. df/dp is evaluated at inArgs in the form supported by the model (linear operator, Jacobian or gradient multivector). dfdp_op and dfdp_mv cache the derivative objects between calls (pass null RCPs on the first call).

Definition at line 197 of file Tempus_AdjointSensitivityUtils.hpp.

◆ createAdjointLinearOpWithSolve()

template<class Scalar>
Teuchos::RCP< Thyra::LinearOpWithSolveBase< Scalar > > Tempus::AdjointSensitivityUtils::createAdjointLinearOpWithSolve ( const Thyra::ModelEvaluator< Scalar > & adjoint_model,
const Thyra::ModelEvaluatorBase::InArgs< Scalar > & inArgs,
const Scalar alpha,
const Scalar beta )

Create a solver for the adjoint model's W = (alpha*df/dx_dot + beta*df/dx)^T at inArgs.

Uses the W out-arg of the adjoint model if supported, otherwise its W_op, its W_factory, and the preconditioner of the W_factory (or of the model).

Definition at line 240 of file Tempus_AdjointSensitivityUtils.hpp.

◆ addResponseTimeEvents()

template<class Scalar>
void Tempus::AdjointSensitivityUtils::addResponseTimeEvents ( TimeStepControl< Scalar > & tsc,
const std::vector< Scalar > & times )

Add the response times to the time step control as time events on which the time steps land exactly.

This only adjusts the time steps for "Step Type" = "Variable"; with "Constant" time steps the response times must be on the time grid. The time steps are not flagged for output.

Definition at line 310 of file Tempus_AdjointSensitivityUtils.hpp.