| 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 | * Header info for the hypre_BoxNeighbors structures
|
|---|
| 17 | *
|
|---|
| 18 | *****************************************************************************/
|
|---|
| 19 |
|
|---|
| 20 | #ifndef hypre_BOX_NEIGHBORS_HEADER
|
|---|
| 21 | #define hypre_BOX_NEIGHBORS_HEADER
|
|---|
| 22 |
|
|---|
| 23 | /*--------------------------------------------------------------------------
|
|---|
| 24 | * hypre_RankLink:
|
|---|
| 25 | *--------------------------------------------------------------------------*/
|
|---|
| 26 |
|
|---|
| 27 | typedef struct hypre_RankLink_struct
|
|---|
| 28 | {
|
|---|
| 29 | int rank;
|
|---|
| 30 | int prank;
|
|---|
| 31 | struct hypre_RankLink_struct *next;
|
|---|
| 32 |
|
|---|
| 33 | } hypre_RankLink;
|
|---|
| 34 |
|
|---|
| 35 | /*--------------------------------------------------------------------------
|
|---|
| 36 | * hypre_BoxNeighbors:
|
|---|
| 37 | *--------------------------------------------------------------------------*/
|
|---|
| 38 |
|
|---|
| 39 | typedef struct hypre_BoxNeighbors_struct
|
|---|
| 40 | {
|
|---|
| 41 | hypre_BoxArray *boxes; /* boxes in the neighborhood */
|
|---|
| 42 | int *procs; /* procs for 'boxes' */
|
|---|
| 43 | int *boxnums; /* local boxnums for 'boxes' */
|
|---|
| 44 | int *ids; /* ids for 'boxes' */
|
|---|
| 45 | int first_local; /* first local box address */
|
|---|
| 46 | int num_local; /* number of local boxes */
|
|---|
| 47 |
|
|---|
| 48 | hypre_Index periodic; /* directions of periodicity */
|
|---|
| 49 | int id_period; /* period used for box ids */
|
|---|
| 50 | int num_periods; /* number of box set periods */
|
|---|
| 51 | hypre_Index *pshifts; /* shifts of periodicity */
|
|---|
| 52 |
|
|---|
| 53 | hypre_RankLink **rank_links; /* neighbors of local boxes */
|
|---|
| 54 |
|
|---|
| 55 | } hypre_BoxNeighbors;
|
|---|
| 56 |
|
|---|
| 57 | /*--------------------------------------------------------------------------
|
|---|
| 58 | * Accessor macros: hypre_RankLink
|
|---|
| 59 | *--------------------------------------------------------------------------*/
|
|---|
| 60 |
|
|---|
| 61 | #define hypre_RankLinkRank(link) ((link) -> rank)
|
|---|
| 62 | #define hypre_RankLinkPRank(link) ((link) -> prank)
|
|---|
| 63 | #define hypre_RankLinkNext(link) ((link) -> next)
|
|---|
| 64 |
|
|---|
| 65 | /*--------------------------------------------------------------------------
|
|---|
| 66 | * Accessor macros: hypre_BoxNeighbors
|
|---|
| 67 | *--------------------------------------------------------------------------*/
|
|---|
| 68 |
|
|---|
| 69 | #define hypre_BoxNeighborsBoxes(neighbors) ((neighbors) -> boxes)
|
|---|
| 70 | #define hypre_BoxNeighborsProcs(neighbors) ((neighbors) -> procs)
|
|---|
| 71 | #define hypre_BoxNeighborsBoxnums(neighbors) ((neighbors) -> boxnums)
|
|---|
| 72 | #define hypre_BoxNeighborsIDs(neighbors) ((neighbors) -> ids)
|
|---|
| 73 | #define hypre_BoxNeighborsFirstLocal(neighbors) ((neighbors) -> first_local)
|
|---|
| 74 | #define hypre_BoxNeighborsNumLocal(neighbors) ((neighbors) -> num_local)
|
|---|
| 75 | #define hypre_BoxNeighborsPeriodic(neighbors) ((neighbors) -> periodic)
|
|---|
| 76 | #define hypre_BoxNeighborsIDPeriod(neighbors) ((neighbors) -> id_period)
|
|---|
| 77 | #define hypre_BoxNeighborsNumPeriods(neighbors) ((neighbors) -> num_periods)
|
|---|
| 78 | #define hypre_BoxNeighborsPShifts(neighbors) ((neighbors) -> pshifts)
|
|---|
| 79 | #define hypre_BoxNeighborsPShift(neighbors, i) ((neighbors) -> pshifts[i])
|
|---|
| 80 | #define hypre_BoxNeighborsRankLinks(neighbors) ((neighbors) -> rank_links)
|
|---|
| 81 |
|
|---|
| 82 | #define hypre_BoxNeighborsNumBoxes(neighbors) \
|
|---|
| 83 | (hypre_BoxArraySize(hypre_BoxNeighborsBoxes(neighbors)))
|
|---|
| 84 | #define hypre_BoxNeighborsRankLink(neighbors, b) \
|
|---|
| 85 | (hypre_BoxNeighborsRankLinks(neighbors)[b])
|
|---|
| 86 |
|
|---|
| 87 | /*--------------------------------------------------------------------------
|
|---|
| 88 | * Looping macros:
|
|---|
| 89 | *--------------------------------------------------------------------------*/
|
|---|
| 90 |
|
|---|
| 91 | #define hypre_BeginBoxNeighborsLoop(n, neighbors, b)\
|
|---|
| 92 | {\
|
|---|
| 93 | hypre_RankLink *hypre__rank_link;\
|
|---|
| 94 | int hypre__num_boxes;\
|
|---|
| 95 | \
|
|---|
| 96 | hypre__num_boxes = hypre_BoxNeighborsNumBoxes(neighbors) / \
|
|---|
| 97 | hypre_BoxNeighborsNumPeriods(neighbors);\
|
|---|
| 98 | \
|
|---|
| 99 | hypre__rank_link = hypre_BoxNeighborsRankLink(neighbors, b);\
|
|---|
| 100 | while (hypre__rank_link)\
|
|---|
| 101 | {\
|
|---|
| 102 | n = hypre_RankLinkRank(hypre__rank_link) +\
|
|---|
| 103 | hypre_RankLinkPRank(hypre__rank_link)*hypre__num_boxes;
|
|---|
| 104 |
|
|---|
| 105 | #define hypre_EndBoxNeighborsLoop\
|
|---|
| 106 | hypre__rank_link = hypre_RankLinkNext(hypre__rank_link);\
|
|---|
| 107 | }\
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | #endif
|
|---|