Timothy  0.9
Tissue Modelling Framework
 All Data Structures Files Functions Variables Typedefs Macros
domdec.c File Reference

contains domain decomposition functions More...

#include <stdio.h>
#include <stdlib.h>
#include "global.h"
Include dependency graph for domdec.c:

Go to the source code of this file.

Functions

int ztnReturnDimension (void *data, int *ierr)
 
void ztnReturnCoords (void *data, int numGidEntries, int numLidEntries, ZOLTAN_ID_PTR globalId, ZOLTAN_ID_PTR localId, double *geomVec, int *ierr)
 
int ztnReturnNumNode (void *data, int *ierr)
 
void ztnReturnOwnedNodes (void *data, int numGIdEntries, int numLIdEntries, ZOLTAN_ID_PTR globalIds, ZOLTAN_ID_PTR localIds, int wgtDim, float *objWgts, int *ierr)
 
int ztnReturnParticleDataSize (void *data, int numGIdEntries, int numLIdEntries, ZOLTAN_ID_PTR globalId, ZOLTAN_ID_PTR localId, int *ierr)
 
void ztnPack (void *data, int numGIdEntries, int numLIdEntries, ZOLTAN_ID_PTR globalId, ZOLTAN_ID_PTR localId, int dest, int size, char *buf, int *ierr)
 
void ztnPre (void *data, int numGIdEntries, int numLIdEntries, int numImport, ZOLTAN_ID_PTR importGlobalIds, ZOLTAN_ID_PTR importLocalIds, int *importProcs, int *importToPart, int numExport, ZOLTAN_ID_PTR exportGlobalIds, ZOLTAN_ID_PTR exportLocalIds, int *exportProcs, int *exportToPart, int *ierr)
 
void ztnMid (void *data, int numGIdEntries, int numLIdEntries, int numImport, ZOLTAN_ID_PTR importGlobalIds, ZOLTAN_ID_PTR importLocalIds, int *importProcs, int *importToPart, int numExport, ZOLTAN_ID_PTR exportGlobalIds, ZOLTAN_ID_PTR exportLocalIds, int *exportProcs, int *exportToPart, int *ierr)
 
void ztnPost (void *data, int numGIdEntries, int numLIdEntries, int numImport, ZOLTAN_ID_PTR importGlobalIds, ZOLTAN_ID_PTR importLocalIds, int *importProcs, int *importToPart, int numExport, ZOLTAN_ID_PTR exportGlobalIds, ZOLTAN_ID_PTR exportLocalIds, int *exportProcs, int *exportToPart, int *ierr)
 
void ztnUnpack (void *data, int numGIdEntries, ZOLTAN_ID_PTR globalId, int size, char *buf, int *ierr)
 
void decompositionInit (int argc, char **argv, MPI_Comm Comm)
 
void decompositionExecute ()
 
void decompositionFinalize ()
 

Variables

int changes
 
int numGidEntries
 
int numLidEntries
 
int numImport
 
ZOLTAN_ID_PTR importGlobalGids
 
ZOLTAN_ID_PTR importLocalGids
 
int * importProcs
 
int * importToPart
 
int numExport
 
ZOLTAN_ID_PTR exportGlobalGids
 
ZOLTAN_ID_PTR exportLocalGids
 
int * exportProcs
 
int * exportToPart
 

Detailed Description

contains domain decomposition functions

Definition in file domdec.c.

Function Documentation

void decompositionExecute ( )

This function calls the Zoltan's domain decomposition and migration functions. It is called at the beginning of each simulation step.

Definition at line 240 of file domdec.c.

References changes, exportGlobalGids, exportLocalGids, exportProcs, exportToPart, importGlobalGids, importLocalGids, importProcs, importToPart, MPIsize, nc, numExport, numGidEntries, numImport, numLidEntries, stopRun(), and ztn.

