EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_BlockDiagMatrix.h
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 
42 #ifndef EPETRAEXT_BLOCKDIAGMATRIX_H
43 #define EPETRAEXT_BLOCKDIAGMATRIX_H
44 
45 #if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
46 #ifdef __GNUC__
47 #warning "The EpetraExt package is deprecated"
48 #endif
49 #endif
50 
51 #include "Epetra_BLAS.h"
52 #include "Epetra_LAPACK.h"
53 #include "Epetra_DistObject.h"
54 #include "Epetra_BlockMap.h"
55 #include "Epetra_Map.h"
56 #include "Epetra_Operator.h"
58 
59 class Epetra_Comm;
60 
62 
71 //=========================================================================
73 
74  public:
76  EpetraExt_BlockDiagMatrix(const Epetra_BlockMap& Map,bool zero_out=true);
77 
78 
81 
84 
86 
93 
95 
98  double* operator [] (int index) {return &Values_[DataMap_->FirstPointInElement(index)];}
100 
103  const double* operator [] (int index) const {return &Values_[DataMap_->FirstPointInElement(index)];}
105 
106 
108 
109 
111  virtual int SetUseTranspose(bool /* useTranspose */){return -1;}
112 
114  virtual int SetParameters(Teuchos::ParameterList & List);
115 
117  virtual int Compute();
118 
120 
121 
123 
124 
126  virtual const char * Label() const{return "EpetraExt::BlockDiagMatrix";}//HAQ
127 
129  virtual bool UseTranspose() const {return false;}
130 
132  virtual bool HasNormInf() const {return false;}
133 
135  virtual const Epetra_Comm & Comm() const {return Map().Comm();}
136 
138  virtual const Epetra_Map & OperatorDomainMap() const {return *dynamic_cast<const Epetra_Map*>(&Map());}
139 
141  virtual const Epetra_Map & OperatorRangeMap() const {return *dynamic_cast<const Epetra_Map*>(&Map());}
142 
144  virtual const Epetra_BlockMap & BlockMap() const {return Map();}
145 
147  double* Values() const {return(Values_);}
148 
150  int BlockSize(int LID) const {return Map().ElementSize(LID);}
151 
153  int DataSize(int LID) const {return DataMap_->ElementSize(LID);}
154 
156  bool ConstantBlockSize() const {return Map().ConstantElementSize();}
157 
159  int NumMyBlocks() const {return(Map().NumMyElements());}
160 
162 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
163  int NumGlobalBlocks() const {return(Map().NumGlobalElements());}
164 #endif
165  long long NumGlobalBlocks64() const {return(Map().NumGlobalElements64());}
166 
168  int NumMyUnknowns() const {return(Map().NumMyPoints());}
169 
171 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
172  int NumGlobalUnknowns() const {return(Map().NumGlobalPoints());}
173 #endif
174  long long NumGlobalUnknowns64() const {return(Map().NumGlobalPoints64());}
175 
177  int NumData() const {return DataMap_->NumMyPoints();}
178 
180  int GetApplyMode() {return ApplyMode_;}
181 
183  virtual void Print(std::ostream & os) const;
184 
186 
187 
189 
190 
192 
199  virtual int Apply(const Epetra_MultiVector& /* X */, Epetra_MultiVector& /* Y */) const {return -1;}
200 
202 
213  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
214 
216  virtual double NormInf() const{return -1;}
217 
219  void PutScalar(double value);
220 
222  virtual const Epetra_BlockMap & DataMap() const {return *DataMap_;}
223 
225 
226 
227 private:
228  void Allocate();
229 
230  int DoCopy(const EpetraExt_BlockDiagMatrix& Source);
231 
232  // Routines to implement Epetra_DistObject virtual methods
233  // Allows the source and target (\e this) objects to be compared for compatibility, return nonzero if not.
234  int CheckSizes(const Epetra_SrcDistObject& Source);
235  // Perform ID copies and permutations that are on processor.
236  int CopyAndPermute(const Epetra_SrcDistObject& Source,
237  int NumSameIDs,
238  int NumPermuteIDs,
239  int * PermuteToLIDs,
240  int * PermuteFromLIDs,
241  const Epetra_OffsetIndex * Indexor,
242  Epetra_CombineMode CombineMode = Zero);
243 
244  // Perform any packing or preparation required for call to DoTransfer().
245  int PackAndPrepare(const Epetra_SrcDistObject& Source,
246  int NumExportIDs,
247  int* ExportLIDs,
248  int& LenExports,
249  char*& Exports,
250  int& SizeOfPacket,
251  int* Sizes,
252  bool & VarSizes,
253  Epetra_Distributor& Distor);
254 
255  // Perform any unpacking and combining after call to DoTransfer().
256  int UnpackAndCombine(const Epetra_SrcDistObject& Source,
257  int NumImportIDs,
258  int* ImportLIDs,
259  int LenImports,
260  char* Imports,
261  int& SizeOfPacket,
262  Epetra_Distributor& Distor,
263  Epetra_CombineMode CombineMode,
264  const Epetra_OffsetIndex * Indexor);
265 
268 
271 
274 
277 
279  double *Values_;
280 
282  int *Pivots_;
283 
284 }; /* EPETRAEXT_BLOCKDIAGMATRIX_H */
285 
286 #endif
virtual const Epetra_BlockMap & DataMap() const
Returns the Epetra_BlockMap object with the distribution of underlying values.
bool ConstantBlockSize() const
Returns true if the element size is constant.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y...
int NumGlobalUnknowns() const
Returns the number of global unknowns.
int ElementSize() const
int * Pivots_
Pivots for factorization.
int NumMyBlocks() const
Returns the number of local blocks.
int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)
Epetra_BlockMap * DataMap_
Map for the data.
double * Values() const
Returns a pointer to the array containing the blocks.
bool ConstantElementSize() const
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
int NumMyUnknowns() const
Returns the number of local unknowns.
EpetraExt_BlockDiagMatrix & operator=(const EpetraExt_BlockDiagMatrix &Source)
= Operator.
int NumGlobalBlocks() const
Returns the number of global blocks.
virtual double NormInf() const
NormInf - Not Implemented.
virtual ~EpetraExt_BlockDiagMatrix()
Destructor.
double * operator[](int index)
Block access function.
EpetraExt_BlockDiagMatrix: A class for storing distributed block matrices.
int BlockSize(int LID) const
Returns the size of the given block.
virtual void Print(std::ostream &os) const
Print method.
int NumData() const
Returns the size of the total Data block.
int FirstPointInElement(int LID) const
EpetraExt_BlockDiagMatrix(const Epetra_BlockMap &Map, bool zero_out=true)
Constructor - This map is the map of the vector this can be applied to.
virtual int SetUseTranspose(bool)
SetUseTranspose - not implemented.
virtual const Epetra_BlockMap & Map() const =0
int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)
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)
virtual int Compute()
Computes the inverse / factorization if such is set on the list.
virtual int Apply(const Epetra_MultiVector &, Epetra_MultiVector &) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
virtual int SetParameters(Teuchos::ParameterList &List)
SetParameters.
const Epetra_Comm & Comm() const
double * Values_
Actual Data values.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
bool HasComputed_
Has Computed? Needed for Inverse/Factorization modes.
int DoCopy(const EpetraExt_BlockDiagMatrix &Source)
virtual const char * Label() const
Returns a character std::string describing the operator.
Epetra_CombineMode
int ApplyMode_
Which Apply Mode to use.
int DataSize(int LID) const
Returns the size of the data in the given block.
int NumMyPoints() const
int GetApplyMode()
Gets apply mode info.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
int CheckSizes(const Epetra_SrcDistObject &Source)
virtual const Epetra_BlockMap & BlockMap() const
Returns the Epetra_BlockMap object associated with the range of this operator.
void PutScalar(double value)
PutScalar function.