source: CIVL/examples/mpi-omp/AMG2013/struct_mv/grow.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[2aa6644]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 * Routines for "growing" boxes.
17 *
18 *****************************************************************************/
19
20#include "headers.h"
21
22/*--------------------------------------------------------------------------
23 * hypre_GrowBoxByStencil:
24 * The argument `transpose' is a boolean that indicates whether
25 * or not to use the transpose of the stencil.
26 *--------------------------------------------------------------------------*/
27
28hypre_BoxArray *
29hypre_GrowBoxByStencil( hypre_Box *box,
30 hypre_StructStencil *stencil,
31 int transpose )
32{
33 hypre_BoxArray *grow_box_array;
34
35 hypre_BoxArray *shift_box_array;
36 hypre_Box *shift_box;
37
38 hypre_Index *stencil_shape;
39
40 int s, d;
41
42 stencil_shape = hypre_StructStencilShape(stencil);
43
44 shift_box_array = hypre_BoxArrayCreate(hypre_StructStencilSize(stencil));
45 shift_box = hypre_BoxCreate();
46 for (s = 0; s < hypre_StructStencilSize(stencil); s++)
47 {
48 if (transpose)
49 for (d = 0; d < 3; d++)
50 {
51 hypre_BoxIMinD(shift_box, d) =
52 hypre_BoxIMinD(box, d) - hypre_IndexD(stencil_shape[s], d);
53 hypre_BoxIMaxD(shift_box, d) =
54 hypre_BoxIMaxD(box, d) - hypre_IndexD(stencil_shape[s], d);
55 }
56 else
57 for (d = 0; d < 3; d++)
58 {
59 hypre_BoxIMinD(shift_box, d) =
60 hypre_BoxIMinD(box, d) + hypre_IndexD(stencil_shape[s], d);
61 hypre_BoxIMaxD(shift_box, d) =
62 hypre_BoxIMaxD(box, d) + hypre_IndexD(stencil_shape[s], d);
63 }
64
65 hypre_CopyBox(shift_box, hypre_BoxArrayBox(shift_box_array, s));
66 }
67 hypre_BoxDestroy(shift_box);
68
69 hypre_UnionBoxes(shift_box_array);
70 grow_box_array = shift_box_array;
71
72 return grow_box_array;
73}
74
75/*--------------------------------------------------------------------------
76 * hypre_GrowBoxArrayByStencil:
77 *--------------------------------------------------------------------------*/
78
79hypre_BoxArrayArray *
80hypre_GrowBoxArrayByStencil( hypre_BoxArray *box_array,
81 hypre_StructStencil *stencil,
82 int transpose )
83{
84 hypre_BoxArrayArray *grow_box_array_array;
85
86 int i;
87
88 grow_box_array_array =
89 hypre_BoxArrayArrayCreate(hypre_BoxArraySize(box_array));
90
91 hypre_ForBoxI(i, box_array)
92 {
93 hypre_BoxArrayDestroy(
94 hypre_BoxArrayArrayBoxArray(grow_box_array_array, i));
95 hypre_BoxArrayArrayBoxArray(grow_box_array_array, i) =
96 hypre_GrowBoxByStencil(hypre_BoxArrayBox(box_array, i),
97 stencil, transpose);
98 }
99
100 return grow_box_array_array;
101}
Note: See TracBrowser for help on using the repository browser.