241 {
242  int rc;
243  int i;
244 
245  if (nc < MPIsize)
246  return;
247 
248  rc = Zoltan_LB_Partition(ztn, /* input (all remaining fields are output) */
249  &changes, /* 1 if partitioning was changed, 0 otherwise */
250  &numGidEntries, /* number of integers used for a global ID */
251  &numLidEntries, /* number of integers used for a local ID */
252  &numImport, /* number of objects to be sent to me */
253  &importGlobalGids, /* global IDs of objects to be sent to me */
254  &importLocalGids, /* local IDs of objects to be sent to me */
255  &importProcs, /* process rank for source of each incoming object */
256  &importToPart, /* new partition for each incoming object */
257  &numExport, /* number of objects I must send to other processes */
258  &exportGlobalGids, /* global IDs of the objects I must send */
259  &exportLocalGids, /* local IDs of the objects I must send */
260  &exportProcs, /* process to which I send each of the objects */
261  &exportToPart); /* partition to which each object will belong */
262 
263  if (rc != ZOLTAN_OK)
264  stopRun(112, NULL, __FILE__, __LINE__);
265 
266  /* free the arrays allocated by Zoltan_LB_Partiotion */
267  Zoltan_LB_Free_Part(&importGlobalGids, &importLocalGids, &importProcs,
268  &importToPart);
269  Zoltan_LB_Free_Part(&exportGlobalGids, &exportLocalGids, &exportProcs,
270  &exportToPart);
271 }
ZOLTAN_ID_PTR exportGlobalGids
Definition: domdec.c:42
int MPIsize
Definition: global.h:135
ZOLTAN_ID_PTR importGlobalGids
Definition: domdec.c:37
ZOLTAN_ID_PTR importLocalGids
Definition: domdec.c:38
struct Zoltan_Struct * ztn
Definition: global.h:146
int numGidEntries
Definition: domdec.c:34
int changes
Definition: domdec.c:33
ZOLTAN_ID_PTR exportLocalGids
Definition: domdec.c:43
int * importProcs
Definition: domdec.c:39
int numLidEntries
Definition: domdec.c:35
int * importToPart
Definition: domdec.c:40
int numImport
Definition: domdec.c:36
#define nc
Definition: global.h:93
int * exportProcs
Definition: domdec.c:44
int numExport
Definition: domdec.c:41
void stopRun(int ierr, char *name, char *file, int line)
Definition: utils.c:72
int * exportToPart
Definition: domdec.c:45

Here is the call graph for this function:

Here is the caller graph for this function:

void decompositionFinalize ( )

This function deactivates the Zoltan library. It is called at the end of the simulation.

Definition at line 277 of file domdec.c.

References ztn.

278 {
279  Zoltan_Destroy(&ztn);
280 }
struct Zoltan_Struct * ztn
Definition: global.h:146

Here is the caller graph for this function:

void decompositionInit ( int  argc,
char **  argv,
MPI_Comm  Comm 
)

This function initializes the Zoltan library. It is called at the beginning of the simulation.

Definition at line 191 of file domdec.c.

References cells, MPIrank, stopRun(), ztn, ztnMid(), ztnPack(), ztnPost(), ztnPre(), ztnReturnCoords(), ztnReturnDimension(), ztnReturnNumNode(), ztnReturnOwnedNodes(), ztnReturnParticleDataSize(), and ztnUnpack().

