45 #ifndef _ZOLTAN2_ALGZOLTANCALLBACKS_HPP_ 46 #define _ZOLTAN2_ALGZOLTANCALLBACKS_HPP_ 58 #include <zoltan_cpp.h> 73 template <
typename Adapter>
75 const Adapter *adp =
static_cast<Adapter *
>(data);
77 return int(adp->getLocalNumIDs());
82 template <
typename Adapter>
84 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
85 int wdim,
float *wgts,
int *ierr)
87 const Adapter *adp =
static_cast<Adapter *
>(data);
90 size_t mynObj = adp->getLocalNumIDs();
92 const typename Adapter::gno_t *myids = NULL;
93 adp->getIDsView(myids);
94 for (
size_t i = 0; i < mynObj; i++) {
95 gids[i] = ZOLTAN_ID_TYPE(myids[i]);
96 lids[i] = ZOLTAN_ID_TYPE(i);
100 int mywdim = adp->getNumWeightsPerID();
101 for (
int w = 0; w < wdim; w++) {
104 const typename Adapter::scalar_t *mywgts;
106 adp->getWeightsView(mywgts, mystride, w);
107 for (
size_t i = 0; i < mynObj; i++)
108 wgts[i*wdim+w] =
float(mywgts[i*mystride]);
112 for (
size_t i = 0; i < mynObj; i++)
121 template <
typename Adapter>
122 static void zoltanParts(
void *data,
int nGidEnt,
int nLidEnt,
int nObj,
123 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
124 int *parts,
int *ierr)
126 const Adapter *adp =
static_cast<Adapter *
>(data);
128 const typename Adapter::part_t *myparts;
129 adp->getPartsView(myparts);
131 for (
int i = 0; i < nObj; i++)
132 parts[i] =
int(myparts[lids[i]]);
137 template <
typename Adapter>
140 const Adapter *adp =
static_cast<Adapter *
>(data);
142 return adp->getDimension();
147 template <
typename Adapter>
148 static void zoltanGeom(
void *data,
int nGidEnt,
int nLidEnt,
int nObj,
149 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
150 int nDim,
double *coords,
int *ierr)
152 const Adapter *adp =
static_cast<Adapter *
>(data);
155 for (
int d = 0; d < nDim; d++) {
156 const typename Adapter::scalar_t *mycoords;
158 adp->getCoordinatesView(mycoords, mystride, d);
159 for (
int i = 0; i < nObj; i++)
160 coords[i*nDim+d] =
double(mycoords[lids[i]*mystride]);
170 template <
typename Adapter>
172 void *data,
int *nEdges,
int *nPins,
173 int *format,
int *ierr
176 std::cout <<
"HELLO FROM HGSizeCS with MATRIX ADAPTER" << std::endl;
177 *ierr = ZOLTAN_FATAL;
182 template <
typename Adapter>
184 void *data,
int nGidEnt,
int nEdges,
int nPins,
185 int format, ZOLTAN_ID_PTR edgeIds,
186 int *edgeIdx, ZOLTAN_ID_PTR pinIds,
int *ierr
189 std::cout <<
"HELLO FROM HGCS with MATRIX ADAPTER" << std::endl;
190 *ierr = ZOLTAN_FATAL;
203 template <
typename Adapter>
212 template <
typename Adapter>
214 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
215 int wdim,
float *wgts,
int *ierr)
218 typedef typename Adapter::gno_t gno_t;
219 typedef typename Adapter::lno_t lno_t;
220 typedef typename Adapter::scalar_t scalar_t;
224 ArrayView<const gno_t> Ids;
225 ArrayView<input_t> model_wgts;
227 ArrayView<bool> isOwner;
230 for (
size_t i=0;i<num_verts;i++) {
239 for (
int w = 0; w < wdim; w++) {
242 for (
size_t i = 0; i < num_verts; i++) {
244 wgts[j*wdim+w] = float(model_wgts[w][i]);
251 for (
size_t i = 0; i < num_verts; i++) {
264 template <
typename Adapter>
266 void *data,
int *nEdges,
int *nPins,
267 int *format,
int *ierr
275 *format = ZOLTAN_COMPRESSED_EDGE;
277 *format = ZOLTAN_COMPRESSED_VERTEX;
282 template <
typename Adapter>
284 void *data,
int nGidEnt,
int nEdges,
int nPins,
285 int format, ZOLTAN_ID_PTR edgeIds,
286 int *edgeIdx, ZOLTAN_ID_PTR pinIds,
int *ierr
291 typedef typename Adapter::gno_t gno_t;
292 typedef typename Adapter::lno_t lno_t;
293 typedef typename Adapter::scalar_t scalar_t;
296 ArrayView<const gno_t> Ids;
297 ArrayView<input_t> wgts;
299 ArrayView<const gno_t> pinIds_;
300 ArrayView<const lno_t> offsets;
301 ArrayView<input_t> pin_wgts;
303 for (
int i=0;i<nEdges;i++) {
305 edgeIdx[i]=offsets[i];
308 for (
int i=0;i<nPins;i++)
309 pinIds[i] = pinIds_[i];
318 template <
typename Adapter>
320 void *data,
int *nEdges,
int *nPins,
321 int *format,
int *ierr
325 typedef typename Adapter::user_t user_t;
329 *format = ZOLTAN_COMPRESSED_EDGE;
334 template <
typename Adapter>
336 void *data,
int nGidEnt,
int nEdges,
int nPins,
337 int format, ZOLTAN_ID_PTR edgeIds,
338 int *edgeIdx, ZOLTAN_ID_PTR pinIds,
int *ierr
342 typedef typename Adapter::gno_t gno_t;
343 typedef typename Adapter::lno_t lno_t;
344 typedef typename Adapter::user_t user_t;
348 const lno_t* offsets;
352 for (
int i=0;i<nEdges;i++) {
354 edgeIdx[i]=offsets[i];
356 for (
int i=0;i<nPins;i++)
357 pinIds[i] = adjIds[i];
static int zoltanNumGeom(void *data, int *ierr)
static void zoltanHGCSForMeshAdapter(void *data, int nGidEnt, int nEdges, int nPins, int format, ZOLTAN_ID_PTR edgeIds, int *edgeIdx, ZOLTAN_ID_PTR pinIds, int *ierr)
static void zoltanHGModelCSForMeshAdapter(void *data, int nGidEnt, int nEdges, int nPins, int format, ZOLTAN_ID_PTR edgeIds, int *edgeIdx, ZOLTAN_ID_PTR pinIds, int *ierr)
Defines the MeshAdapter interface.
CentricView getCentricView() const
Returns the centric view of the hypergraph.
MeshAdapter defines the interface for mesh input.
virtual size_t getLocalNumOf(MeshEntityType etype) const =0
Returns the global number of mesh entities of MeshEntityType.
size_t getPinList(ArrayView< const gno_t > &pinIds, ArrayView< const lno_t > &offsets, ArrayView< input_t > &wgts) const
Sets pointers to this process' pins global Ids based on the centric view given by getCentricView() ...
Defines the IdentifierAdapter interface.
Defines the VectorAdapter interface.
enum MeshEntityType getAdjacencyEntityType() const
Returns the entity that describes adjacencies between the entities to be partitioned, ordered, colored, etc. That is, a primaryEntityType that contains an adjacencyEntityType are adjacent.
static void zoltanObjList(void *data, int nGidEnt, int nLidEnt, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int wdim, float *wgts, int *ierr)
static int zoltanNumObj(void *data, int *ierr)
size_t getOwnedList(ArrayView< bool > &isOwner) const
Sets pointer to the ownership of this processes vertices.
static void zoltanHGModelSizeCSForMeshAdapter(void *data, int *nEdges, int *nPins, int *format, int *ierr)
virtual void getIDsViewOf(MeshEntityType etype, gno_t const *&Ids) const =0
Provide a pointer to this process' identifiers.
size_t getEdgeList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
Sets pointers to this process' hyperedge Ids and their weights.
static void zoltanGeom(void *data, int nGidEnt, int nLidEnt, int nObj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int nDim, double *coords, int *ierr)
size_t getLocalNumHyperEdges() const
Returns the number of hyper edges on this process. These are all hyper edges that have an adjacency t...
virtual size_t getLocalNumAdjs(MeshEntityType source, MeshEntityType target) const
Returns the number of first adjacencies on this process.
The StridedData class manages lists of weights or coordinates.
virtual void getAdjsView(MeshEntityType source, MeshEntityType target, const lno_t *&offsets, const gno_t *&adjacencyIds) const
Sets pointers to this process' mesh first adjacencies.
size_t getLocalNumPins() const
Returns the local number of pins.
size_t getVertexList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
Sets pointers to this process' vertex Ids and their weights.
Traits class to handle conversions between gno_t/lno_t and TPL data types (e.g., ParMETIS's idx_t...
static int zoltanHGModelNumObj(void *data, int *ierr)
static void zoltanParts(void *data, int nGidEnt, int nLidEnt, int nObj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int *parts, int *ierr)
static void zoltanHGSizeCSForMeshAdapter(void *data, int *nEdges, int *nPins, int *format, int *ierr)
static void zoltanHGCSForMatrixAdapter(void *data, int nGidEnt, int nEdges, int nPins, int format, ZOLTAN_ID_PTR edgeIds, int *edgeIdx, ZOLTAN_ID_PTR pinIds, int *ierr)
static void zoltanHGModelObjList(void *data, int nGidEnt, int nLidEnt, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int wdim, float *wgts, int *ierr)
Defines the HyperGraphModel interface.
Defines the MatrixAdapter interface.
Defines the GraphAdapter interface.
A gathering of useful namespace methods.
HyperGraphModel defines the interface required for hyper graph models.
enum MeshEntityType getPrimaryEntityType() const
Returns the entity to be partitioned, ordered, colored, etc.
static void zoltanHGSizeCSForMatrixAdapter(void *data, int *nEdges, int *nPins, int *format, int *ierr)
int getNumWeightsPerVertex() const
Returns the number (0 or greater) of weights per vertex.
size_t getLocalNumOwnedVertices() const
Returns the number vertices on this process that are owned.