| 1 |
|
| 2 |
//@HEADER |
| 3 |
// *********************************************************************** |
| 4 |
// |
| 5 |
// EpetraExt: Epetra Extended - 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 ([email protected]) |
| 39 |
// |
| 40 |
// *********************************************************************** |
| 41 |
//@HEADER |
| 42 |
|
| 43 |
#ifndef _POISSON2DOPERATOR_H_ |
| 44 |
#define _POISSON2DOPERATOR_H_ |
| 45 |
|
| 46 |
#if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS) |
| 47 |
#ifdef __GNUC__ |
| 48 |
#warning "The EpetraExt package is deprecated" |
| 49 |
#endif |
| 50 |
#endif |
| 51 |
|
| 52 |
class Epetra_MultiVector; |
| 53 |
class Epetra_CrsMatrix; |
| 54 |
class Epetra_Map; |
| 55 |
class Epetra_Import; |
| 56 |
class Epetra_BlockMap; |
| 57 |
class Epetra_Comm; |
| 58 |
#include "Epetra_Operator.h" |
| 59 |
|
| 60 |
//! Poisson2dOperator: A sample implementation of the Epetra_Operator class. |
| 61 |
/*! The Poisson2dOperator class is a class that implements Epetra_Operator for a 5-point Poisson stencil |
| 62 |
operator. |
| 63 |
*/ |
| 64 |
|
| 65 |
class Poisson2dOperator: public virtual Epetra_Operator { |
| 66 |
|
| 67 |
public: |
| 68 |
|
| 69 |
//@{ \name Constructors. |
| 70 |
//! Builds a 2 dimensional Poisson operator for a nx by ny grid, assuming zero Dirichlet BCs. |
| 71 |
/*! Build a 2 D Poisson operator. Split the y-dimension across the processor space. |
| 72 |
\param In nx - Number of gridpoints in the x direction. |
| 73 |
\param In ny - Number of gridpoints in the y direction. |
| 74 |
*/ |
| 75 |
Poisson2dOperator(int nx, int ny, const Epetra_Comm & comm); |
| 76 |
//@{ \name Destructor. |
| 77 |
//! Destructor |
| 78 |
~Poisson2dOperator(); |
| 79 |
//@} |
| 80 |
|
| 81 |
//@{ \name Attribute set methods. |
| 82 |
|
| 83 |
//! If set true, transpose of this operator will be applied. |
| 84 |
/*! This flag allows the transpose of the given operator to be used implicitly. Setting this flag |
| 85 |
affects only the Apply() and ApplyInverse() methods. If the implementation of this interface |
| 86 |
does not support transpose use, this method should return a value of -1. |
| 87 |
|
| 88 |
\param In |
| 89 |
UseTranspose -If true, multiply by the transpose of operator, otherwise just use operator. |
| 90 |
|
| 91 |
\return Integer error code, set to 0 if successful. Set to -1 if this implementation does not support transpose. |
| 92 |
*/ |
| 93 |
int SetUseTranspose(bool UseTranspose){useTranspose_ = UseTranspose; return(0);}; |
| 94 |
//@} |
| 95 |
|
| 96 |
//@{ \name Mathematical functions. |
| 97 |
|
| 98 |
//! Returns the result of a Poisson2dOperator applied to a Epetra_MultiVector X in Y. |
| 99 |
/*! |
| 100 |
\param In |
| 101 |
X - A Epetra_MultiVector of dimension NumVectors to multiply with matrix. |
| 102 |
\param Out |
| 103 |
Y -A Epetra_MultiVector of dimension NumVectors containing result. |
| 104 |
|
| 105 |
\return Integer error code, set to 0 if successful. |
| 106 |
*/ |
| 107 |
int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; |
| 108 |
|
| 109 |
//! Returns the result of a Poisson2dOperator inverse applied to an Epetra_MultiVector X in Y. |
| 110 |
/*! |
| 111 |
\param In |
| 112 |
X - A Epetra_MultiVector of dimension NumVectors to solve for. |
| 113 |
\param Out |
| 114 |
Y -A Epetra_MultiVector of dimension NumVectors containing result. |
| 115 |
|
| 116 |
\return Integer error code, set to 0 if successful. |
| 117 |
|
| 118 |
\warning In order to work with AztecOO, any implementation of this method must |
| 119 |
support the case where X and Y are the same object. |
| 120 |
*/ |
| 121 |
int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {return(Apply(X,Y));}; |
| 122 |
|
| 123 |
//! Returns the infinity norm of the global matrix. |
| 124 |
/* Returns the quantity \f$ \| A \|_\infty\f$ such that |
| 125 |
\f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f]. |
| 126 |
|
| 127 |
\warning This method must not be called unless HasNormInf() returns true. |
| 128 |
*/ |
| 129 |
double NormInf() const {return(8.0);}; |
| 130 |
//@} |
| 131 |
|
| 132 |
//@{ \name Attribute access functions |
| 133 |
|
| 134 |
//! Returns a character string describing the operator |
| 135 |
const char * Label() const{return(Label_);}; |
| 136 |
|
| 137 |
//! Returns the current UseTranspose setting. |
| 138 |
bool UseTranspose() const {return(useTranspose_);}; |
| 139 |
|
| 140 |
//! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise. |
| 141 |
bool HasNormInf() const{return(true);}; |
| 142 |
|
| 143 |
//! Returns a pointer to the Epetra_Comm communicator associated with this operator. |
| 144 |
const Epetra_Comm & Comm() const{return(comm_);}; |
| 145 |
|
| 146 |
//! Returns the Epetra_Map object associated with the domain of this operator. |
| 147 |
const Epetra_Map & OperatorDomainMap() const {return(*map_);}; |
| 148 |
|
| 149 |
//! Returns the Epetra_Map object associated with the range of this operator. |
| 150 |
const Epetra_Map & OperatorRangeMap() const {return(*map_);}; |
| 151 |
//@} |
| 152 |
|
| 153 |
//@{ \name Approximate matrix generators |
| 154 |
//! Generate a tridiagonal approximation to the 5-point Poisson as an Epetra_CrsMatrix |
| 155 |
|
| 156 |
Epetra_CrsMatrix * GeneratePrecMatrix() const; |
| 157 |
//@} |
| 158 |
|
| 159 |
|
| 160 |
int nx_, ny_, myny_; |
| 161 |
bool useTranspose_; |
| 162 |
const Epetra_Comm & comm_; |
| 163 |
Epetra_Map * map_; |
| 164 |
int numImports_; |
| 165 |
long long * importIDs_; |
| 166 |
Epetra_Map * importMap_; |
| 167 |
Epetra_Import * importer_; |
| 168 |
mutable Epetra_MultiVector * importX_; |
| 169 |
const char * Label_; |
| 170 |
}; |
| 171 |
|
| 172 |
#endif /* _POISSON2DOPERATOR_H_ */ |