| 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 | * Member functions for hypre_Box class:
|
|---|
| 17 | * Basic class functions.
|
|---|
| 18 | *
|
|---|
| 19 | *****************************************************************************/
|
|---|
| 20 |
|
|---|
| 21 | #include "headers.h"
|
|---|
| 22 |
|
|---|
| 23 | /*--------------------------------------------------------------------------
|
|---|
| 24 | * hypre_BoxCreate
|
|---|
| 25 | *--------------------------------------------------------------------------*/
|
|---|
| 26 |
|
|---|
| 27 | hypre_Box *
|
|---|
| 28 | hypre_BoxCreate( )
|
|---|
| 29 | {
|
|---|
| 30 | hypre_Box *box;
|
|---|
| 31 |
|
|---|
| 32 | #if 1
|
|---|
| 33 | box = hypre_TAlloc(hypre_Box, 1);
|
|---|
| 34 | #else
|
|---|
| 35 | box = hypre_BoxAlloc();
|
|---|
| 36 | #endif
|
|---|
| 37 |
|
|---|
| 38 | return box;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | /*--------------------------------------------------------------------------
|
|---|
| 42 | * hypre_BoxSetExtents
|
|---|
| 43 | *--------------------------------------------------------------------------*/
|
|---|
| 44 |
|
|---|
| 45 | int
|
|---|
| 46 | hypre_BoxSetExtents( hypre_Box *box,
|
|---|
| 47 | hypre_Index imin,
|
|---|
| 48 | hypre_Index imax )
|
|---|
| 49 | {
|
|---|
| 50 | int ierr = 0;
|
|---|
| 51 |
|
|---|
| 52 | hypre_CopyIndex(imin, hypre_BoxIMin(box));
|
|---|
| 53 | hypre_CopyIndex(imax, hypre_BoxIMax(box));
|
|---|
| 54 |
|
|---|
| 55 | return ierr;
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | /*--------------------------------------------------------------------------
|
|---|
| 59 | * hypre_BoxArrayCreate
|
|---|
| 60 | *--------------------------------------------------------------------------*/
|
|---|
| 61 |
|
|---|
| 62 | hypre_BoxArray *
|
|---|
| 63 | hypre_BoxArrayCreate( int size )
|
|---|
| 64 | {
|
|---|
| 65 | hypre_BoxArray *box_array;
|
|---|
| 66 |
|
|---|
| 67 | box_array = hypre_TAlloc(hypre_BoxArray, 1);
|
|---|
| 68 |
|
|---|
| 69 | hypre_BoxArrayBoxes(box_array) = hypre_CTAlloc(hypre_Box, size);
|
|---|
| 70 | hypre_BoxArraySize(box_array) = size;
|
|---|
| 71 | hypre_BoxArrayAllocSize(box_array) = size;
|
|---|
| 72 |
|
|---|
| 73 | return box_array;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | /*--------------------------------------------------------------------------
|
|---|
| 77 | * hypre_BoxArraySetSize
|
|---|
| 78 | *--------------------------------------------------------------------------*/
|
|---|
| 79 |
|
|---|
| 80 | int
|
|---|
| 81 | hypre_BoxArraySetSize( hypre_BoxArray *box_array,
|
|---|
| 82 | int size )
|
|---|
| 83 | {
|
|---|
| 84 | int ierr = 0;
|
|---|
| 85 | int alloc_size;
|
|---|
| 86 |
|
|---|
| 87 | alloc_size = hypre_BoxArrayAllocSize(box_array);
|
|---|
| 88 |
|
|---|
| 89 | if (size > alloc_size)
|
|---|
| 90 | {
|
|---|
| 91 | alloc_size = size + hypre_BoxArrayExcess;
|
|---|
| 92 |
|
|---|
| 93 | hypre_BoxArrayBoxes(box_array) =
|
|---|
| 94 | hypre_TReAlloc(hypre_BoxArrayBoxes(box_array),
|
|---|
| 95 | hypre_Box, alloc_size);
|
|---|
| 96 |
|
|---|
| 97 | hypre_BoxArrayAllocSize(box_array) = alloc_size;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | hypre_BoxArraySize(box_array) = size;
|
|---|
| 101 |
|
|---|
| 102 | return ierr;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | /*--------------------------------------------------------------------------
|
|---|
| 106 | * hypre_BoxArrayArrayCreate
|
|---|
| 107 | *--------------------------------------------------------------------------*/
|
|---|
| 108 |
|
|---|
| 109 | hypre_BoxArrayArray *
|
|---|
| 110 | hypre_BoxArrayArrayCreate( int size )
|
|---|
| 111 | {
|
|---|
| 112 | hypre_BoxArrayArray *box_array_array;
|
|---|
| 113 | int i;
|
|---|
| 114 |
|
|---|
| 115 | box_array_array = hypre_CTAlloc(hypre_BoxArrayArray, 1);
|
|---|
| 116 |
|
|---|
| 117 | hypre_BoxArrayArrayBoxArrays(box_array_array) =
|
|---|
| 118 | hypre_CTAlloc(hypre_BoxArray *, size);
|
|---|
| 119 |
|
|---|
| 120 | for (i = 0; i < size; i++)
|
|---|
| 121 | {
|
|---|
| 122 | hypre_BoxArrayArrayBoxArray(box_array_array, i) = hypre_BoxArrayCreate(0);
|
|---|
| 123 | }
|
|---|
| 124 | hypre_BoxArrayArraySize(box_array_array) = size;
|
|---|
| 125 |
|
|---|
| 126 | return box_array_array;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | /*--------------------------------------------------------------------------
|
|---|
| 130 | * hypre_BoxDestroy
|
|---|
| 131 | *--------------------------------------------------------------------------*/
|
|---|
| 132 |
|
|---|
| 133 | int
|
|---|
| 134 | hypre_BoxDestroy( hypre_Box *box )
|
|---|
| 135 | {
|
|---|
| 136 | int ierr = 0;
|
|---|
| 137 |
|
|---|
| 138 | if (box)
|
|---|
| 139 | {
|
|---|
| 140 | #if 1
|
|---|
| 141 | hypre_TFree(box);
|
|---|
| 142 | #else
|
|---|
| 143 | hypre_BoxFree(box);
|
|---|
| 144 | #endif
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | return ierr;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | /*--------------------------------------------------------------------------
|
|---|
| 151 | * hypre_BoxArrayDestroy
|
|---|
| 152 | *--------------------------------------------------------------------------*/
|
|---|
| 153 |
|
|---|
| 154 | int
|
|---|
| 155 | hypre_BoxArrayDestroy( hypre_BoxArray *box_array )
|
|---|
| 156 | {
|
|---|
| 157 | int ierr = 0;
|
|---|
| 158 |
|
|---|
| 159 | if (box_array)
|
|---|
| 160 | {
|
|---|
| 161 | hypre_TFree(hypre_BoxArrayBoxes(box_array));
|
|---|
| 162 | hypre_TFree(box_array);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | return ierr;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | /*--------------------------------------------------------------------------
|
|---|
| 169 | * hypre_BoxArrayArrayDestroy
|
|---|
| 170 | *--------------------------------------------------------------------------*/
|
|---|
| 171 |
|
|---|
| 172 | int
|
|---|
| 173 | hypre_BoxArrayArrayDestroy( hypre_BoxArrayArray *box_array_array )
|
|---|
| 174 | {
|
|---|
| 175 | int ierr = 0;
|
|---|
| 176 | int i;
|
|---|
| 177 |
|
|---|
| 178 | if (box_array_array)
|
|---|
| 179 | {
|
|---|
| 180 | hypre_ForBoxArrayI(i, box_array_array)
|
|---|
| 181 | hypre_BoxArrayDestroy(
|
|---|
| 182 | hypre_BoxArrayArrayBoxArray(box_array_array, i));
|
|---|
| 183 |
|
|---|
| 184 | hypre_TFree(hypre_BoxArrayArrayBoxArrays(box_array_array));
|
|---|
| 185 | hypre_TFree(box_array_array);
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | return ierr;
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | /*--------------------------------------------------------------------------
|
|---|
| 192 | * hypre_BoxDuplicate:
|
|---|
| 193 | * Return a duplicate box.
|
|---|
| 194 | *--------------------------------------------------------------------------*/
|
|---|
| 195 |
|
|---|
| 196 | hypre_Box *
|
|---|
| 197 | hypre_BoxDuplicate( hypre_Box *box )
|
|---|
| 198 | {
|
|---|
| 199 | hypre_Box *new_box;
|
|---|
| 200 |
|
|---|
| 201 | new_box = hypre_BoxCreate();
|
|---|
| 202 | hypre_CopyBox(box, new_box);
|
|---|
| 203 |
|
|---|
| 204 | return new_box;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | /*--------------------------------------------------------------------------
|
|---|
| 208 | * hypre_BoxArrayDuplicate:
|
|---|
| 209 | * Return a duplicate box_array.
|
|---|
| 210 | *--------------------------------------------------------------------------*/
|
|---|
| 211 |
|
|---|
| 212 | hypre_BoxArray *
|
|---|
| 213 | hypre_BoxArrayDuplicate( hypre_BoxArray *box_array )
|
|---|
| 214 | {
|
|---|
| 215 | hypre_BoxArray *new_box_array;
|
|---|
| 216 |
|
|---|
| 217 | int i;
|
|---|
| 218 |
|
|---|
| 219 | new_box_array = hypre_BoxArrayCreate(hypre_BoxArraySize(box_array));
|
|---|
| 220 | hypre_ForBoxI(i, box_array)
|
|---|
| 221 | {
|
|---|
| 222 | hypre_CopyBox(hypre_BoxArrayBox(box_array, i),
|
|---|
| 223 | hypre_BoxArrayBox(new_box_array, i));
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | return new_box_array;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | /*--------------------------------------------------------------------------
|
|---|
| 230 | * hypre_BoxArrayArrayDuplicate:
|
|---|
| 231 | * Return a duplicate box_array_array.
|
|---|
| 232 | *--------------------------------------------------------------------------*/
|
|---|
| 233 |
|
|---|
| 234 | hypre_BoxArrayArray *
|
|---|
| 235 | hypre_BoxArrayArrayDuplicate( hypre_BoxArrayArray *box_array_array )
|
|---|
| 236 | {
|
|---|
| 237 | hypre_BoxArrayArray *new_box_array_array;
|
|---|
| 238 | hypre_BoxArray **new_box_arrays;
|
|---|
| 239 | int new_size;
|
|---|
| 240 |
|
|---|
| 241 | hypre_BoxArray **box_arrays;
|
|---|
| 242 | int i;
|
|---|
| 243 |
|
|---|
| 244 | new_size = hypre_BoxArrayArraySize(box_array_array);
|
|---|
| 245 | new_box_array_array = hypre_BoxArrayArrayCreate(new_size);
|
|---|
| 246 |
|
|---|
| 247 | if (new_size)
|
|---|
| 248 | {
|
|---|
| 249 | new_box_arrays = hypre_BoxArrayArrayBoxArrays(new_box_array_array);
|
|---|
| 250 | box_arrays = hypre_BoxArrayArrayBoxArrays(box_array_array);
|
|---|
| 251 |
|
|---|
| 252 | for (i = 0; i < new_size; i++)
|
|---|
| 253 | {
|
|---|
| 254 | hypre_AppendBoxArray(box_arrays[i], new_box_arrays[i]);
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | return new_box_array_array;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | /*--------------------------------------------------------------------------
|
|---|
| 262 | * hypre_AppendBox:
|
|---|
| 263 | * Append box to the end of box_array.
|
|---|
| 264 | * The box_array may be empty.
|
|---|
| 265 | *--------------------------------------------------------------------------*/
|
|---|
| 266 |
|
|---|
| 267 | int
|
|---|
| 268 | hypre_AppendBox( hypre_Box *box,
|
|---|
| 269 | hypre_BoxArray *box_array )
|
|---|
| 270 | {
|
|---|
| 271 | int ierr = 0;
|
|---|
| 272 | int size;
|
|---|
| 273 |
|
|---|
| 274 | size = hypre_BoxArraySize(box_array);
|
|---|
| 275 | hypre_BoxArraySetSize(box_array, (size + 1));
|
|---|
| 276 | hypre_CopyBox(box, hypre_BoxArrayBox(box_array, size));
|
|---|
| 277 |
|
|---|
| 278 | return ierr;
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | /*--------------------------------------------------------------------------
|
|---|
| 282 | * hypre_DeleteBox:
|
|---|
| 283 | * Delete box from box_array.
|
|---|
| 284 | *--------------------------------------------------------------------------*/
|
|---|
| 285 |
|
|---|
| 286 | int
|
|---|
| 287 | hypre_DeleteBox( hypre_BoxArray *box_array,
|
|---|
| 288 | int index )
|
|---|
| 289 | {
|
|---|
| 290 | int ierr = 0;
|
|---|
| 291 | int i;
|
|---|
| 292 |
|
|---|
| 293 | for (i = index; i < hypre_BoxArraySize(box_array) - 1; i++)
|
|---|
| 294 | {
|
|---|
| 295 | hypre_CopyBox(hypre_BoxArrayBox(box_array, i+1),
|
|---|
| 296 | hypre_BoxArrayBox(box_array, i));
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 | hypre_BoxArraySize(box_array) --;
|
|---|
| 300 |
|
|---|
| 301 | return ierr;
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | /*--------------------------------------------------------------------------
|
|---|
| 305 | * hypre_AppendBoxArray:
|
|---|
| 306 | * Append box_array_0 to the end of box_array_1.
|
|---|
| 307 | * The box_array_1 may be empty.
|
|---|
| 308 | *--------------------------------------------------------------------------*/
|
|---|
| 309 |
|
|---|
| 310 | int
|
|---|
| 311 | hypre_AppendBoxArray( hypre_BoxArray *box_array_0,
|
|---|
| 312 | hypre_BoxArray *box_array_1 )
|
|---|
| 313 | {
|
|---|
| 314 | int ierr = 0;
|
|---|
| 315 | int size, size_0;
|
|---|
| 316 | int i;
|
|---|
| 317 |
|
|---|
| 318 | size = hypre_BoxArraySize(box_array_1);
|
|---|
| 319 | size_0 = hypre_BoxArraySize(box_array_0);
|
|---|
| 320 | hypre_BoxArraySetSize(box_array_1, (size + size_0));
|
|---|
| 321 |
|
|---|
| 322 | /* copy box_array_0 boxes into box_array_1 */
|
|---|
| 323 | for (i = 0; i < size_0; i++)
|
|---|
| 324 | {
|
|---|
| 325 | hypre_CopyBox(hypre_BoxArrayBox(box_array_0, i),
|
|---|
| 326 | hypre_BoxArrayBox(box_array_1, size + i));
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | return ierr;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | /*--------------------------------------------------------------------------
|
|---|
| 333 | * hypre_BoxGetSize:
|
|---|
| 334 | *--------------------------------------------------------------------------*/
|
|---|
| 335 |
|
|---|
| 336 | int
|
|---|
| 337 | hypre_BoxGetSize( hypre_Box *box,
|
|---|
| 338 | hypre_Index size )
|
|---|
| 339 | {
|
|---|
| 340 | hypre_IndexD(size, 0) = hypre_BoxSizeD(box, 0);
|
|---|
| 341 | hypre_IndexD(size, 1) = hypre_BoxSizeD(box, 1);
|
|---|
| 342 | hypre_IndexD(size, 2) = hypre_BoxSizeD(box, 2);
|
|---|
| 343 |
|
|---|
| 344 | return 0;
|
|---|
| 345 | }
|
|---|
| 346 |
|
|---|
| 347 | /*--------------------------------------------------------------------------
|
|---|
| 348 | * hypre_BoxGetStrideSize:
|
|---|
| 349 | *--------------------------------------------------------------------------*/
|
|---|
| 350 |
|
|---|
| 351 | int
|
|---|
| 352 | hypre_BoxGetStrideSize( hypre_Box *box,
|
|---|
| 353 | hypre_Index stride,
|
|---|
| 354 | hypre_Index size )
|
|---|
| 355 | {
|
|---|
| 356 | int d, s;
|
|---|
| 357 |
|
|---|
| 358 | for (d = 0; d < 3; d++)
|
|---|
| 359 | {
|
|---|
| 360 | s = hypre_BoxSizeD(box, d);
|
|---|
| 361 | if (s > 0)
|
|---|
| 362 | {
|
|---|
| 363 | s = (s - 1) / hypre_IndexD(stride, d) + 1;
|
|---|
| 364 | }
|
|---|
| 365 | hypre_IndexD(size, d) = s;
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | return 0;
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | /*--------------------------------------------------------------------------
|
|---|
| 372 | * hypre_BoxGetStrideVolume:
|
|---|
| 373 | *--------------------------------------------------------------------------*/
|
|---|
| 374 |
|
|---|
| 375 | int
|
|---|
| 376 | hypre_BoxGetStrideVolume( hypre_Box *box,
|
|---|
| 377 | hypre_Index stride,
|
|---|
| 378 | int *volume_ptr )
|
|---|
| 379 | {
|
|---|
| 380 | int volume = 1;
|
|---|
| 381 | int d, s;
|
|---|
| 382 |
|
|---|
| 383 | for (d = 0; d < 3; d++)
|
|---|
| 384 | {
|
|---|
| 385 | s = hypre_BoxSizeD(box, d);
|
|---|
| 386 | if (s > 0)
|
|---|
| 387 | {
|
|---|
| 388 | s = (s - 1) / hypre_IndexD(stride, d) + 1;
|
|---|
| 389 | }
|
|---|
| 390 | volume *= s;
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | *volume_ptr = volume;
|
|---|
| 394 |
|
|---|
| 395 | return 0;
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | /*--------------------------------------------------------------------------
|
|---|
| 399 | * GEC0209 function to expand a box given a ghostvector numexp
|
|---|
| 400 | * the idea is to dilatate the box using two vectors.
|
|---|
| 401 | *
|
|---|
| 402 | * even components of numexp shift negatively the imin of the box
|
|---|
| 403 | * odd components of numexp shift positively the imax of the box
|
|---|
| 404 | *
|
|---|
| 405 | *
|
|---|
| 406 | *--------------------------------------------------------------------------*/
|
|---|
| 407 |
|
|---|
| 408 | int
|
|---|
| 409 | hypre_BoxExpand( hypre_Box *box,
|
|---|
| 410 | int *numexp)
|
|---|
| 411 | {
|
|---|
| 412 | int ierr = 0;
|
|---|
| 413 | int *imin = hypre_BoxIMin(box);
|
|---|
| 414 | int *imax = hypre_BoxIMax(box);
|
|---|
| 415 | int d;
|
|---|
| 416 |
|
|---|
| 417 | for (d = 0; d < 3; d++)
|
|---|
| 418 | {
|
|---|
| 419 | imin[d] -= numexp[2*d];
|
|---|
| 420 | imax[d] += numexp[2*d+1];
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | return ierr;
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 | /*--------------------------------------------------------------------------
|
|---|
| 428 | * hypre_DeleteMultipleBoxes:
|
|---|
| 429 | * Deletes boxes corrsponding to indices from box_array.
|
|---|
| 430 | * Assumes indices are in ascending order. (AB 11/04)
|
|---|
| 431 | *--------------------------------------------------------------------------*/
|
|---|
| 432 |
|
|---|
| 433 | int
|
|---|
| 434 | hypre_DeleteMultipleBoxes( hypre_BoxArray *box_array,
|
|---|
| 435 | int* indices , int num )
|
|---|
| 436 | {
|
|---|
| 437 | int ierr = 0;
|
|---|
| 438 | int i, j, start, array_size;
|
|---|
| 439 |
|
|---|
| 440 |
|
|---|
| 441 | if (num < 1) return ierr;
|
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 | array_size = hypre_BoxArraySize(box_array);
|
|---|
| 445 | start = indices[0];
|
|---|
| 446 | j = 0;
|
|---|
| 447 |
|
|---|
| 448 | for (i = start; (i + j) < array_size; i++)
|
|---|
| 449 | {
|
|---|
| 450 | if (j < num)
|
|---|
| 451 | {
|
|---|
| 452 | while ((i+j) == indices[j]) /* see if deleting consecutive items */
|
|---|
| 453 | {
|
|---|
| 454 | j++; /*increase the shift*/
|
|---|
| 455 | if (j == num) break;
|
|---|
| 456 | }
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | if ( (i+j) < array_size) /* if deleting the last item then no moving */
|
|---|
| 460 | {
|
|---|
| 461 |
|
|---|
| 462 | hypre_CopyBox(hypre_BoxArrayBox(box_array, i+j),
|
|---|
| 463 | hypre_BoxArrayBox(box_array, i));
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 |
|
|---|
| 470 | hypre_BoxArraySize(box_array) = array_size - num;
|
|---|
| 471 |
|
|---|
| 472 | return ierr;
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 |
|
|---|
| 476 | /*--------------------------------------------------------------------------
|
|---|
| 477 | * hypre_MaxIndexPosition - which index coordinate is the min.?
|
|---|
| 478 | * (AB 11/04)
|
|---|
| 479 | *--------------------------------------------------------------------------*/
|
|---|
| 480 |
|
|---|
| 481 | int
|
|---|
| 482 | hypre_MaxIndexPosition(hypre_Index index, int *position)
|
|---|
| 483 | {
|
|---|
| 484 | int ierr = 0;
|
|---|
| 485 | int i, value;
|
|---|
| 486 |
|
|---|
| 487 | value = hypre_IndexD(index, 0);
|
|---|
| 488 | *position = 0;
|
|---|
| 489 |
|
|---|
| 490 | for (i = 1; i< 3; i++)
|
|---|
| 491 | {
|
|---|
| 492 | if (value < hypre_IndexD(index, i))
|
|---|
| 493 | {
|
|---|
| 494 | value = hypre_IndexD(index, i);
|
|---|
| 495 | *position = i;
|
|---|
| 496 | }
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | return ierr;
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | /*--------------------------------------------------------------------------
|
|---|
| 503 | * hypre_MinIndexPosition - which index coordinate is the max. ?
|
|---|
| 504 | * (AB 11/04)
|
|---|
| 505 | *--------------------------------------------------------------------------*/
|
|---|
| 506 |
|
|---|
| 507 | int
|
|---|
| 508 | hypre_MinIndexPosition(hypre_Index index, int *position)
|
|---|
| 509 | {
|
|---|
| 510 | int ierr = 0;
|
|---|
| 511 | int i, value;
|
|---|
| 512 |
|
|---|
| 513 | value = hypre_IndexD(index, 0);
|
|---|
| 514 | *position = 0;
|
|---|
| 515 |
|
|---|
| 516 | for (i = 1; i< 3; i++)
|
|---|
| 517 | {
|
|---|
| 518 | if (value > hypre_IndexD(index, i))
|
|---|
| 519 | {
|
|---|
| 520 | value = hypre_IndexD(index, i);
|
|---|
| 521 | *position = i;
|
|---|
| 522 | }
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 | return ierr;
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | /*--------------------------------------------------------------------------
|
|---|
| 529 | * hypre_BoxExpandConstant - grow a box the same distance in each direction
|
|---|
| 530 | * (AB 11/04)
|
|---|
| 531 | *--------------------------------------------------------------------------*/
|
|---|
| 532 |
|
|---|
| 533 | int
|
|---|
| 534 | hypre_BoxExpandConstant( hypre_Box *box,
|
|---|
| 535 | int expand)
|
|---|
| 536 | {
|
|---|
| 537 | int ierr = 0;
|
|---|
| 538 | int *imin = hypre_BoxIMin(box);
|
|---|
| 539 | int *imax = hypre_BoxIMax(box);
|
|---|
| 540 | int d;
|
|---|
| 541 |
|
|---|
| 542 | for (d = 0; d < 3; d++)
|
|---|
| 543 | {
|
|---|
| 544 | imin[d] -= expand;
|
|---|
| 545 | imax[d] += expand;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | return ierr;
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 |
|
|---|
| 552 |
|
|---|
| 553 |
|
|---|