本文整理汇总了C++中stratimikos::DefaultLinearSolverBuilder::setPreconditioningStrategyFactory方法的典型用法代码示例。如果您正苦于以下问题:C++ DefaultLinearSolverBuilder::setPreconditioningStrategyFactory方法的具体用法?C++ DefaultLinearSolverBuilder::setPreconditioningStrategyFactory怎么用?C++ DefaultLinearSolverBuilder::setPreconditioningStrategyFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stratimikos::DefaultLinearSolverBuilder
的用法示例。
在下文中一共展示了DefaultLinearSolverBuilder::setPreconditioningStrategyFactory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addMueLuToStratimikosBuilder
void addMueLuToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder,
const std::string & stratName)
{
TEUCHOS_TEST_FOR_EXCEPTION(builder.getValidParameters()->sublist("Preconditioner Types").isParameter(stratName),std::logic_error,
"MueLu::addMueLuToStratimikosBuilder cannot add \"" + stratName +"\" because it is already included in builder!");
// use default constructor to add Teko::StratimikosFactory
builder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Thyra::PreconditionerFactoryBase<double>,Thyra::MueLuPreconditionerFactory>(),
stratName);
}
示例2: addTekoToStratimikosBuilder
void addTekoToStratimikosBuilder(Stratimikos::DefaultLinearSolverBuilder & builder,
const Teuchos::RCP<Teko::RequestHandler> & rh,
const std::string & stratName)
{
TEUCHOS_TEST_FOR_EXCEPTION(builder.getValidParameters()->sublist("Preconditioner Types").isParameter(stratName),std::logic_error,
"Teko::addTekoToStratimikosBuilder cannot add \"" + stratName +"\" because it is already included in builder!");
// build an instance of a Teuchos::AbsractFactory<Thyra::PFB> so request handler is passed onto
// the resulting StratimikosFactory
Teuchos::RCP<TekoFactoryBuilder> tekoFactoryBuilder = Teuchos::rcp(new TekoFactoryBuilder(rh));
builder.setPreconditioningStrategyFactory(tekoFactoryBuilder,stratName);
}
示例3: comm
TEUCHOS_UNIT_TEST(tStratimikosFactory, test_Defaults)
{
using Teuchos::RCP;
using Teuchos::ParameterList;
// build global (or serial communicator)
#ifdef HAVE_MPI
Epetra_MpiComm comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm comm;
#endif
// build epetra operator
RCP<Epetra_Operator> eA = buildSystem(comm,5);
RCP<Thyra::LinearOpBase<double> > tA = Thyra::nonconstEpetraLinearOp(eA);
// build stratimikos factory, adding Teko's version
Stratimikos::DefaultLinearSolverBuilder stratFactory;
stratFactory.setPreconditioningStrategyFactory(
Teuchos::abstractFactoryStd<Thyra::PreconditionerFactoryBase<double>,Teko::StratimikosFactory>(),
"Teko");
RCP<const ParameterList> validParams = stratFactory.getValidParameters();
stratFactory.setParameterList(Teuchos::rcp(new Teuchos::ParameterList(*validParams)));
// print out Teko's parameter list and fail if it doesn't exist!
TEST_NOTHROW(validParams->sublist("Preconditioner Types").sublist("Teko").print(out,
ParameterList::PrintOptions().showDoc(true).indent(2).showTypes(true)));
// build teko preconditioner factory
RCP<Thyra::PreconditionerFactoryBase<double> > precFactory
= stratFactory.createPreconditioningStrategy("Teko");
// make sure factory is built
TEST_ASSERT(precFactory!=Teuchos::null);
// build preconditioner
RCP<Thyra::PreconditionerBase<double> > prec = Thyra::prec<double>(*precFactory,tA);
TEST_ASSERT(prec!=Teuchos::null);
// build an operator to test against
RCP<const Teko::InverseLibrary> invLib = Teko::InverseLibrary::buildFromStratimikos();
RCP<const Teko::InverseFactory> invFact = invLib->getInverseFactory("Amesos");
Teko::LinearOp testOp = Teko::buildInverse(*invFact,tA);
Teko::LinearOp precOp = prec->getUnspecifiedPrecOp();
TEST_ASSERT(precOp!=Teuchos::null);
Thyra::LinearOpTester<double> tester;
tester.show_all_tests(true);
tester.set_all_error_tol(0);
TEST_ASSERT(tester.compare(*precOp,*testOp,Teuchos::ptrFromRef(out)));
}
示例4: if
//.........这里部分代码省略.........
{
const std::string verbosity = rythmosSolverPL->get("Verbosity Level", "VERB_DEFAULT");
if (verbosity == "VERB_NONE") solnVerbLevel = Teuchos::VERB_NONE;
else if (verbosity == "VERB_DEFAULT") solnVerbLevel = Teuchos::VERB_DEFAULT;
else if (verbosity == "VERB_LOW") solnVerbLevel = Teuchos::VERB_LOW;
else if (verbosity == "VERB_MEDIUM") solnVerbLevel = Teuchos::VERB_MEDIUM;
else if (verbosity == "VERB_HIGH") solnVerbLevel = Teuchos::VERB_HIGH;
else if (verbosity == "VERB_EXTREME") solnVerbLevel = Teuchos::VERB_EXTREME;
else TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
"Unknown verbosity option specified in Piro_RythmosSolver.");
}
t_initial = rythmosPL->sublist("Integrator Settings").get("Initial Time", 0.0);
t_final = rythmosPL->sublist("Integrator Settings").get("Final Time", 0.1);
const std::string stepperType = rythmosPL->sublist("Stepper Settings")
.sublist("Stepper Selection").get("Stepper Type", "Backward Euler");
//
// *out << "\nB) Create the Stratimikos linear solver factory ...\n";
//
// This is the linear solve strategy that will be used to solve for the
// linear system with the W.
//
Stratimikos::DefaultLinearSolverBuilder linearSolverBuilder;
#ifdef HAVE_PIRO_IFPACK2
typedef Thyra::PreconditionerFactoryBase<double> Base;
#ifdef ALBANY_BUILD
typedef Thyra::Ifpack2PreconditionerFactory<Tpetra::CrsMatrix<double, LocalOrdinal, GlobalOrdinal, Node> > Impl;
#else
typedef Thyra::Ifpack2PreconditionerFactory<Tpetra::CrsMatrix<double> > Impl;
#endif
linearSolverBuilder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(), "Ifpack2");
#endif
#ifdef HAVE_PIRO_MUELU
#ifdef ALBANY_BUILD
Stratimikos::enableMueLu<LocalOrdinal, GlobalOrdinal, Node>(linearSolverBuilder);
#else
Stratimikos::enableMueLu(linearSolverBuilder);
#endif
#endif
linearSolverBuilder.setParameterList(sublist(rythmosSolverPL, "Stratimikos", true));
rythmosSolverPL->validateParameters(*getValidRythmosSolverParameters(),0);
RCP<Thyra::LinearOpWithSolveFactoryBase<double> > lowsFactory =
createLinearSolveStrategy(linearSolverBuilder);
//
*out << "\nC) Create and initalize the forward model ...\n";
//
// C.1) Create the underlying EpetraExt::ModelEvaluator
// already constructed as "model". Decorate if needed.
// TODO: Generelize to any explicit method, option to invert mass matrix
if (stepperType == "Explicit RK") {
if (rythmosSolverPL->get("Invert Mass Matrix", false)) {
Teuchos::RCP<Thyra::ModelEvaluator<Scalar> > origModel = model;
rythmosSolverPL->get("Lump Mass Matrix", false); //JF line does not do anything
model = Teuchos::rcp(new Piro::InvertMassMatrixDecorator<Scalar>(
sublist(rythmosSolverPL,"Stratimikos", true), origModel,
true,rythmosSolverPL->get("Lump Mass Matrix", false),false));
}
}
// C.2) Create the Thyra-wrapped ModelEvaluator
thyraModel = rcp(new Thyra::DefaultModelEvaluatorWithSolveFactory<Scalar>(model, lowsFactory));