src/identityoperator.h

Go to the documentation of this file.
00001 //
00002 // C++ Interface: identityoperator
00003 //
00004 // Description: Identity operator
00005 //
00006 //
00007 // Author: Roman Geus <roman.geus@psi.ch>, (C) 2004
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 
00013 #ifndef IDENTITY_OPERATOR_H
00014 #define IDENTITY_OPERATOR_H
00015 
00016 #include "Epetra_Operator.h"
00017 
00018 class Epetra_MultiVector;
00019 class Epetra_Map;
00020 class Epetra_Comm;
00021 
00025 class IdentityOperator : public Epetra_Operator {
00026     public:
00027         IdentityOperator(const Epetra_Map& domain_map,
00028                          const Epetra_Map& range_map,
00029                          const Epetra_Comm& comm)
00030             : domain_map_(domain_map),
00031               range_map_(range_map),
00032               comm_(comm),
00033               use_transpose_(false)
00034         { }
00035 
00036         ~IdentityOperator() {}
00037 
00038         int SetUseTranspose(bool use_transpose) {
00039             use_transpose_ = use_transpose;
00040             return 0;
00041         }
00042 
00043         int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00044             if (&X != &Y) {
00045                 // X and Y are not the same obj: copy X to Y, vector by vector
00046 
00047                 if (!X.Map().SameAs(OperatorDomainMap()))
00048                     EPETRA_CHK_ERR(-1);
00049                 if (!Y.Map().SameAs(OperatorRangeMap()))
00050                     EPETRA_CHK_ERR(-2);
00051                 if (Y.NumVectors() != X.NumVectors())
00052                     EPETRA_CHK_ERR(-3);
00053                 if (!domain_map_.SameAs(range_map_))
00054                     EPETRA_CHK_ERR(-4);
00055 
00056                 int num_vectors = X.NumVectors();
00057                 int my_length = X.MyLength();
00058 
00059                 for (int i = 0; i < num_vectors; i ++) {
00060                     memcpy(Y[i], X[i], my_length * sizeof(double));
00061                 }
00062             }
00063             return 0;
00064         }
00065 
00066         int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00067             return Apply(X, Y);
00068         }
00069 
00070         double NormInf() const {
00071             return 0.0;
00072         }
00073 
00074         const char * Label() const {
00075             return "Identity operator";
00076         }
00077 
00078         bool UseTranspose() const {
00079             return use_transpose_;
00080         }
00081 
00082         bool HasNormInf() const {
00083             return false;
00084         }
00085 
00086         const Epetra_Comm& Comm() const {
00087             return comm_;
00088         }
00089 
00090         const Epetra_Map & OperatorDomainMap() const {
00091             return domain_map_;
00092         }
00093 
00094         const Epetra_Map & OperatorRangeMap() const {
00095             return range_map_;
00096         }
00097 
00098     private:
00099         const Epetra_Map& domain_map_;
00100         const Epetra_Map& range_map_;
00101         const Epetra_Comm& comm_;
00102         bool use_transpose_;
00103 };
00104 
00105 #endif

Generated on Fri Oct 26 13:35:12 2007 for FEMAXX (Finite Element Maxwell Eigensolver) by  doxygen 1.4.7