1997-11-13 23:59:20 +08:00
|
|
|
/*BHEADER**********************************************************************
|
2008-07-18 09:34:48 +08:00
|
|
|
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
2006-07-28 07:26:57 +08:00
|
|
|
* Produced at the Lawrence Livermore National Laboratory.
|
2008-07-18 09:34:48 +08:00
|
|
|
* This file is part of HYPRE. See file COPYRIGHT for details.
|
1997-11-13 23:59:20 +08:00
|
|
|
*
|
2008-07-18 09:34:48 +08:00
|
|
|
* HYPRE is free software; you can redistribute it and/or modify it under the
|
|
|
|
|
* terms of the GNU Lesser General Public License (as published by the Free
|
|
|
|
|
* Software Foundation) version 2.1 dated February 1999.
|
1997-11-13 23:59:20 +08:00
|
|
|
*
|
|
|
|
|
* $Revision$
|
2006-07-28 07:26:57 +08:00
|
|
|
***********************************************************************EHEADER*/
|
|
|
|
|
|
1997-11-13 23:59:20 +08:00
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Projection routines.
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2012-03-07 03:15:29 +08:00
|
|
|
#include "_hypre_struct_mv.h"
|
1997-11-13 23:59:20 +08:00
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
1998-02-18 01:56:00 +08:00
|
|
|
* hypre_ProjectBox:
|
1997-11-13 23:59:20 +08:00
|
|
|
* Projects a box onto a strided index space that contains the
|
|
|
|
|
* index `index' and has stride `stride'.
|
1997-11-26 04:30:53 +08:00
|
|
|
*
|
1998-12-15 06:20:22 +08:00
|
|
|
* Note: An "empty" projection is represented by a box with volume 0.
|
1997-11-13 23:59:20 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_ProjectBox( hypre_Box *box,
|
1998-02-19 07:45:29 +08:00
|
|
|
hypre_Index index,
|
|
|
|
|
hypre_Index stride )
|
1997-11-13 23:59:20 +08:00
|
|
|
{
|
2013-10-04 02:35:31 +08:00
|
|
|
HYPRE_Int i, s, d, hl, hu, kl, ku, ndim = hypre_BoxNDim(box);
|
1997-11-13 23:59:20 +08:00
|
|
|
|
|
|
|
|
/*------------------------------------------------------
|
2013-10-04 02:35:31 +08:00
|
|
|
* project in all ndim dimensions
|
1997-11-13 23:59:20 +08:00
|
|
|
*------------------------------------------------------*/
|
|
|
|
|
|
2013-10-04 02:35:31 +08:00
|
|
|
for (d = 0; d < ndim; d++)
|
1997-11-13 23:59:20 +08:00
|
|
|
{
|
1998-09-24 03:39:26 +08:00
|
|
|
|
1998-02-18 01:56:00 +08:00
|
|
|
i = hypre_IndexD(index, d);
|
|
|
|
|
s = hypre_IndexD(stride, d);
|
1997-11-13 23:59:20 +08:00
|
|
|
|
1998-12-15 06:20:22 +08:00
|
|
|
hl = hypre_BoxIMinD(box, d) - i;
|
|
|
|
|
hu = hypre_BoxIMaxD(box, d) - i;
|
1998-09-24 03:39:26 +08:00
|
|
|
|
|
|
|
|
if ( hl <= 0 )
|
2010-12-21 03:27:44 +08:00
|
|
|
kl = (HYPRE_Int) (hl / s);
|
1998-09-24 03:39:26 +08:00
|
|
|
else
|
2010-12-21 03:27:44 +08:00
|
|
|
kl = (HYPRE_Int) ((hl + (s-1)) / s);
|
1998-09-24 03:39:26 +08:00
|
|
|
|
|
|
|
|
if ( hu >= 0 )
|
2010-12-21 03:27:44 +08:00
|
|
|
ku = (HYPRE_Int) (hu / s);
|
1998-09-24 03:39:26 +08:00
|
|
|
else
|
2010-12-21 03:27:44 +08:00
|
|
|
ku = (HYPRE_Int) ((hu - (s-1)) / s);
|
1997-11-13 23:59:20 +08:00
|
|
|
|
1998-12-15 06:20:22 +08:00
|
|
|
hypre_BoxIMinD(box, d) = i + kl * s;
|
|
|
|
|
hypre_BoxIMaxD(box, d) = i + ku * s;
|
1997-11-13 23:59:20 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-04 01:17:14 +08:00
|
|
|
return hypre_error_flag;
|
1997-11-13 23:59:20 +08:00
|
|
|
}
|
|
|
|
|
|
1997-12-11 04:45:11 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
1998-02-18 01:56:00 +08:00
|
|
|
* hypre_ProjectBoxArray:
|
1997-12-11 04:45:11 +08:00
|
|
|
*
|
1998-12-15 06:20:22 +08:00
|
|
|
* Note: The dimensions of the modified box array are not changed.
|
|
|
|
|
* So, it is possible to have boxes with volume 0.
|
1997-12-11 04:45:11 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_ProjectBoxArray( hypre_BoxArray *box_array,
|
1998-02-19 07:45:29 +08:00
|
|
|
hypre_Index index,
|
|
|
|
|
hypre_Index stride )
|
1997-12-11 04:45:11 +08:00
|
|
|
{
|
1998-12-15 06:20:22 +08:00
|
|
|
hypre_Box *box;
|
2010-12-23 09:25:40 +08:00
|
|
|
HYPRE_Int i;
|
1997-12-11 04:45:11 +08:00
|
|
|
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_ForBoxI(i, box_array)
|
2012-05-04 01:17:14 +08:00
|
|
|
{
|
|
|
|
|
box = hypre_BoxArrayBox(box_array, i);
|
|
|
|
|
hypre_ProjectBox(box, index, stride);
|
|
|
|
|
}
|
1997-12-11 04:45:11 +08:00
|
|
|
|
2012-05-04 01:17:14 +08:00
|
|
|
return hypre_error_flag;
|
1997-12-11 04:45:11 +08:00
|
|
|
}
|
|
|
|
|
|
1997-11-13 23:59:20 +08:00
|
|
|
/*--------------------------------------------------------------------------
|
1998-02-18 01:56:00 +08:00
|
|
|
* hypre_ProjectBoxArrayArray:
|
1997-11-26 04:30:53 +08:00
|
|
|
*
|
1998-12-15 06:20:22 +08:00
|
|
|
* Note: The dimensions of the modified box array-array are not changed.
|
|
|
|
|
* So, it is possible to have boxes with volume 0.
|
1997-11-13 23:59:20 +08:00
|
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
|
|
2010-12-21 03:27:44 +08:00
|
|
|
HYPRE_Int
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_ProjectBoxArrayArray( hypre_BoxArrayArray *box_array_array,
|
1998-02-19 07:45:29 +08:00
|
|
|
hypre_Index index,
|
|
|
|
|
hypre_Index stride )
|
1997-11-13 23:59:20 +08:00
|
|
|
{
|
1998-12-15 06:20:22 +08:00
|
|
|
hypre_BoxArray *box_array;
|
|
|
|
|
hypre_Box *box;
|
2010-12-23 09:25:40 +08:00
|
|
|
HYPRE_Int i, j;
|
1997-11-13 23:59:20 +08:00
|
|
|
|
1998-02-18 01:56:00 +08:00
|
|
|
hypre_ForBoxArrayI(i, box_array_array)
|
2012-05-04 01:17:14 +08:00
|
|
|
{
|
|
|
|
|
box_array = hypre_BoxArrayArrayBoxArray(box_array_array, i);
|
|
|
|
|
hypre_ForBoxI(j, box_array)
|
1998-02-19 07:45:29 +08:00
|
|
|
{
|
2012-05-04 01:17:14 +08:00
|
|
|
box = hypre_BoxArrayBox(box_array, j);
|
|
|
|
|
hypre_ProjectBox(box, index, stride);
|
1998-02-19 07:45:29 +08:00
|
|
|
}
|
2012-05-04 01:17:14 +08:00
|
|
|
}
|
1997-11-13 23:59:20 +08:00
|
|
|
|
2012-05-04 01:17:14 +08:00
|
|
|
return hypre_error_flag;
|
1997-11-13 23:59:20 +08:00
|
|
|
}
|
|
|
|
|
|