Zoltan | Things to Remember
Thu Sep 15 2022
// Partition Interface
int Zoltan_LB_Partition (
struct Zoltan_Struct *zz,
int *changes,
int *num_gid_entries,
int *num_lid_entries,
int *num_import,
ZOLTAN_ID_PTR *import_global_ids,
ZOLTAN_ID_PTR *import_local_ids,
int **import_procs,
int **import_to_part,
int *num_export,
ZOLTAN_ID_PTR *export_global_ids,
ZOLTAN_ID_PTR *export_local_ids,
int **export_procs,
int **export_to_part);
#include "zoltan.h"
/* Application data type for particle simulation. */
struct Particle {
int id;
double x, y, z;
/* ... solution values, etc. ... */
};
/* Return coordinates for objects requested by Zoltan in globalIDs array. */
void user_geom_multi_fn(void *data, int nge, int nle, int numObj,
ZOLTAN_ID_PTR globalIDs, ZOLTAN_ID_PTR localIDs,
int dim, double *geomVec, int *err)
{
/* Cast data pointer provided in Zoltan_Set_Fn to application data type. */
/* Application data is an array of Particle structures. */
struct Particle *user_particles = (struct Particle *) data;
/* Assume for this example that each globalID and localID is one integer. */
/* Each globalID is a global particle number; each localID is an index */
/* into the user’s array of Particles. */
if (nge != 1 || nle != 1) {*err = ZOLTAN_FATAL; return;}
/* Loop over objects for which coordinates are requested */
int i, j = 0;
for (i = 0; i < numObj; i++) {
/* Copy the coordinates for the object globalID[i] (with localID[i]) */
/* into the geomVec vector. Note that Zoltan allocates geomVec. */
geomVec[j++] = user_particles[localIDs[i]].x;
if (dim > 1) geomVec[j++] = user_particles[localIDs[i]].y;
if (dim > 2) geomVec[j++] = user_particles[localIDs[i]].z;
}
*err = ZOLTAN_OK;
}