本文整理汇总了C++中thyra::modelevaluatorbase::InArgs::get_x_dot方法的典型用法代码示例。如果您正苦于以下问题:C++ InArgs::get_x_dot方法的具体用法?C++ InArgs::get_x_dot怎么用?C++ InArgs::get_x_dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thyra::modelevaluatorbase::InArgs
的用法示例。
在下文中一共展示了InArgs::get_x_dot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setInitialCondition
void ImplicitRKStepper<Scalar>::setInitialCondition(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initialCondition
)
{
typedef ScalarTraits<Scalar> ST;
typedef Thyra::ModelEvaluatorBase MEB;
basePoint_ = initialCondition;
// x
RCP<const Thyra::VectorBase<Scalar> >
x_init = initialCondition.get_x();
#ifdef HAVE_RYTHMOS_DEBUG
TEUCHOS_TEST_FOR_EXCEPTION(
is_null(x_init), std::logic_error,
"Error, if the client passes in an intial condition to setInitialCondition(...),\n"
"then x can not be null!" );
#endif
x_ = x_init->clone_v();
// x_dot
x_dot_ = createMember(x_->space());
RCP<const Thyra::VectorBase<Scalar> >
x_dot_init = initialCondition.get_x_dot();
if (!is_null(x_dot_init))
assign(x_dot_.ptr(),*x_dot_init);
else
assign(x_dot_.ptr(),ST::zero());
// t
const Scalar t =
(
initialCondition.supports(MEB::IN_ARG_t)
? initialCondition.get_t()
: ST::zero()
);
timeRange_ = timeRange(t,t);
// x_old
x_old_ = x_->clone_v();
haveInitialCondition_ = true;
}
示例2: productVectorSpace
void TimeDiscretizedBackwardEulerModelEvaluator<Scalar>::initialize(
const RCP<const Thyra::ModelEvaluator<Scalar> > &daeModel,
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &initCond,
const Scalar finalTime,
const int numTimeSteps,
const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > &W_bar_factory
)
{
TEST_FOR_EXCEPT(is_null(daeModel));
TEST_FOR_EXCEPT(is_null(initCond.get_x()));
TEST_FOR_EXCEPT(is_null(initCond.get_x_dot()));
TEST_FOR_EXCEPT(finalTime <= initCond.get_t());
TEST_FOR_EXCEPT(numTimeSteps <= 0);
// ToDo: Validate that daeModel is of the right form!
daeModel_ = daeModel;
initCond_ = initCond;
finalTime_ = finalTime;
numTimeSteps_ = numTimeSteps;
initTime_ = initCond.get_t();
delta_t_ = (finalTime_ - initTime_) / numTimeSteps_;
x_bar_space_ = productVectorSpace(daeModel_->get_x_space(),numTimeSteps_);
f_bar_space_ = productVectorSpace(daeModel_->get_f_space(),numTimeSteps_);
if (!is_null(W_bar_factory)) {
W_bar_factory_ = W_bar_factory;
}
else {
W_bar_factory_ =
Thyra::defaultBlockedTriangularLinearOpWithSolveFactory<Scalar>(
daeModel_->get_W_factory()
);
}
}
示例3: vanderPolModel
//.........这里部分代码省略.........
double h = 0.1;
std::vector<double> x_0_exact;
std::vector<double> x_1_exact;
std::vector<double> x_0_dot_exact;
std::vector<double> x_1_dot_exact;
{
x_0_exact.push_back(2.0); // IC
x_1_exact.push_back(0.0);
x_0_exact.push_back(1.982896621392518e+00); // matlab
x_1_exact.push_back(-1.710337860748234e-01);
x_0_exact.push_back(1.951487185706842e+00); // matlab
x_1_exact.push_back(-3.140943568567556e-01);
x_0_exact.push_back(1.908249109758246e+00); // matlab
x_1_exact.push_back(-4.323807594859574e-01);
x_0_dot_exact.push_back(0.0);
x_1_dot_exact.push_back(0.0);
for ( int i=1 ; i< Teuchos::as<int>(x_0_exact.size()) ; ++i ) {
x_0_dot_exact.push_back( (x_0_exact[i]-x_0_exact[i-1])/h );
x_1_dot_exact.push_back( (x_1_exact[i]-x_1_exact[i-1])/h );
//std::cout << "x_0_dot_exact["<<i<<"] = "<<x_0_dot_exact[i] << std::endl;
//std::cout << "x_1_dot_exact["<<i<<"] = "<<x_1_dot_exact[i] << std::endl;
}
}
double tol_discrete = 1.0e-12;
double tol_continuous = 1.0e-2;
{
// Get IC out
double t = 0.0;
RCP<const VectorBase<double> > x;
RCP<const VectorBase<double> > xdot;
{
// Get x out of stepper.
Array<double> t_vec;
Array<RCP<const VectorBase<double> > > x_vec;
Array<RCP<const VectorBase<double> > > xdot_vec;
t_vec.resize(1); t_vec[0] = t;
stepper->getPoints(t_vec,&x_vec,&xdot_vec,NULL);
x = x_vec[0];
xdot = xdot_vec[0];
}
{
Thyra::ConstDetachedVectorView<double> x_view( *x );
TEST_FLOATING_EQUALITY( x_view[0], x_0_exact[0], tol_discrete );
TEST_FLOATING_EQUALITY( x_view[1], x_1_exact[0], tol_discrete );
Thyra::ConstDetachedVectorView<double> xdot_view( *xdot );
TEST_FLOATING_EQUALITY( xdot_view[0], x_0_dot_exact[0], tol_discrete );
TEST_FLOATING_EQUALITY( xdot_view[1], x_1_dot_exact[0], tol_discrete );
}
}
for (int i=1 ; i < Teuchos::as<int>(x_0_exact.size()); ++i) {
// Each time step
double t = 0.0+i*h;
double h_taken = stepper->takeStep(h,STEP_TYPE_FIXED);
TEST_ASSERT( h_taken == h );
RCP<const VectorBase<double> > x;
RCP<const VectorBase<double> > xdot;
{
// Get x out of stepper.
Array<double> t_vec;
Array<RCP<const VectorBase<double> > > x_vec;
Array<RCP<const VectorBase<double> > > xdot_vec;
t_vec.resize(1); t_vec[0] = t;
stepper->getPoints(t_vec,&x_vec,&xdot_vec,NULL);
x = x_vec[0];
xdot = xdot_vec[0];
}
{
Thyra::ConstDetachedVectorView<double> x_view( *x );
TEST_FLOATING_EQUALITY( x_view[0], x_0_exact[i], tol_discrete );
TEST_FLOATING_EQUALITY( x_view[1], x_1_exact[i], tol_discrete );
Thyra::ConstDetachedVectorView<double> xdot_view( *xdot );
TEST_FLOATING_EQUALITY( xdot_view[0], x_0_dot_exact[i], tol_discrete );
TEST_FLOATING_EQUALITY( xdot_view[1], x_1_dot_exact[i], tol_discrete );
}
// Now compare this to the continuous exact solution:
{
Thyra::ModelEvaluatorBase::InArgs<double> inArgs = model->getExactSolution(t);
RCP<const VectorBase<double> > x_continuous_exact = inArgs.get_x();
RCP<const VectorBase<double> > xdot_continuous_exact = inArgs.get_x_dot();
{
Thyra::ConstDetachedVectorView<double> x_view( *x );
Thyra::ConstDetachedVectorView<double> xce_view( *x_continuous_exact );
TEST_FLOATING_EQUALITY( x_view[0], xce_view[0], tol_continuous );
TEST_FLOATING_EQUALITY( x_view[1], xce_view[1], tol_continuous*10 );
Thyra::ConstDetachedVectorView<double> xdot_view( *xdot );
Thyra::ConstDetachedVectorView<double> xdotce_view( *xdot_continuous_exact );
TEST_FLOATING_EQUALITY( xdot_view[0], xdotce_view[0], tol_continuous*10 );
TEST_FLOATING_EQUALITY( xdot_view[1], xdotce_view[1], tol_continuous*10 );
}
}
}
}
示例4: Timer
void
Albany::ModelEvaluatorT::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<ST>& inArgsT,
const Thyra::ModelEvaluatorBase::OutArgs<ST>& outArgsT) const
{
#ifdef OUTPUT_TO_SCREEN
std::cout << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
#endif
Teuchos::TimeMonitor Timer(*timer); //start timer
//
// Get the input arguments
//
const Teuchos::RCP<const Tpetra_Vector> xT =
ConverterT::getConstTpetraVector(inArgsT.get_x());
const Teuchos::RCP<const Tpetra_Vector> x_dotT =
(supports_xdot && Teuchos::nonnull(inArgsT.get_x_dot())) ?
ConverterT::getConstTpetraVector(inArgsT.get_x_dot()) :
Teuchos::null;
const Teuchos::RCP<const Tpetra_Vector> x_dotdotT =
(supports_xdotdot && Teuchos::nonnull(this->get_x_dotdot())) ?
ConverterT::getConstTpetraVector(this->get_x_dotdot()) :
Teuchos::null;
const double alpha = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_alpha() : 0.0;
const double omega = Teuchos::nonnull(x_dotdotT) ? this->get_omega() : 0.0;
const double beta = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_beta() : 1.0;
const double curr_time = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_t() : 0.0;
for (int l = 0; l < inArgsT.Np(); ++l) {
const Teuchos::RCP<const Thyra::VectorBase<ST> > p = inArgsT.get_p(l);
if (Teuchos::nonnull(p)) {
const Teuchos::RCP<const Tpetra_Vector> pT = ConverterT::getConstTpetraVector(p);
const Teuchos::ArrayRCP<const ST> pT_constView = pT->get1dView();
ParamVec &sacado_param_vector = sacado_param_vec[l];
for (unsigned int k = 0; k < sacado_param_vector.size(); ++k) {
sacado_param_vector[k].baseValue = pT_constView[k];
}
}
}
//
// Get the output arguments
//
const Teuchos::RCP<Tpetra_Vector> fT_out =
Teuchos::nonnull(outArgsT.get_f()) ?
ConverterT::getTpetraVector(outArgsT.get_f()) :
Teuchos::null;
const Teuchos::RCP<Tpetra_Operator> W_op_outT =
Teuchos::nonnull(outArgsT.get_W_op()) ?
ConverterT::getTpetraOperator(outArgsT.get_W_op()) :
Teuchos::null;
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 4/24/15: adding object to hold mass matrix to be written to matrix market file
const Teuchos::RCP<Tpetra_Operator> Mass =
Teuchos::nonnull(outArgsT.get_W_op()) ?
ConverterT::getTpetraOperator(outArgsT.get_W_op()) :
Teuchos::null;
//IK, 4/24/15: needed for writing mass matrix out to matrix market file
const Teuchos::RCP<Tpetra_Vector> ftmp =
Teuchos::nonnull(outArgsT.get_f()) ?
ConverterT::getTpetraVector(outArgsT.get_f()) :
Teuchos::null;
#endif
// Cast W to a CrsMatrix, throw an exception if this fails
const Teuchos::RCP<Tpetra_CrsMatrix> W_op_out_crsT =
Teuchos::nonnull(W_op_outT) ?
Teuchos::rcp_dynamic_cast<Tpetra_CrsMatrix>(W_op_outT, true) :
Teuchos::null;
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 4/24/15: adding object to hold mass matrix to be written to matrix market file
const Teuchos::RCP<Tpetra_CrsMatrix> Mass_crs =
Teuchos::nonnull(Mass) ?
Teuchos::rcp_dynamic_cast<Tpetra_CrsMatrix>(Mass, true) :
Teuchos::null;
#endif
//
// Compute the functions
//
bool f_already_computed = false;
// W matrix
if (Teuchos::nonnull(W_op_out_crsT)) {
app->computeGlobalJacobianT(
alpha, beta, omega, curr_time, x_dotT.get(), x_dotdotT.get(), *xT,
sacado_param_vec, fT_out.get(), *W_op_out_crsT);
f_already_computed = true;
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 4/24/15: write mass matrix to matrix market file
//Warning: to read this in to MATLAB correctly, code must be run in serial.
//.........这里部分代码省略.........
示例5: Timer
void
Albany::ModelEvaluatorT::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<ST>& inArgsT,
const Thyra::ModelEvaluatorBase::OutArgs<ST>& outArgsT) const
{
Teuchos::TimeMonitor Timer(*timer); //start timer
//
// Get the input arguments
//
const Teuchos::RCP<const Tpetra_Vector> xT =
ConverterT::getConstTpetraVector(inArgsT.get_x());
const Teuchos::RCP<const Tpetra_Vector> x_dotT =
Teuchos::nonnull(inArgsT.get_x_dot()) ?
ConverterT::getConstTpetraVector(inArgsT.get_x_dot()) :
Teuchos::null;
// AGS: x_dotdot time integrators not imlemented in Thyra ME yet
//const Teuchos::RCP<const Tpetra_Vector> x_dotdotT =
// Teuchos::nonnull(inArgsT.get_x_dotdot()) ?
// ConverterT::getConstTpetraVector(inArgsT.get_x_dotdot()) :
// Teuchos::null;
const Teuchos::RCP<const Tpetra_Vector> x_dotdotT = Teuchos::null;
const double alpha = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_alpha() : 0.0;
// AGS: x_dotdot time integrators not imlemented in Thyra ME yet
// const double omega = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_omega() : 0.0;
const double omega = 0.0;
const double beta = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_beta() : 1.0;
const double curr_time = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_t() : 0.0;
for (int l = 0; l < inArgsT.Np(); ++l) {
const Teuchos::RCP<const Thyra::VectorBase<ST> > p = inArgsT.get_p(l);
if (Teuchos::nonnull(p)) {
const Teuchos::RCP<const Tpetra_Vector> pT = ConverterT::getConstTpetraVector(p);
const Teuchos::ArrayRCP<const ST> pT_constView = pT->get1dView();
ParamVec &sacado_param_vector = sacado_param_vec[l];
for (unsigned int k = 0; k < sacado_param_vector.size(); ++k) {
sacado_param_vector[k].baseValue = pT_constView[k];
}
}
}
//
// Get the output arguments
//
const Teuchos::RCP<Tpetra_Vector> fT_out =
Teuchos::nonnull(outArgsT.get_f()) ?
ConverterT::getTpetraVector(outArgsT.get_f()) :
Teuchos::null;
const Teuchos::RCP<Tpetra_Operator> W_op_outT =
Teuchos::nonnull(outArgsT.get_W_op()) ?
ConverterT::getTpetraOperator(outArgsT.get_W_op()) :
Teuchos::null;
// Cast W to a CrsMatrix, throw an exception if this fails
const Teuchos::RCP<Tpetra_CrsMatrix> W_op_out_crsT =
Teuchos::nonnull(W_op_outT) ?
Teuchos::rcp_dynamic_cast<Tpetra_CrsMatrix>(W_op_outT, true) :
Teuchos::null;
//
// Compute the functions
//
bool f_already_computed = false;
// W matrix
if (Teuchos::nonnull(W_op_out_crsT)) {
app->computeGlobalJacobianT(
alpha, beta, omega, curr_time, x_dotT.get(), x_dotdotT.get(), *xT,
sacado_param_vec, fT_out.get(), *W_op_out_crsT);
f_already_computed = true;
}
// df/dp
for (int l = 0; l < outArgsT.Np(); ++l) {
const Teuchos::RCP<Thyra::MultiVectorBase<ST> > dfdp_out =
outArgsT.get_DfDp(l).getMultiVector();
const Teuchos::RCP<Tpetra_MultiVector> dfdp_outT =
Teuchos::nonnull(dfdp_out) ?
ConverterT::getTpetraMultiVector(dfdp_out) :
Teuchos::null;
if (Teuchos::nonnull(dfdp_outT)) {
const Teuchos::RCP<ParamVec> p_vec = Teuchos::rcpFromRef(sacado_param_vec[l]);
app->computeGlobalTangentT(
0.0, 0.0, 0.0, curr_time, false, x_dotT.get(), x_dotdotT.get(), *xT,
sacado_param_vec, p_vec.get(),
NULL, NULL, NULL, NULL, fT_out.get(), NULL,
dfdp_outT.get());
f_already_computed = true;
}
}
//.........这里部分代码省略.........
示例6: Timer
// hide the original parental method AMET->evalModelImpl():
void
Aeras::HVDecorator::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<ST>& inArgsT,
const Thyra::ModelEvaluatorBase::OutArgs<ST>& outArgsT) const
{
#ifdef OUTPUT_TO_SCREEN
std::cout << "DEBUG WHICH HVDecorator: " << __PRETTY_FUNCTION__ << "\n";
#endif
Teuchos::TimeMonitor Timer(*timer); //start timer
//
// Get the input arguments
//
// Thyra vectors
const Teuchos::RCP<const Thyra_Vector> x = inArgsT.get_x();
const Teuchos::RCP<const Thyra_Vector> x_dot =
(supports_xdot ? inArgsT.get_x_dot() : Teuchos::null);
const Teuchos::RCP<const Thyra_Vector> x_dotdot =
(supports_xdotdot ? inArgsT.get_x_dot_dot() : Teuchos::null);
const double alpha = (Teuchos::nonnull(x_dot) || Teuchos::nonnull(x_dotdot)) ? inArgsT.get_alpha() : 0.0;
// AGS: x_dotdot time integrators not imlemented in Thyra ME yet
// const double omega = (Teuchos::nonnull(x_dot) || Teuchos::nonnull(x_dotdot)) ? inArgsT.get_omega() : 0.0;
const double omega = 0.0;
const double beta = (Teuchos::nonnull(x_dot) || Teuchos::nonnull(x_dotdot)) ? inArgsT.get_beta() : 1.0;
const double curr_time = (Teuchos::nonnull(x_dot) || Teuchos::nonnull(x_dotdot)) ? inArgsT.get_t() : 0.0;
for (int l = 0; l < inArgsT.Np(); ++l) {
const Teuchos::RCP<const Thyra_Vector> p = inArgsT.get_p(l);
if (Teuchos::nonnull(p)) {
const Teuchos::RCP<const Tpetra_Vector> pT = Albany::getConstTpetraVector(p);
const Teuchos::ArrayRCP<const ST> pT_constView = pT->get1dView();
ParamVec &sacado_param_vector = sacado_param_vec[l];
for (unsigned int k = 0; k < sacado_param_vector.size(); ++k) {
sacado_param_vector[k].baseValue = pT_constView[k];
}
}
}
//
// Get the output arguments
//
auto f = outArgsT.get_f();
auto W_op = outArgsT.get_W_op();
//
// Compute the functions
//
bool f_already_computed = false;
// W matrix
if (Teuchos::nonnull(W_op)) {
app->computeGlobalJacobian(
alpha, beta, omega, curr_time, x, x_dot, x_dotdot,
sacado_param_vec, f, W_op);
f_already_computed = true;
}
// df/dp
for (int l = 0; l < outArgsT.Np(); ++l) {
const Teuchos::RCP<Thyra_MultiVector> df_dp = outArgsT.get_DfDp(l).getMultiVector();
if (Teuchos::nonnull(df_dp)) {
const Teuchos::RCP<ParamVec> p_vec = Teuchos::rcpFromRef(sacado_param_vec[l]);
app->computeGlobalTangent(
0.0, 0.0, 0.0, curr_time, false, x, x_dot, x_dotdot,
sacado_param_vec, p_vec.get(),
Teuchos::null, Teuchos::null, Teuchos::null, Teuchos::null,
f, Teuchos::null, df_dp);
f_already_computed = true;
}
}
// f
if (app->is_adjoint) {
const Thyra_Derivative f_deriv(f, Thyra::ModelEvaluatorBase::DERIV_TRANS_MV_BY_ROW);
const Thyra_Derivative dummy_deriv;
const int response_index = 0; // need to add capability for sending this in
app->evaluateResponseDerivative(
response_index, curr_time, x, x_dot, x_dotdot,
sacado_param_vec, NULL,
Teuchos::null, f_deriv, dummy_deriv, dummy_deriv, dummy_deriv);
} else {
if (Teuchos::nonnull(f) && !f_already_computed) {
app->computeGlobalResidual(
curr_time, x, x_dot, x_dotdot,
sacado_param_vec, f);
}
}
//compute xtilde
applyLinvML(x, xtilde);
#ifdef WRITE_TO_MATRIX_MARKET_TO_MM_FILE
//.........这里部分代码省略.........
示例7:
void
Piro::VelocityVerletSolver<Scalar>::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<Scalar>& inArgs,
const Thyra::ModelEvaluatorBase::OutArgs<Scalar>& outArgs) const
{
using Teuchos::RCP;
using Teuchos::rcp;
// TODO: Support more than 1 parameter and 1 response
const int j = 0;
const int l = 0;
// Parse InArgs
RCP<const Thyra::VectorBase<Scalar> > p_in;
if (num_p > 0) {
p_in = inArgs.get_p(l);
}
// Parse OutArgs
RCP<Thyra::VectorBase<Scalar> > g_out;
if (num_g > 0) {
g_out = outArgs.get_g(j);
}
const RCP<Thyra::VectorBase<Scalar> > gx_out = outArgs.get_g(num_g);
Teuchos::RCP<Thyra::VectorBase<Scalar> > x = inArgs.get_x()->clone_v();
Teuchos::RCP<Thyra::VectorBase<Scalar> > v = inArgs.get_x_dot()->clone_v();
Teuchos::RCP<Thyra::VectorBase<Scalar> > a = Thyra::createMember<Scalar>(model->get_f_space());
RCP<Thyra::VectorBase<Scalar> > finalSolution;
// Zero out the acceleration vector
put_scalar(0.0, a.ptr());
TEUCHOS_TEST_FOR_EXCEPTION(v == Teuchos::null || x == Teuchos::null,
Teuchos::Exceptions::InvalidParameter,
std::endl << "Error in Piro::VelocityVerletSolver " <<
"Requires initial x and x_dot: " << std::endl);
Scalar t = t_init;
// Observe initial condition
if (observer != Teuchos::null) observer->observeSolution(*x, t);
Scalar vo = norm_2(*v);
*out << "Initial Velocity = " << vo << std::endl;
if (Teuchos::VERB_MEDIUM <= solnVerbLevel) *out << std::endl;
Thyra::ModelEvaluatorBase::InArgs<Scalar> model_inargs = model->createInArgs();
Thyra::ModelEvaluatorBase::OutArgs<Scalar> model_outargs = model->createOutArgs();
model_inargs.set_x(x);
if (num_p > 0) model_inargs.set_p(0, p_in);
model_outargs.set_f(a);
if (g_out != Teuchos::null) model_outargs.set_g(0, g_out);
Scalar ddt = 0.5 * delta_t * delta_t;
// Calculate acceleration at time 0
model->evalModel(model_inargs, model_outargs);
for (int timeStep = 1; timeStep <= numTimeSteps; timeStep++) {
// x->Update(delta_t, *v, ddt, *a, 1.0);
V_StVpStV(x.ptr(), delta_t, *v, ddt, *a);
t += delta_t; model_inargs.set_t(t);
// v->Update(0.5*delta_t, *a, 1.0);
V_StV(v.ptr(), 0.5 * delta_t, *a);
//calc a(x,t,p);
model->evalModel(model_inargs, model_outargs);
// v->Update(0.5*delta_t, *a, 1.0);
V_StV(v.ptr(), 0.5 * delta_t, *a);
// Observe completed time step
if (observer != Teuchos::null) observer->observeSolution(*x, t);
}
// return the final solution as an additional g-vector, if requested
if (finalSolution != Teuchos::null) finalSolution = x->clone_v();
// Return the final solution as an additional g-vector, if requested
if (Teuchos::nonnull(gx_out)) {
Thyra::copy(*finalSolution, gx_out.ptr());
}
}
示例8: Timer
// hide the original parental method AMET->evalModelImpl():
void
Aeras::HVDecorator::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<ST>& inArgsT,
const Thyra::ModelEvaluatorBase::OutArgs<ST>& outArgsT) const
{
std::cout << "DEBUG WHICH HVDecorator: " << __PRETTY_FUNCTION__ << "\n";
Teuchos::TimeMonitor Timer(*timer); //start timer
//
// Get the input arguments
//
const Teuchos::RCP<const Tpetra_Vector> xT =
ConverterT::getConstTpetraVector(inArgsT.get_x());
const Teuchos::RCP<const Tpetra_Vector> x_dotT =
Teuchos::nonnull(inArgsT.get_x_dot()) ?
ConverterT::getConstTpetraVector(inArgsT.get_x_dot()) :
Teuchos::null;
// AGS: x_dotdot time integrators not imlemented in Thyra ME yet
//const Teuchos::RCP<const Tpetra_Vector> x_dotdotT =
// Teuchos::nonnull(inArgsT.get_x_dotdot()) ?
// ConverterT::getConstTpetraVector(inArgsT.get_x_dotdot()) :
// Teuchos::null;
const Teuchos::RCP<const Tpetra_Vector> x_dotdotT = Teuchos::null;
const double alpha = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_alpha() : 0.0;
// AGS: x_dotdot time integrators not imlemented in Thyra ME yet
// const double omega = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_omega() : 0.0;
const double omega = 0.0;
const double beta = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_beta() : 1.0;
const double curr_time = (Teuchos::nonnull(x_dotT) || Teuchos::nonnull(x_dotdotT)) ? inArgsT.get_t() : 0.0;
for (int l = 0; l < inArgsT.Np(); ++l) {
const Teuchos::RCP<const Thyra::VectorBase<ST> > p = inArgsT.get_p(l);
if (Teuchos::nonnull(p)) {
const Teuchos::RCP<const Tpetra_Vector> pT = ConverterT::getConstTpetraVector(p);
const Teuchos::ArrayRCP<const ST> pT_constView = pT->get1dView();
ParamVec &sacado_param_vector = sacado_param_vec[l];
for (unsigned int k = 0; k < sacado_param_vector.size(); ++k) {
sacado_param_vector[k].baseValue = pT_constView[k];
}
}
}
//
// Get the output arguments
//
const Teuchos::RCP<Tpetra_Vector> fT_out =
Teuchos::nonnull(outArgsT.get_f()) ?
ConverterT::getTpetraVector(outArgsT.get_f()) :
Teuchos::null;
const Teuchos::RCP<Tpetra_Operator> W_op_outT =
Teuchos::nonnull(outArgsT.get_W_op()) ?
ConverterT::getTpetraOperator(outArgsT.get_W_op()) :
Teuchos::null;
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 4/24/15: adding object to hold mass matrix to be written to matrix market file
const Teuchos::RCP<Tpetra_Operator> Mass =
Teuchos::nonnull(outArgsT.get_W_op()) ?
ConverterT::getTpetraOperator(outArgsT.get_W_op()) :
Teuchos::null;
//IK, 4/24/15: needed for writing mass matrix out to matrix market file
const Teuchos::RCP<Tpetra_Vector> ftmp =
Teuchos::nonnull(outArgsT.get_f()) ?
ConverterT::getTpetraVector(outArgsT.get_f()) :
Teuchos::null;
#endif
// Cast W to a CrsMatrix, throw an exception if this fails
const Teuchos::RCP<Tpetra_CrsMatrix> W_op_out_crsT =
Teuchos::nonnull(W_op_outT) ?
Teuchos::rcp_dynamic_cast<Tpetra_CrsMatrix>(W_op_outT, true) :
Teuchos::null;
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 4/24/15: adding object to hold mass matrix to be written to matrix market file
const Teuchos::RCP<Tpetra_CrsMatrix> Mass_crs =
Teuchos::nonnull(Mass) ?
Teuchos::rcp_dynamic_cast<Tpetra_CrsMatrix>(Mass, true) :
Teuchos::null;
#endif
//
// Compute the functions
//
bool f_already_computed = false;
// W matrix
if (Teuchos::nonnull(W_op_out_crsT)) {
app->computeGlobalJacobianT(
alpha, beta, omega, curr_time, x_dotT.get(), x_dotdotT.get(), *xT,
sacado_param_vec, fT_out.get(), *W_op_out_crsT);
f_already_computed = true;
//.........这里部分代码省略.........