Zoltan2  Version of the Day
Zoltan2_MeshInput.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 Vitus Leung (vjleung@sandia.gov)
39 //
40 // ***********************************************************************
41 //
42 // @HEADER
43 
49 #ifndef _ZOLTAN2_MESHINPUT_HPP_
50 #define _ZOLTAN2_MESHINPUT_HPP_
51 
52 #include <Zoltan2_InputAdapter.hpp>
54 
55 #include <string>
56 
57 namespace Zoltan2 {
58 
95 template <typename User>
96  class MeshInput : public InputAdapter {
97 private:
98 
99 public:
100 
101 #ifndef DOXYGEN_SHOULD_SKIP_THIS
102  typedef typename InputTraits<User>::scalar_t scalar_t;
103  typedef typename InputTraits<User>::lno_t lno_t;
104  typedef typename InputTraits<User>::gno_t gno_t;
105  typedef typename InputTraits<User>::gid_t gid_t;
106  typedef typename InputTraits<User>::node_t node_t;
107  typedef User user_t;
108 #endif
109 
111 
114  virtual ~MeshInput() {};
115 
116  enum entityType = {REGION, FACE, EDGE, VERTEX};
117 
120  virtual size_t getGlobalNumEntityIDs(entityType etype) const = 0;
121 
122 
125  virtual size_t getLocalNumEntityIDs(entityType etype) const = 0;
126 
127 
133  virtual int getNumWeightsPerEntityID(entityType etype) const = 0;
134 
135 
144  virtual size_t getLocalEntityIDsView(entityType etype,
145  gid_t const *&Ids) const = 0;
146 
147 
170  virtual size_t getLocalEntityIDsWeightsView(entityType etype,
171  const scalar_t *&weights, int &stride, int number) const = 0;
172 
173 
184  virtual size_t getEntityIDWeights(gid_t id, scalar_t *wgts) const = 0;
185 
186 
195  virtual int getEntityCoordinateDimension(entityType etype) const = 0;
196 
214  virtual size_t getLocalEntityCoordinatesView(entityType etype,
215  const scalar_t *&coords, int &stride, int coordDim) const = 0;
216 
217 
227  virtual size_t getEntityCoordinates(gid_t id, scalar_t *coords) const = 0;
228 
229 
232  virtual bool availAdjs(entityType source, entityType target);
233 
234 
240  virtual size_t getGlobalNumAdjs(entityType source,
241  entityType target) const = 0;
242 
243 
246  virtual size_t getLocalNumAdjs(entityType source,
247  entityType target) const = 0;
248 
249 
253  virtual size_t getEntityNumAdjs(entityType source, entityType target,
254  gid_t id) const = 0;
255 
256 
272  virtual size_t getLocalAdjsView(entityType source, entityType target,
273  const lno_t *&offsets, const gid_t *& adjacencyIds) const = 0;
274 
275 
283  virtual size_t getEntityAdjs(entityType source, entityType target,
284  gid_t id, gid_t *adjacencyIds) const = 0;
285 
286 
289  virtual bool avail2ndAdjs(entityType sourcetarget, entityType through);
290 
291 
296  virtual size_t getGlobalNum2ndAdjs(entityType sourcetarget,
297  entityType through) const = 0;
298 
299 
307  virtual size_t getLocalNum2ndAdjs(entityType sourcetarget,
308  entityType through) const = 0;
309 
310 
316  virtual lno_t getEntityNum2ndAdjs(entityType sourcetarget,
317  entityType through, gid_t id) const = 0;
318 
319 
335 // TODO: Later may allow user to not implement second adjacencies and, if we want them,
336 // TODO: we compute A^T A, where A is matrix of first adjacencies.
337  virtual size_t getLocal2ndAdjsView(entityType sourcetarget,
338  entityType through, const lno_t *&offsets,
339  const gid_t *& adjacencyIds) const = 0;
340 
341 
349  virtual size_t getEntity2ndAdjs(entityType sourcetarget,
350  entityType through, gid_t id, gid_t *nborIds) const = 0;
351 
352 
355  virtual int getNumWeightsPer2ndAdj(entityType sourcetarger,
356  entityType through) const = 0;
357 
358 
372  virtual size_t getLocal2ndAdjWeightsView(entityType sourcetarget,
373  entityType through, const scalar_t *&weights, int &stride,
374  int number) const = 0;
375 
376 
384  virtual size_t getEntity2ndAdjWeights(entityType sourcetarget,
385  entityType through, gid_t id, scalar_t *ewgts);
386 
387 
406  template <typename Adapter>
407  size_t applyPartitioningSolution(const User &in, User *&out,
408  const PartitioningSolution<Adapter> &solution) const
409  {
410  return 0;
411  }
412 
413 };
414 
415 } //namespace Zoltan2
416 
417 #endif
virtual size_t getGlobalNum2ndAdjs(entityType sourcetarget, entityType through) const =0
Return the global number of entity second adjacencies across all processes TODO: Do we need this func...
InputAdapter defines methods required by all InputAdapters.
virtual size_t getLocalNumAdjs(entityType source, entityType target) const =0
Returns the number of first adjacencies on this process.
virtual size_t getGlobalNumAdjs(entityType source, entityType target) const =0
Returns the global number of edges across all processes Need to define whether an undirected edge A<-...
virtual int getNumWeightsPerEntityID(entityType etype) const =0
Return the number of weights per entity.
virtual size_t getEntity2ndAdjWeights(entityType sourcetarget, entityType through, gid_t id, scalar_t *ewgts)
Copy the second adjacency weights incident to a specific entity id into array provided by Zoltan2...
virtual size_t getLocalNum2ndAdjs(entityType sourcetarget, entityType through) const =0
Returns the number of second adjacencies on this process.
virtual size_t getEntityIDWeights(gid_t id, scalar_t *wgts) const =0
Copy the weights for a specific entity into array provided by Zoltan2.
virtual bool avail2ndAdjs(entityType sourcetarget, entityType through)
Returns whether a second adjacency combination is available.
Defines the PartitioningSolution class.
Zoltan2::BasicUserTypes< scalar_t, gno_t, lno_t, gno_t > user_t
enum InputAdapterType inputAdapterType() const
Returns the type of adapter.
virtual bool availAdjs(entityType source, entityType target)
Returns whether a first adjacency combination is available.
Defines the InputAdapter interface.
virtual size_t getLocalEntityIDsView(entityType etype, gid_t const *&Ids) const =0
Provide a pointer to this process&#39; identifiers.
virtual size_t getLocal2ndAdjWeightsView(entityType sourcetarget, entityType through, const scalar_t *&weights, int &stride, int number) const =0
Provide a pointer to the second adjacency weights, if any.
InputAdapterType
An enum to identify general types of input adapters.
size_t applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Apply a partitioning problem solution to an input.
enum virtual entityType size_t getGlobalNumEntityIDs(entityType etype) const =0
Return the global number of IDs across all processes.
A PartitioningSolution is a solution to a partitioning problem.
virtual lno_t getEntityNum2ndAdjs(entityType sourcetarget, entityType through, gid_t id) const =0
Return number of second adjacencies to specific entity.
virtual size_t getEntityAdjs(entityType source, entityType target, gid_t id, gid_t *adjacencyIds) const =0
Copy all the first adjacency IDs for a specific entity into arrays provided by Zoltan2.
default_lno_t lno_t
The ordinal type (e.g., int, long, int64_t) that represents local counts and local indices...
default_gno_t gid_t
The data type that the user uses for global Identifiers.
virtual size_t getLocalNumEntityIDs(entityType etype) const =0
Returns the number of mesh entities on this process.
virtual size_t getEntityCoordinates(gid_t id, scalar_t *coords) const =0
Copy the coordinates for a specific ID into array provided by Zoltan2.
MeshInput defines the interface for mesh input adapters.
default_gno_t gno_t
The ordinal type (e.g., int, long, int64_t) that can represent global counts and identifiers.
virtual int getNumWeightsPer2ndAdj(entityType sourcetarger, entityType through) const =0
Returns the number (0 or greater) of weights per second adjacency.
virtual size_t getLocal2ndAdjsView(entityType sourcetarget, entityType through, const lno_t *&offsets, const gid_t *&adjacencyIds) const =0
Sets pointers to this process&#39; mesh second adjacencies.
virtual size_t getLocalAdjsView(entityType source, entityType target, const lno_t *&offsets, const gid_t *&adjacencyIds) const =0
Sets pointers to this process&#39; mesh first adjacencies.
virtual size_t getEntity2ndAdjs(entityType sourcetarget, entityType through, gid_t id, gid_t *nborIds) const =0
Copy the second adjacency IDs for all adjacencies incident to a specific entity into array provided b...
Kokkos::DefaultNode::DefaultNodeType node_t
The Kokkos node type. This is only meaningful for users of Tpetra objects.
virtual ~MeshInput()
Destructor.
virtual size_t getLocalEntityIDsWeightsView(entityType etype, const scalar_t *&weights, int &stride, int number) const =0
Provide a pointer to one of the number of this process&#39; optional entity weights.
default_scalar_t scalar_t
The data type for weights and coordinates.
virtual size_t getEntityNumAdjs(entityType source, entityType target, gid_t id) const =0
Returns the number of first adjacencies for this entity.
Kokkos::DefaultNode::DefaultNodeType node_t
virtual int getEntityCoordinateDimension(entityType etype) const =0
Return dimension of the entity coordinates, if any.
virtual size_t getLocalEntityCoordinatesView(entityType etype, const scalar_t *&coords, int &stride, int coordDim) const =0
Provide a pointer to one dimension of entity coordinates.