00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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
00182 return(0);
00183 }
00184
00186 int Finalize()
00187 {
00188
00189 return(0);
00190 }
00191
00192 private:
00193 Epetra_Vector* obj_;
00194 };
00195
00196 }
00197 #endif
00198 #endif