hypre/struct_ls/sparse_msg_setup_rap.c
2006-09-22 22:06:21 +00:00

135 lines
4.9 KiB
C

/*BHEADER**********************************************************************
* Copyright (c) 2006 The Regents of the University of California.
* Produced at the Lawrence Livermore National Laboratory.
* Written by the HYPRE team. UCRL-CODE-222953.
* All rights reserved.
*
* This file is part of HYPRE (see http://www.llnl.gov/CASC/hypre/).
* Please see the COPYRIGHT_and_LICENSE file for the copyright notice,
* disclaimer, contact information and the GNU Lesser General Public License.
*
* HYPRE is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License (as published by the Free Software
* Foundation) version 2.1 dated February 1999.
*
* HYPRE is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the terms and conditions of the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision$
***********************************************************************EHEADER*/
/******************************************************************************
*
*
*****************************************************************************/
#include "headers.h"
/*--------------------------------------------------------------------------
* hypre_SparseMSGCreateRAPOp
*
* Wrapper for 2 and 3d CreateRAPOp routines which set up new coarse
* grid structures.
*--------------------------------------------------------------------------*/
hypre_StructMatrix *
hypre_SparseMSGCreateRAPOp( hypre_StructMatrix *R,
hypre_StructMatrix *A,
hypre_StructMatrix *P,
hypre_StructGrid *coarse_grid,
int cdir )
{
hypre_StructMatrix *RAP;
hypre_StructStencil *stencil;
stencil = hypre_StructMatrixStencil(A);
switch (hypre_StructStencilDim(stencil))
{
case 2:
RAP = hypre_SparseMSG2CreateRAPOp(R ,A, P, coarse_grid, cdir);
break;
case 3:
RAP = hypre_SparseMSG3CreateRAPOp(R ,A, P, coarse_grid, cdir);
break;
}
return RAP;
}
/*--------------------------------------------------------------------------
* hypre_SparseMSGSetupRAPOp
*
* Wrapper for 2 and 3d, symmetric and non-symmetric routines to calculate
* entries in RAP. Incomplete error handling at the moment.
*--------------------------------------------------------------------------*/
int
hypre_SparseMSGSetupRAPOp( hypre_StructMatrix *R,
hypre_StructMatrix *A,
hypre_StructMatrix *P,
int cdir,
hypre_Index cindex,
hypre_Index cstride,
hypre_Index stridePR,
hypre_StructMatrix *Ac )
{
int ierr = 0;
hypre_StructStencil *stencil;
stencil = hypre_StructMatrixStencil(A);
switch (hypre_StructStencilDim(stencil))
{
case 2:
/*--------------------------------------------------------------------
* Set lower triangular (+ diagonal) coefficients
*--------------------------------------------------------------------*/
ierr = hypre_SparseMSG2BuildRAPSym(A, P, R, cdir,
cindex, cstride, stridePR, Ac);
/*--------------------------------------------------------------------
* For non-symmetric A, set upper triangular coefficients as well
*--------------------------------------------------------------------*/
if(!hypre_StructMatrixSymmetric(A))
ierr += hypre_SparseMSG2BuildRAPNoSym(A, P, R, cdir,
cindex, cstride, stridePR, Ac);
break;
case 3:
/*--------------------------------------------------------------------
* Set lower triangular (+ diagonal) coefficients
*--------------------------------------------------------------------*/
ierr = hypre_SparseMSG3BuildRAPSym(A, P, R, cdir,
cindex, cstride, stridePR, Ac);
/*--------------------------------------------------------------------
* For non-symmetric A, set upper triangular coefficients as well
*--------------------------------------------------------------------*/
if(!hypre_StructMatrixSymmetric(A))
ierr += hypre_SparseMSG3BuildRAPNoSym(A, P, R, cdir,
cindex, cstride, stridePR, Ac);
break;
}
hypre_StructMatrixAssemble(Ac);
return ierr;
}