本文整理汇总了C++中Epetra_CrsGraph::NumGlobalNonzeros方法的典型用法代码示例。如果您正苦于以下问题:C++ Epetra_CrsGraph::NumGlobalNonzeros方法的具体用法?C++ Epetra_CrsGraph::NumGlobalNonzeros怎么用?C++ Epetra_CrsGraph::NumGlobalNonzeros使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Epetra_CrsGraph
的用法示例。
在下文中一共展示了Epetra_CrsGraph::NumGlobalNonzeros方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
int check(Epetra_CrsGraph& L, Epetra_CrsGraph& U, Ifpack_IlukGraph& LU,
int NumGlobalRows1, int NumMyRows1, int LevelFill1, bool verbose) {
using std::cout;
using std::endl;
int i, j;
int NumIndices, * Indices;
int NumIndices1, * Indices1;
bool debug = true;
Epetra_CrsGraph& L1 = LU.L_Graph();
Epetra_CrsGraph& U1 = LU.U_Graph();
// Test entries and count nonzeros
int Nout = 0;
for (i=0; i<LU.NumMyRows(); i++) {
assert(L.ExtractMyRowView(i, NumIndices, Indices)==0);
assert(L1.ExtractMyRowView(i, NumIndices1, Indices1)==0);
assert(NumIndices==NumIndices1);
for (j=0; j<NumIndices1; j++) {
if (debug &&(Indices[j]!=Indices1[j])) {
int MyPID = L.RowMap().Comm().MyPID();
cout << "Proc " << MyPID
<< " Local Row = " << i
<< " L.Indices["<< j <<"] = " << Indices[j]
<< " L1.Indices["<< j <<"] = " << Indices1[j] << endl;
}
assert(Indices[j]==Indices1[j]);
}
Nout += (NumIndices-NumIndices1);
assert(U.ExtractMyRowView(i, NumIndices, Indices)==0);
assert(U1.ExtractMyRowView(i, NumIndices1, Indices1)==0);
assert(NumIndices==NumIndices1);
for (j=0; j<NumIndices1; j++) {
if (debug &&(Indices[j]!=Indices1[j])) {
int MyPID = L.RowMap().Comm().MyPID();
cout << "Proc " << MyPID
<< " Local Row = " << i
<< " U.Indices["<< j <<"] = " << Indices[j]
<< " U1.Indices["<< j <<"] = " << Indices1[j] << endl;
}
assert(Indices[j]==Indices1[j]);
}
Nout += (NumIndices-NumIndices1);
}
// Test query functions
int NumGlobalRows = LU.NumGlobalRows();
if (verbose) cout << "\n\nNumber of Global Rows = " << NumGlobalRows << endl<< endl;
assert(NumGlobalRows==NumGlobalRows1);
int NumGlobalNonzeros = LU.NumGlobalNonzeros();
if (verbose) cout << "\n\nNumber of Global Nonzero entries = "
<< NumGlobalNonzeros << endl<< endl;
int NoutG = 0;
L.RowMap().Comm().SumAll(&Nout, &NoutG, 1);
assert(NumGlobalNonzeros==L.NumGlobalNonzeros()+U.NumGlobalNonzeros()-NoutG);
int NumMyRows = LU.NumMyRows();
if (verbose) cout << "\n\nNumber of Rows = " << NumMyRows << endl<< endl;
assert(NumMyRows==NumMyRows1);
int NumMyNonzeros = LU.NumMyNonzeros();
if (verbose) cout << "\n\nNumber of Nonzero entries = " << NumMyNonzeros << endl<< endl;
assert(NumMyNonzeros==L.NumMyNonzeros()+U.NumMyNonzeros()-Nout);
if (verbose) cout << "\n\nLU check OK" << endl<< endl;
return(0);
}
示例2: TotalTime
// ============================================================================
int ML_Epetra::MatrixFreePreconditioner::
Compute(const Epetra_CrsGraph& Graph, Epetra_MultiVector& NullSpace)
{
Epetra_Time TotalTime(Comm());
const int NullSpaceDim = NullSpace.NumVectors();
// get parameters from the list
std::string PrecType = List_.get("prec: type", "hybrid");
std::string SmootherType = List_.get("smoother: type", "Jacobi");
std::string ColoringType = List_.get("coloring: type", "JONES_PLASSMAN");
int PolynomialDegree = List_.get("smoother: degree", 3);
std::string DiagonalColoringType = List_.get("diagonal coloring: type", "JONES_PLASSMAN");
int MaximumIterations = List_.get("eigen-analysis: max iters", 10);
std::string EigenType_ = List_.get("eigen-analysis: type", "cg");
double boost = List_.get("eigen-analysis: boost for lambda max", 1.0);
int OutputLevel = List_.get("ML output", -47);
if (OutputLevel == -47) OutputLevel = List_.get("output", 10);
omega_ = List_.get("smoother: damping", omega_);
ML_Set_PrintLevel(OutputLevel);
bool LowMemory = List_.get("low memory", true);
double AllocationFactor = List_.get("AP allocation factor", 0.5);
verbose_ = (MyPID() == 0 && ML_Get_PrintLevel() > 5);
// ================ //
// check parameters //
// ================ //
if (PrecType == "presmoother only")
PrecType_ = ML_MFP_PRESMOOTHER_ONLY;
else if (PrecType == "hybrid")
PrecType_ = ML_MFP_HYBRID;
else if (PrecType == "additive")
PrecType_ = ML_MFP_ADDITIVE;
else
ML_CHK_ERR(-3); // not recognized
if (SmootherType == "none")
SmootherType_ = ML_MFP_NONE;
else if (SmootherType == "Jacobi")
SmootherType_ = ML_MFP_JACOBI;
else if (SmootherType == "block Jacobi")
SmootherType_ = ML_MFP_BLOCK_JACOBI;
else if (SmootherType == "Chebyshev")
SmootherType_ = ML_MFP_CHEBY;
else
ML_CHK_ERR(-4); // not recognized
if (AllocationFactor <= 0.0)
ML_CHK_ERR(-1); // should be positive
// =============================== //
// basic checkings and some output //
// =============================== //
int OperatorDomainPoints = Operator_.OperatorDomainMap().NumGlobalPoints();
int OperatorRangePoints = Operator_.OperatorRangeMap().NumGlobalPoints();
int GraphBlockRows = Graph.NumGlobalBlockRows();
int GraphNnz = Graph.NumGlobalNonzeros();
NumPDEEqns_ = OperatorRangePoints / GraphBlockRows;
NumMyBlockRows_ = Graph.NumMyBlockRows();
if (OperatorDomainPoints != OperatorRangePoints)
ML_CHK_ERR(-1); // only square matrices
if (OperatorRangePoints % NumPDEEqns_ != 0)
ML_CHK_ERR(-2); // num PDEs seems not constant
if (verbose_)
{
ML_print_line("=",78);
std::cout << "*** " << std::endl;
std::cout << "*** ML_Epetra::MatrixFreePreconditioner" << std::endl;
std::cout << "***" << std::endl;
std::cout << "Number of rows and columns = " << OperatorDomainPoints << std::endl;
std::cout << "Number of rows per processor = " << OperatorDomainPoints / Comm().NumProc()
<< " (on average)" << std::endl;
std::cout << "Number of rows in the graph = " << GraphBlockRows << std::endl;
std::cout << "Number of nonzeros in the graph = " << GraphNnz << std::endl;
std::cout << "Processors used in computation = " << Comm().NumProc() << std::endl;
std::cout << "Number of PDE equations = " << NumPDEEqns_ << std::endl;
std::cout << "Null space dimension = " << NullSpaceDim << std::endl;
std::cout << "Preconditioner type = " << PrecType << std::endl;
std::cout << "Smoother type = " << SmootherType << std::endl;
std::cout << "Coloring type = " << ColoringType << std::endl;
std::cout << "Allocation factor = " << AllocationFactor << std::endl;
std::cout << "Number of V-cycles for C = " << List_.sublist("ML list").get("cycle applications", 1) << std::endl;
std::cout << std::endl;
}
ResetStartTime();
// ==================================== //
// compute the inverse of the diagonal, //
// control that no elements are zero. //
// ==================================== //
for (int i = 0; i < InvPointDiagonal_->MyLength(); ++i)
if ((*InvPointDiagonal_)[i] != 0.0)
//.........这里部分代码省略.........