Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_FECrsMatrix.cpp
Go to the documentation of this file.
1 
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 
43 #include <Epetra_ConfigDefs.h>
44 #include <Epetra_FECrsMatrix.h>
47 #include <Epetra_FECrsGraph.h>
48 #include <Epetra_Export.h>
49 #include <Epetra_Comm.h>
50 #include <Epetra_Map.h>
51 #include <Epetra_Util.h>
52 
53 //----------------------------------------------------------------------------
55  const Epetra_Map& rowMap,
56  int* NumEntriesPerRow,
57  bool ignoreNonLocalEntries)
58  : Epetra_CrsMatrix(CV, rowMap, NumEntriesPerRow),
59  myFirstRow_(0),
60  myNumRows_(0),
61  ignoreNonLocalEntries_(ignoreNonLocalEntries),
62 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
65 #endif
66 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
69 #endif
71  workData_(128),
72  useNonlocalMatrix_ (false),
73  nonlocalMatrix_ (NULL),
74  sourceMap_(NULL),
75  colMap_(NULL),
76  exporter_(NULL),
77  tempMat_(NULL)
78 {
79  myFirstRow_ = rowMap.MinMyGID64();
80  myNumRows_ = rowMap.NumMyElements();
81 }
82 
83 //----------------------------------------------------------------------------
85  const Epetra_Map& rowMap,
86  int NumEntriesPerRow,
87  bool ignoreNonLocalEntries)
88  : Epetra_CrsMatrix(CV, rowMap, NumEntriesPerRow),
89  myFirstRow_(0),
90  myNumRows_(0),
91  ignoreNonLocalEntries_(ignoreNonLocalEntries),
92 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
95 #endif
96 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
99 #endif
100  nonlocalCoefs_(),
101  workData_(128),
102  useNonlocalMatrix_ (false),
103  nonlocalMatrix_ (NULL),
104  sourceMap_(NULL),
105  colMap_(NULL),
106  exporter_(NULL),
107  tempMat_(NULL)
108 {
109  myFirstRow_ = rowMap.MinMyGID64();
110  myNumRows_ = rowMap.NumMyElements();
111 }
112 
113 //----------------------------------------------------------------------------
115  const Epetra_Map& rowMap,
116  const Epetra_Map& colMap,
117  int* NumEntriesPerRow,
118  bool ignoreNonLocalEntries)
119  : Epetra_CrsMatrix(CV, rowMap, colMap, NumEntriesPerRow),
120  myFirstRow_(0),
121  myNumRows_(0),
122  ignoreNonLocalEntries_(ignoreNonLocalEntries),
123 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
126 #endif
127 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
130 #endif
131  nonlocalCoefs_(),
132  workData_(128),
133  useNonlocalMatrix_ (false),
134  nonlocalMatrix_ (NULL),
135  sourceMap_(NULL),
136  colMap_(NULL),
137  exporter_(NULL),
138  tempMat_(NULL)
139 {
140  myFirstRow_ = rowMap.MinMyGID64();
141  myNumRows_ = rowMap.NumMyElements();
142 }
143 
144 //----------------------------------------------------------------------------
146  const Epetra_Map& rowMap,
147  const Epetra_Map& colMap,
148  int NumEntriesPerRow,
149  bool ignoreNonLocalEntries)
150  : Epetra_CrsMatrix(CV, rowMap, colMap, NumEntriesPerRow),
151  myFirstRow_(0),
152  myNumRows_(0),
153  ignoreNonLocalEntries_(ignoreNonLocalEntries),
154 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
157 #endif
158 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
161 #endif
162  nonlocalCoefs_(),
163  workData_(128),
164  useNonlocalMatrix_ (false),
165  nonlocalMatrix_ (NULL),
166  sourceMap_(NULL),
167  colMap_(NULL),
168  exporter_(NULL),
169  tempMat_(NULL)
170 {
171  myFirstRow_ = rowMap.MinMyGID64();
172  myNumRows_ = rowMap.NumMyElements();
173 }
174 
175 //----------------------------------------------------------------------------
177  const Epetra_CrsGraph& graph,
178  bool ignoreNonLocalEntries)
179  : Epetra_CrsMatrix(CV, graph),
180  myFirstRow_(0),
181  myNumRows_(0),
182  ignoreNonLocalEntries_(ignoreNonLocalEntries),
183 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
186 #endif
187 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
190 #endif
191  nonlocalCoefs_(),
192  workData_(128),
193  useNonlocalMatrix_ (false),
194  nonlocalMatrix_ (NULL),
195  sourceMap_(NULL),
196  colMap_(NULL),
197  exporter_(NULL),
198  tempMat_(NULL)
199 {
202 }
203 
204 //----------------------------------------------------------------------------
206  const Epetra_FECrsGraph& graph,
207  bool ignoreNonLocalEntries)
208  : Epetra_CrsMatrix(CV, graph),
209  myFirstRow_(0),
210  myNumRows_(0),
211  ignoreNonLocalEntries_(ignoreNonLocalEntries),
212 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
215 #endif
216 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
219 #endif
220  nonlocalCoefs_(),
221  workData_(128),
222  useNonlocalMatrix_ (graph.UseNonlocalGraph() && graph.nonlocalGraph_ != 0),
224  new Epetra_CrsMatrix(Copy,*graph.nonlocalGraph_) : NULL),
225  sourceMap_(NULL),
226  colMap_(NULL),
227  exporter_(NULL),
228  tempMat_(NULL)
229 {
232 }
233 
234 //----------------------------------------------------------------------------
236  : Epetra_CrsMatrix(src),
237  myFirstRow_(0),
238  myNumRows_(0),
239  ignoreNonLocalEntries_(false),
240 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
243 #endif
244 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
247 #endif
248  nonlocalCoefs_(),
249  workData_(128),
250  nonlocalMatrix_ (NULL),
251  sourceMap_(NULL),
252  colMap_(NULL),
253  exporter_(NULL),
254  tempMat_(NULL)
255 {
256  operator=(src);
257 }
258 
259 //----------------------------------------------------------------------------
261 {
262  if (this == &src) {
263  return( *this );
264  }
265 
266  DeleteMemory();
267 
269 
271 
272  myFirstRow_ = src.myFirstRow_;
273  myNumRows_ = src.myNumRows_;
275 
276 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
277  if (src.RowMap().GlobalIndicesInt() && nonlocalRows_int_.size() < 1) {
278  return( *this );
279  }
280 #endif
281 
282 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
283  if (src.RowMap().GlobalIndicesLongLong() && nonlocalRows_LL_.size() < 1) {
284  return( *this );
285  }
286 #endif
287 
288  if (useNonlocalMatrix_ && src.nonlocalMatrix_ != 0) {
290  return( *this );
291  }
292 
293 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
294  if (src.RowMap().GlobalIndicesInt()) {
297  }
298 #endif
299 
300 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
301  if (src.RowMap().GlobalIndicesLongLong()) {
304  }
305 #endif
306 
308 
309  return( *this );
310 }
311 
312 //----------------------------------------------------------------------------
314 {
315  DeleteMemory();
316 }
317 
318 //----------------------------------------------------------------------------
320 {
321 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
322  if (RowMap().GlobalIndicesInt()) {
323  nonlocalRows_int_.clear();
324  nonlocalCols_int_.clear();
325  }
326 #endif
327 
328 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
329  if (RowMap().GlobalIndicesLongLong()) {
330  nonlocalRows_LL_.clear();
331  nonlocalCols_LL_.clear();
332  }
333 #endif
334 
335  nonlocalCoefs_.clear();
336 
337  if (nonlocalMatrix_ != 0)
338  delete nonlocalMatrix_;
339 
340  if ( sourceMap_ )
341  delete sourceMap_;
342  if ( colMap_ )
343  delete colMap_;
344  if ( exporter_ )
345  delete exporter_;
346  if ( tempMat_ )
347  delete tempMat_;
348 
349 }
350 
351 //----------------------------------------------------------------------------
352 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
353 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numIndices, const int* indices,
354  const double* const* values,
355  int format)
356 {
357  return(InputGlobalValues(numIndices, indices,
358  numIndices, indices,
359  values, format, SUMINTO));
360 }
361 #endif
362 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
363 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numIndices, const long long* indices,
364  const double* const* values,
365  int format)
366 {
367  return(InputGlobalValues(numIndices, indices,
368  numIndices, indices,
369  values, format, SUMINTO));
370 }
371 #endif
372 //----------------------------------------------------------------------------
373 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
374 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numRows, const int* rows,
375  int numCols, const int* cols,
376  const double* const* values,
377  int format)
378 {
379  return(InputGlobalValues(numRows, rows,
380  numCols, cols,
381  values, format, SUMINTO));
382 }
383 #endif
384 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
385 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numRows, const long long* rows,
386  int numCols, const long long* cols,
387  const double* const* values,
388  int format)
389 {
390  return(InputGlobalValues(numRows, rows,
391  numCols, cols,
392  values, format, SUMINTO));
393 }
394 #endif
395 //----------------------------------------------------------------------------
396 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
397 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numIndices, const int* indices,
398  const double* values,
399  int format)
400 {
401  return(InputGlobalValues(numIndices, indices,
402  numIndices, indices,
403  values, format, SUMINTO));
404 }
405 #endif
406 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
407 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numIndices, const long long* indices,
408  const double* values,
409  int format)
410 {
411  return(InputGlobalValues(numIndices, indices,
412  numIndices, indices,
413  values, format, SUMINTO));
414 }
415 #endif
416 //----------------------------------------------------------------------------
417 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
418 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numRows, const int* rows,
419  int numCols, const int* cols,
420  const double* values,
421  int format)
422 {
423  return(InputGlobalValues(numRows, rows,
424  numCols, cols,
425  values, format, SUMINTO));
426 }
427 
428 #endif
429 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
430 int Epetra_FECrsMatrix::SumIntoGlobalValues(int numRows, const long long* rows,
431  int numCols, const long long* cols,
432  const double* values,
433  int format)
434 {
435  return(InputGlobalValues(numRows, rows,
436  numCols, cols,
437  values, format, SUMINTO));
438 }
439 #endif
440 //----------------------------------------------------------------------------
441 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
443  const Epetra_SerialDenseMatrix& values,
444  int format)
445 {
446  if (indices.Length() != values.M() || indices.Length() != values.N()) {
447  return(-1);
448  }
449 
450  return( SumIntoGlobalValues(indices.Length(), indices.Values(),
451  values.A(), format) );
452 }
453 
454 #endif
455 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
457  const Epetra_SerialDenseMatrix& values,
458  int format)
459 {
460  if (indices.Length() != values.M() || indices.Length() != values.N()) {
461  return(-1);
462  }
463 
464  return( SumIntoGlobalValues(indices.Length(), indices.Values(),
465  values.A(), format) );
466 }
467 #endif
468 //----------------------------------------------------------------------------
469 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
471  const Epetra_SerialDenseMatrix& values,
472  int format)
473 {
474  if (indices.Length() != values.M() || indices.Length() != values.N()) {
475  return(-1);
476  }
477 
478  return( InsertGlobalValues(indices.Length(), indices.Values(),
479  values.A(), format) );
480 }
481 #endif
482 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
484  const Epetra_SerialDenseMatrix& values,
485  int format)
486 {
487  if (indices.Length() != values.M() || indices.Length() != values.N()) {
488  return(-1);
489  }
490 
491  return( InsertGlobalValues(indices.Length(), indices.Values(),
492  values.A(), format) );
493 }
494 #endif
495 //----------------------------------------------------------------------------
496 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
498  const Epetra_SerialDenseMatrix& values,
499  int format)
500 {
501  if (indices.Length() != values.M() || indices.Length() != values.N()) {
502  return(-1);
503  }
504 
505  return( ReplaceGlobalValues(indices.Length(), indices.Values(),
506  values.A(), format) );
507 }
508 #endif
509 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
511  const Epetra_SerialDenseMatrix& values,
512  int format)
513 {
514  if (indices.Length() != values.M() || indices.Length() != values.N()) {
515  return(-1);
516  }
517 
518  return( ReplaceGlobalValues(indices.Length(), indices.Values(),
519  values.A(), format) );
520 }
521 #endif
522 //----------------------------------------------------------------------------
523 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
525  const Epetra_IntSerialDenseVector& cols,
526  const Epetra_SerialDenseMatrix& values,
527  int format)
528 {
529  if (rows.Length() != values.M() || cols.Length() != values.N()) {
530  return(-1);
531  }
532 
533  return( SumIntoGlobalValues(rows.Length(), rows.Values(),
534  cols.Length(), cols.Values(),
535  values.A(), format) );
536 }
537 #endif
538 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
541  const Epetra_SerialDenseMatrix& values,
542  int format)
543 {
544  if (rows.Length() != values.M() || cols.Length() != values.N()) {
545  return(-1);
546  }
547 
548  return( SumIntoGlobalValues(rows.Length(), rows.Values(),
549  cols.Length(), cols.Values(),
550  values.A(), format) );
551 }
552 #endif
553 //----------------------------------------------------------------------------
554 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
556  const Epetra_IntSerialDenseVector& cols,
557  const Epetra_SerialDenseMatrix& values,
558  int format)
559 {
560  if (rows.Length() != values.M() || cols.Length() != values.N()) {
561  return(-1);
562  }
563 
564  return( InsertGlobalValues(rows.Length(), rows.Values(),
565  cols.Length(), cols.Values(),
566  values.A(), format) );
567 }
568 #endif
569 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
572  const Epetra_SerialDenseMatrix& values,
573  int format)
574 {
575  if (rows.Length() != values.M() || cols.Length() != values.N()) {
576  return(-1);
577  }
578 
579  return( InsertGlobalValues(rows.Length(), rows.Values(),
580  cols.Length(), cols.Values(),
581  values.A(), format) );
582 }
583 #endif
584 //----------------------------------------------------------------------------
585 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
587  const Epetra_IntSerialDenseVector& cols,
588  const Epetra_SerialDenseMatrix& values,
589  int format)
590 {
591  if (rows.Length() != values.M() || cols.Length() != values.N()) {
592  return(-1);
593  }
594 
595  return( ReplaceGlobalValues(rows.Length(), rows.Values(),
596  cols.Length(), cols.Values(),
597  values.A(), format) );
598 }
599 #endif
600 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
601 
604  const Epetra_SerialDenseMatrix& values,
605  int format)
606 {
607  if (rows.Length() != values.M() || cols.Length() != values.N()) {
608  return(-1);
609  }
610 
611  return( ReplaceGlobalValues(rows.Length(), rows.Values(),
612  cols.Length(), cols.Values(),
613  values.A(), format) );
614 }
615 #endif
616 //----------------------------------------------------------------------------
617 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
618 int Epetra_FECrsMatrix::InsertGlobalValues(int numIndices, const int* indices,
619  const double* const* values,
620  int format)
621 {
622  return(InputGlobalValues(numIndices, indices,
623  numIndices, indices,
624  values, format, INSERT));
625 }
626 #endif
627 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
628 
629 int Epetra_FECrsMatrix::InsertGlobalValues(int numIndices, const long long* indices,
630  const double* const* values,
631  int format)
632 {
633  return(InputGlobalValues(numIndices, indices,
634  numIndices, indices,
635  values, format, INSERT));
636 }
637 #endif
638 //----------------------------------------------------------------------------
639 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
640 int Epetra_FECrsMatrix::InsertGlobalValues(int numRows, const int* rows,
641  int numCols, const int* cols,
642  const double* const* values,
643  int format)
644 {
645  return(InputGlobalValues(numRows, rows,
646  numCols, cols,
647  values, format, INSERT));
648 }
649 #endif
650 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
651 
652 int Epetra_FECrsMatrix::InsertGlobalValues(int numRows, const long long* rows,
653  int numCols, const long long* cols,
654  const double* const* values,
655  int format)
656 {
657  return(InputGlobalValues(numRows, rows,
658  numCols, cols,
659  values, format, INSERT));
660 }
661 #endif
662 //----------------------------------------------------------------------------
663 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
664 int Epetra_FECrsMatrix::InsertGlobalValues(int numIndices, const int* indices,
665  const double* values,
666  int format)
667 {
668  return(InputGlobalValues(numIndices, indices,
669  numIndices, indices,
670  values, format, INSERT));
671 }
672 #endif
673 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
674 
675 int Epetra_FECrsMatrix::InsertGlobalValues(int numIndices, const long long* indices,
676  const double* values,
677  int format)
678 {
679  return(InputGlobalValues(numIndices, indices,
680  numIndices, indices,
681  values, format, INSERT));
682 }
683 #endif
684 //----------------------------------------------------------------------------
685 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
686 int Epetra_FECrsMatrix::InsertGlobalValues(int numRows, const int* rows,
687  int numCols, const int* cols,
688  const double* values,
689  int format)
690 {
691  return(InputGlobalValues(numRows, rows,
692  numCols, cols,
693  values, format, INSERT));
694 }
695 #endif
696 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
697 
698 int Epetra_FECrsMatrix::InsertGlobalValues(int numRows, const long long* rows,
699  int numCols, const long long* cols,
700  const double* values,
701  int format)
702 {
703  return(InputGlobalValues(numRows, rows,
704  numCols, cols,
705  values, format, INSERT));
706 }
707 #endif
708 //----------------------------------------------------------------------------
709 template<typename int_type>
710 int Epetra_FECrsMatrix::SumIntoGlobalValues(int_type GlobalRow, int NumEntries,
711  const double* values, const int_type* Indices)
712 {
713  if (Map().MyGID(GlobalRow))
714  return Epetra_CrsMatrix::SumIntoGlobalValues(GlobalRow, NumEntries,
715  values, Indices);
716  else if (useNonlocalMatrix_)
717  return nonlocalMatrix_->SumIntoGlobalValues(GlobalRow,
718  NumEntries, values, Indices);
719  else
720  return InputNonlocalGlobalValues(GlobalRow, NumEntries, Indices, values, SUMINTO);
721 }
722 
723 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
724 int Epetra_FECrsMatrix::SumIntoGlobalValues(int GlobalRow, int NumEntries,
725  const double* values, const int* Indices)
726 {
727  if(RowMap().GlobalIndicesInt())
728  return SumIntoGlobalValues<int>(GlobalRow, NumEntries, values, Indices);
729  else
730  throw ReportError("Epetra_FECrsMatrix::SumIntoGlobalValues int version called for a matrix that is not int.", -1);
731 }
732 #endif
733 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
734 
735 
736 int Epetra_FECrsMatrix::SumIntoGlobalValues(long long GlobalRow, int NumEntries,
737  const double* values, const long long* Indices)
738 {
739  if(RowMap().GlobalIndicesLongLong())
740  return SumIntoGlobalValues<long long>(GlobalRow, NumEntries, values, Indices);
741  else
742  throw ReportError("Epetra_FECrsMatrix::SumIntoGlobalValues long long version called for a matrix that is not long long.", -1);
743 }
744 #endif
745 //----------------------------------------------------------------------------
746 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
747 int Epetra_FECrsMatrix::InsertGlobalValues(int GlobalRow, int NumEntries,
748  const double* values, const int* Indices)
749 {
750  return(InputGlobalValues(1, &GlobalRow,
751  NumEntries, Indices, values,
753 }
754 #endif
755 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
756 
757 int Epetra_FECrsMatrix::InsertGlobalValues(long long GlobalRow, int NumEntries,
758  const double* values, const long long* Indices)
759 {
760  return(InputGlobalValues(1, &GlobalRow,
761  NumEntries, Indices, values,
763 }
764 #endif
765 //----------------------------------------------------------------------------
766 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
767 int Epetra_FECrsMatrix::InsertGlobalValues(int GlobalRow, int NumEntries,
768  double* values, int* Indices)
769 {
770  return(InputGlobalValues(1, &GlobalRow,
771  NumEntries, Indices, values,
773 }
774 #endif
775 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
776 int Epetra_FECrsMatrix::InsertGlobalValues(long long GlobalRow, int NumEntries,
777  double* values, long long* Indices)
778 {
779  return(InputGlobalValues(1, &GlobalRow,
780  NumEntries, Indices, values,
782 }
783 #endif
784 //----------------------------------------------------------------------------
785 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
786 int Epetra_FECrsMatrix::ReplaceGlobalValues(int GlobalRow, int NumEntries,
787  const double* values, const int* Indices)
788 {
789  return(InputGlobalValues(1, &GlobalRow,
790  NumEntries, Indices, values,
792 }
793 #endif
794 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
795 int Epetra_FECrsMatrix::ReplaceGlobalValues(long long GlobalRow, int NumEntries,
796  const double* values, const long long* Indices)
797 {
798  return(InputGlobalValues(1, &GlobalRow,
799  NumEntries, Indices, values,
801 }
802 #endif
803 //----------------------------------------------------------------------------
804 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
805 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numIndices, const int* indices,
806  const double* const* values,
807  int format)
808 {
809  return(InputGlobalValues(numIndices, indices,
810  numIndices, indices,
811  values, format, REPLACE));
812 }
813 #endif
814 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
815 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numIndices, const long long* indices,
816  const double* const* values,
817  int format)
818 {
819  return(InputGlobalValues(numIndices, indices,
820  numIndices, indices,
821  values, format, REPLACE));
822 }
823 #endif
824 //----------------------------------------------------------------------------
825 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
826 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numRows, const int* rows,
827  int numCols, const int* cols,
828  const double* const* values,
829  int format)
830 {
831  return(InputGlobalValues(numRows, rows,
832  numCols, cols,
833  values, format, REPLACE));
834 }
835 #endif
836 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
837 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numRows, const long long* rows,
838  int numCols, const long long* cols,
839  const double* const* values,
840  int format)
841 {
842  return(InputGlobalValues(numRows, rows,
843  numCols, cols,
844  values, format, REPLACE));
845 }
846 #endif
847 //----------------------------------------------------------------------------
848 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
849 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numIndices, const int* indices,
850  const double* values,
851  int format)
852 {
853  return(InputGlobalValues(numIndices, indices,
854  numIndices, indices,
855  values, format, REPLACE));
856 }
857 #endif
858 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
859 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numIndices, const long long* indices,
860  const double* values,
861  int format)
862 {
863  return(InputGlobalValues(numIndices, indices,
864  numIndices, indices,
865  values, format, REPLACE));
866 }
867 #endif
868 //----------------------------------------------------------------------------
869 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
870 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numRows, const int* rows,
871  int numCols, const int* cols,
872  const double* values,
873  int format)
874 {
875  return(InputGlobalValues(numRows, rows,
876  numCols, cols,
877  values, format, REPLACE));
878 }
879 #endif
880 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
881 int Epetra_FECrsMatrix::ReplaceGlobalValues(int numRows, const long long* rows,
882  int numCols, const long long* cols,
883  const double* values,
884  int format)
885 {
886  return(InputGlobalValues(numRows, rows,
887  numCols, cols,
888  values, format, REPLACE));
889 }
890 #endif
891 //----------------------------------------------------------------------------
892 int Epetra_FECrsMatrix::GlobalAssemble(bool callFillComplete, Epetra_CombineMode combineMode,
893  bool save_off_and_reuse_map_exporter)
894 {
895  return( GlobalAssemble(DomainMap(), RangeMap(), callFillComplete, combineMode, save_off_and_reuse_map_exporter));
896 }
897 
898 //----------------------------------------------------------------------------
899 template<typename int_type>
901  const Epetra_Map& range_map,
902  bool callFillComplete,
903  Epetra_CombineMode combineMode,
904  bool save_off_and_reuse_map_exporter)
905 {
906  if (Map().Comm().NumProc() < 2 || ignoreNonLocalEntries_) {
907  if (callFillComplete) {
908  EPETRA_CHK_ERR( FillComplete(domain_map, range_map) );
909  }
910  return(0);
911  }
912 
913  std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
914  std::vector<std::vector<int_type> >& nonlocalCols_var = nonlocalCols<int_type>();
915 
916  if (useNonlocalMatrix_) {
918  }
919  else {
920  //In this method we need to gather all the non-local (overlapping) data
921  //that's been input on each processor, into the
922  //non-overlapping distribution defined by the map that 'this' matrix was
923  //constructed with.
924 
925  //First build a map that describes our nonlocal data.
926  //We'll use the arbitrary distribution constructor of Map.
927 
928  int_type* nlr_ptr = Epetra_Util_data_ptr(nonlocalRows_var);
929  if (sourceMap_ == NULL)
930  sourceMap_ = new Epetra_Map((int_type) -1, (int) nonlocalRows_var.size(), nlr_ptr,
931  (int_type) Map().IndexBase64(), Map().Comm());
932 
933  //If sourceMap has global size 0, then no nonlocal data exists and we can
934  //skip most of this function.
935  if (sourceMap_->NumGlobalElements64() < 1) {
936  if (callFillComplete) {
937  EPETRA_CHK_ERR( FillComplete(domain_map, range_map) );
938  }
939  if (!save_off_and_reuse_map_exporter) {
940  delete sourceMap_;
941  sourceMap_ = NULL;
942  }
943  return(0);
944  }
945 
946  //We also need to build a column-map, containing the columns in our
947  //nonlocal data. To do that, create a list of all column-indices that
948  //occur in our nonlocal rows.
949  bool first_time=!save_off_and_reuse_map_exporter;
950  if ( colMap_ == NULL ) {
951  first_time = true;
952  std::vector<int_type> cols;
953 
954  for(size_t i=0; i<nonlocalRows_var.size(); ++i) {
955  for(size_t j=0; j<nonlocalCols_var[i].size(); ++j) {
956  int_type col = nonlocalCols_var[i][j];
957  typename std::vector<int_type>::iterator it =
958  std::lower_bound(cols.begin(), cols.end(), col);
959  if (it == cols.end() || *it != col) {
960  cols.insert(it, col);
961  }
962  }
963  }
964 
965  int_type* cols_ptr = Epetra_Util_data_ptr(cols);
966 
967  colMap_ = new Epetra_Map((int_type) -1, (int) cols.size(), cols_ptr,
968  (int_type) Map().IndexBase64(), Map().Comm());
969  }
970  //now we need to create a matrix with sourceMap and colMap, and fill it with
971  //our nonlocal data so we can then export it to the correct owning processors.
972 
973  std::vector<int> nonlocalRowLengths(nonlocalRows_var.size());
974  for(size_t i=0; i<nonlocalRows_var.size(); ++i) {
975  nonlocalRowLengths[i] = (int) nonlocalCols_var[i].size();
976  }
977 
978  int* nlRLptr = Epetra_Util_data_ptr(nonlocalRowLengths);
979  if ( first_time && tempMat_ == NULL )
980  tempMat_ = new Epetra_CrsMatrix(Copy, *sourceMap_, *colMap_, nlRLptr);
981  else
982  tempMat_->PutScalar(0.);
983 
984  for(size_t i=0; i<nonlocalRows_var.size(); ++i) {
985  if ( first_time ) {
986  EPETRA_CHK_ERR( tempMat_->InsertGlobalValues(nonlocalRows_var[i],
987  (int) nonlocalCols_var[i].size(),
989  Epetra_Util_data_ptr(nonlocalCols_var[i])) );
990  } else {
991  EPETRA_CHK_ERR( tempMat_->SumIntoGlobalValues(nonlocalRows_var[i],
992  (int) nonlocalCols_var[i].size(),
994  Epetra_Util_data_ptr(nonlocalCols_var[i])) );
995  }
996  }
997 
998  if (!save_off_and_reuse_map_exporter) {
999  delete sourceMap_;
1000  delete colMap_;
1001  sourceMap_ = colMap_ = NULL;
1002  }
1003 
1004  //Next we need to make sure the 'indices-are-global' attribute of tempMat's
1005  //graph is set to true, in case this processor doesn't end up calling the
1006  //InsertGlobalValues method...
1007 
1008  if (first_time) {
1009  const Epetra_CrsGraph& graph = tempMat_->Graph();
1010  Epetra_CrsGraph& nonconst_graph = const_cast<Epetra_CrsGraph&>(graph);
1011  nonconst_graph.SetIndicesAreGlobal(true);
1012  }
1013  }
1014  //Now we need to call FillComplete on our temp matrix. We need to
1015  //pass a DomainMap and RangeMap, which are not the same as the RowMap
1016  //and ColMap that we constructed the matrix with.
1017  EPETRA_CHK_ERR(tempMat_->FillComplete(domain_map, range_map));
1018 
1019  if (exporter_ == NULL)
1021 
1022  EPETRA_CHK_ERR(Export(*tempMat_, *exporter_, combineMode));
1023 
1024  if(callFillComplete) {
1025  EPETRA_CHK_ERR(FillComplete(domain_map, range_map));
1026  }
1027 
1028  //now reset the values in our nonlocal data
1029  if (!useNonlocalMatrix_) {
1030  for(size_t i=0; i<nonlocalRows_var.size(); ++i) {
1031  nonlocalCols_var[i].resize(0);
1032  nonlocalCoefs_[i].resize(0);
1033  }
1034  }
1035 
1036  if (!save_off_and_reuse_map_exporter) {
1037  delete exporter_;
1038  exporter_ = NULL;
1039  if (!useNonlocalMatrix_)
1040  delete tempMat_;
1041  tempMat_ = NULL;
1042  }
1043  return(0);
1044 }
1045 
1046 int Epetra_FECrsMatrix::GlobalAssemble(const Epetra_Map& domain_map,
1047  const Epetra_Map& range_map,
1048  bool callFillComplete,
1049  Epetra_CombineMode combineMode,
1050  bool save_off_and_reuse_map_exporter)
1051 {
1052  if(!domain_map.GlobalIndicesTypeMatch(range_map))
1053  throw ReportError("Epetra_FECrsMatrix::GlobalAssemble: cannot be called with different indices types for domainMap and rangeMap", -1);
1054 
1055  if(!RowMap().GlobalIndicesTypeMatch(domain_map))
1056  throw ReportError("Epetra_FECrsMatrix::GlobalAssemble: cannot be called with different indices types for row map and incoming rangeMap", -1);
1057 
1058  if(RowMap().GlobalIndicesInt())
1059 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1060  return GlobalAssemble<int>(domain_map, range_map, callFillComplete, combineMode, save_off_and_reuse_map_exporter);
1061 #else
1062  throw ReportError("Epetra_FECrsMatrix::GlobalAssemble: ERROR, GlobalIndicesInt but no API for it.",-1);
1063 #endif
1064 
1065  if(RowMap().GlobalIndicesLongLong())
1066 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1067  return GlobalAssemble<long long>(domain_map, range_map, callFillComplete, combineMode, save_off_and_reuse_map_exporter);
1068 #else
1069  throw ReportError("Epetra_FECrsMatrix::GlobalAssemble: ERROR, GlobalIndicesLongLong but no API for it.",-1);
1070 #endif
1071 
1072  throw ReportError("Epetra_FECrsMatrix::GlobalAssemble: Internal error, unable to determine global index type of maps", -1);
1073 }
1074 
1075 //----------------------------------------------------------------------------
1076 template<typename int_type>
1078  int numRows, const int_type* rows,
1079  int numCols, const int_type* cols,
1080  const double* values,
1081  int mode)
1082 {
1083  if(!RowMap().template GlobalIndicesIsType<int_type>())
1084  throw ReportError("Epetra_FECrsMatrix::InputGlobalValues_RowMajor mismatch between argument types (int/long long) and map type.", -1);
1085 
1086  int returncode = 0;
1087  int err = 0;
1088 
1089  for(int i=0; i<numRows; ++i) {
1090  double* valuesptr = (double*)values + i*numCols;
1091 
1092  int local_row_id = Map().LID(rows[i]);
1093  if (local_row_id >= 0) {
1094  switch(mode) {
1096  err = this->Epetra_CrsMatrix::SumIntoGlobalValues(rows[i], numCols,
1097  valuesptr, (int_type*)cols);
1098  if (err<0) return(err);
1099  if (err>0) returncode = err;
1100  break;
1102  err = this->Epetra_CrsMatrix::ReplaceGlobalValues(rows[i], numCols,
1103  valuesptr, (int_type*)cols);
1104  if (err<0) return(err);
1105  if (err>0) returncode = err;
1106  break;
1108  err = this->Epetra_CrsMatrix::InsertGlobalValues(rows[i], numCols,
1109  valuesptr, (int_type*)cols);
1110  if (err<0) return(err);
1111  if (err>0) returncode = err;
1112  break;
1113  default:
1114  std::cerr << "Epetra_FECrsMatrix: internal error, bad input mode."<< std::endl;
1115  return(-1);
1116  }
1117  }
1118  else {
1119 #ifdef EPETRA_HAVE_OMP
1120 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1121  if (! ignoreNonLocalEntries_) {
1122 #endif
1123 #endif
1124  err = InputNonlocalGlobalValues(rows[i], numCols, cols,
1125  valuesptr, mode);
1126  if (err<0) return(err);
1127  if (err>0) returncode = err;
1128 #ifdef EPETRA_HAVE_OMP
1129 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1130  }
1131 #endif
1132 #endif
1133  }
1134  }
1135 
1136  return(returncode);
1137 }
1138 
1139 //----------------------------------------------------------------------------
1140 template<typename int_type>
1141 int Epetra_FECrsMatrix::InputGlobalValues(int numRows, const int_type* rows,
1142  int numCols, const int_type* cols,
1143  const double*const* values,
1144  int format, int mode)
1145 {
1146  if(!RowMap().template GlobalIndicesIsType<int_type>())
1147  throw ReportError("Epetra_FECrsMatrix::InputGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1148 
1149  if (format != Epetra_FECrsMatrix::ROW_MAJOR &&
1151  std::cerr << "Epetra_FECrsMatrix: unrecognized format specifier."<< std::endl;
1152  return(-1);
1153  }
1154 
1155  if (format == Epetra_FECrsMatrix::COLUMN_MAJOR) {
1156  workData_.resize(numCols);
1157  }
1158 
1159  int returncode = 0;
1160 
1161  for(int i=0; i<numRows; ++i) {
1162  if (format == Epetra_FECrsMatrix::ROW_MAJOR) {
1163  returncode += InputGlobalValues_RowMajor(1, &rows[i], numCols, cols,
1164  values[i], mode);
1165  if (returncode < 0) return returncode;
1166  continue;
1167  }
1168 
1169  //If we get to here, the data is in column-major order.
1170 
1171  double* valuesptr = Epetra_Util_data_ptr(workData_);
1172 
1173  //Since the data is in column-major order, then we copy the i-th row
1174  //of the values table into workData_, in order to have the row in
1175  //contiguous memory.
1176  //This is slow and not thread-safe.
1177 
1178  for(int j=0; j<numCols; ++j) {
1179  valuesptr[j] = values[j][i];
1180  }
1181 
1182  returncode += InputGlobalValues_RowMajor(1, &rows[i], numCols, cols, valuesptr, mode);
1183  if (returncode < 0) return returncode;
1184  }
1185 
1186  return(returncode);
1187 }
1188 
1189 //----------------------------------------------------------------------------
1190 template<typename int_type>
1191 int Epetra_FECrsMatrix::InputGlobalValues(int numRows, const int_type* rows,
1192  int numCols, const int_type* cols,
1193  const double* values,
1194  int format, int mode)
1195 {
1196  if(!RowMap().template GlobalIndicesIsType<int_type>())
1197  throw ReportError("Epetra_FECrsMatrix::InputGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1198 
1199  if (format == Epetra_FECrsMatrix::ROW_MAJOR) {
1200  return InputGlobalValues_RowMajor(numRows, rows, numCols, cols, values, mode);
1201  }
1202 
1203  workData_.resize(numCols);
1204 
1205  int returncode = 0;
1206  for(int i=0; i<numRows; ++i) {
1207  //copy each row out of the column-major values array, so we can pass it
1208  //to a row-major input function.
1209  for(int j=0; j<numCols; ++j) {
1210  workData_[j] = values[i+j*numRows];
1211  }
1212  int err = InputGlobalValues_RowMajor(1, &rows[i], numCols, cols, Epetra_Util_data_ptr(workData_), mode);
1213  if (err < 0) return err;
1214  returncode += err;
1215  }
1216 
1217  return(returncode);
1218 }
1219 
1220 //----------------------------------------------------------------------------
1221 template<typename int_type>
1223  int numCols, const int_type* cols,
1224  const double* values,
1225  int mode)
1226 {
1227  if(!RowMap().template GlobalIndicesIsType<int_type>())
1228  throw ReportError("Epetra_FECrsMatrix::InputNonlocalGlobalValues mismatch between argument types (int/long long) and map type.", -1);
1229 
1230  // if we already have a nonlocal matrix object, this is easier...
1231  if (useNonlocalMatrix_) {
1232  int err, returncode = 0;
1233  double* valuesptr = (double*)values;
1234  switch(mode) {
1236  err = nonlocalMatrix_->SumIntoGlobalValues(row, numCols,
1237  valuesptr, (int_type*)cols);
1238  if (err<0) return(err);
1239  if (err>0) returncode = err;
1240  break;
1242  err = nonlocalMatrix_->ReplaceGlobalValues(row, numCols,
1243  valuesptr, (int_type*)cols);
1244  if (err<0) return(err);
1245  if (err>0) returncode = err;
1246  break;
1248  err = nonlocalMatrix_->InsertGlobalValues(row, numCols,
1249  valuesptr, (int_type*)cols);
1250  if (err<0) return(err);
1251  if (err>0) returncode = err;
1252  break;
1253  default:
1254  std::cerr << "Epetra_FECrsMatrix: internal error, bad input mode."<< std::endl;
1255  return(-1);
1256  }
1257  return (returncode);
1258  }
1259  int ierr1 = 0, ierr2 = 0;
1260 #ifdef EPETRA_HAVE_OMP
1261 #ifdef EPETRA_HAVE_OMP_NONASSOCIATIVE
1262 #pragma omp critical
1263 #endif
1264 #endif
1265  {
1266  std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
1267 
1268  //find offset of this row in our list of nonlocal rows.
1269  typename std::vector<int_type>::iterator it =
1270  std::lower_bound(nonlocalRows_var.begin(), nonlocalRows_var.end(), row);
1271 
1272  int rowoffset = (int) (it - nonlocalRows_var.begin());
1273  if (it == nonlocalRows_var.end() || *it != row) {
1274  ierr1 = InsertNonlocalRow(row, it);
1275  }
1276 
1277  for(int i=0; i<numCols; ++i) {
1278  ierr2 = InputNonlocalValue(rowoffset, cols[i], values[i], mode);
1279  }
1280  }
1281  EPETRA_CHK_ERR(ierr1);
1282  EPETRA_CHK_ERR(ierr2);
1283 
1284  return(0);
1285 }
1286 
1287 //----------------------------------------------------------------------------
1288 template<typename int_type>
1289 int Epetra_FECrsMatrix::InsertNonlocalRow(int_type row, typename std::vector<int_type>::iterator iter)
1290 {
1291  if(!RowMap().template GlobalIndicesIsType<int_type>())
1292  throw ReportError("Epetra_FECrsMatrix::InsertNonlocalRow mismatch between argument types (int/long long) and map type.", -1);
1293 
1294  std::vector<int_type>& nonlocalRows_var = nonlocalRows<int_type>();
1295  std::vector<std::vector<int_type> >& nonlocalCols_var = nonlocalCols<int_type>();
1296 
1297  int offset = (int) (iter - nonlocalRows_var.begin());
1298  nonlocalRows_var.insert(iter, row);
1299  typename std::vector<std::vector<int_type> >::iterator cols_iter = nonlocalCols_var.begin() + offset;
1300  nonlocalCols_var.insert(cols_iter, std::vector<int_type>());
1301  std::vector<std::vector<double> >::iterator coefs_iter = nonlocalCoefs_.begin() + offset;
1302  nonlocalCoefs_.insert(coefs_iter, std::vector<double>());
1303 
1304  return(0);
1305 }
1306 
1307 //----------------------------------------------------------------------------
1308 template<typename int_type>
1310  int_type col, double value,
1311  int mode)
1312 {
1313  if(!RowMap().template GlobalIndicesIsType<int_type>())
1314  throw ReportError("Epetra_FECrsMatrix::InputNonlocalValue mismatch between argument types (int/long long) and map type.", -1);
1315 
1316  std::vector<int_type>& colIndices = nonlocalCols<int_type>()[rowoffset];
1317  std::vector<double>& coefs = nonlocalCoefs_[rowoffset];
1318 
1319  typename std::vector<int_type>::iterator it =
1320  std::lower_bound(colIndices.begin(), colIndices.end(), col);
1321 
1322  if (it == colIndices.end() || *it != col) {
1323  int offset = (int) (it - colIndices.begin());
1324  colIndices.insert(it, col);
1325  std::vector<double>::iterator dit = coefs.begin()+offset;
1326  coefs.insert(dit, value);
1327  return 0;
1328  }
1329 
1330  int coloffset = (int) (it - colIndices.begin());
1331  if (mode == SUMINTO || mode == INSERT) {
1332  coefs[coloffset] += value;
1333  }
1334  else {
1335  coefs[coloffset] = value;
1336  }
1337 
1338  return(0);
1339 }
1340 
long long MinMyGID64() const
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
const Epetra_Map & RangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
int Length() const
Returns length of vector.
int InputGlobalValues_RowMajor(int numRows, const int_type *rows, int numCols, const int_type *cols, const double *values, int mode)
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
long long * Values()
Returns pointer to the values in vector.
long long IndexBase64() const
Epetra_CrsMatrix * tempMat_
long long NumGlobalElements64() const
std::vector< std::vector< int > > nonlocalCols_int_
int InsertNonlocalRow(int_type row, typename std::vector< int_type >::iterator offset)
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given global row of the matrix.
Epetra Finite-Element CrsGraph.
virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Add this list of entries to existing values for a given global row of the matrix. ...
T * Epetra_Util_data_ptr(std::vector< T > &vec)
Function that returns either a pointer to the first entry in the vector or, if the vector is empty...
Definition: Epetra_Util.h:422
#define EPETRA_CHK_ERR(a)
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:62
int InputNonlocalGlobalValues(int_type row, int numCols, const int_type *cols, const double *values, int mode)
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
std::vector< int > nonlocalRows_int_
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
int Length() const
Returns length of vector.
int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::InsertGlobalValues method
std::vector< long long > nonlocalRows_LL_
int PutScalar(double ScalarConstant)
Initialize all values in the matrix with constant value.
double * A() const
Returns pointer to the this matrix.
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
int NumMyElements() const
Number of elements on the calling processor.
Epetra Finite-Element CrsMatrix.
Epetra_FECrsMatrix & operator=(const Epetra_FECrsMatrix &src)
Assignment operator.
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Exports an Epetra_DistObject using the Epetra_Import object.
void SetIndicesAreGlobal(bool Flag)
Epetra_Export * exporter_
int GlobalAssemble(bool callFillComplete=true, Epetra_CombineMode combineMode=Add, bool save_off_and_reuse_map_exporter=false)
Gather any overlapping/shared data into the non-overlapping partitioning defined by the Map that was ...
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
int InputGlobalValues(int numRows, const int_type *rows, int numCols, const int_type *cols, const double *const *values, int format, int mode)
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
std::vector< std::vector< long long > > nonlocalCols_LL_
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
std::vector< std::vector< double > > nonlocalCoefs_
int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::SumIntoGlobalValues method
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
const Epetra_Map & DomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
Epetra_CrsMatrix & operator=(const Epetra_CrsMatrix &src)
Assignment operator.
int InputNonlocalValue(int rowoffset, int_type col, double value, int mode)
Epetra_CombineMode
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
int N() const
Returns column dimension of system.
const Epetra_CrsGraph & Graph() const
Returns a reference to the Epetra_CrsGraph object associated with this matrix.
Epetra_FECrsMatrix(Epetra_DataAccess CV, const Epetra_Map &RowMap, int *NumEntriesPerRow, bool ignoreNonLocalEntries=false)
Constructor.
Epetra_DataAccess
int * Values()
Returns pointer to the values in vector.
const Epetra_BlockMap & Map() const
Map() method inherited from Epetra_DistObject.
std::vector< double > workData_
int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
override base-class Epetra_CrsMatrix::ReplaceGlobalValues method
virtual ~Epetra_FECrsMatrix()
Destructor.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Replace specified existing values with this list of entries for a given global row of the matrix...
int M() const
Returns row dimension of system.
Epetra_CrsMatrix(Epetra_DataAccess CV, const Epetra_Map &RowMap, const int *NumEntriesPerRow, bool StaticProfile=false)
Epetra_CrsMatrix constructor with variable number of indices per row.
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
Epetra_CrsMatrix * nonlocalMatrix_
bool GlobalIndicesTypeMatch(const Epetra_BlockMap &other) const