EpetraExt Development
Loading...
Searching...
No Matches
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
45#ifdef HAVE_EPETRAEXT_HDF5
46
47namespace EpetraExt {
48
49class Handle
50{
51 public:
52 virtual ~Handle() {}
53
55 virtual int NumMyElements() const = 0;
56
58 virtual int NumGlobalElements() const = 0;
59
61 virtual std::string Type() const = 0;
62
63 virtual bool HasInt() const = 0;
64
65 virtual bool HasDouble() const = 0;
66
68 virtual int IntSize(const int EID) const = 0;
69
71 virtual int DoubleSize(const int EID) const = 0;
72
74 virtual int GetLabels(std::vector<std::string>& IntLabels,
75 std::vector<std::string>& DoubleLabels) const = 0;
76
78 virtual int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
79 std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const = 0;
80
82 virtual int SetLabels(const std::vector<int>& IntLabelsData,
83 const std::vector<double>& DoubleLabelsData) = 0;
84
86 virtual int Pack(const int EID, int* IntData, double* DoubleData) const = 0;
87
89 virtual int UnPack(const int EID, int IntSize, int* IntData,
90 int DoubleSize, double* DoubleData) = 0;
91
93 virtual int Initialize() = 0;
94
96 virtual int Finalize() = 0;
97};
98
99#include "Epetra_Vector.h"
100
102{
103 public:
105 obj_(&obj)
106 {}
107
109 int NumMyElements() const
110 {
111 return(obj_->Map().NumMyElements());
112 }
113
116 {
117 return(obj_->Map().NumGlobalElements());
118 }
119
121 std::string Type() const
122 {
123 return("Handle<Epetra_Vector>");
124 }
125
126 bool HasInt() const
127 {
128 return(false);
129 }
130
131 bool HasDouble() const
132 {
133 return(true);
134 }
135
137 int IntSize(const int EID) const
138 {
139 return(0);
140 }
141
143 int DoubleSize(const int EID) const
144 {
145 return(1);
146 }
147
149 int GetLabels(std::vector<std::string>& IntLabels,
150 std::vector<std::string>& DoubleLabels) const
151 {
152 IntLabels.resize(0);
153 DoubleLabels.resize(0);
154
155 return(0);
156 }
157
159 int GetLabels(std::vector<std::string>& IntLabels, std::vector<int>& IntLabelsData,
160 std::vector<std::string>& DoubleLabels, std::vector<double>& DoubleLabelsData) const
161 {
162 return(0);
163 }
164
166 int SetLabels(const std::vector<int>& IntLabelsData,
167 const std::vector<double>& DoubleLabelsData)
168 {
169 return(0);
170 }
171
173 int Pack(const int EID, int* IntData, double* DoubleData) const
174 {
175 DoubleData[0] = (*obj_)[EID];
176
177 return(0);
178 }
179
181 int UnPack(const int EID, int IntSize, int* IntData,
182 int DoubleSize, double* DoubleData)
183 {
184 (*obj_)[EID] = DoubleData[0];
185
186 return(0);
187 }
188
191 {
192 // do nothing here
193 return(0);
194 }
195
198 {
199 // do nothing here
200 return(0);
201 }
202
203 private:
204 Epetra_Vector* obj_;
205};
206
207} // namespace EpetraExt
208#endif
209#endif /* EPETRAEXT_HDF5_HANDLE_H */
int GetLabels(std::vector< std::string > &IntLabels, std::vector< std::string > &DoubleLabels) const
Packs all global information.
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.
std::string Type() const
Returns the identifier of the distributed object.
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.
int SetLabels(const std::vector< int > &IntLabelsData, const std::vector< double > &DoubleLabelsData)
Sets global information.
int NumMyElements() const
Returns the local number of elements.
int DoubleSize(const int EID) const
Returns the size of double data for local element EID.
int IntSize(const int EID) const
Returns the size of integer data for local element EID.
int Finalize()
Performs any finalization procedure after unpacking.
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 NumGlobalElements() const
Returns the global number of elements.
virtual int Finalize()=0
Performs any finalization procedure after unpacking.
virtual int NumGlobalElements() const =0
Returns the global number of elements.
virtual int IntSize(const int EID) const =0
Returns the size of integer data for local element EID.
virtual bool HasInt() const =0
virtual int DoubleSize(const int EID) const =0
Returns the size of double data for local element EID.
virtual int NumMyElements() const =0
Returns the local number of elements.
virtual std::string Type() const =0
Returns the identifier of the distributed object.
virtual bool HasDouble() const =0
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 int GetLabels(std::vector< std::string > &IntLabels, std::vector< int > &IntLabelsData, std::vector< std::string > &DoubleLabels, std::vector< double > &DoubleLabelsData) const =0
Packs all global information.
virtual int GetLabels(std::vector< std::string > &IntLabels, std::vector< std::string > &DoubleLabels) const =0
Packs all global information.
virtual int Pack(const int EID, int *IntData, double *DoubleData) const =0
Packs all data for local element EID in the specified arrays.
virtual int Initialize()=0
Performs any initialization procedure before unpacking.
virtual int SetLabels(const std::vector< int > &IntLabelsData, const std::vector< double > &DoubleLabelsData)=0
Sets global information.
int NumGlobalElements() const
int NumMyElements() const
const Epetra_BlockMap & Map() const
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.