192 {
193  int rc;
194  float version;
195 
196  rc = Zoltan_Initialize(argc, argv, &version);
197  if (rc != ZOLTAN_OK)
198  stopRun(112, NULL, __FILE__, __LINE__);
199 
200  if (MPIrank == 0)
201  printf("Zoltan Version %.3f. Initialized.\n", version);
202 
203  ztn = Zoltan_Create(MPI_COMM_WORLD);
204 
205  Zoltan_Set_Param(ztn, "IMBALANCE_TOL", "2.0");
206  Zoltan_Set_Param(ztn, "LB_METHOD", "HSFC"); /* Hilbert Space-Filling Curve Partitioning */
207  Zoltan_Set_Param(ztn, "NUM_GID_ENTRIES", "1"); /* global ID is 1 integer */
208  Zoltan_Set_Param(ztn, "NUM_LID_ENTRIES", "1"); /* local ID is 1 integer */
209  Zoltan_Set_Param(ztn, "OBJ_WEIGHT_DIM", "1"); /* we use object weights */
210  Zoltan_Set_Param(ztn, "DEBUG_LEVEL", "0"); /* quiet mode; no output unless an error or warning is produced */
211  Zoltan_Set_Param(ztn, "KEEP_CUTS", "1"); /* save the cuts for later use */
212  Zoltan_Set_Param(ztn, "AUTO_MIGRATE", "1"); /* use the auto migration mechanism */
213 
214  Zoltan_Set_Fn(ztn, ZOLTAN_NUM_GEOM_FN_TYPE,
215  (void (*)()) ztnReturnDimension, cells);
216  Zoltan_Set_Fn(ztn, ZOLTAN_GEOM_FN_TYPE, (void (*)()) ztnReturnCoords,
217  cells);
218  Zoltan_Set_Fn(ztn, ZOLTAN_NUM_OBJ_FN_TYPE, (void (*)()) ztnReturnNumNode,
219  cells);
220  Zoltan_Set_Fn(ztn, ZOLTAN_OBJ_LIST_FN_TYPE,
221  (void (*)()) ztnReturnOwnedNodes, cells);
222  Zoltan_Set_Fn(ztn, ZOLTAN_OBJ_SIZE_FN_TYPE,
223  (void (*)()) ztnReturnParticleDataSize, cells);
224  Zoltan_Set_Fn(ztn, ZOLTAN_PACK_OBJ_FN_TYPE, (void (*)()) ztnPack, cells);
225  Zoltan_Set_Fn(ztn, ZOLTAN_UNPACK_OBJ_FN_TYPE, (void (*)()) ztnUnpack,
226  cells);
227  Zoltan_Set_Fn(ztn, ZOLTAN_PRE_MIGRATE_PP_FN_TYPE, (void (*)()) ztnPre,
228  cells);
229  Zoltan_Set_Fn(ztn, ZOLTAN_MID_MIGRATE_PP_FN_TYPE, (void (*)()) ztnMid,
230  cells);
231  Zoltan_Set_Fn(ztn, ZOLTAN_POST_MIGRATE_PP_FN_TYPE, (void (*)()) ztnPost,
232  cells);
233 
234 }
int MPIrank
Definition: global.h:134
void ztnReturnCoords(void *data, int numGidEntries, int numLidEntries, ZOLTAN_ID_PTR globalId, ZOLTAN_ID_PTR localId, double *geomVec, int *ierr)
Definition: domdec.c:61
struct Zoltan_Struct * ztn
Definition: global.h:146
void ztnPack(void *data, int numGIdEntries, int numLIdEntries, ZOLTAN_ID_PTR globalId, ZOLTAN_ID_PTR localId, int dest, int size, char *buf, int *ierr)
Definition: domdec.c:115
int ztnReturnParticleDataSize(void *data, int numGIdEntries, int numLIdEntries, ZOLTAN_ID_PTR globalId, ZOLTAN_ID_PTR localId, int *ierr)
Definition: domdec.c:105
int ztnReturnDimension(void *data, int *ierr)
Definition: domdec.c:50
struct cellData * cells
Definition: global.h:82
void ztnUnpack(void *data, int numGIdEntries, ZOLTAN_ID_PTR globalId, int size, char *buf, int *ierr)
Definition: domdec.c:179
void ztnReturnOwnedNodes(void *data, int numGIdEntries, int numLIdEntries, ZOLTAN_ID_PTR globalIds, ZOLTAN_ID_PTR localIds, int wgtDim, float *objWgts, int *ierr)
Definition: domdec.c:87
void ztnPre(void *data, int numGIdEntries, int numLIdEntries, int numImport, ZOLTAN_ID_PTR importGlobalIds, ZOLTAN_ID_PTR importLocalIds, int *importProcs, int *importToPart, int numExport, ZOLTAN_ID_PTR exportGlobalIds, ZOLTAN_ID_PTR exportLocalIds, int *exportProcs, int *exportToPart, int *ierr)
Definition: domdec.c:127
void ztnPost(void *data, int numGIdEntries, int numLIdEntries, int numImport, ZOLTAN_ID_PTR importGlobalIds, ZOLTAN_ID_PTR importLocalIds, int *importProcs, int *importToPart, int numExport, ZOLTAN_ID_PTR exportGlobalIds, ZOLTAN_ID_PTR exportLocalIds, int *exportProcs, int *exportToPart, int *ierr)
Definition: domdec.c:163
void stopRun(int ierr, char *name, char *file, int line)
Definition: utils.c:72
void ztnMid(void *data, int numGIdEntries, int numLIdEntries, int numImport, ZOLTAN_ID_PTR importGlobalIds, ZOLTAN_ID_PTR importLocalIds, int *importProcs, int *importToPart, int numExport, ZOLTAN_ID_PTR exportGlobalIds, ZOLTAN_ID_PTR exportLocalIds, int *exportProcs, int *exportToPart, int *ierr)
Definition: domdec.c:140
int ztnReturnNumNode(void *data, int *ierr)
Definition: domdec.c:79

