Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_IntMultiVector.h
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 
44 #ifndef EPETRA_INTMULTIVECTOR_H
45 #define EPETRA_INTMULTIVECTOR_H
46 
47 class Epetra_Comm;
48 class Epetra_BlockMap;
49 class Epetra_Map;
50 class Epetra_Import;
51 class Epetra_Export;
52 class Epetra_Distributor;
53 class Epetra_IntVector;
54 
55 #include "Epetra_ConfigDefs.h"
56 #include "Epetra_DistObject.h"
57 #include "Epetra_CompObject.h"
58 #include "Epetra_BLAS.h"
59 #include "Epetra_Util.h"
60 
62 
178 //==========================================================================
179 class EPETRA_LIB_DLL_EXPORT Epetra_IntMultiVector: public Epetra_DistObject, public Epetra_CompObject, public Epetra_BLAS {
180 
181  public:
182 
184 
185 
203  Epetra_IntMultiVector(const Epetra_BlockMap& Map, int NumVectors, bool zeroOut = true);
204 
206 
208 
210 
230  int *A, int MyLDA, int NumVectors);
231 
233 
249  int **ArrayOfPointers, int NumVectors);
250 
252 
267  const Epetra_IntMultiVector& Source, int *Indices, int NumVectors);
268 
270 
285  const Epetra_IntMultiVector& Source, int StartIndex,
286  int NumVectors);
287 
289  virtual ~Epetra_IntMultiVector();
291 
293 
294 
296 
315 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
316  int ReplaceGlobalValue(int GlobalRow, int VectorIndex, int OrdinalValue);
317 #endif
318 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
319  int ReplaceGlobalValue(long long GlobalRow, int VectorIndex, int OrdinalValue);
320 #endif
321 
322 
324 
342 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
343  int ReplaceGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, int OrdinalValue);
344 #endif
345 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
346  int ReplaceGlobalValue(long long GlobalBlockRow, int BlockRowOffset, int VectorIndex, int OrdinalValue);
347 #endif
348 
349 
351 
370 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
371  int SumIntoGlobalValue(int GlobalRow, int VectorIndex, int OrdinalValue);
372 #endif
373 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
374  int SumIntoGlobalValue(long long GlobalRow, int VectorIndex, int OrdinalValue);
375 #endif
376 
377 
379 
397 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
398  int SumIntoGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, int OrdinalValue);
399 #endif
400 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
401  int SumIntoGlobalValue(long long GlobalBlockRow, int BlockRowOffset, int VectorIndex, int OrdinalValue);
402 #endif
403 
405 
429  int ReplaceMyValue(int MyRow, int VectorIndex, int OrdinalValue);
430 
431 
433 
451  int ReplaceMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, int OrdinalValue);
452 
453 
455 
474  int SumIntoMyValue(int MyRow, int VectorIndex, int OrdinalValue);
475 
476 
478 
496  int SumIntoMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, int OrdinalValue);
497 
499 
505  int PutScalar (int OrdinalConstant);
506 
508 
510 
511 
513 
527  int ExtractCopy(int *A, int MyLDA) const;
528 
530 
540  int ExtractCopy(int **ArrayOfPointers) const;
541 
542  // ExtractView functions
543 
544 
546 
560  int ExtractView(int **A, int *MyLDA) const;
561 
563 
573  int ExtractView(int ***ArrayOfPointers) const;
574 
576 
578 
579 
581 
590  int MinValue (int * Result) const;
591 
593 
602  int MaxValue (int * Result) const;
603 
605 
607 
608 
610 
617 
618  // Local element access functions
619 
620  //
621 
623 
626  int*& operator [] (int i) { return Pointers_[i]; }
628 
631  // const int*& operator [] (int i) const;
632  int * const & operator [] (int i) const { return Pointers_[i]; }
633 
635 
638  Epetra_IntVector * & operator () (int i);
640 
643  const Epetra_IntVector * & operator () (int i) const;
644 
646 
648 
649 
651  int NumVectors() const {return(NumVectors_);}
652 
654  int MyLength() const {return(MyLength_);}
655 
657 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
658  int GlobalLength() const {
659  if(Map().GlobalIndicesInt())
660  return (int) GlobalLength_;
661  throw "Epetra_MultiVector::GlobalLength: GlobalIndices not int.";
662  }
663 #endif
664  long long GlobalLength64() const {return(GlobalLength_);}
665 
667  int Stride() const {return(Stride_);}
668 
670  bool ConstantStride() const {return(ConstantStride_);}
672 
676  int ReplaceMap(const Epetra_BlockMap& map);
677 
679 
680 
682  virtual void Print(std::ostream & os) const;
684 
686 
687 
689 
708  int ResetView(int ** ArrayOfPointers);
709 
711  int* Values() const {return Values_;}
712 
714  int** Pointers() const {return Pointers_;}
716 
717  // Expert-only function
718  // SuperLU defines Reduce to be a macro in util.h
719 #ifdef Reduce
720 #undef Reduce
721 #endif
722  int Reduce();
723 
724  protected:
725 
726  // Internal utilities
727  void Assign(const Epetra_IntMultiVector& rhs);
728  int CheckInput();
729 
730  int *Values_; // local MultiVector coefficients
731 
732  private:
733 
734 
735  // Internal utilities
736 
737  int AllocateForCopy(void);
738  int DoCopy(void);
739 
740  inline void UpdateOrdinalTemp() const
741  {if (OrdinalTemp_==0) OrdinalTemp_=new int[NumVectors_+1]; return;}
742 
743  inline void UpdateIntVectors() const {if (IntVectors_==0) { IntVectors_ = new Epetra_IntVector *[NumVectors_];
744  for (int i=0; i<NumVectors_; i++) IntVectors_[i] = 0;}
745  return;
746  }
747 
748  int AllocateForView(void);
749  int DoView(void);
750  template<typename int_type>
751  int ChangeGlobalValue(int_type GlobalBlockRow,
752  int BlockRowOffset,
753  int VectorIndex,
754  int OrdinalValue,
755  bool SumInto);
756  int ChangeMyValue(int MyBlockRow,
757  int BlockRowOffset,
758  int VectorIndex,
759  int OrdinalValue,
760  bool SumInto);
761 
762  int CheckSizes(const Epetra_SrcDistObject& A);
763 
764  int CopyAndPermute(const Epetra_SrcDistObject & Source,
765  int NumSameIDs,
766  int NumPermuteIDs,
767  int * PermuteToLIDs,
768  int * PermuteFromLIDs,
769  const Epetra_OffsetIndex * Indexor,
770  Epetra_CombineMode CombineMode = Zero);
771 
772  int PackAndPrepare(const Epetra_SrcDistObject & Source,
773  int NumExportIDs,
774  int * ExportLIDs,
775  int & LenExports,
776  char * & Exports,
777  int & SizeOfPacket,
778  int * Sizes,
779  bool & VarSizes,
780  Epetra_Distributor & Distor);
781 
782  int UnpackAndCombine(const Epetra_SrcDistObject & Source,
783  int NumImportIDs,
784  int * ImportLIDs,
785  int LenImports,
786  char * Imports,
787  int & SizeOfPacket,
788  Epetra_Distributor & Distor,
789  Epetra_CombineMode CombineMode,
790  const Epetra_OffsetIndex * Indexor );
791 
792  int **Pointers_; // Pointers to each vector;
793 
795  long long GlobalLength_;
799  int Stride_;
801  mutable int * OrdinalTemp_;
804 
805 };
806 
807 #endif /* EPETRA_INTMULTIVECTOR_H */
int ** Pointers() const
Get pointer to individual vector pointers.
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
virtual int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)=0
Perform ID copies and permutations that are on processor.
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
Epetra_IntVector: A class for constructing and using dense integer vectors on a parallel computer...
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
virtual void Print(std::ostream &os) const
Print method.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:62
bool ConstantStride() const
Returns true if this multi-vector has constant stride between vectors.
int NumVectors() const
Returns the number of vectors in the multi-vector.
int * Values() const
Get pointer to MultiVector values.
Epetra_IntMultiVector: A class for constructing and using dense multi-vectors, vectors and matrices i...
Epetra_CompObject & operator=(const Epetra_CompObject &src)
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
Definition: Epetra_Import.h:63
virtual int CheckSizes(const Epetra_SrcDistObject &Source)=0
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
Epetra_IntVector ** IntVectors_
Epetra_Util: The Epetra Util Wrapper Class.
Definition: Epetra_Util.h:79
Epetra_BLAS: The Epetra BLAS Wrapper Class.
Definition: Epetra_BLAS.h:70
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
Epetra_CompObject: Functionality and data that is common to all computational classes.
virtual int UnpackAndCombine(const Epetra_SrcDistObject &Source, int NumImportIDs, int *ImportLIDs, int LenImports, char *Imports, int &SizeOfPacket, Epetra_Distributor &Distor, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor)=0
Perform any unpacking and combining after call to DoTransfer().
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
int GlobalLength() const
Returns the global vector length of vectors in the multi-vector.
int Stride() const
Returns the stride between vectors in the multi-vector (only meaningful if ConstantStride() is true)...
Epetra_CombineMode
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
Epetra_DataAccess
long long GlobalLength64() const
Epetra_DistObject: A class for constructing and using dense multi-vectors, vectors and matrices in pa...
virtual int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)=0
Perform any packing or preparation required for call to DoTransfer().
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.