00001 #include "Epetra_CrsMatrix.h"
00002 #include "Epetra_Map.h"
00003 #include "Epetra_MultiVector.h"
00004 #include "Epetra_Vector.h"
00005 #include "Epetra_Comm.h"
00006
00007 #include <pbedefs.h>
00008
00009 #include "Projector.h"
00010
00011 Projector::Projector(Epetra_Operator* Y, const Epetra_Operator* H, Epetra_Operator* C)
00012 : _Y(Y),
00013 _H(H),
00014 _C(C),
00015 _useTranspose(false),
00016 _vector1(new Epetra_Vector(H->OperatorRangeMap())),
00017 _vector2(new Epetra_Vector(H->OperatorRangeMap())),
00018 _vector3(new Epetra_Vector(Y->OperatorRangeMap())),
00019 _Comm(Y->Comm()) {
00020
00021 }
00022
00023 Projector::~Projector() {
00024 delete _vector1;
00025 delete _vector2;
00026 delete _vector3;
00027 }
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 int Projector::SetUseTranspose(bool UseTranspose) {
00046 int ierr = 0;
00047 _useTranspose = UseTranspose;
00048 return(ierr);
00049 }
00050
00051 int Projector::Apply(const Epetra_MultiVector& X, Epetra_MultiVector& B) const {
00052
00053 int ierr = 0;
00054 int i = 0;
00055 int dim = X.NumVectors();
00056 const Epetra_Vector* x = 0;
00057
00058 pbe_start(84, "Nullspace projector application");
00059
00060 if (_useTranspose) {
00061 _Y->SetUseTranspose(true);
00062 _C->SetUseTranspose(false);
00063 for (i=0; i<dim; i++) {
00064 x = (Epetra_Vector*) X(i);
00065 _Y->Apply(*x, *_vector1);
00066 _H->ApplyInverse(*_vector1, *_vector2);
00067 _C->Apply(*_vector2, *_vector3);
00068 B(i)->Update(1.0, *x, -1.0, *_vector3, 0.0);
00069 }
00070 }
00071 else {
00072 _Y->SetUseTranspose(false);
00073 _C->SetUseTranspose(true);
00074 for (i=0; i<dim; i++) {
00075 x = (Epetra_Vector*) X(i);
00076 _C->Apply(*x, *_vector1);
00077 _H->ApplyInverse(*_vector1, *_vector2);
00078 _Y->Apply(*_vector2, *_vector3);
00079 B(i)->Update(1.0, *x, -1.0, *_vector3, 0.0);
00080 }
00081 }
00082 pbe_stop(84);
00083
00084 return(ierr);
00085 }
00086
00087 int Projector::ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00088 return(1);
00089 }
00090
00091 double Projector::NormInf() const {
00092 return(1);
00093 }
00094
00095 const char* Projector::Label() const {
00096 return("projector");
00097 }
00098
00099 bool Projector::UseTranspose() const {
00100 return(_useTranspose);
00101 }
00102
00103 bool Projector::HasNormInf() const {
00104 return(false);
00105 }
00106
00107 const Epetra_Comm& Projector::Comm() const {
00108 return(_Comm);
00109 }
00110
00111
00112 const Epetra_Map& Projector::OperatorDomainMap() const {
00113 return(_Y->OperatorRangeMap());
00114 }
00115
00116
00117 const Epetra_Map& Projector::OperatorRangeMap() const {
00118 return(_Y->OperatorRangeMap());
00119 }