Here is the call graph for this function:

Here is the caller graph for this function:

void ztnMid ( void *  data,
int  numGIdEntries,
int  numLIdEntries,
int  numImport,
ZOLTAN_ID_PTR  importGlobalIds,
ZOLTAN_ID_PTR  importLocalIds,
int *  importProcs,
int *  importToPart,
int  numExport,
ZOLTAN_ID_PTR  exportGlobalIds,
ZOLTAN_ID_PTR  exportLocalIds,
int *  exportProcs,
int *  exportToPart,
int *  ierr 
)

Zoltan callback function. This function is executed after packing of send buffer and unpacking of receive buffer during migration.

Definition at line 140 of file domdec.c.

References cellData::gid, lnc, and numExport.

146 {
147  int pos, i;
148  struct cellData *c = (struct cellData *) data;
149  pos = 0;
150  for (i = 0; i < lnc; i++) {
151  if (i != pos && c[i].gid != -1) {
152  c[pos] = c[i];
153  }
154  if (c[i].gid != -1)
155  pos++;
156  }
157  lnc = lnc - numExport;
158 }
#define lnc
Definition: global.h:102
ZOLTAN_ID_TYPE gid
Definition: global.h:68
int numExport
Definition: domdec.c:41

Here is the caller graph for this function:

void ztnPack ( void *  data,
int  numGIdEntries,
int  numLIdEntries,
ZOLTAN_ID_PTR  globalId,
ZOLTAN_ID_PTR  localId,
int  dest,
int  size,
char *  buf,
int *  ierr 
)

Zoltan callback function. This function packs data into a send buffer before migration.

Definition at line 115 of file domdec.c.

References cellData::gid.

118 {
119  struct cellData *c = (struct cellData *) data;
120  memcpy(buf, &(c[localId[0]]), sizeof(struct cellData));
121  c[(int) (*localId)].gid = -1; /* mark local particle as exported */
122 }
ZOLTAN_ID_TYPE gid
Definition: global.h:68

Here is the caller graph for this function:

void ztnPost ( void *  data,
int  numGIdEntries,
int  numLIdEntries,
int  numImport,
ZOLTAN_ID_PTR  importGlobalIds,
ZOLTAN_ID_PTR  importLocalIds,
int *  importProcs,
int *  importToPart,
int  numExport,
ZOLTAN_ID_PTR  exportGlobalIds,
ZOLTAN_ID_PTR  exportLocalIds,
int *  exportProcs,
int *  exportToPart,
int *  ierr 
)

Zoltan callback function. This function is executed after migration of data between processes.

Definition at line 163 of file domdec.c.

References lnc, and tlnc.

169 {
170  /* any post communication operations should go here */
171  /* gather number of cells from each process */
172  MPI_Allgather(&lnc, 1, MPI_LONG_LONG, tlnc, 1, MPI_LONG_LONG,
173  MPI_COMM_WORLD);
174 }
int64_t * tlnc
Definition: global.h:111
#define lnc
Definition: global.h:102

Here is the caller graph for this function:

void ztnPre ( void *  data,
int  numGIdEntries,
int  numLIdEntries,
int  numImport,
ZOLTAN_ID_PTR  importGlobalIds,
ZOLTAN_ID_PTR  importLocalIds,
int *  importProcs,
int *  importToPart,
int  numExport,
ZOLTAN_ID_PTR  exportGlobalIds,
ZOLTAN_ID_PTR  exportLocalIds,
int *  exportProcs,
int *  exportToPart,
int *  ierr 
)

Zoltan callback function. This function is executed before migration of data between processes.

Definition at line 127 of file domdec.c.

133 {
134  /* any pre communication operations should go here */
135 }

Here is the caller graph for this function:

void ztnReturnCoords ( void *  data,
int  numGidEntries,
int  numLidEntries,
ZOLTAN_ID_PTR  globalId,
ZOLTAN_ID_PTR  localId,
double *  geomVec,
int *  ierr 
)

Zoltan callback function. This function returns the spatial coordinates of the cell identified by its global and local id.

Definition at line 61 of file domdec.c.

References cells, sdim, cellData::x, cellData::y, and cellData::z.

