EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_PointToBlockDiagPermute.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_POINTTOBLOCKDIAGPERMUTE_H
43 #define EPETRAEXT_POINTTOBLOCKDIAGPERMUTE_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_ConfigDefs.h"
52 #include "Epetra_DistObject.h"
53 #include "Epetra_BlockMap.h"
54 #include "Epetra_BlockMap.h"
55 #include "Epetra_Map.h"
56 #include "Epetra_Operator.h"
57 #include "Epetra_CrsMatrix.h"
58 #include "Epetra_FECrsMatrix.h"
60 
61 class Epetra_Comm;
62 class Epetra_Import;
63 class Epetra_Export;
65 
67 
75 // NTS: Map() == RowMap is the convention
76 
77 //=========================================================================
79 public:
80 
82 
86 
88 
92 
93 
95 
96 
98  virtual int SetParameters(Teuchos::ParameterList & List);
99 
106  virtual int SetUseTranspose (bool /* useTranspose */) {return -1;}
107 
109  virtual int Compute();
110 
112 
114 
115 
117 
125  virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
126 
128 
139  virtual int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
140 
142  virtual double NormInf() const {return -1;}
144 
146 
147 
149  virtual const char * Label() const{return "Fix Me";}
150 
152  virtual bool UseTranspose() const {return false;}
153 
155  virtual bool HasNormInf() const {return false;}
156 
158  virtual const Epetra_Comm & Comm() const {return Map().Comm();}
159 
161  virtual const Epetra_Map & OperatorDomainMap() const {return Matrix_->OperatorDomainMap();}
162 
164  virtual const Epetra_Map & OperatorRangeMap() const {return Matrix_->OperatorRangeMap();}
165 
167  virtual const EpetraExt_BlockDiagMatrix & BlockMatrix(){return *BDMat_;}
168 
173 
175 
176 
178  virtual void Print(std::ostream& os) const;
179 
181 
183 
185 
197  int Import(const Epetra_SrcDistObject& A, const Epetra_Import& Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
198 
200 
212  int Import(const Epetra_SrcDistObject& A, const Epetra_Export& Exporter, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
213 
215 
227  int Export(const Epetra_SrcDistObject& A, const Epetra_Import & Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
228 
230 
242  int Export(const Epetra_SrcDistObject& A, const Epetra_Export& Exporter, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex * Indexor = 0);
244 
245  protected:
246 
247 
249 
250  virtual int CheckSizes(const Epetra_SrcDistObject& Source);
253  virtual int CopyAndPermute(const Epetra_SrcDistObject& Source,
254  int NumSameIDs,
255  int NumPermuteIDs,
256  int * PermuteToLIDs,
257  int * PermuteFromLIDs,
258  const Epetra_OffsetIndex * Indexor,
259  Epetra_CombineMode CombineMode = Zero);
260 
262  virtual int PackAndPrepare(const Epetra_SrcDistObject& Source,
263  int NumExportIDs,
264  int* ExportLIDs,
265  int& LenExports,
266  char*& Exports,
267  int& SizeOfPacket,
268  int* Sizes,
269  bool & VarSizes,
270  Epetra_Distributor& Distor);
271 
273  virtual int UnpackAndCombine(const Epetra_SrcDistObject& Source,
274  int NumImportIDs,
275  int* ImportLIDs,
276  int LenImports,
277  char* Imports,
278  int& SizeOfPacket,
279  Epetra_Distributor& Distor,
280  Epetra_CombineMode CombineMode,
281  const Epetra_OffsetIndex * Indexor);
282 
284 
285 private:
287  int ExtractBlockDiagonal();
288 
290  int SetupContiguousMode();
291  int CleanupContiguousMode();
292 
293  // Copied from Epetra_CrsMatrix
294  void UpdateImportVector(int NumVectors) const;
295  void UpdateExportVector(int NumVectors) const;
296 
300 
301  // For contiguous blocking only
304 
308 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
309  long long *Blockids_LL_;
310 #endif
312  Epetra_Map *CompatibleMap_; //A map compatible with BD's block map - used for imports
318 
319  template<typename int_type>
321 
322  template<typename int_type>
323  int TSetupContiguousMode();
324 
325  template<typename int_type>
326  int TExtractBlockDiagonal();
327 
328  template<typename int_type>
330 
331  template<typename int_type>
332  const int_type* Blockids_const_ptr() const;
333 
334  template<typename int_type>
335  int_type*& Blockids_ref();
336 
337 }; /* EPETRAEXT_POINTTOBLOCKDIAGPERMUTE_H */
338 
339 template<> inline const int* EpetraExt_PointToBlockDiagPermute::Blockids_const_ptr<int>() const { return Blockids_int_; }
340 
341 template<> inline int*& EpetraExt_PointToBlockDiagPermute::Blockids_ref<int>() { return Blockids_int_; }
342 
343 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
344 template<> inline const long long* EpetraExt_PointToBlockDiagPermute::Blockids_const_ptr<long long>() const { return Blockids_LL_; }
345 template<> inline long long*& EpetraExt_PointToBlockDiagPermute::Blockids_ref<long long>() { return Blockids_LL_; }
346 #endif
347 
348 #endif
int TSetParameters(Teuchos::ParameterList &List)
virtual const EpetraExt_BlockDiagMatrix & BlockMatrix()
Return the block matrix. Only call this after calling Compute.
EpetraExt_PointToBlockDiagPermute: A class for managing point-to-block-diagonal permutations.
virtual const Epetra_Map & OperatorDomainMap() const
Return the Epetra_Map object associated with the domain of this operator.
virtual bool HasNormInf() const
Return true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets the parameter list.
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...
const Epetra_Map & OperatorDomainMap() const
virtual const Epetra_Comm & Comm() const
Return a pointer to the Epetra_Comm communicator associated with this operator.
virtual bool UseTranspose() const
Return the current UseTranspose setting.
EpetraExt_BlockDiagMatrix: A class for storing distributed block matrices.
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)
Perform any unpacking and combining after call to DoTransfer().
virtual int CheckSizes(const Epetra_SrcDistObject &Source)
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
const int_type * Blockids_const_ptr() const
virtual const Epetra_BlockMap & Map() const =0
virtual int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)
Perform ID copies and permutations that are on processor.
const Epetra_Comm & Comm() const
EpetraExt_PointToBlockDiagPermute(const Epetra_CrsMatrix &MAT)
@ Name Constructors
virtual const char * Label() const
Return a string describing the operator.
virtual int Compute()
Extracts the block-diagonal, builds maps, etc.
virtual int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)
Perform any packing or preparation required for call to DoTransfer().
virtual Epetra_FECrsMatrix * CreateFECrsMatrix()
Create an Epetra_FECrsMatrix from the BlockDiagMatrix.
const Epetra_Map & OperatorRangeMap() const
int SetupContiguousMode()
Setup/Cleanup for Contiguous Mode.
Epetra_CombineMode
virtual const Epetra_Map & OperatorRangeMap() const
Return the Epetra_Map object associated with the range of this operator.
virtual void Print(std::ostream &os) const
Print information about this object to the given output stream.
virtual double NormInf() const
Returns the infinity norm of the global matrix - NOT IMPLEMENTED.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
int ExtractBlockDiagonal()
Pulls the block diagonal of the matrix and then builds the BDMat_.
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
Imports an Epetra_DistObject using the Epetra_Import object.
virtual int SetUseTranspose(bool)
Set whether to use the transpose.
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.