47 #include "Epetra_Vector.h" 48 #include "shylu_probing_operator.h" 49 #include "shylu_local_schur_operator.h" 50 #include <EpetraExt_Reindex_CrsMatrix.h> 63 double relative_thres = config->relative_threshold;
67 localDRowMap, nvectors);
86 int *mySGID =
new int[totalElems];
87 int *allSGID =
new int[totalElems];
89 for (i = 0, j = 0; i < totalElems ; i++)
91 if (i >= prefixSum - localElems && i < prefixSum)
103 C->
Comm().
SumAll(mySGID, allSGID, totalElems);
115 Copy, rMap, localElems));
117 double *values =
new double[localElems];
118 int *indices =
new int[localElems];
121 double *maxvalue =
new double[nvectors];
128 int findex = totalElems / nvectors ;
129 for (i = 0 ; i < findex*nvectors ; i+=nvectors)
136 for (
int k = 0; k < nvectors; k++)
139 if (cindex >= prefixSum - localElems && cindex < prefixSum)
148 probeop.Apply(probevec, Scol);
153 for (
int k = 0; k < nvectors; k++)
158 for (j = 0 ; j < localElems ; j++)
161 if (allSGID[cindex] == rows[j])
163 values[nentries] = vecvalues[j];
164 indices[nentries] = allSGID[cindex];
168 else if (abs(vecvalues[j]/maxvalue[k]) > relative_thres)
170 values[nentries] = vecvalues[j];
171 indices[nentries] = allSGID[cindex];
177 if (vecvalues[j] != 0.0) dropped++;
183 probeop.ResetTempVectors(1);
185 for ( ; i < totalElems ; i++)
191 if (i >= prefixSum - localElems && i < prefixSum)
199 probeop.Apply(probevec, Scol);
206 for (j = 0 ; j < localElems ; j++)
209 if (allSGID[i] == rows[j])
211 values[nentries] = vecvalues[j];
212 indices[nentries] = allSGID[i];
216 else if (abs(vecvalues[j]/maxvalue[0]) > relative_thres)
218 values[nentries] = vecvalues[j];
219 indices[nentries] = allSGID[i];
225 if (vecvalues[j] != 0.0) dropped++;
231 cout <<
"Time in finding and dropping entries" << ftime.
totalElapsedTime() << endl;
238 cout <<
"#dropped entries" << dropped << endl;
257 double relative_thres = config->relative_threshold;
282 Epetra_Map G_localRMap (-1, g_localElems, g_rows, 0, LComm);
290 double *values1 =
new double[maxentries];
291 double *values2 =
new double[maxentries];
292 double *values3 =
new double[maxentries];
293 int *indices1 =
new int[maxentries];
294 int *indices2 =
new int[maxentries];
295 int *indices3 =
new int[maxentries];
299 Copy, GrMap, g_localElems));
304 for (i = 0; i < g_localElems ; i++)
311 for (
int j = 0 ; j < nentries1 ; j++)
313 if (G->
LRID(indices1[j]) != -1)
315 values2[cnt] = values1[j];
316 indices2[cnt++] = indices1[j];
321 values3[scnt] = values1[j];
322 indices3[scnt++] = indices1[j];
326 localG.InsertGlobalValues(gid, cnt, values2, indices2);
329 localG.FillComplete();
336 ifSolver, C, localDRowMap, nvectors);
368 double *values =
new double[nvectors];
369 int *indices =
new int[nvectors];
375 #endif // SHYLU_DEBUG 376 double *maxvalue =
new double[nvectors];
380 int findex = g_localElems / nvectors ;
387 for (i = 0 ; i < findex*nvectors ; i+=nvectors)
390 for (
int k = 0; k < nvectors; k++)
403 probeop.Apply(probevec, Scol);
409 for (
int k = 0; k < nvectors; k++)
417 for (
int j = 0 ; j < g_localElems ; j++)
419 for (
int k = 0; k < nvectors; k++)
423 if ((g_rows[cindex] == g_rows[j]) ||
424 (abs(vecvalues[j]/maxvalue[k]) > relative_thres))
427 values[nentries] = vecvalues[j];
428 indices[nentries++] = g_rows[cindex];
431 else if (vecvalues[j] != 0.0)
435 #endif // SHYLU_DEBUG 443 if (i < g_localElems)
445 nvectors = g_localElems - i;
446 probeop.ResetTempVectors(nvectors);
451 for (
int k = 0; k < nvectors; k++)
462 probeop.Apply(probevec1, Scol1);
468 for (
int j = 0 ; j < g_localElems ; j++)
471 for (
int k = 0; k < nvectors; k++)
474 vecvalues = Scol1[k];
476 if ((g_rows[cindex] == g_rows[j]) ||
477 (abs(vecvalues[j]/maxvalue[k]) > relative_thres))
480 values[nentries] = vecvalues[j];
481 indices[nentries++] = g_rows[cindex];
484 else if (vecvalues[j] != 0.0)
488 #endif // SHYLU_DEBUG 502 probeop.PrintTimingInfo();
508 EpetraExt::ViewTransform<Epetra_CrsMatrix> * ReIdx_MatTrans2 =
509 new EpetraExt::CrsMatrix_Reindex( defMap2 );
511 ReIdx_MatTrans2->fwd();
512 EpetraExt::RowMatrixToMatlabFile(
"Schur.mat", t2S);
516 cout <<
"#dropped entries" << dropped << endl;
542 double relative_thres = config->relative_threshold;
547 Amesos_BaseSolver *solver = ssym->Solver.
getRawPtr();
548 Ifpack_Preconditioner *ifSolver = ssym->ifSolver.
getRawPtr();
556 int *c_cols = (C->
ColMap()).MyGlobalElements();
559 int c_localcolElems = (C->
ColMap()).NumMyElements();
568 int *r_cols = (R->
ColMap()).MyGlobalElements();
571 int r_localcolElems = (R->
ColMap()).NumMyElements();
574 Epetra_Map C_localRMap (-1, c_localElems, c_rows, 0, LComm);
575 Epetra_Map C_localCMap (-1, c_localcolElems, c_cols, 0, LComm);
576 Epetra_Map G_localRMap (-1, g_localElems, g_rows, 0, LComm);
577 Epetra_Map R_localRMap (-1, r_localElems, r_rows, 0, LComm);
578 Epetra_Map R_localCMap (-1, r_localcolElems, r_cols, 0, LComm);
583 cout <<
"DEBUG MODE" << endl;
587 int gids[nrows], gids1[nrows];
590 cout <<
"Comparing R's domain map with D's row map" << endl;
592 for (
int i = 0; i < nrows; i++)
594 assert(gids[i] == gids1[i]);
604 double *values1 =
new double[maxentries];
605 double *values2 =
new double[maxentries];
606 double *values3 =
new double[maxentries];
607 int *indices1 =
new int[maxentries];
608 int *indices2 =
new int[maxentries];
609 int *indices3 =
new int[maxentries];
614 for (i = 0; i < c_localElems ; i++)
622 err = localC.InsertGlobalValues(gid, nentries1, values1, indices1);
626 localC.FillComplete(G_localRMap, C_localRMap);
631 for (i = 0; i < r_localElems ; i++)
635 localR.InsertGlobalValues(gid, nentries1, values1, indices1);
637 localR.FillComplete(*localDRowMap, R_localRMap);
642 Copy, GrMap, g_localElems));
647 for (i = 0; i < g_localElems ; i++)
654 for (
int j = 0 ; j < nentries1 ; j++)
656 if (G->
LRID(indices1[j]) != -1)
658 values2[cnt] = values1[j];
659 indices2[cnt++] = indices1[j];
664 values3[scnt] = values1[j];
665 indices3[scnt++] = indices1[j];
669 localG.InsertGlobalValues(gid, cnt, values2, indices2);
672 localG.FillComplete();
673 cout <<
"Created local G matrix" << endl;
677 ifSolver, &localC, localDRowMap, nvectors);
707 if (data->num_compute % config->reset_iter == 0)
713 double *values =
new double[g_localElems];
714 int *indices =
new int[g_localElems];
717 double *maxvalue =
new double[nvectors];
721 int findex = g_localElems / nvectors ;
727 for (i = 0 ; i < findex*nvectors ; i+=nvectors)
730 for (
int k = 0; k < nvectors; k++)
744 probeop.Apply(probevec, Scol);
750 for (
int k = 0; k < nvectors; k++)
755 for (
int j = 0 ; j < g_localElems ; j++)
758 if (g_rows[cindex] == g_rows[j])
760 values[nentries] = vecvalues[j];
761 indices[nentries] = g_rows[cindex];
770 else if (abs(vecvalues[j]/maxvalue[k]) > relative_thres)
772 values[nentries] = vecvalues[j];
773 indices[nentries] = g_rows[cindex];
784 if (vecvalues[j] != 0.0)
795 probeop.ResetTempVectors(1);
797 for ( ; i < g_localElems ; i++)
811 probeop.Apply(probevec, Scol);
818 for (
int j = 0 ; j < g_localElems ; j++)
821 if (g_rows[i] == g_rows[j])
823 values[nentries] = vecvalues[j];
824 indices[nentries] = g_rows[i];
831 else if (abs(vecvalues[j]/maxvalue[0]) > relative_thres)
833 values[nentries] = vecvalues[j];
834 indices[nentries] = g_rows[i];
843 if (vecvalues[j] != 0.0) dropped++;
850 cout <<
"Time in finding and dropping entries" << ftime.
totalElapsedTime() << endl;
856 probeop.PrintTimingInfo();
860 data->localSbargraph = lSGraph;
864 EpetraExt::ViewTransform<Epetra_CrsMatrix> * ReIdx_MatTrans2 =
865 new EpetraExt::CrsMatrix_Reindex( defMap2 );
867 ReIdx_MatTrans2->fwd();
868 EpetraExt::RowMatrixToMatlabFile(
"Schur.mat", t2S);
871 cout <<
"#dropped entries" << dropped << endl;
878 if (((data->num_compute-1) % config->reset_iter) == 0)
886 Isorropia::Epetra::Prober(
887 data->localSbargraph.
getRawPtr(), pList,
false));
889 data->guided_prober = gprober;
894 int nvectors = data->guided_prober->getNumOrthogonalVectors();
895 cout <<
"Number of Orthogonal Vectors for guided probing" << nvectors
898 probeop.ResetTempVectors(nvectors);
900 data->guided_prober->probe(probeop);
902 int *indices =
new int[maxentries];
903 double *values =
new double[maxentries];
908 int gid = blockdiag_Sbar->
GRID(i);
const Epetra_Map & RowMap() const
int GlobalMaxNumEntries() const
int MaxNumEntries() const
int MyGlobalElements(int *MyGlobalElementList) const
Teuchos::RCP< Epetra_CrsMatrix > computeSchur_GuidedProbing(shylu_config *config, shylu_symbolic *ssym, shylu_data *data, Epetra_Map *localDRowMap)
Compute an approximate Schur Complement using the option of Guided Probing.
Teuchos::RCP< Epetra_CrsMatrix > computeApproxSchur(shylu_config *config, shylu_symbolic *ssym, Epetra_CrsMatrix *G, Epetra_CrsMatrix *R, Epetra_LinearProblem *LP, Amesos_BaseSolver *solver, Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C, Epetra_Map *localDRowMap)
Compute an approximate Schur Complement (Narrow Sep)
int LRID(int GRID_in) const
int PutScalar(double ScalarConstant)
Teuchos::RCP< Epetra_CrsMatrix > computeApproxWideSchur(shylu_config *config, shylu_symbolic *ssym, Epetra_CrsMatrix *G, Epetra_CrsMatrix *R, Epetra_LinearProblem *LP, Amesos_BaseSolver *solver, Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C, Epetra_Map *localDRowMap)
Compute an approximate Shur Complete (Wide Sep)
int MaxValue(double *Result) const
const Epetra_Comm & Comm() const
int FillComplete(bool OptimizeDataStorage=true)
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const=0
void start(bool reset=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int GRID(int LRID_in) const
int NumMyElements() const
int ReplaceGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue)
const Epetra_Map & ColMap() const
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
double totalElapsedTime(bool readCurrentTime=false) const
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
int ExtractGlobalRowCopy(int GlobalRow, int Length, int &NumEntries, double *Values, int *Indices) const
int NumGlobalElements() const
Main data structure holding needed offset and temp variables.
int NumGlobalRows() const
Main header file of ShyLU (Include main user calls)
virtual int ScanSum(double *MyVals, double *ScanSums, int Count) const=0