本文整理汇总了C++中AztecOO::SetUserOperator方法的典型用法代码示例。如果您正苦于以下问题:C++ AztecOO::SetUserOperator方法的具体用法?C++ AztecOO::SetUserOperator怎么用?C++ AztecOO::SetUserOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AztecOO
的用法示例。
在下文中一共展示了AztecOO::SetUserOperator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(sg_model->create_W());
Teuchos::RCP<ML_Epetra::MultiLevelPreconditioner> sg_M =
Teuchos::rcp(new ML_Epetra::MultiLevelPreconditioner(*sg_J, precParams,
false));
// Setup InArgs and OutArgs
EpetraExt::ModelEvaluator::InArgs sg_inArgs = sg_model->createInArgs();
EpetraExt::ModelEvaluator::OutArgs sg_outArgs = sg_model->createOutArgs();
sg_inArgs.set_p(1, sg_p);
sg_inArgs.set_x(sg_x);
sg_outArgs.set_f(sg_f);
sg_outArgs.set_W(sg_J);
// Evaluate model
sg_model->evalModel(sg_inArgs, sg_outArgs);
sg_M->ComputePreconditioner();
// Print initial residual norm
double norm_f;
sg_f->Norm2(&norm_f);
if (MyPID == 0)
std::cout << "\nInitial residual norm = " << norm_f << std::endl;
// Setup AztecOO solver
AztecOO aztec;
if (symmetric)
aztec.SetAztecOption(AZ_solver, AZ_cg);
else
aztec.SetAztecOption(AZ_solver, AZ_gmres);
aztec.SetAztecOption(AZ_precond, AZ_none);
aztec.SetAztecOption(AZ_kspace, 20);
aztec.SetAztecOption(AZ_conv, AZ_r0);
aztec.SetAztecOption(AZ_output, 1);
aztec.SetUserOperator(sg_J.get());
aztec.SetPrecOperator(sg_M.get());
aztec.SetLHS(sg_dx.get());
aztec.SetRHS(sg_f.get());
// Solve linear system
aztec.Iterate(1000, 1e-12);
// Update x
sg_x->Update(-1.0, *sg_dx, 1.0);
// Save solution to file
EpetraExt::VectorToMatrixMarketFile("stochastic_solution_interlaced.mm",
*sg_x);
// Save RHS to file
EpetraExt::VectorToMatrixMarketFile("stochastic_RHS_interlaced.mm",
*sg_f);
// Save operator to file
EpetraExt::RowMatrixToMatrixMarketFile("stochastic_operator_interlaced.mm",
*sg_J);
// Save mean and variance to file
Teuchos::RCP<Stokhos::EpetraVectorOrthogPoly> sg_x_poly =
sg_model->create_x_sg(View, sg_x.get());
Epetra_Vector mean(*(model->get_x_map()));
Epetra_Vector std_dev(*(model->get_x_map()));
sg_x_poly->computeMean(mean);
sg_x_poly->computeStandardDeviation(std_dev);
EpetraExt::VectorToMatrixMarketFile("mean_gal_interlaced.mm", mean);
EpetraExt::VectorToMatrixMarketFile("std_dev_gal_interlaced.mm", std_dev);