int HYPRE_SStructGraphDestroy( HYPRE_SStructGraph graph ) { int ierr = 0; int nparts; hypre_SStructPGrid **pgrids; hypre_SStructStencil ***stencils; int nUventries; int *iUventries; hypre_SStructUVEntry **Uventries; hypre_SStructUVEntry *Uventry; int nvars; int part, var, i; if (graph) { hypre_SStructGraphRefCount(graph) --; if (hypre_SStructGraphRefCount(graph) == 0) { nparts = hypre_SStructGraphNParts(graph); pgrids = hypre_SStructGraphPGrids(graph); stencils = hypre_SStructGraphStencils(graph); nUventries = hypre_SStructGraphNUVEntries(graph); iUventries = hypre_SStructGraphIUVEntries(graph); Uventries = hypre_SStructGraphUVEntries(graph); for (part = 0; part < nparts; part++) { nvars = hypre_SStructPGridNVars(pgrids[part]); for (var = 0; var < nvars; var++) { HYPRE_SStructStencilDestroy(stencils[part][var]); } hypre_TFree(stencils[part]); } HYPRE_SStructGridDestroy(hypre_SStructGraphGrid(graph)); hypre_TFree(stencils); for (i = 0; i < nUventries; i++) { Uventry = Uventries[iUventries[i]]; if (Uventry) { hypre_TFree(hypre_SStructUVEntryUEntries(Uventry)); hypre_TFree(Uventry); } Uventries[iUventries[i]] = NULL; } hypre_TFree(iUventries); hypre_TFree(Uventries); hypre_TFree(graph); } } return ierr; }
int hypre_SStructGraphRef( hypre_SStructGraph *graph, hypre_SStructGraph **graph_ref ) { hypre_SStructGraphRefCount(graph) ++; *graph_ref = graph; return 0; }
int HYPRE_SStructGraphCreate( MPI_Comm comm, HYPRE_SStructGrid grid, HYPRE_SStructGraph *graph_ptr ) { int ierr = 0; hypre_SStructGraph *graph; int nparts; hypre_SStructStencil ***stencils; hypre_SStructPGrid **pgrids; int nvars; int part, var; graph = hypre_TAlloc(hypre_SStructGraph, 1); hypre_SStructGraphComm(graph) = comm; hypre_SStructGraphNDim(graph) = hypre_SStructGridNDim(grid); hypre_SStructGridRef(grid, &hypre_SStructGraphGrid(graph)); nparts = hypre_SStructGridNParts(grid); hypre_SStructGraphNParts(graph) = nparts; pgrids = hypre_SStructGridPGrids(grid); hypre_SStructGraphPGrids(graph) = pgrids; stencils = hypre_TAlloc(hypre_SStructStencil **, nparts); for (part = 0; part < nparts; part++) { nvars = hypre_SStructPGridNVars(pgrids[part]); stencils[part] = hypre_TAlloc(hypre_SStructStencil *, nvars); for (var = 0; var < nvars; var++) { stencils[part][var] = NULL; } } hypre_SStructGraphStencils(graph) = stencils; hypre_SStructGraphNUVEntries(graph) = 0; hypre_SStructGraphAUVEntries(graph) = 0; hypre_SStructGraphIUVEntries(graph) = NULL; hypre_SStructGraphUVEntries(graph) = NULL; hypre_SStructGraphTotUEntries(graph) = 0; hypre_SStructGraphRefCount(graph) = 1; hypre_SStructGraphObjectType(graph) = HYPRE_SSTRUCT; *graph_ptr = graph; return ierr; }
HYPRE_Int HYPRE_SStructGraphDestroy( HYPRE_SStructGraph graph ) { HYPRE_Int nparts; hypre_SStructPGrid **pgrids; hypre_SStructStencil ***stencils; HYPRE_Int *fem_nsparse; HYPRE_Int **fem_sparse_i; HYPRE_Int **fem_sparse_j; HYPRE_Int **fem_entries; HYPRE_Int nUventries; HYPRE_Int *iUventries; hypre_SStructUVEntry **Uventries; hypre_SStructUVEntry *Uventry; HYPRE_Int nvars; HYPRE_Int part, var, i; if (graph) { hypre_SStructGraphRefCount(graph) --; if (hypre_SStructGraphRefCount(graph) == 0) { nparts = hypre_SStructGraphNParts(graph); pgrids = hypre_SStructGraphPGrids(graph); stencils = hypre_SStructGraphStencils(graph); fem_nsparse = hypre_SStructGraphFEMNSparse(graph); fem_sparse_i = hypre_SStructGraphFEMSparseJ(graph); fem_sparse_j = hypre_SStructGraphFEMSparseI(graph); fem_entries = hypre_SStructGraphFEMEntries(graph); nUventries = hypre_SStructGraphNUVEntries(graph); iUventries = hypre_SStructGraphIUVEntries(graph); Uventries = hypre_SStructGraphUVEntries(graph); for (part = 0; part < nparts; part++) { nvars = hypre_SStructPGridNVars(pgrids[part]); for (var = 0; var < nvars; var++) { HYPRE_SStructStencilDestroy(stencils[part][var]); } hypre_TFree(stencils[part]); hypre_TFree(fem_sparse_i[part]); hypre_TFree(fem_sparse_j[part]); hypre_TFree(fem_entries[part]); } HYPRE_SStructGridDestroy(hypre_SStructGraphGrid(graph)); HYPRE_SStructGridDestroy(hypre_SStructGraphDomainGrid(graph)); hypre_TFree(stencils); hypre_TFree(fem_nsparse); hypre_TFree(fem_sparse_i); hypre_TFree(fem_sparse_j); hypre_TFree(fem_entries); /* RDF: THREAD? */ for (i = 0; i < nUventries; i++) { Uventry = Uventries[iUventries[i]]; if (Uventry) { hypre_TFree(hypre_SStructUVEntryUEntries(Uventry)); hypre_TFree(Uventry); } Uventries[iUventries[i]] = NULL; } hypre_TFree(iUventries); hypre_TFree(Uventries); hypre_TFree(graph); } } return hypre_error_flag; }
HYPRE_Int HYPRE_SStructGraphCreate( MPI_Comm comm, HYPRE_SStructGrid grid, HYPRE_SStructGraph *graph_ptr ) { hypre_SStructGraph *graph; HYPRE_Int nparts; hypre_SStructStencil ***stencils; hypre_SStructPGrid **pgrids; HYPRE_Int *fem_nsparse; HYPRE_Int **fem_sparse_i; HYPRE_Int **fem_sparse_j; HYPRE_Int **fem_entries; HYPRE_Int nvars; HYPRE_Int part, var; graph = hypre_TAlloc(hypre_SStructGraph, 1); hypre_SStructGraphComm(graph) = comm; hypre_SStructGraphNDim(graph) = hypre_SStructGridNDim(grid); hypre_SStructGridRef(grid, &hypre_SStructGraphGrid(graph)); hypre_SStructGridRef(grid, &hypre_SStructGraphDomainGrid(graph)); nparts = hypre_SStructGridNParts(grid); hypre_SStructGraphNParts(graph) = nparts; pgrids = hypre_SStructGridPGrids(grid); stencils = hypre_TAlloc(hypre_SStructStencil **, nparts); fem_nsparse = hypre_TAlloc(HYPRE_Int, nparts); fem_sparse_i = hypre_TAlloc(HYPRE_Int *, nparts); fem_sparse_j = hypre_TAlloc(HYPRE_Int *, nparts); fem_entries = hypre_TAlloc(HYPRE_Int *, nparts); for (part = 0; part < nparts; part++) { nvars = hypre_SStructPGridNVars(pgrids[part]); stencils[part] = hypre_TAlloc(hypre_SStructStencil *, nvars); fem_nsparse[part] = 0; fem_sparse_i[part] = NULL; fem_sparse_j[part] = NULL; fem_entries[part] = NULL; for (var = 0; var < nvars; var++) { stencils[part][var] = NULL; } } hypre_SStructGraphStencils(graph) = stencils; hypre_SStructGraphFEMNSparse(graph) = fem_nsparse; hypre_SStructGraphFEMSparseJ(graph) = fem_sparse_i; hypre_SStructGraphFEMSparseI(graph) = fem_sparse_j; hypre_SStructGraphFEMEntries(graph) = fem_entries; hypre_SStructGraphNUVEntries(graph) = 0; hypre_SStructGraphAUVEntries(graph) = 0; hypre_SStructGraphIUVEntries(graph) = NULL; hypre_SStructGraphUVEntries(graph) = NULL; hypre_SStructGraphTotUEntries(graph) = 0; hypre_SStructGraphRefCount(graph) = 1; hypre_SStructGraphObjectType(graph) = HYPRE_SSTRUCT; hypre_SStructGraphEntries(graph) = NULL; hypre_SStructNGraphEntries(graph) = 0; hypre_SStructAGraphEntries(graph) = 0; *graph_ptr = graph; return hypre_error_flag; }