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);
88 typedef typename Adapter::gno_t gno_t;
89 typedef typename Adapter::lno_t lno_t;
92 size_t mynObj = adp->getLocalNumIDs();
94 const gno_t *myids = NULL;
95 adp->getIDsView(myids);
96 for (
size_t i = 0; i < mynObj; i++) {
97 ZOLTAN_ID_PTR idPtr = &(gids[i*nGidEnt]);
99 idPtr = &(lids[i*nLidEnt]);
104 int mywdim = adp->getNumWeightsPerID();
105 for (
int w = 0; w < wdim; w++) {
108 const typename Adapter::scalar_t *mywgts;
110 adp->getWeightsView(mywgts, mystride, w);
111 for (
size_t i = 0; i < mynObj; i++)
112 wgts[i*wdim+w] =
float(mywgts[i*mystride]);
116 for (
size_t i = 0; i < mynObj; i++)
125 template <
typename Adapter>
126 static void zoltanParts(
void *data,
int nGidEnt,
int nLidEnt,
int nObj,
127 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
128 int *parts,
int *ierr)
130 typedef typename Adapter::lno_t lno_t;
131 const Adapter *adp =
static_cast<Adapter *
>(data);
133 const typename Adapter::part_t *myparts;
134 adp->getPartsView(myparts);
136 for (
int i = 0; i < nObj; i++) {
139 parts[i] = int(myparts[lidx]);
145 template <
typename Adapter>
148 const Adapter *adp =
static_cast<Adapter *
>(data);
150 return adp->getDimension();
155 template <
typename Adapter>
156 static void zoltanGeom(
void *data,
int nGidEnt,
int nLidEnt,
int nObj,
157 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
158 int nDim,
double *coords,
int *ierr)
160 typedef typename Adapter::lno_t lno_t;
161 const Adapter *adp =
static_cast<Adapter *
>(data);
164 for (
int d = 0; d < nDim; d++) {
165 const typename Adapter::scalar_t *mycoords;
167 adp->getCoordinatesView(mycoords, mystride, d);
168 for (
int i = 0; i < nObj; i++) {
171 coords[i*nDim+d] = double(mycoords[lidx*mystride]);
185 template <
typename Adapter>
187 int *format,
int *ierr
191 typedef typename Adapter::user_t user_t;
199 *format = ZOLTAN_COMPRESSED_VERTEX;
203 *format = ZOLTAN_COMPRESSED_EDGE;
207 *format = ZOLTAN_COMPRESSED_EDGE;
211 *format = ZOLTAN_COMPRESSED_VERTEX;
216 *ierr = ZOLTAN_FATAL;
222 template <
typename Adapter>
224 int nPins,
int format,
225 ZOLTAN_ID_PTR listIds,
int *listIdx,
226 ZOLTAN_ID_PTR pinIds,
int *ierr
230 typedef typename Adapter::gno_t gno_t;
231 typedef typename Adapter::lno_t lno_t;
232 typedef typename Adapter::user_t user_t;
237 const lno_t *offsets;
245 catch (std::exception &e) {
246 *ierr = ZOLTAN_FATAL;
254 catch (std::exception &e) {
255 *ierr = ZOLTAN_FATAL;
260 *ierr = ZOLTAN_FATAL;
263 if (*ierr == ZOLTAN_OK) {
265 for (
int i=0; i < nLists; i++) {
266 ZOLTAN_ID_PTR idPtr = &(listIds[i*nGidEnt]);
268 listIdx[i] = Teuchos::as<int>(offsets[i]);
270 listIdx[nLists] = Teuchos::as<int>(offsets[nLists]);
271 for (
int i=0; i < nPins; i++) {
272 ZOLTAN_ID_PTR idPtr = &(pinIds[i*nGidEnt]);
293 template <
typename Adapter>
295 int *format,
int *ierr
299 typedef typename Adapter::user_t user_t;
307 *format = ZOLTAN_COMPRESSED_VERTEX;
315 *format = ZOLTAN_COMPRESSED_EDGE;
320 *format = -1*ZOLTAN_COMPRESSED_VERTEX;
321 *ierr = ZOLTAN_FATAL;
327 template <
typename Adapter>
329 void *data,
int nGidEnt,
int nLists,
int nPins,
330 int format, ZOLTAN_ID_PTR listIds,
331 int *listIdx, ZOLTAN_ID_PTR pinIds,
int *ierr
335 typedef typename Adapter::gno_t gno_t;
336 typedef typename Adapter::lno_t lno_t;
337 typedef typename Adapter::user_t user_t;
342 if (format == ZOLTAN_COMPRESSED_VERTEX)
347 else if (format == ZOLTAN_COMPRESSED_EDGE)
353 *ierr = ZOLTAN_FATAL;
356 if (*ierr == ZOLTAN_OK) {
363 catch (std::exception &e) {
364 *ierr = ZOLTAN_FATAL;
368 const lno_t* offsets;
371 madp->
getAdjsView(listType, pinType, offsets, adjIds);
373 catch (std::exception &e) {
374 *ierr = ZOLTAN_FATAL;
378 for (
int i=0; i < nLists; i++) {
379 ZOLTAN_ID_PTR idPtr = &(listIds[i*nGidEnt]);
381 listIdx[i] = Teuchos::as<int>(offsets[i]);
383 listIdx[nLists] = Teuchos::as<int>(offsets[nLists]);
384 for (
int i=0; i < nPins; i++) {
385 ZOLTAN_ID_PTR idPtr = &(pinIds[i*nGidEnt]);
397 template <
typename Adapter>
407 template <
typename Adapter>
409 ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids,
410 int wdim,
float *wgts,
int *ierr)
414 typedef typename Adapter::gno_t gno_t;
415 typedef typename Adapter::lno_t lno_t;
416 typedef typename Adapter::scalar_t scalar_t;
420 ArrayView<const gno_t> Ids;
421 ArrayView<input_t> model_wgts;
423 ArrayView<bool> isOwner;
426 for (
size_t i=0;i<num_verts;i++) {
428 ZOLTAN_ID_PTR idPtr = &(gids[j*nGidEnt]);
430 idPtr = &(lids[j*nLidEnt]);
437 for (
int w = 0; w < wdim; w++) {
440 for (
size_t i = 0; i < num_verts; i++) {
442 wgts[j*wdim+w] = float(model_wgts[w][i]);
449 for (
size_t i = 0; i < num_verts; i++) {
462 template <
typename Adapter>
464 int *format,
int *ierr
473 *format = ZOLTAN_COMPRESSED_EDGE;
475 *format = ZOLTAN_COMPRESSED_VERTEX;
480 template <
typename Adapter>
482 int format, ZOLTAN_ID_PTR edgeIds,
483 int *edgeIdx, ZOLTAN_ID_PTR pinIds,
int *ierr
489 typedef typename Adapter::gno_t gno_t;
490 typedef typename Adapter::lno_t lno_t;
491 typedef typename Adapter::scalar_t scalar_t;
494 ArrayView<const gno_t> Ids;
495 ArrayView<input_t> wgts;
497 ArrayView<const gno_t> pinIds_;
498 ArrayView<const lno_t> offsets;
499 ArrayView<input_t> pin_wgts;
501 for (
int i=0;i<nEdges;i++) {
502 ZOLTAN_ID_PTR idPtr = &(edgeIds[i*nGidEnt]);
504 edgeIdx[i] = Teuchos::as<int>(offsets[i]);
507 for (
int i=0;i<nPins;i++) {
508 ZOLTAN_ID_PTR idPtr = &(pinIds[i*nGidEnt]);
static void zoltanHGCS_withModel(void *data, int nGidEnt, int nEdges, int nPins, int format, ZOLTAN_ID_PTR edgeIds, int *edgeIdx, ZOLTAN_ID_PTR pinIds, int *ierr)
static int zoltanNumGeom(void *data, int *ierr)
virtual bool availAdjs(MeshEntityType source, MeshEntityType target) const
Returns whether a first adjacency combination is available.
MatrixAdapter defines the adapter interface for matrices.
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 MatrixEntityType getPrimaryEntityType() const
Returns the entity to be partitioned, ordered, colored, etc. Valid values are MATRIX_ROW, MATRIX_COLUMN, MATRIX_NONZERO.
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 void zoltanHGCS_withMeshAdapter(void *data, int nGidEnt, int nLists, int nPins, int format, ZOLTAN_ID_PTR listIds, int *listIdx, ZOLTAN_ID_PTR pinIds, 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.
virtual size_t getLocalNumColumns() const =0
Returns the number of columns on this process.
virtual void getCRSView(const lno_t *&offsets, const gno_t *&colIds) const
Sets pointers to this process' matrix entries using compressed sparse row (CRS) format. All matrix adapters must implement either getCRSView or getCCSView, but implementation of both is not required.
virtual void getIDsViewOf(MeshEntityType etype, gno_t const *&Ids) const =0
Provide a pointer to this process' identifiers.
static void zoltanHGCS_withMatrixAdapter(void *data, int nGidEnt, int nLists, int nPins, int format, ZOLTAN_ID_PTR listIds, int *listIdx, ZOLTAN_ID_PTR pinIds, int *ierr)
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 zoltanHGSizeCS_withModel(void *data, int *nEdges, int *nPins, int *format, int *ierr)
virtual bool CCSViewAvailable() const
Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse column (CCS)...
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.
static int zoltanHGNumObj_withModel(void *data, int *ierr)
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 void zoltanParts(void *data, int nGidEnt, int nLidEnt, int nObj, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int *parts, int *ierr)
virtual void getCCSView(const lno_t *&offsets, const gno_t *&rowIds) const
Sets pointers to this process' matrix entries using compressed sparse column (CCS) format...
static void zoltanHGSizeCS_withMeshAdapter(void *data, int *nLists, int *nPins, int *format, int *ierr)
static void zoltanHGObjList_withModel(void *data, int nGidEnt, int nLidEnt, ZOLTAN_ID_PTR gids, ZOLTAN_ID_PTR lids, int wdim, float *wgts, int *ierr)
Defines the HyperGraphModel interface.
MeshEntityType
Enumerate entity types for meshes: Regions, Faces, Edges, or Vertices.
Defines the MatrixAdapter interface.
static void ASSIGN_TPL_T(tpl_t &a, zno_t b)
Defines the GraphAdapter interface.
virtual void getRowIDsView(const gno_t *&rowIds) const
Sets pointer to this process' rows' global IDs.
virtual bool CRSViewAvailable() const
Indicates whether the MatrixAdapter implements a view of the matrix in compressed sparse row (CRS) fo...
static void zoltanHGSizeCS_withMatrixAdapter(void *data, int *nLists, int *nPins, int *format, int *ierr)
virtual size_t getLocalNumRows() const =0
Returns the number of rows on this process.
virtual size_t getLocalNumEntries() const =0
Returns the number of nonzeros on this process.
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.
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.
virtual void getColumnIDsView(const gno_t *&colIds) const
Sets pointer to this process' columns' global IDs.