This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/ThirdParty/mingwBuild/x64/patches/ParMGridGen-1.0/MGridGen/Lib/mgridgen.c
2015-08-07 13:21:09 +01:00

111 lines
3.3 KiB
C

/*
* Copyright 2001, Regents of the University of Minnesota
*
* mgridgen.c
*
* This file contains the top level routines for the sparse hierarchical
* clustering algorithm.
*
* George Irene
*/
#include "mgridgen.h"
#include "rand48.h"
/*************************************************************************
* This function is the entry point for the SHCluster() routine.
**************************************************************************/
void MGridGen(int nvtxs, idxtype *xadj, realtype *vvol, realtype *vsurf,
idxtype *adjncy, realtype *adjwgt, int minsize, int maxsize,
int *options, int *nmoves, int *nparts, idxtype *part)
{
GraphType graph;
CtrlType ctrl;
srand(4321);
srand48(7654321L);
/*------------------------------------------------------------
* Set up the various control structures
*------------------------------------------------------------*/
ctrl.CType = options[OPTION_CTYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
ctrl.dim = options[OPTION_DIM];
ctrl.minsize = minsize;
ctrl.maxsize = maxsize;
ctrl.nparts = -1;
/*------------------------------------------------------------
* Set up the graph
*------------------------------------------------------------*/
SetUpGraph(&graph, nvtxs, xadj, vvol, vsurf, adjncy, adjwgt);
CreateGrid(&ctrl, &graph);
*nparts = ctrl.nparts;
icopy(nvtxs, graph.where, part);
*nmoves = graph.nmoves;
FreeGraph(&graph);
}
/*************************************************************************
* This function is the entry point for performing refinement
**************************************************************************/
void MGridGenRefine(int nvtxs, idxtype *xadj, realtype *vvol, realtype *vsurf,
idxtype *adjncy, idxtype *fusedinfo, realtype *adjwgt,
int minsize, int maxsize, int *options, int *nmoves,
int *nparts, idxtype *part)
{
int i;
GraphType graph;
CtrlType ctrl;
srand(4321);
srand48(7654321L);
/*------------------------------------------------------------
* Set up the various control structures
*------------------------------------------------------------*/
ctrl.CType = options[OPTION_CTYPE];
ctrl.RType = options[OPTION_RTYPE];
ctrl.dbglvl = options[OPTION_DBGLVL];
ctrl.dim = options[OPTION_DIM];
ctrl.minsize = minsize;
ctrl.maxsize = maxsize;
ctrl.nparts = -1;
/*------------------------------------------------------------
* Set up the graph
*------------------------------------------------------------*/
SetUpGraph(&graph, nvtxs, xadj, vvol, vsurf, adjncy, adjwgt);
graph.cmap = NULL;
graph.where = idxmalloc(graph.nvtxs, "graph.where");
for (i=0; i<graph.nvtxs; i++)
graph.where[i] = fusedinfo[i];
RefineKWayOnce(&ctrl, &graph, 10);
*nparts = ctrl.nparts;
icopy(nvtxs, graph.where, part);
*nmoves = graph.nmoves;
FreeGraph(&graph);
}
/*************************************************************************
* This function creates the coarse grid
**************************************************************************/
void CreateGrid(CtrlType *ctrl, GraphType *graph)
{
GraphType *cgraph;
cgraph = Coarsen(ctrl, graph);
RefineKWay(ctrl, graph, cgraph, 10);
}