EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_HDF5_Handle.h
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 
42 #ifndef EPETRAEXT_HDF5_HANDLE_H
43 #define EPETRAEXT_HDF5_HANDLE_H
44 
45 #if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
46 #ifdef __GNUC__
47 #warning "The EpetraExt package is deprecated"
48 #endif
49 #endif
50 #include "EpetraExt_ConfigDefs.h"
51 #ifdef HAVE_EPETRAEXT_HDF5
52 
53 namespace EpetraExt {
54 
55 class Handle
56 {
57  public:
58  virtual ~Handle() {}
59 
61  virtual int NumMyElements() const = 0;
62 
64  virtual int NumGlobalElements() const = 0;
65 
67  virtual std::string Type() const = 0;
68 
69  virtual bool HasInt() const = 0;
70 
71  virtual bool HasDouble() const = 0;
72 
74  virtual int IntSize(const int EID) const = 0;
75 
77  virtual int DoubleSize(const int EID) const = 0;
78 
80  virtual int GetLabels(std::vector<std::string>& IntLabels,
81  std::vector<std::string>& DoubleLabels) const = 0;
82 
84  virtual int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
85  std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const = 0;
86 
88  virtual int SetLabels(const std::vector<int>& IntLabelsData,
89  const std::vector<double>& DoubleLabelsData) = 0;
90 
92  virtual int Pack(const int EID, int* IntData, double* DoubleData) const = 0;
93 
95  virtual int UnPack(const int EID, int IntSize, int* IntData,
96  int DoubleSize, double* DoubleData) = 0;
97 
99  virtual int Initialize() = 0;
100 
102  virtual int Finalize() = 0;
103 };
104 
105 #include "Epetra_Vector.h"
106 
108 {
109  public:
111  obj_(&obj)
112  {}
113 
115  int NumMyElements() const
116  {
117  return(obj_->Map().NumMyElements());
118  }
119 
121  int NumGlobalElements() const
122  {
123  return(obj_->Map().NumGlobalElements());
124  }
125 
127  std::string Type() const
128  {
129  return("Handle<Epetra_Vector>");
130  }
131 
132  bool HasInt() const
133  {
134  return(false);
135  }
136 
137  bool HasDouble() const
138  {
139  return(true);
140  }
141 
143  int IntSize(const int EID) const
144  {
145  return(0);
146  }
147 
149  int DoubleSize(const int EID) const
150  {
151  return(1);
152  }
153 
155  int GetLabels(std::vector<std::string>& IntLabels,
156  std::vector<std::string>& DoubleLabels) const
157  {
158  IntLabels.resize(0);
159  DoubleLabels.resize(0);
160 
161  return(0);
162  }
163 
165  int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
166  std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const
167  {
168  return(0);
169  }
170 
172  int SetLabels(const std::vector<int>& IntLabelsData,
173  const std::vector<double>& DoubleLabelsData)
174  {
175  return(0);
176  }
177 
179  int Pack(const int EID, int* IntData, double* DoubleData) const
180  {
181  DoubleData[0] = (*obj_)[EID];
182 
183  return(0);
184  }
185 
187  int UnPack(const int EID, int IntSize, int* IntData,
188  int DoubleSize, double* DoubleData)
189  {
190  (*obj_)[EID] = DoubleData[0];
191 
192  return(0);
193  }
194 
197  {
198  // do nothing here
199  return(0);
200  }
201 
203  int Finalize()
204  {
205  // do nothing here
206  return(0);
207  }
208 
209  private:
211 };
212 
213 } // namespace EpetraExt
214 #endif
215 #endif /* EPETRAEXT_HDF5_HANDLE_H */
int NumGlobalElements() const
std::string Type() const
Returns the identifier of the distributed object.
virtual int GetLabels(std::vector< std::string > &IntLabels, std::vector< std::string > &DoubleLabels) const =0
Packs all global information.
int Initialize()
Performs any initialization procedure before unpacking.
int Pack(const int EID, int *IntData, double *DoubleData) const
Packs all data for local element EID in the specified arrays.
virtual int NumMyElements() const =0
Returns the local number of elements.
int UnPack(const int EID, int IntSize, int *IntData, int DoubleSize, double *DoubleData)
Unpacks all data for local element EID in the specified arrays.
int GetLabels(std::vector< std::string > &IntLabels, std::vector< std::string > &DoubleLabels) const
Packs all global information.
int NumMyElements() const
int NumMyElements() const
Returns the local number of elements.
virtual const Epetra_BlockMap & Map() const =0
virtual int Finalize()=0
Performs any finalization procedure after unpacking.
int DoubleSize(const int EID) const
Returns the size of double data for local element EID.
virtual int UnPack(const int EID, int IntSize, int *IntData, int DoubleSize, double *DoubleData)=0
Unpacks all data for local element EID in the specified arrays.
virtual bool HasDouble() const =0
virtual int IntSize(const int EID) const =0
Returns the size of integer data for local element EID.
virtual int DoubleSize(const int EID) const =0
Returns the size of double data for local element EID.
virtual int Initialize()=0
Performs any initialization procedure before unpacking.
int Finalize()
Performs any finalization procedure after unpacking.
virtual int SetLabels(const std::vector< int > &IntLabelsData, const std::vector< double > &DoubleLabelsData)=0
Sets global information.
int NumGlobalElements() const
Returns the global number of elements.
int GetLabels(std::vector< std::string > &IntLabels, std::vector< int > &IntLabelsData, std::vector< std::string > &DoubleLabels, std::vector< double > &DoubleLabelsData) const
Packs all global information.
int IntSize(const int EID) const
Returns the size of integer data for local element EID.
virtual int NumGlobalElements() const =0
Returns the global number of elements.
virtual int Pack(const int EID, int *IntData, double *DoubleData) const =0
Packs all data for local element EID in the specified arrays.
int SetLabels(const std::vector< int > &IntLabelsData, const std::vector< double > &DoubleLabelsData)
Sets global information.
virtual std::string Type() const =0
Returns the identifier of the distributed object.
virtual bool HasInt() const =0