本文整理汇总了C++中InArgs::get_t方法的典型用法代码示例。如果您正苦于以下问题:C++ InArgs::get_t方法的具体用法?C++ InArgs::get_t怎么用?C++ InArgs::get_t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InArgs
的用法示例。
在下文中一共展示了InArgs::get_t方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evalModel
void LorenzModel::evalModel( const InArgs& inArgs, const OutArgs& outArgs ) const
{
const Epetra_Vector &yin = *(inArgs.get_x());
const double t = inArgs.get_t(); // ignored
#ifdef LORENZMODEL_DEBUG
std::cout << "----------------------------------------------------------------------" << std::endl;
std::cout << "LorenzModel::evalModel yin = " << std::endl;
yin.Print(std::cout);
#endif
Epetra_Vector &yout = *outArgs.get_f();
yout[0] = -param0 * yin[0] + param0 * yin[1];
yout[1] = param1 * yin[0] - yin[1] - yin[0]*yin[2];
yout[2] = -param2*yin[2] + yin[0]*yin[1];
#ifdef LORENZMODEL_DEBUG
std::cout << "LorenzModel::evalModel (explicit) f = " << std::endl;
yout.Print(std::cout);
#endif
#ifdef LORENZMODEL_DEBUG
std::cout << "----------------------------------------------------------------------" << std::endl;
#endif
}
示例2: evalModel
void ExampleApplication::evalModel( const InArgs& inArgs, const OutArgs& outArgs ) const
{
const Epetra_Vector &x = *(inArgs.get_x());
const double t = inArgs.get_t();
const Epetra_Vector &lambda = *lambda_ptr_;
#ifdef EXAMPLEAPPLICATION_DEBUG
std::cout << "----------------------------------------------------------------------" << std::endl;
std::cout << "ExampleApplication::evalModel x = " << std::endl;
x.Print(std::cout);
std::cout << "ExampleApplication::evalModel lambda = " << std::endl;
lambda.Print(std::cout);
#endif
int localNumElements = x.MyLength();
if(implicit_)
{
const Epetra_Vector &x_dot = *inArgs.get_x_dot();
if(outArgs.get_f().get())
{
Epetra_Vector &f = *outArgs.get_f();
for (int i=0 ; i<localNumElements ; ++i)
{
f[i] = x_dot[i] - lambda[i]*x[i] - evalR(t,lambda[i],coeff_s_);
}
#ifdef EXAMPLEAPPLICATION_DEBUG
std::cout << "ExampleApplication::evalModel (implicit) x_dot = " << std::endl;
x_dot.Print(std::cout);
std::cout << "ExampleApplication::evalModel (implicit) f = " << std::endl;
f.Print(std::cout);
#endif
}
Teuchos::RCP<Epetra_Operator> W;
if( (W = outArgs.get_W()).get() ) {
const double alpha = inArgs.get_alpha();
const double beta = inArgs.get_beta();
Epetra_CrsMatrix &crsW = Teuchos::dyn_cast<Epetra_CrsMatrix>(*W);
double values[1];
int indices[1];
const int IB = epetra_map_ptr_->IndexBase();
for( int i = 0; i < localNumElements; ++i )
{
values[0] = alpha - beta*lambda[i];
indices[0] = i + IB; // global column
crsW.ReplaceGlobalValues(i + IB // GlobalRow
,1 // NumEntries
,values // Values
,indices // Indices
);
}
#ifdef EXAMPLEAPPLICATION_DEBUG
std::cout << "ExampleApplication::evalModel (implicit) alpha, beta = " << std::endl;
std::cout << "alpha = " << alpha << std::endl;
std::cout << "beta = " << beta << std::endl;
std::cout << "ExampleApplication::evalModel (implicit) W = " << std::endl;
crsW.Print(std::cout);
#endif
}
}
else
{
Epetra_Vector &f = *outArgs.get_f();
for (int i=0 ; i<localNumElements ; ++i)
{
f[i] = lambda[i]*x[i]+evalR(t,lambda[i],coeff_s_);
}
#ifdef EXAMPLEAPPLICATION_DEBUG
std::cout << "ExampleApplication::evalModel (explicit) f = " << std::endl;
f.Print(std::cout);
#endif
}
#ifdef EXAMPLEAPPLICATION_DEBUG
std::cout << "----------------------------------------------------------------------" << std::endl;
#endif
}
示例3: Timer
void
Albany::ModelEvaluator::evalModel(const InArgs& inArgs,
const OutArgs& outArgs) const
{
Teuchos::TimeMonitor Timer(*timer); //start timer
//
// Get the input arguments
//
Teuchos::RCP<const Epetra_Vector> x = inArgs.get_x();
Teuchos::RCP<const Epetra_Vector> x_dot;
Teuchos::RCP<const Epetra_Vector> x_dotdot;
double alpha = 0.0;
double omega = 0.0;
double beta = 1.0;
double curr_time = 0.0;
x_dot = inArgs.get_x_dot();
x_dotdot = inArgs.get_x_dotdot();
if (x_dot != Teuchos::null || x_dotdot != Teuchos::null) {
alpha = inArgs.get_alpha();
omega = inArgs.get_omega();
beta = inArgs.get_beta();
curr_time = inArgs.get_t();
}
for (int i=0; i<num_param_vecs; i++) {
Teuchos::RCP<const Epetra_Vector> p = inArgs.get_p(i);
if (p != Teuchos::null) {
for (unsigned int j=0; j<sacado_param_vec[i].size(); j++)
sacado_param_vec[i][j].baseValue = (*p)[j];
}
}
for (int i=0; i<num_dist_param_vecs; i++) {
Teuchos::RCP<const Epetra_Vector> p = inArgs.get_p(i+num_param_vecs);
if (p != Teuchos::null) {
*(distParamLib->get(dist_param_names[i])->vector()) = *p;
}
}
//
// Get the output arguments
//
EpetraExt::ModelEvaluator::Evaluation<Epetra_Vector> f_out = outArgs.get_f();
Teuchos::RCP<Epetra_Operator> W_out = outArgs.get_W();
// Cast W to a CrsMatrix, throw an exception if this fails
Teuchos::RCP<Epetra_CrsMatrix> W_out_crs;
if (W_out != Teuchos::null)
W_out_crs = Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W_out, true);
int test_var = 0;
if(test_var != 0){
std::cout << "The current solution length is: " << x->MyLength() << std::endl;
x->Print(std::cout);
}
// Get preconditioner operator, if requested
Teuchos::RCP<Epetra_Operator> WPrec_out;
if (outArgs.supports(OUT_ARG_WPrec)) WPrec_out = outArgs.get_WPrec();
//
// Compute the functions
//
bool f_already_computed = false;
// W matrix
if (W_out != Teuchos::null) {
app->computeGlobalJacobian(alpha, beta, omega, curr_time, x_dot.get(), x_dotdot.get(),*x,
sacado_param_vec, f_out.get(), *W_out_crs);
f_already_computed=true;
if(test_var != 0){
//std::cout << "The current rhs length is: " << f_out->MyLength() << std::endl;
//f_out->Print(std::cout);
std::cout << "The current Jacobian length is: " << W_out_crs->NumGlobalRows() << std::endl;
W_out_crs->Print(std::cout);
}
}
if (WPrec_out != Teuchos::null) {
app->computeGlobalJacobian(alpha, beta, omega, curr_time, x_dot.get(), x_dotdot.get(), *x,
sacado_param_vec, f_out.get(), *Extra_W_crs);
f_already_computed=true;
if(test_var != 0){
//std::cout << "The current rhs length is: " << f_out->MyLength() << std::endl;
//f_out->Print(std::cout);
std::cout << "The current preconditioner length is: " << Extra_W_crs->NumGlobalRows() << std::endl;
Extra_W_crs->Print(std::cout);
}
app->computeGlobalPreconditioner(Extra_W_crs, WPrec_out);
}
// scalar df/dp
for (int i=0; i<num_param_vecs; i++) {
Teuchos::RCP<Epetra_MultiVector> dfdp_out =
outArgs.get_DfDp(i).getMultiVector();
if (dfdp_out != Teuchos::null) {
Teuchos::Array<int> p_indexes =
outArgs.get_DfDp(i).getDerivativeMultiVector().getParamIndexes();
Teuchos::RCP<ParamVec> p_vec;
//.........这里部分代码省略.........
示例4: Timer
void
Albany::ModelEvaluator::evalModel(const InArgs& inArgs,
const OutArgs& outArgs) const
{
Teuchos::TimeMonitor Timer(*timer); //start timer
//
// Get the input arguments
//
Teuchos::RCP<const Epetra_Vector> x = inArgs.get_x();
Teuchos::RCP<const Epetra_Vector> x_dot;
Teuchos::RCP<const Epetra_Vector> x_dotdot;
//create comm and node objects for Epetra -> Tpetra conversions
Teuchos::RCP<const Teuchos::Comm<int> > commT = app->getComm();
Teuchos::RCP<Epetra_Comm> comm = Albany::createEpetraCommFromTeuchosComm(commT);
//Create Tpetra copy of x, call it xT
Teuchos::RCP<const Tpetra_Vector> xT;
if (x != Teuchos::null)
xT = Petra::EpetraVector_To_TpetraVectorConst(*x, commT);
double alpha = 0.0;
double omega = 0.0;
double beta = 1.0;
double curr_time = 0.0;
if(num_time_deriv > 0)
x_dot = inArgs.get_x_dot();
if(num_time_deriv > 1)
x_dotdot = inArgs.get_x_dotdot();
//Declare and create Tpetra copy of x_dot, call it x_dotT
Teuchos::RCP<const Tpetra_Vector> x_dotT;
if (Teuchos::nonnull(x_dot))
x_dotT = Petra::EpetraVector_To_TpetraVectorConst(*x_dot, commT);
//Declare and create Tpetra copy of x_dotdot, call it x_dotdotT
Teuchos::RCP<const Tpetra_Vector> x_dotdotT;
if (Teuchos::nonnull(x_dotdot))
x_dotdotT = Petra::EpetraVector_To_TpetraVectorConst(*x_dotdot, commT);
if (Teuchos::nonnull(x_dot)){
alpha = inArgs.get_alpha();
beta = inArgs.get_beta();
curr_time = inArgs.get_t();
}
if (Teuchos::nonnull(x_dotdot)) {
omega = inArgs.get_omega();
}
for (int i=0; i<num_param_vecs; i++) {
Teuchos::RCP<const Epetra_Vector> p = inArgs.get_p(i);
if (p != Teuchos::null) {
for (unsigned int j=0; j<sacado_param_vec[i].size(); j++) {
sacado_param_vec[i][j].baseValue = (*p)[j];
}
}
}
for (int i=0; i<num_dist_param_vecs; i++) {
Teuchos::RCP<const Epetra_Vector> p = inArgs.get_p(i+num_param_vecs);
//create Tpetra copy of p
Teuchos::RCP<const Tpetra_Vector> pT;
if (p != Teuchos::null) {
pT = Petra::EpetraVector_To_TpetraVectorConst(*p, commT);
//*(distParamLib->get(dist_param_names[i])->vector()) = *p;
*(distParamLib->get(dist_param_names[i])->vector()) = *pT;
}
}
//
// Get the output arguments
//
EpetraExt::ModelEvaluator::Evaluation<Epetra_Vector> f_out = outArgs.get_f();
Teuchos::RCP<Epetra_Operator> W_out = outArgs.get_W();
// Cast W to a CrsMatrix, throw an exception if this fails
Teuchos::RCP<Epetra_CrsMatrix> W_out_crs;
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 7/15/14: adding object to hold mass matrix to be written to matrix market file
Teuchos::RCP<Epetra_CrsMatrix> Mass;
//IK, 7/15/14: needed for writing mass matrix out to matrix market file
EpetraExt::ModelEvaluator::Evaluation<Epetra_Vector> ftmp = outArgs.get_f();
#endif
if (W_out != Teuchos::null) {
W_out_crs = Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W_out, true);
#ifdef WRITE_MASS_MATRIX_TO_MM_FILE
//IK, 7/15/14: adding object to hold mass matrix to be written to matrix market file
Mass = Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(W_out, true);
#endif
}
int test_var = 0;
if(test_var != 0){
std::cout << "The current solution length is: " << x->MyLength() << std::endl;
x->Print(std::cout);
}
// Get preconditioner operator, if requested
//.........这里部分代码省略.........
示例5: 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);
}
}
//.........这里部分代码省略.........