Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
Epetra_MultiVector.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_MULTIVECTOR_H
45#define EPETRA_MULTIVECTOR_H
46
47class Epetra_Comm;
48class Epetra_BlockMap;
49class Epetra_Map;
50class Epetra_Import;
51class Epetra_Export;
53class Epetra_Vector;
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
183//==========================================================================
184class EPETRA_LIB_DLL_EXPORT Epetra_MultiVector: public Epetra_DistObject, public Epetra_CompObject, public Epetra_BLAS {
185
186 public:
187
189
190
208 Epetra_MultiVector(const Epetra_BlockMap& Map, int NumVectors, bool zeroOut = true);
209
211
213
215
235 double *A, int MyLDA, int NumVectors);
236
238
254 double **ArrayOfPointers, int NumVectors);
255
257
272 const Epetra_MultiVector& Source, int *Indices, int NumVectors);
273
275
290 const Epetra_MultiVector& Source, int StartIndex,
291 int NumVectors);
292
294 virtual ~Epetra_MultiVector();
296
298
299
301
320#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
321 int ReplaceGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue);
322#endif
323#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
324 int ReplaceGlobalValue(long long GlobalRow, int VectorIndex, double ScalarValue);
325#endif
326
327
329
347#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
348 int ReplaceGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
349#endif
350#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
351 int ReplaceGlobalValue(long long GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
352#endif
353
354
356
375#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
376 int SumIntoGlobalValue(int GlobalRow, int VectorIndex, double ScalarValue);
377#endif
378#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
379 int SumIntoGlobalValue(long long GlobalRow, int VectorIndex, double ScalarValue);
380#endif
381
382
384
402#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
403 int SumIntoGlobalValue(int GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
404#endif
405#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
406 int SumIntoGlobalValue(long long GlobalBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
407#endif
408
410
434 int ReplaceMyValue(int MyRow, int VectorIndex, double ScalarValue);
435
436
438
456 int ReplaceMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
457
458
460
479 int SumIntoMyValue(int MyRow, int VectorIndex, double ScalarValue);
480
481
483
501 int SumIntoMyValue(int MyBlockRow, int BlockRowOffset, int VectorIndex, double ScalarValue);
502
504
510 int PutScalar (double ScalarConstant);
511
513
519 int Random();
520
522
524
525
527
541 int ExtractCopy(double *A, int MyLDA) const;
542
544
554 int ExtractCopy(double **ArrayOfPointers) const;
555
556 // ExtractView functions
557
558
560
574 int ExtractView(double **A, int *MyLDA) const;
575
577
587 int ExtractView(double ***ArrayOfPointers) const;
588
590
592
593
595
603 int Dot(const Epetra_MultiVector& A, double *Result) const;
604
606
616 int Abs(const Epetra_MultiVector& A);
617
619
634 int Reciprocal(const Epetra_MultiVector& A);
635
637
645 int Scale(double ScalarValue);
646
648
658 int Scale(double ScalarA, const Epetra_MultiVector& A);
659
661
673 int Update(double ScalarA, const Epetra_MultiVector& A, double ScalarThis);
674
676
692 int Update(double ScalarA, const Epetra_MultiVector& A,
693 double ScalarB, const Epetra_MultiVector& B, double ScalarThis);
694
696
703 int Norm1 (double * Result) const;
704
706
713 int Norm2 (double * Result) const;
714
716
722 int NormInf (double * Result) const;
723
725
740 int NormWeighted (const Epetra_MultiVector& Weights, double * Result) const;
741
743
752 int MinValue (double * Result) const;
753
755
764 int MaxValue (double * Result) const;
765
767
774 int MeanValue (double * Result) const;
775
776
778
830 int Multiply(char TransA, char TransB, double ScalarAB,
831 const Epetra_MultiVector& A, const Epetra_MultiVector& B,
832 double ScalarThis );
833
834
835
837
843 int Multiply(double ScalarAB, const Epetra_MultiVector& A, const Epetra_MultiVector& B,
844 double ScalarThis );
845
846
848
854 int ReciprocalMultiply(double ScalarAB, const Epetra_MultiVector& A, const Epetra_MultiVector& B,
855 double ScalarThis );
856
858
860
861
862
864
870 int SetSeed(unsigned int Seed_in){return(Util_.SetSeed(Seed_in));};
871
873
876 unsigned int Seed(){return(Util_.Seed());};
877
879
881
882
884
891
892 // Local element access functions
893
894 //
895
897
900 double*& operator [] (int i) { return Pointers_[i]; }
902
905 // const double*& operator [] (int i) const;
906 double * const & operator [] (int i) const { return Pointers_[i]; }
907
909
912 Epetra_Vector * & operator () (int i);
914
917 const Epetra_Vector * & operator () (int i) const;
918
920
922
923
925 int NumVectors() const {return(NumVectors_);};
926
928 int MyLength() const {return(MyLength_);};
929
931 int GlobalLength() const { int ret_val = GlobalLength_; return ret_val; }
932
934 long long GlobalLength64() const {return(GlobalLength_);};
935
937 int Stride() const {return(Stride_);};
938
940 bool ConstantStride() const {return(ConstantStride_);};
942
946 int ReplaceMap(const Epetra_BlockMap& map);
947
949
950
952 virtual void Print(std::ostream & os) const;
954
956
957
959
978 int ResetView(double ** ArrayOfPointers);
979
981 double* Values() const {return Values_;};
982
984 double** Pointers() const {return Pointers_;};
986
987 // Expert-only function
988#ifdef Reduce
989#undef Reduce
990#endif
991 int Reduce();
992
993 protected:
994
995 // Internal utilities
996 void Assign(const Epetra_MultiVector& rhs);
998
999 double *Values_; // local MultiVector coefficients
1000
1001 private:
1002
1003
1004 // Internal utilities
1005
1006 int AllocateForCopy(void);
1007 int DoCopy(void);
1008
1009 inline void UpdateDoubleTemp() const
1010 {if (DoubleTemp_==0) DoubleTemp_=new double[NumVectors_+1]; return;}
1011
1012 inline void UpdateVectors() const {if (Vectors_==0) { Vectors_ = new Epetra_Vector *[NumVectors_];
1013 for (int i=0; i<NumVectors_; i++) Vectors_[i] = 0;}
1014 return;
1015 }
1016
1017 int AllocateForView(void);
1018 int DoView(void);
1019 template<typename int_type>
1020 int ChangeGlobalValue(int_type GlobalBlockRow,
1021 int BlockRowOffset,
1022 int VectorIndex,
1023 double ScalarValue,
1024 bool SumInto);
1025 int ChangeMyValue(int MyBlockRow,
1026 int BlockRowOffset,
1027 int VectorIndex,
1028 double ScalarValue,
1029 bool SumInto);
1030
1031 int CheckSizes(const Epetra_SrcDistObject& A);
1032
1033 int CopyAndPermute(const Epetra_SrcDistObject & Source,
1034 int NumSameIDs,
1035 int NumPermuteIDs,
1036 int * PermuteToLIDs,
1037 int * PermuteFromLIDs,
1038 const Epetra_OffsetIndex * Indexor,
1039 Epetra_CombineMode CombineMode = Zero);
1040
1041 int PackAndPrepare(const Epetra_SrcDistObject & Source,
1042 int NumExportIDs,
1043 int * ExportLIDs,
1044 int & LenExports,
1045 char * & Exports,
1046 int & SizeOfPacket,
1047 int * Sizes,
1048 bool & VarSizes,
1049 Epetra_Distributor & Distor);
1050
1051 int UnpackAndCombine(const Epetra_SrcDistObject & Source,
1052 int NumImportIDs,
1053 int * ImportLIDs,
1054 int LenImports,
1055 char * Imports,
1056 int & SizeOfPacket,
1057 Epetra_Distributor & Distor,
1058 Epetra_CombineMode CombineMode,
1059 const Epetra_OffsetIndex * Indexor );
1060
1061 double **Pointers_; // Pointers to each vector;
1062
1064 long long GlobalLength_;
1070 mutable double * DoubleTemp_;
1073
1074};
1075
1076#endif /* EPETRA_MULTIVECTOR_H */
Epetra_CombineMode
@ Zero
Epetra_DataAccess
Epetra_BLAS: The Epetra BLAS Wrapper Class.
Definition: Epetra_BLAS.h:70
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
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.
Epetra_DistObject: A class for constructing and using dense multi-vectors, vectors and matrices in pa...
virtual int CheckSizes(const Epetra_SrcDistObject &Source)=0
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not.
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().
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().
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_DistObject & operator=(const Epetra_DistObject &src)
virtual void Print(std::ostream &os) const
Print method.
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements.
Definition: Epetra_Export.h:62
Epetra_Import: This class builds an import object for efficient importing of off-processor elements.
Definition: Epetra_Import.h:63
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int GlobalLength() const
Returns the global vector length of vectors in the multi-vector.
int NumVectors() const
Returns the number of vectors in the multi-vector.
int MyLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
bool ConstantStride() const
Returns true if this multi-vector has constant stride between vectors.
int Stride() const
Returns the stride between vectors in the multi-vector (only meaningful if ConstantStride() is true).
double * Values() const
Get pointer to MultiVector values.
void UpdateDoubleTemp() const
double ** Pointers() const
Get pointer to individual vector pointers.
unsigned int Seed()
Get seed from Random function.
long long GlobalLength64() const
Returns the 64-bit global vector length of vectors in the multi-vector.
int SetSeed(unsigned int Seed_in)
Set seed for Random function.
Epetra_Vector ** Vectors_
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
Epetra_Util: The Epetra Util Wrapper Class.
Definition: Epetra_Util.h:79
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.