EpetraExt Development
EpetraExt_HDF5_Handle.h
Go to the documentation of this file.
00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00005 //                 Copyright (2011) Sandia Corporation
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 
00042 #ifndef EPETRAEXT_HDF5_HANDLE_H
00043 #define EPETRAEXT_HDF5_HANDLE_H
00044 #include "EpetraExt_ConfigDefs.h"
00045 #ifdef HAVE_EPETRAEXT_HDF5
00046 
00047 namespace EpetraExt {
00048 
00049 class Handle 
00050 {
00051   public:
00052     virtual ~Handle() {}
00053 
00055     virtual int NumMyElements() const = 0;
00056 
00058     virtual int NumGlobalElements() const = 0;
00059 
00061     virtual std::string Type() const = 0;
00062 
00063     virtual bool HasInt() const = 0;
00064 
00065     virtual bool HasDouble() const = 0;
00066 
00068     virtual int IntSize(const int EID) const = 0;
00069 
00071     virtual int DoubleSize(const int EID) const = 0;
00072 
00074     virtual int GetLabels(std::vector<std::string>& IntLabels, 
00075                   std::vector<std::string>& DoubleLabels) const = 0;
00076 
00078     virtual int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
00079                   std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const = 0;
00080 
00082     virtual int SetLabels(const std::vector<int>& IntLabelsData,
00083                   const std::vector<double>& DoubleLabelsData) = 0;
00084 
00086     virtual int Pack(const int EID, int* IntData, double* DoubleData) const = 0;
00087 
00089     virtual int UnPack(const int EID, int IntSize, int* IntData, 
00090                int DoubleSize, double* DoubleData) = 0;
00091 
00093     virtual int Initialize() = 0;
00094 
00096     virtual int Finalize() = 0;
00097 };
00098 
00099 #include "Epetra_Vector.h"
00100 
00101 class Epetra_Vector_Handle : public Handle
00102 {
00103   public:
00104     Epetra_Vector_Handle(Epetra_Vector& obj) :
00105       obj_(&obj)
00106     {}
00107 
00109     int NumMyElements() const
00110     {
00111       return(obj_->Map().NumMyElements());
00112     }
00113 
00115     int NumGlobalElements() const
00116     {
00117       return(obj_->Map().NumGlobalElements());
00118     }
00119 
00121     std::string Type() const
00122     {
00123       return("Handle<Epetra_Vector>");
00124     }
00125 
00126     bool HasInt() const
00127     {
00128       return(false);
00129     }
00130 
00131     bool HasDouble() const
00132     {
00133       return(true);
00134     }
00135 
00137     int IntSize(const int EID) const
00138     {
00139       return(0);
00140     }
00141 
00143     int DoubleSize(const int EID) const
00144     {
00145       return(1);
00146     }
00147 
00149     int GetLabels(std::vector<std::string>& IntLabels, 
00150                   std::vector<std::string>& DoubleLabels) const
00151     {
00152       IntLabels.resize(0);
00153       DoubleLabels.resize(0);
00154 
00155       return(0);
00156     }
00157 
00159     int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
00160                   std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const
00161     {
00162       return(0);
00163     }
00164 
00166     int SetLabels(const std::vector<int>& IntLabelsData,
00167                   const std::vector<double>& DoubleLabelsData)
00168     {
00169       return(0);
00170     }
00171 
00173     int Pack(const int EID, int* IntData, double* DoubleData) const
00174     {
00175       DoubleData[0] = (*obj_)[EID];
00176 
00177       return(0);
00178     }
00179 
00181     int UnPack(const int EID, int IntSize, int* IntData, 
00182                int DoubleSize, double* DoubleData)
00183     {
00184       (*obj_)[EID] = DoubleData[0];
00185 
00186       return(0);
00187     }
00188 
00190     int Initialize()
00191     {
00192       // do nothing here
00193       return(0);
00194     }
00195 
00197     int Finalize()
00198     {
00199       // do nothing here
00200       return(0);
00201     }
00202 
00203   private:
00204     Epetra_Vector* obj_;
00205 };
00206 
00207 } // namespace EpetraExt
00208 #endif
00209 #endif /* EPETRAEXT_HDF5_HANDLE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines