本文整理汇总了C++中InArgs::supports方法的典型用法代码示例。如果您正苦于以下问题:C++ InArgs::supports方法的具体用法?C++ InArgs::supports怎么用?C++ InArgs::supports使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InArgs
的用法示例。
在下文中一共展示了InArgs::supports方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modelOutArgs
void Piro::Epetra::MatrixFreeDecorator::evalModel( const InArgs& inArgs,
const OutArgs& outArgs ) const
{
using Teuchos::RCP;
using Teuchos::rcp;
RCP<Epetra_Operator> W_out = outArgs.get_W();
if (W_out == Teuchos::null) {
// Just pass through as is: nothing to Decorate
model->evalModel(inArgs, outArgs);
}
else {
RCP<Piro::Epetra::MatrixFreeOperator> W_mfo =
Teuchos::rcp_dynamic_cast<Piro::Epetra::MatrixFreeOperator>(W_out);
TEUCHOS_TEST_FOR_EXCEPTION(W_mfo==Teuchos::null, std::logic_error,
"Epetra_Operator sent as W to Piro::Epetra::MatrixFreeDecorator\n"
"be of type Piro::Epetra::MatrixFreeOperator");
// Do base case for MatrixFree: set f instead of W
OutArgs modelOutArgs(outArgs);
InArgs modelInArgs(inArgs);
// Store f_out in case it was also requested
RCP<Epetra_Vector> f_out = outArgs.get_f();
modelOutArgs.set_f(fBase);
modelOutArgs.set_W(Teuchos::null);
//Evaluate the underlying model
model->evalModel(modelInArgs, modelOutArgs);
// If f_out was requested, return it.
if (f_out != Teuchos::null) *f_out = *fBase;
// Save unperturbed solution (deep copy inArgs, shallow f)
InArgs clonedInArgs = inArgs;
for (int l = 0; l < inArgs.Np(); ++l) {
const RCP<const Epetra_Vector> p_l = inArgs.get_p(l);
if (nonnull(p_l))
clonedInArgs.set_p(l, Teuchos::rcp(new Epetra_Vector(*p_l)));
}
clonedInArgs.set_x(Teuchos::rcp(new Epetra_Vector(*inArgs.get_x())));
bool haveXdot = false;
if (inArgs.supports(IN_ARG_x_dot)) {
RCP<const Epetra_Vector> xdot = inArgs.get_x_dot();
if (nonnull(xdot)) {
clonedInArgs.set_x_dot(Teuchos::rcp(new Epetra_Vector(*inArgs.get_x_dot())));
haveXdot = true;
}
}
W_mfo->setBase(clonedInArgs, fBase, haveXdot);
}
}
示例2: if
void
Stokhos::SGQuadModelEvaluator::
evalModel(const InArgs& inArgs, const OutArgs& outArgs) const
{
// Create underlying inargs
InArgs me_inargs = me->createInArgs();
if (me_inargs.supports(IN_ARG_x))
me_inargs.set_x(inArgs.get_x());
if (me_inargs.supports(IN_ARG_x_dot))
me_inargs.set_x_dot(inArgs.get_x_dot());
if (me_inargs.supports(IN_ARG_alpha))
me_inargs.set_alpha(inArgs.get_alpha());
if (me_inargs.supports(IN_ARG_beta))
me_inargs.set_beta(inArgs.get_beta());
if (me_inargs.supports(IN_ARG_t))
me_inargs.set_t(inArgs.get_t());
for (int i=0; i<num_p; i++)
me_inargs.set_p(i, inArgs.get_p(i));
// Create underlying outargs
OutArgs me_outargs = me->createOutArgs();
if (me_outargs.supports(OUT_ARG_f))
me_outargs.set_f(outArgs.get_f());
if (me_outargs.supports(OUT_ARG_W))
me_outargs.set_W(outArgs.get_W());
for (int j=0; j<num_p; j++)
if (!outArgs.supports(OUT_ARG_DfDp, j).none())
me_outargs.set_DfDp(j, outArgs.get_DfDp(j));
for (int i=0; i<num_g; i++) {
me_outargs.set_g(i, outArgs.get_g(i));
if (!outArgs.supports(OUT_ARG_DgDx, i).none())
me_outargs.set_DgDx(i, outArgs.get_DgDx(i));
if (!outArgs.supports(OUT_ARG_DgDx_dot, i).none())
me_outargs.set_DgDx(i, outArgs.get_DgDx_dot(i));
for (int j=0; j<num_p; j++)
if (!outArgs.supports(OUT_ARG_DgDp, i, j).none())
me_outargs.set_DgDp(i, j, outArgs.get_DgDp(i,j));
}
bool do_quad = false;
InArgs::sg_const_vector_t x_sg;
InArgs::sg_const_vector_t x_dot_sg;
Teuchos::Array<InArgs::sg_const_vector_t> p_sg(num_p);
OutArgs::sg_vector_t f_sg;
OutArgs::sg_operator_t W_sg;
Teuchos::Array<SGDerivative> dfdp_sg(num_p);
Teuchos::Array<OutArgs::sg_vector_t> g_sg(num_g);
Teuchos::Array<SGDerivative> dgdx_sg(num_g);
Teuchos::Array<SGDerivative> dgdx_dot_sg(num_g);
Teuchos::Array< Teuchos::Array<SGDerivative> > dgdp_sg(num_g);
TEUCHOS_TEST_FOR_EXCEPTION(inArgs.get_sg_basis() == Teuchos::null,
std::logic_error,
"Error! Stokhos::SGQuadModelEvaluator::evalModel(): " <<
"SG basis inArg cannot be null!");
TEUCHOS_TEST_FOR_EXCEPTION(inArgs.get_sg_quadrature() == Teuchos::null,
std::logic_error,
"Error! Stokhos::SGQuadModelEvaluator::evalModel(): " <<
"SG quadrature inArg cannot be null!");
Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> > basis =
inArgs.get_sg_basis();
Teuchos::RCP< const Stokhos::Quadrature<int,double> > quad =
inArgs.get_sg_quadrature();
if (inArgs.supports(IN_ARG_x_sg)) {
x_sg = inArgs.get_x_sg();
if (x_sg != Teuchos::null) {
do_quad = true;
}
}
if (inArgs.supports(IN_ARG_x_dot_sg)) {
x_dot_sg = inArgs.get_x_dot_sg();
if (x_dot_sg != Teuchos::null) {
do_quad = true;
}
}
for (int i=0; i<num_p; i++) {
p_sg[i] = inArgs.get_p_sg(i);
if (p_sg[i] != Teuchos::null) {
do_quad = true;
}
}
if (outArgs.supports(OUT_ARG_f_sg)) {
f_sg = outArgs.get_f_sg();
if (f_sg != Teuchos::null)
f_sg->init(0.0);
}
if (outArgs.supports(OUT_ARG_W_sg)) {
W_sg = outArgs.get_W_sg();
if (W_sg != Teuchos::null)
W_sg->init(0.0);
}
for (int i=0; i<num_p; i++) {
if (!outArgs.supports(OUT_ARG_DfDp_sg, i).none()) {
dfdp_sg[i] = outArgs.get_DfDp_sg(i);
if (dfdp_sg[i].getMultiVector() != Teuchos::null)
dfdp_sg[i].getMultiVector()->init(0.0);
else if (dfdp_sg[i].getLinearOp() != Teuchos::null)
dfdp_sg[i].getLinearOp()->init(0.0);
}
}
//.........这里部分代码省略.........