64 {
65  if (sdim == 3) {
66  geomVec[0] = cells[localId[0]].x;
67  geomVec[1] = cells[localId[0]].y;
68  geomVec[2] = cells[localId[0]].z;
69  }
70  if (sdim == 2) {
71  geomVec[0] = cells[localId[0]].x;
72  geomVec[1] = cells[localId[0]].y;
73  }
74 }
int sdim
Definition: global.h:160
double x
Definition: global.h:69
struct cellData * cells
Definition: global.h:82
double z
Definition: global.h:71
double y
Definition: global.h:70

Here is the caller graph for this function:

int ztnReturnDimension ( void *  data,
int *  ierr 
)

Zoltan callback function. This function returns the dimension (2D or 3D) of the system.

Definition at line 50 of file domdec.c.

References sdim.

51 {
52  if (sdim == 3)
53  return 3;
54  if (sdim == 2)
55  return 2;
56 }
int sdim
Definition: global.h:160

Here is the caller graph for this function:

int ztnReturnNumNode ( void *  data,
int *  ierr 
)

Zoltan callback function. This function returns the number of cells assigned to this process.

Definition at line 79 of file domdec.c.

References lnc.

80 {
81  return lnc;
82 }
#define lnc
Definition: global.h:102

Here is the caller graph for this function:

void ztnReturnOwnedNodes ( void *  data,
int  numGIdEntries,
int  numLIdEntries,
ZOLTAN_ID_PTR  globalIds,
ZOLTAN_ID_PTR  localIds,
int  wgtDim,
float *  objWgts,
int *  ierr 
)

Zoltan callback function. This function fills the tables of global ids, local ids and weights for all cells assigned to this process.

Definition at line 87 of file domdec.c.

References cells, cellData::gid, and lnc.

90 {
91  int i;
92  struct cell *p = (struct cell *) data;
93  for (i = 0; i < lnc; i++) {
94  globalIds[i * numGIdEntries] = cells[i].gid;
95  localIds[i * numLIdEntries] = i;
96  objWgts[i] = 1.0;
97  //if(nc==1 || step==0) obj_wgts[i]=1.0;
98  //else obj_wgts[i]=cells[i].density;
99  }
100 }
#define lnc
Definition: global.h:102
ZOLTAN_ID_TYPE gid
Definition: global.h:68
struct cellData * cells
Definition: global.h:82

Here is the caller graph for this function:

int ztnReturnParticleDataSize ( void *  data,
int  numGIdEntries,
int  numLIdEntries,
ZOLTAN_ID_PTR  globalId,
ZOLTAN_ID_PTR  localId,
int *  ierr 
)

Zoltan callback function. This function returns the size of a data structure used for keeping the data of a single cell.

Definition at line 105 of file domdec.c.

108 {
109  return sizeof(struct cellData);
110 }

Here is the caller graph for this function:

void ztnUnpack ( void *  data,
int  numGIdEntries,
ZOLTAN_ID_PTR  globalId,
int  size,
char *  buf,
int *  ierr 
)

Zoltan callback function. This function unpacks data from the receive buffer.

Definition at line 179 of file domdec.c.

References lnc.

181 {
182  struct cellData *c = (struct cellData *) data;
183  memcpy(&c[lnc], buf, sizeof(struct cellData));
184  lnc++;
185 }
#define lnc
Definition: global.h:102

Here is the caller graph for this function:

Variable Documentation

int changes

Definition at line 33 of file domdec.c.

ZOLTAN_ID_PTR exportGlobalGids

Definition at line 42 of file domdec.c.

ZOLTAN_ID_PTR exportLocalGids

Definition at line 43 of file domdec.c.

int* exportProcs

Definition at line 44 of file domdec.c.

int* exportToPart

Definition at line 45 of file domdec.c.

ZOLTAN_ID_PTR importGlobalGids

Definition at line 37 of file domdec.c.

ZOLTAN_ID_PTR importLocalGids

Definition at line 38 of file domdec.c.

int* importProcs

Definition at line 39 of file domdec.c.

int* importToPart

Definition at line 40 of file domdec.c.

int numExport

Definition at line 41 of file domdec.c.

int numGidEntries

Definition at line 34 of file domdec.c.

int numImport

Definition at line 36 of file domdec.c.

int numLidEntries

Definition at line 35 of file domdec.c.