本文整理汇总了C++中Thyra::epetraLinearOp方法的典型用法代码示例。如果您正苦于以下问题:C++ Thyra::epetraLinearOp方法的具体用法?C++ Thyra::epetraLinearOp怎么用?C++ Thyra::epetraLinearOp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thyra
的用法示例。
在下文中一共展示了Thyra::epetraLinearOp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadStableSystem
void tLSCIntegrationTest::loadStableSystem()
{
Epetra_CrsMatrix *F=0, *B=0, *Bt=0,*Qu=0;
F=0; B=0; Bt=0; Qu=0;
// read in stable discretization
TEST_FOR_EXCEPT(EpetraExt::MatrixMarketFileToCrsMatrix("./data/lsc_F_2.mm",*velMap_,*velMap_,*velMap_,F));
TEST_FOR_EXCEPT(EpetraExt::MatrixMarketFileToCrsMatrix("./data/lsc_B_2.mm",*prsMap_,*prsMap_,*velMap_,B));
TEST_FOR_EXCEPT(EpetraExt::MatrixMarketFileToCrsMatrix("./data/lsc_Bt_2.mm",*velMap_,*velMap_,*prsMap_,Bt));
TEST_FOR_EXCEPT(EpetraExt::MatrixMarketFileToCrsMatrix("./data/lsc_Qu_2.mm",*velMap_,*velMap_,*velMap_,Qu));
// set stable matrix pointers
sF_ = rcp(F); sB_ = rcp(B); sBt_ = rcp(Bt); sQu_ = rcp(Qu);
Teko::LinearOp C;
Teko::LinearOp tA_ = Teko::block2x2<double>(epetraLinearOp(sF_),epetraLinearOp(sBt_),epetraLinearOp(sB_),C,"A");
sA_ = rcp(new Teko::Epetra::EpetraOperatorWrapper(tA_));
// build an exporter to work around issue with MMFileToVector
Epetra_Export exporter(*fullMap_,sA_->OperatorRangeMap());
// read in RHS vector
{
Epetra_Vector *vfull=0, *temp=0;
// read in rhs file
TEST_FOR_EXCEPT(EpetraExt::MatrixMarketFileToVector("./data/lsc_rhs.mm",*fullMap_,vfull));
// MMFileToVector is immplemented incompletely...thats why an exporter is used
temp = new Epetra_Vector(sA_->OperatorRangeMap());
temp->Export(*vfull,exporter,Insert);
rhs_ = rcp(temp);
delete vfull;
}
// read in solution vector
{
Epetra_Vector *vfull=0, *temp=0;
// read in exact solution file
TEST_FOR_EXCEPT(EpetraExt::MatrixMarketFileToVector("./data/lsc_exact_2.mm",*fullMap_,vfull));
// MMFileToVector is immplemented incompletely...thats why an exporter is used
temp = new Epetra_Vector(sA_->OperatorRangeMap());
temp->Export(*vfull,exporter,Insert);
sExact_ = rcp(temp);
delete vfull;
}
}
示例2: test_withmassStable
bool tLSCIntegrationTest::test_withmassStable(int verbosity,std::ostream & os)
{
Teuchos::ParameterList paramList;
solveList(paramList,8);
RCP<Teko::InverseFactory> invFact = Teko::invFactoryFromParamList(paramList,"ML");
TEUCHOS_ASSERT(invFact!=Teuchos::null);
bool status = false;
bool allPassed = true;
// load everything
loadStableSystem();
// if you get here you automatically pass the first test
if(verbosity>=10 ) {
os << std::endl << " tLSCIntegrationTest::test_withmassStable: loading system ... "
<< toString(true) << std::endl;
}
LinearOp Qu = epetraLinearOp(sQu_);
const RCP<Teko::NS::LSCStrategy> strategy = rcp(new Teko::NS::InvLSCStrategy(invFact,Qu));
const RCP<Teko::BlockPreconditionerFactory> precFact = rcp(new Teko::NS::LSCPreconditionerFactory(strategy));
const RCP<Teko::Epetra::EpetraBlockPreconditioner> prec = rcp(new Teko::Epetra::EpetraBlockPreconditioner(precFact));
prec->buildPreconditioner(sA_);
// B. Build solver and solve system
Epetra_Vector x(sA_->OperatorDomainMap());
x.Scale(0.0);
// build Epetra problem
Epetra_LinearProblem problem(&*sA_,&x,&*rhs_); // this doesn't take const arguments!
AztecOO solver(problem);
solver.SetAztecOption(AZ_solver,AZ_gmres);
solver.SetAztecOption(AZ_precond,AZ_none);
solver.SetAztecOption(AZ_kspace,50);
solver.SetAztecOption(AZ_output,AZ_none);
solver.SetPrecOperator(&*prec);
solver.Iterate(1000,1e-8);
// check iteration count
status = (solver.NumIters()<=16);
if(not status || verbosity>=10 ) {
os << std::endl << " tLSCIntegrationTest::test_withmassStable " << toString(status)
<< ": # of iterations = " << solver.NumIters() << " (should be 16)" << std::endl;
}
allPassed &= status;
// check exact answer (versus IFISS solution)
x.Update(-1.0,*sExact_,1.0); // x = x - x*
double errnorm,exactnorm,relerr;
x.Norm2(&errnorm);
sExact_->Norm2(&exactnorm);
status = ((relerr = errnorm/exactnorm) <= tolerance_);
if(not status || verbosity>=10 ) {
os << std::endl << " tLSCIntegrationTest::test_withmassStable " << toString(status)
<< ": error in solution = " << std::scientific << relerr << " <= " << tolerance_ << std::endl;
}
allPassed &= status;
return allPassed;
}