| 1 | /*BHEADER**********************************************************************
|
|---|
| 2 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 4 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 5 | *
|
|---|
| 6 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 7 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 8 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 9 | *
|
|---|
| 10 | * $Revision: 2.4 $
|
|---|
| 11 | ***********************************************************************EHEADER*/
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | /******************************************************************************
|
|---|
| 16 | *
|
|---|
| 17 | * Member functions for hypre_SStructGraph class.
|
|---|
| 18 | *
|
|---|
| 19 | *****************************************************************************/
|
|---|
| 20 |
|
|---|
| 21 | #include "headers.h"
|
|---|
| 22 |
|
|---|
| 23 | /*--------------------------------------------------------------------------
|
|---|
| 24 | * hypre_SStructGraphRef
|
|---|
| 25 | *--------------------------------------------------------------------------*/
|
|---|
| 26 |
|
|---|
| 27 | int
|
|---|
| 28 | hypre_SStructGraphRef( hypre_SStructGraph *graph,
|
|---|
| 29 | hypre_SStructGraph **graph_ref )
|
|---|
| 30 | {
|
|---|
| 31 | hypre_SStructGraphRefCount(graph) ++;
|
|---|
| 32 | *graph_ref = graph;
|
|---|
| 33 |
|
|---|
| 34 | return 0;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | /*--------------------------------------------------------------------------
|
|---|
| 38 | * hypre_SStructGraphFindUVEntry
|
|---|
| 39 | *
|
|---|
| 40 | * NOTE: This may search an Octree in the future.
|
|---|
| 41 | *--------------------------------------------------------------------------*/
|
|---|
| 42 |
|
|---|
| 43 | int
|
|---|
| 44 | hypre_SStructGraphFindUVEntry( hypre_SStructGraph *graph,
|
|---|
| 45 | int part,
|
|---|
| 46 | hypre_Index index,
|
|---|
| 47 | int var,
|
|---|
| 48 | hypre_SStructUVEntry **Uventry_ptr )
|
|---|
| 49 | {
|
|---|
| 50 | int ierr = 0;
|
|---|
| 51 |
|
|---|
| 52 | hypre_SStructUVEntry **Uventries = hypre_SStructGraphUVEntries(graph);
|
|---|
| 53 | hypre_SStructGrid *grid = hypre_SStructGraphGrid(graph);
|
|---|
| 54 | int type = hypre_SStructGraphObjectType(graph);
|
|---|
| 55 | hypre_BoxMapEntry *map_entry;
|
|---|
| 56 | HYPRE_BigInt big_rank;
|
|---|
| 57 | int rank;
|
|---|
| 58 |
|
|---|
| 59 | hypre_SStructGridFindMapEntry(grid, part, index, var, &map_entry);
|
|---|
| 60 | hypre_SStructMapEntryGetGlobalRank(map_entry, index, &big_rank, type);
|
|---|
| 61 |
|
|---|
| 62 | if (type == HYPRE_SSTRUCT || type == HYPRE_STRUCT)
|
|---|
| 63 | {
|
|---|
| 64 | rank = (int)(big_rank - hypre_SStructGridGhstartRank(grid));
|
|---|
| 65 | }
|
|---|
| 66 | if (type == HYPRE_PARCSR)
|
|---|
| 67 | {
|
|---|
| 68 | rank = (int)(big_rank - hypre_SStructGridStartRank(grid));
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | *Uventry_ptr = Uventries[rank];
|
|---|
| 72 |
|
|---|
| 73 | return ierr;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | /*--------------------------------------------------------------------------
|
|---|
| 77 | * hypre_SStructGraphFindBoxEndpt
|
|---|
| 78 | *
|
|---|
| 79 | * Computes the local Uventries index for the endpt of a box. This index
|
|---|
| 80 | * can be used to localize a search for Uventries of a box.
|
|---|
| 81 | * endpt= 0 start of boxes
|
|---|
| 82 | * endpt= 1 end of boxes
|
|---|
| 83 | *--------------------------------------------------------------------------*/
|
|---|
| 84 |
|
|---|
| 85 | int
|
|---|
| 86 | hypre_SStructGraphFindBoxEndpt(hypre_SStructGraph *graph,
|
|---|
| 87 | int part,
|
|---|
| 88 | int var,
|
|---|
| 89 | int proc,
|
|---|
| 90 | int endpt,
|
|---|
| 91 | int boxi)
|
|---|
| 92 | {
|
|---|
| 93 | hypre_SStructGrid *grid = hypre_SStructGraphGrid(graph);
|
|---|
| 94 | int type = hypre_SStructGraphObjectType(graph);
|
|---|
| 95 | hypre_BoxMap *map;
|
|---|
| 96 | hypre_BoxMapEntry *map_entry;
|
|---|
| 97 | hypre_StructGrid *sgrid;
|
|---|
| 98 | hypre_Box *box;
|
|---|
| 99 | int rank;
|
|---|
| 100 | HYPRE_BigInt big_rank;
|
|---|
| 101 |
|
|---|
| 102 | map= hypre_SStructGridMap(grid, part, var);
|
|---|
| 103 | hypre_BoxMapFindBoxProcEntry(map, boxi, proc, &map_entry);
|
|---|
| 104 |
|
|---|
| 105 | sgrid= hypre_SStructPGridSGrid(hypre_SStructGridPGrid(grid, part), var);
|
|---|
| 106 | box = hypre_StructGridBox(sgrid, boxi);
|
|---|
| 107 |
|
|---|
| 108 | /* get the global rank of the endpt corner of box boxi */
|
|---|
| 109 | if (endpt < 1)
|
|---|
| 110 | {
|
|---|
| 111 | hypre_SStructMapEntryGetGlobalRank(map_entry, hypre_BoxIMin(box), &big_rank,
|
|---|
| 112 | type);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | else
|
|---|
| 116 | {
|
|---|
| 117 | hypre_SStructMapEntryGetGlobalRank(map_entry, hypre_BoxIMax(box), &big_rank,
|
|---|
| 118 | type);
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | if (type == HYPRE_SSTRUCT || type == HYPRE_STRUCT)
|
|---|
| 122 | {
|
|---|
| 123 | rank = (int)(big_rank - hypre_SStructGridGhstartRank(grid));
|
|---|
| 124 | }
|
|---|
| 125 | if (type == HYPRE_PARCSR)
|
|---|
| 126 | {
|
|---|
| 127 | rank = (int)(big_rank - hypre_SStructGridStartRank(grid));
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | return rank;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | /*--------------------------------------------------------------------------
|
|---|
| 134 | * hypre_SStructGraphFindSGridEndpts
|
|---|
| 135 | *
|
|---|
| 136 | * Computes the local Uventries index for the start or end of each box of
|
|---|
| 137 | * a given sgrid.
|
|---|
| 138 | * endpt= 0 start of boxes
|
|---|
| 139 | * endpt= 1 end of boxes
|
|---|
| 140 | *--------------------------------------------------------------------------*/
|
|---|
| 141 |
|
|---|
| 142 | int
|
|---|
| 143 | hypre_SStructGraphFindSGridEndpts(hypre_SStructGraph *graph,
|
|---|
| 144 | int part,
|
|---|
| 145 | int var,
|
|---|
| 146 | int proc,
|
|---|
| 147 | int endpt,
|
|---|
| 148 | int *endpts)
|
|---|
| 149 | {
|
|---|
| 150 | hypre_SStructGrid *grid = hypre_SStructGraphGrid(graph);
|
|---|
| 151 | hypre_StructGrid *sgrid;
|
|---|
| 152 | hypre_BoxArray *boxes;
|
|---|
| 153 | int i;
|
|---|
| 154 |
|
|---|
| 155 | sgrid= hypre_SStructPGridSGrid(hypre_SStructGridPGrid(grid, part), var);
|
|---|
| 156 | boxes= hypre_StructGridBoxes(sgrid);
|
|---|
| 157 |
|
|---|
| 158 | /* get the endpts using hypre_SStructGraphFindBoxEndpt */
|
|---|
| 159 | for (i= 0; i< hypre_BoxArraySize(boxes); i++)
|
|---|
| 160 | {
|
|---|
| 161 | endpts[i]= hypre_SStructGraphFindBoxEndpt(graph, part, var, proc, endpt, i);
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | return 0;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|