本文整理汇总了C++中FactoryManager::GetFactory方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryManager::GetFactory方法的具体用法?C++ FactoryManager::GetFactory怎么用?C++ FactoryManager::GetFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactoryManager
的用法示例。
在下文中一共展示了FactoryManager::GetFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
// Note: aggregates are only used to build Ptent, so it is not useful to keep them. Keeping Ptent is enough.
// RCP<Factory> AggFact = rcp(new CoupledAggregationFactory());
// M.SetFactory("Aggregates", AggFact);
// H.Keep("Aggregates", AggFact.get());
// PTENT:
RCP<Factory> PtentFact = rcp(new TentativePFactory());
M.SetFactory("Ptent", PtentFact);
H.Keep("P", PtentFact.get());
}
RCP<Factory> AcFact = rcp(new RAPFactory());
M.SetFactory("A", AcFact);
if (optRecyclingRAPpattern) {
H.Keep("RAP graph", AcFact.get());
}
if (optRecyclingAPpattern) {
H.Keep("AP graph", AcFact.get());
}
//
H.Setup(M);
{
RCP<Vector> X = VectorFactory::Build(map);
RCP<Vector> B = VectorFactory::Build(map);
X->putScalar((Scalar) 0.0);
B->setSeed(846930886); B->randomize();
int nIts = 9;
H.Iterate(*B, *X, nIts);
ST::magnitudeType residualNorms = Utilities::ResidualNorm(*A1, *X, *B)[0];
if (comm->getRank() == 0)
std::cout << "||Residual|| = " << residualNorms << std::endl;
}
//
// Second solve
//
std::cout << "Status of the preconditioner between runs:" << std::endl;
H.print(*getFancyOStream(Teuchos::rcpFromRef(std::cout)), MueLu::High);
// Change the problem
RCP<Level> finestLevel = H.GetLevel(0);
finestLevel->Set("A", A2);
if (optRecycling) {
// Optional: this makes sure that the aggregates are never requested (and built) during the second run.
// If someone request the aggregates, an exception will be thrown.
M.SetFactory("Aggregates", MueLu::NoFactory::getRCP());
}
// Redo the setup
H.Setup(M);
{
RCP<Vector> X = VectorFactory::Build(map);
RCP<Vector> B = VectorFactory::Build(map);
X->putScalar((Scalar) 0.0);
B->setSeed(846930886); B->randomize();
int nIts = 9;
H.Iterate(*B, *X, nIts);
ST::magnitudeType residualNorms = Utilities::ResidualNorm(*A2, *X, *B)[0];
if (comm->getRank() == 0)
std::cout << "||Residual|| = " << residualNorms << std::endl;
}
//
// Clean-up
//
// Remove kept data from the preconditioner. This will force recomputation on future runs. "Keep" flags are also removed.
if (optRecycling) {
//if aggregates explicitly kept: H.Delete("Aggregates", M.GetFactory("Aggregates").get());
H.Delete("P", M.GetFactory("Ptent").get());
}
if (optRecyclingRAPpattern) {
H.Delete("RAP graph", M.GetFactory("A").get());
}
if (optRecyclingAPpattern) {
H.Delete("AP graph", M.GetFactory("A").get());
}
std::cout << "Status of the preconditioner at the end:" << std::endl;
H.print(*getFancyOStream(Teuchos::rcpFromRef(std::cout)), MueLu::High);
success = true;
}
TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
}
示例2: main
//.........这里部分代码省略.........
{
Teuchos::ParameterList paramList;
paramList.set("minRowsPerProcessor", optMinRowsPerProc);
paramList.set("nonzeroImbalance", optNnzImbalance);
RepartitionFact->SetParameterList(paramList);
}
RepartitionFact->SetFactory("A", AFact);
if(optRepartition == 1) {
RCP<Factory> ZoltanFact = rcp(new ZoltanInterface());
ZoltanFact->SetFactory("A", AFact);
ZoltanFact->SetFactory("Coordinates", TransferCoordinatesFact);
RepartitionFact->SetFactory("Partition", ZoltanFact);
}
else if(optRepartition == 2) {
#if defined(HAVE_MPI) && defined(HAVE_MUELU_ISORROPIA)
RCP<MueLu::IsorropiaInterface<LO, GO, NO, LMO> > isoInterface = rcp(new MueLu::IsorropiaInterface<LO, GO, NO, LMO>());
isoInterface->SetFactory("A", AFact);
// we don't need Coordinates here!
RepartitionFact->SetFactory("Partition", isoInterface);
#else
if (comm->getRank() == 0)
std::cout << "Please recompile Trilinos with Isorropia support enabled." << std::endl;
return EXIT_FAILURE;
#endif
}
// Reordering of the transfer operators
RCP<Factory> RebalancedPFact = rcp(new RebalanceTransferFactory());
RebalancedPFact->SetParameter("type", Teuchos::ParameterEntry(std::string("Interpolation")));
RebalancedPFact->SetFactory("P", PFact);
RebalancedPFact->SetFactory("Coordinates", TransferCoordinatesFact);
RebalancedPFact->SetFactory("Nullspace", M.GetFactory("Ptent")); // TODO
RCP<Factory> RebalancedRFact = rcp(new RebalanceTransferFactory());
RebalancedRFact->SetParameter("type", Teuchos::ParameterEntry(std::string("Restriction")));
RebalancedRFact->SetFactory("R", RFact);
// Compute Ac from rebalanced P and R
RCP<Factory> RebalancedAFact = rcp(new RebalanceAcFactory());
RebalancedAFact->SetFactory("A", AFact);
// Configure FactoryManager
M.SetFactory("A", RebalancedAFact);
M.SetFactory("P", RebalancedPFact);
M.SetFactory("R", RebalancedRFact);
M.SetFactory("Nullspace", RebalancedPFact);
M.SetFactory("Coordinates", RebalancedPFact);
M.SetFactory("Importer", RepartitionFact);
#else
TEUCHOS_TEST_FOR_EXCEPT(true);
#endif
} // optRepartition
} // Transfer
//
// Smoothers
//
{
std::string ifpackType;
Teuchos::ParameterList ifpackList;
ifpackList.set("relaxation: sweeps", (LO) optSweeps);
示例3: main
//.........这里部分代码省略.........
Op->fillComplete();
#endif // NEUMANN
/**********************************************************************************/
/* */
/**********************************************************************************/
RCP<MultiVector> nullSpace = MultiVectorFactory::Build(map,1);
nullSpace->putScalar( (SC) 1.0);
Teuchos::Array<Teuchos::ScalarTraits<SC>::magnitudeType> norms(1);
nullSpace->norm1(norms);
if (comm->getRank() == 0)
std::cout << "||NS|| = " << norms[0] << std::endl;
RCP<MueLu::Hierarchy<SC,LO,GO,NO,LMO> > H = rcp( new Hierarchy() );
H->SetDefaultVerbLevel(MueLu::Extreme);
H->IsPreconditioner(false);
RCP<MueLu::Level> Finest = H->GetLevel();
Finest->setDefaultVerbLevel(Teuchos::VERB_HIGH);
Finest->Set("A", Op);
Finest->Set("Nullspace", nullSpace);
FactoryManager M;
M.SetFactory("Aggregates", rcp(new CoupledAggregationFactory()));
M.SetFactory("Ptent", rcp(new TentativePFactory()));
M.SetFactory("P", rcp(new SaPFactory()));
#ifdef EMIN
// Energy-minimization
RCP<PatternFactory> PatternFact = rcp(new PatternFactory());
#if 0
PatternFact->SetFactory("P", M.GetFactory("Ptent"));
#else
PatternFact->SetFactory("P", M.GetFactory("P"));
#endif
M.SetFactory("Ppattern", PatternFact);
RCP<EminPFactory> EminPFact = rcp(new EminPFactory());
EminPFact->SetFactory("P", M.GetFactory("Ptent"));
M.SetFactory("P", EminPFact);
RCP<NullspacePresmoothFactory> NullPreFact = rcp(new NullspacePresmoothFactory());
NullPreFact->SetFactory("Nullspace", M.GetFactory("Nullspace"));
M.SetFactory("Nullspace", NullPreFact);
#endif
RCP<SmootherPrototype> smooProto = gimmeMergedSmoother(nSmoothers, xpetraParameters.GetLib(), coarseSolver, comm->getRank());
M.SetFactory("Smoother", rcp(new SmootherFactory(smooProto)));
Teuchos::ParameterList status;
RCP<SmootherPrototype> coarseProto;
if (maxLevels != 1)
coarseProto = gimmeCoarseProto(xpetraParameters.GetLib(), coarseSolver, comm->getRank());
else
coarseProto = gimmeMergedSmoother(nSmoothers, xpetraParameters.GetLib(), coarseSolver, comm->getRank());
if (coarseProto == Teuchos::null)
return EXIT_FAILURE;
#ifdef NEUMANN
// Use coarse level projection solver
RCP<SmootherPrototype> projectedSolver = rcp(new ProjectorSmoother(coarseProto));
RCP<SmootherFactory> coarseSolveFact = rcp(new SmootherFactory(projectedSolver));