本文整理汇总了C++中teuchos::RCP::Build方法的典型用法代码示例。如果您正苦于以下问题:C++ RCP::Build方法的具体用法?C++ RCP::Build怎么用?C++ RCP::Build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RCP
的用法示例。
在下文中一共展示了RCP::Build方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[]) {
#include "MueLu_UseShortNames.hpp"
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
bool success = false;
bool verbose = true;
try {
Teuchos::RCP<const Teuchos::Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
/**********************************************************************************/
/* SET TEST PARAMETERS */
/**********************************************************************************/
/**********************************************************************************/
/* SET TEST PARAMETERS */
/**********************************************************************************/
// Note: use --help to list available options.
Teuchos::CommandLineProcessor clp(false);
// Default is Laplace1D with nx = 8748.
// It's a nice size for 1D and perfect aggregation. (6561=3^8)
//Nice size for 1D and perfect aggregation on small numbers of processors. (8748=4*3^7)
Galeri::Xpetra::Parameters<GO> matrixParameters(clp, 8748); // manage parameters of the test case
Xpetra::Parameters xpetraParameters(clp); // manage parameters of xpetra
// custom parameters
int pauseForDebugger=0;
//std::string aggOrdering = "natural";
int minPerAgg=2; //was 3 in simple
int maxNbrAlreadySelected=0;
int printTimings=0;
//clp.setOption("aggOrdering",&aggOrdering,"aggregation ordering strategy (natural,graph)");
clp.setOption("debug",&pauseForDebugger,"pause to attach debugger");
clp.setOption("maxNbrSel",&maxNbrAlreadySelected,"maximum # of nbrs allowed to be in other aggregates");
clp.setOption("minPerAgg",&minPerAgg,"minimum #DOFs per aggregate");
clp.setOption("timings",&printTimings,"print timings to screen");
switch (clp.parse(argc,argv)) {
case Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED: return EXIT_SUCCESS; break;
case Teuchos::CommandLineProcessor::PARSE_ERROR:
case Teuchos::CommandLineProcessor::PARSE_UNRECOGNIZED_OPTION: return EXIT_FAILURE; break;
case Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL: break;
}
Teuchos::RCP<Teuchos::TimeMonitor> globalTimeMonitor = Teuchos::rcp (new Teuchos::TimeMonitor(*Teuchos::TimeMonitor::getNewTimer("Timings: Global Time")));
if (pauseForDebugger) {
Utilities::PauseForDebugger();
}
matrixParameters.check();
xpetraParameters.check();
Xpetra::UnderlyingLib lib = xpetraParameters.GetLib();
if (comm->getRank() == 0) {
std::cout << xpetraParameters << matrixParameters;
}
/**********************************************************************************/
/* CREATE INITIAL MATRIX */
/**********************************************************************************/
Teuchos::RCP<const Map> map;
Teuchos::RCP<Matrix> A;
{
Teuchos::TimeMonitor tm(*Teuchos::TimeMonitor::getNewTimer("Timings: Matrix Build"));
map = MapFactory::Build(lib, matrixParameters.GetNumGlobalElements(), 0, comm);
Teuchos::RCP<Galeri::Xpetra::Problem<Map,CrsMatrixWrap,MultiVector> > Pr =
Galeri::Xpetra::BuildProblem<SC,LO,GO,Map,CrsMatrixWrap,MultiVector>(matrixParameters.GetMatrixType(), map, matrixParameters.GetParameterList()); //TODO: Matrix vs. CrsMatrixWrap
A = Pr->BuildMatrix();
}
/**********************************************************************************/
/* */
/**********************************************************************************/
Teuchos::RCP<Hierarchy> hierarchy = Teuchos::rcp(new Hierarchy(A));
hierarchy->SetDefaultVerbLevel(MueLu::toMueLuVerbLevel(Teuchos::VERB_EXTREME));
hierarchy->SetMaxCoarseSize(100);
///////////////////////////////////////////////////////////
Teuchos::RCP<MueLu::Level> Finest = hierarchy->GetLevel(); // get finest level
Finest->Set("A",A);
Teuchos::RCP<AmalgamationFactory> amalgFact = Teuchos::rcp(new AmalgamationFactory());
Teuchos::RCP<CoalesceDropFactory> dropFact = Teuchos::rcp(new CoalesceDropFactory());
dropFact->SetFactory("UnAmalgamationInfo", amalgFact);
// aggregation factory
Teuchos::RCP<UncoupledAggregationFactory> UnCoupledAggFact = Teuchos::rcp(new UncoupledAggregationFactory(/*dropFact*/));
UnCoupledAggFact->SetFactory("Graph", dropFact);
UnCoupledAggFact->SetFactory("DofsPerNode", dropFact);
//UnCoupledAggFact->SetFactory("Graph", dropFact); // UnCoupledAggFact not changed to new factory handling
//UnCoupledAggFact->SetMinNodesPerAggregate(minPerAgg);
//.........这里部分代码省略.........
示例2: runPermutationTest2
// run tests with "Local" permutation strategy and nDofsPerNode = 3
bool runPermutationTest2(const std::string input_filename, const std::string expected_filename, const Teuchos::RCP<const Teuchos::Comm<int> >& comm) {
#ifndef HAVE_MUELU_INST_COMPLEX_INT_INT
Teuchos::RCP<Teuchos::FancyOStream> out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
out->setOutputToRootOnly(0);
Epetra_CrsMatrix * ptrA = NULL;
Epetra_CrsMatrix * ptrExpected = NULL;
int ret = EpetraExt::MatlabFileToCrsMatrix ( input_filename.c_str(),
*Xpetra::toEpetra(comm),
ptrA
);
if(ret!=0)
std::cout << "failed to read matrix from file" << std::endl;
if(expected_filename.size() > 0)
{
int ret2 = EpetraExt::MatlabFileToCrsMatrix (expected_filename.c_str(),
*Xpetra::toEpetra(comm),
ptrExpected
);
if(ret2!=0)
std::cout << "failed to read matrix from file" << std::endl;
}
Teuchos::RCP<Epetra_CrsMatrix> epA = Teuchos::rcp(ptrA);
Teuchos::RCP<Epetra_CrsMatrix> epExpected = Teuchos::rcp(ptrExpected);
// Epetra_CrsMatrix -> Xpetra::Matrix
Teuchos::RCP<CrsMatrix> exA = Teuchos::rcp(new Xpetra::EpetraCrsMatrix(epA));
Teuchos::RCP<CrsMatrixWrap> crsOp = Teuchos::rcp(new CrsMatrixWrap(exA));
Teuchos::RCP<Matrix> A = Teuchos::rcp_dynamic_cast<Matrix>(crsOp);
A->SetFixedBlockSize(3);
Teuchos::RCP<Level> Finest = Teuchos::rcp(new Level());
Finest->SetLevelID(0); // must be level 0 for NullspaceFactory
Finest->Set("A", A);
// permute full matrix
Teuchos::RCP<PermutationFactory> PermFact = Teuchos::rcp(new MueLu::PermutationFactory<Scalar,LocalOrdinal,GlobalOrdinal,Node,LocalMatOps>());
PermFact->SetParameter("PermutationStrategy",Teuchos::ParameterEntry(std::string("Local")));
PermFact->SetParameter("PermutationRowMapName",Teuchos::ParameterEntry(std::string("")));
PermFact->SetFactory("PermutationRowMapFactory", Teuchos::null);
// setup main factory manager
Teuchos::RCP<FactoryManager> M = Teuchos::rcp(new FactoryManager());
M->SetFactory("permQT", PermFact);
M->SetFactory("A", MueLu::NoFactory::getRCP()); // this is the input matrix
MueLu::SetFactoryManager SFMFinest(Finest, M);
// prepare building process for permutation operators
Finest->Request("A", PermFact.get());
Finest->Request("permA", PermFact.get());
Finest->Request("permP", PermFact.get());
Finest->Request("permQT", PermFact.get());
Finest->Request("permScaling", PermFact.get());
Finest->Request("#RowPermutations", PermFact.get());
Finest->Request("#ColPermutations", PermFact.get());
Finest->Request("#WideRangeRowPermutations", PermFact.get());
Finest->Request("#WideRangeColPermutations", PermFact.get());
// build permutation operators
PermFact->Build(*Finest);
//std::cout << "P" << *GetEpetraMatrix("permP", Finest, PermFact) << std::endl;
//std::cout << "Q^T" << *GetEpetraMatrix("permQT", Finest, PermFact) << std::endl;
//std::cout << "permA" << *GetEpetraMatrix("A", Finest, PermFact) << std::endl;
Teuchos::RCP<const Epetra_CrsMatrix> epResult = GetEpetraMatrix("A", Finest, PermFact);
//std::cout << *epResult << std::endl;
if(epExpected != Teuchos::null) {
Epetra_CrsMatrix* comparison = NULL;
EpetraExt::MatrixMatrix::Add(*epResult, false, -1.0, *epExpected, false, 1.0, comparison);
comparison->FillComplete();
//std::cout << *comparison << std::endl;
double norm = comparison->NormInf();
delete comparison;
comparison = NULL;
if(norm < 1.0e-14) {
*out << "** PASSED **: " << input_filename << std::endl;
return true;
}
else {
*out << "-- FAILED --: " << input_filename << std::endl;
return false;
}
}
#endif
*out << "-- FAILED --: " << input_filename << " no result file found" << std::endl;
return false; // no result for comparison available
}