Zoltan2  Version of the Day
Zoltan2_InputAdapter.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Zoltan2: A package of combinatorial algorithms for scientific computing
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Karen Devine (kddevin@sandia.gov)
39 // Erik Boman (egboman@sandia.gov)
40 // Siva Rajamanickam (srajama@sandia.gov)
41 //
42 // ***********************************************************************
43 //
44 // @HEADER
45 
50 #ifndef _ZOLTAN2_INPUTADAPTER_HPP_
51 #define _ZOLTAN2_INPUTADAPTER_HPP_
52 
53 #include <Zoltan2_Standards.hpp>
54 #include <Zoltan2_InputTraits.hpp>
55 
56 namespace Zoltan2 {
57 
70 };
71 
72 
83 template <typename User>
84  class InputAdapter {
85 
86 private:
87 
88  typedef typename InputTraits<User>::scalar_t scalar_t;
89 
90 public:
91 
94  virtual enum InputAdapterType inputAdapterType()const = 0;
95 
98  virtual ~InputAdapter() {};
99 
102  virtual string inputAdapterName() const = 0;
103 
109  virtual size_t getLocalNumberOfObjects() const = 0;
110 
115  virtual int getNumberOfWeightsPerObject() const = 0;
116 
125  virtual size_t getObjectWeights(int dim, const scalar_t *&wgt,
126  int &stride) const = 0;
127 
130  static string inputAdapterTypeName(InputAdapterType iaType);
131 };
132 
133 template <typename User>
135 {
136  string typeName;
137  switch (iaType){
138  case InvalidAdapterType:
139  typeName = string("invalid");
140  break;
142  typeName = string("identifier");
143  break;
144  case VectorAdapterType:
145  typeName = string("vector");
146  break;
148  typeName = string("coordinate");
149  break;
150  case GraphAdapterType:
151  typeName = string("graph");
152  break;
153  case MeshAdapterType:
154  typeName = string("mesh");
155  break;
156  case MatrixAdapterType:
157  typeName = string("matrix");
158  break;
159  default:
160  typeName = string("unknown");
161  break;
162  }
163 
164  return typeName;
165 }
166 
167 
168 } //namespace Zoltan2
169 
170 #endif
InputAdapter defines methods required by all InputAdapters.
virtual enum InputAdapterType inputAdapterType() const =0
Returns the type of adapter.
virtual size_t getObjectWeights(int dim, const scalar_t *&wgt, int &stride) const =0
Provide pointer to a weight array with stride.
virtual int getNumberOfWeightsPerObject() const =0
Returns the number of weights per object. Number of weights per object should be zero or greater...
virtual ~InputAdapter()
Desstructor.
InputAdapterType
An enum to identify general types of input adapters.
static string inputAdapterTypeName(InputAdapterType iaType)
Returns the name of the input adapter.
Traits for application input objects.
double scalar_t
virtual size_t getLocalNumberOfObjects() const =0
Returns the number of objects in the input.
Gathering definitions used in software development.
virtual string inputAdapterName() const =0
Returns a descriptive name that identifies the concrete adapter.
plain identifier input, just a list of Ids
default_scalar_t scalar_t
The data type for weights and coordinates.