EpetraExt Package Browser (Single Doxygen Collection) Development
EpetraExt_HDF5_Handle.h
Go to the documentation of this file.
00001 //@HEADER
00002 /*
00003 ************************************************************************
00004 
00005               EpetraExt: Linear Algebra Services Package
00006                 Copyright (2001) Sandia Corporation
00007 
00008 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 license for use of this work by or on behalf of the U.S. Government.
00010 
00011 This library is free software; you can redistribute it and/or modify
00012 it under the terms of the GNU Lesser General Public License as
00013 published by the Free Software Foundation; either version 2.1 of the
00014 License, or (at your option) any later version.
00015 
00016 This library is distributed in the hope that it will be useful, but
00017 WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 Lesser General Public License for more details.
00020 
00021 You should have received a copy of the GNU Lesser General Public
00022 License along with this library; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 USA
00025 Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00026 
00027 ************************************************************************
00028 */
00029 //@HEADER
00030 
00031 #ifndef EPETRAEXT_HDF5_HANDLE_H
00032 #define EPETRAEXT_HDF5_HANDLE_H
00033 #include "EpetraExt_ConfigDefs.h"
00034 #ifdef HAVE_EPETRAEXT_HDF5
00035 
00036 namespace EpetraExt {
00037 
00038 class Handle 
00039 {
00040   public:
00041     virtual ~Handle() {}
00042 
00044     virtual int NumMyElements() const = 0;
00045 
00047     virtual int NumGlobalElements() const = 0;
00048 
00050     virtual std::string Type() const = 0;
00051 
00052     virtual bool HasInt() const = 0;
00053 
00054     virtual bool HasDouble() const = 0;
00055 
00057     virtual int IntSize(const int EID) const = 0;
00058 
00060     virtual int DoubleSize(const int EID) const = 0;
00061 
00063     virtual int GetLabels(std::vector<std::string>& IntLabels, 
00064                   std::vector<std::string>& DoubleLabels) const = 0;
00065 
00067     virtual int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
00068                   std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const = 0;
00069 
00071     virtual int SetLabels(const std::vector<int>& IntLabelsData,
00072                   const std::vector<double>& DoubleLabelsData) = 0;
00073 
00075     virtual int Pack(const int EID, int* IntData, double* DoubleData) const = 0;
00076 
00078     virtual int UnPack(const int EID, int IntSize, int* IntData, 
00079                int DoubleSize, double* DoubleData) = 0;
00080 
00082     virtual int Initialize() = 0;
00083 
00085     virtual int Finalize() = 0;
00086 };
00087 
00088 #include "Epetra_Vector.h"
00089 
00090 class Epetra_Vector_Handle : public Handle
00091 {
00092   public:
00093     Epetra_Vector_Handle(Epetra_Vector& obj) :
00094       obj_(&obj)
00095     {}
00096 
00098     int NumMyElements() const
00099     {
00100       return(obj_->Map().NumMyElements());
00101     }
00102 
00104     int NumGlobalElements() const
00105     {
00106       return(obj_->Map().NumGlobalElements());
00107     }
00108 
00110     std::string Type() const
00111     {
00112       return("Handle<Epetra_Vector>");
00113     }
00114 
00115     bool HasInt() const
00116     {
00117       return(false);
00118     }
00119 
00120     bool HasDouble() const
00121     {
00122       return(true);
00123     }
00124 
00126     int IntSize(const int EID) const
00127     {
00128       return(0);
00129     }
00130 
00132     int DoubleSize(const int EID) const
00133     {
00134       return(1);
00135     }
00136 
00138     int GetLabels(std::vector<std::string>& IntLabels, 
00139                   std::vector<std::string>& DoubleLabels) const
00140     {
00141       IntLabels.resize(0);
00142       DoubleLabels.resize(0);
00143 
00144       return(0);
00145     }
00146 
00148     int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
00149                   std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const
00150     {
00151       return(0);
00152     }
00153 
00155     int SetLabels(const std::vector<int>& IntLabelsData,
00156                   const std::vector<double>& DoubleLabelsData)
00157     {
00158       return(0);
00159     }
00160 
00162     int Pack(const int EID, int* IntData, double* DoubleData) const
00163     {
00164       DoubleData[0] = (*obj_)[EID];
00165 
00166       return(0);
00167     }
00168 
00170     int UnPack(const int EID, int IntSize, int* IntData, 
00171                int DoubleSize, double* DoubleData)
00172     {
00173       (*obj_)[EID] = DoubleData[0];
00174 
00175       return(0);
00176     }
00177 
00179     int Initialize()
00180     {
00181       // do nothing here
00182       return(0);
00183     }
00184 
00186     int Finalize()
00187     {
00188       // do nothing here
00189       return(0);
00190     }
00191 
00192   private:
00193     Epetra_Vector* obj_;
00194 };
00195 
00196 } // namespace EpetraExt
00197 #endif
00198 #endif /* EPETRAEXT_HDF5_HANDLE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines