00001 00002 /*@HEADER 00003 // *********************************************************************** 00004 // 00005 // Ifpack: Object-Oriented Algebraic Preconditioner Package 00006 // Copyright (2002) Sandia Corporation 00007 // 00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00009 // license for use of this work by or on behalf of the U.S. Government. 00010 // 00011 // This library is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Lesser General Public License as 00013 // published by the Free Software Foundation; either version 2.1 of the 00014 // License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, but 00017 // WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Lesser General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Lesser General Public 00022 // License along with this library; if not, write to the Free Software 00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00024 // USA 00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00026 // 00027 // *********************************************************************** 00028 //@HEADER 00029 */ 00030 00031 /******************************************************************************* 00032 * MATRIX FREE matrix vector multiplication 00033 ******************************************************************************/ 00034 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 #include <math.h> 00038 #include "az_aztec.h" 00039 #include "az_ifpack.h" 00040 00041 void AZ_ifpack_precon(double x[], int options[], 00042 int proc_config[], double params[], AZ_MATRIX *Amat, 00043 AZ_PRECOND *Prec) 00044 00045 00046 /******************************************************************************/ 00047 /* 00048 * A bogus preconditioning subroutine which simply smooths x[] 00049 * in the interior of each local grid by taking averages with 00050 * neighboring grid points. 00051 * 00052 * Parameters: 00053 * ========= 00054 * x On input, a vector. On output, x[] is 00055 * smoothed by taking averages with neighbors. 00056 * 00057 * prec On input, prec->Pmat->aux_ptr points to 00058 * that data_structure 'pass_data' which contains 00059 * the local grid size (nx,ny) on this processor. 00060 * 00061 * Amat, input_options, Not used. 00062 * proc_config, Amat, 00063 * input_params 00064 * 00065 */ 00066 00067 00068 { 00069 int i, len; 00070 void *precon; 00071 AZ_IFPACK *Prec_pass_data; 00072 int nr, nc; 00073 double *input_vector; 00074 /* Data passing structure. This user- */ 00075 /* defined data structure is used to pass */ 00076 /* information through Aztec and back into*/ 00077 /* the user's subroutines. */ 00078 00079 /*-------------------------------------------------------------------------*/ 00080 /* Extract necessary data from pass_data */ 00081 00082 Prec_pass_data = (AZ_IFPACK *) Prec->Pmat->aux_ptr; 00083 precon = (void *) Prec_pass_data->precon; 00084 nr = Prec_pass_data->nr; 00085 nc = Prec_pass_data->nc; 00086 if (nc != 1) abort(); 00087 /* input_vector = (double *) Prec_pass_data->input_vector; */ 00088 input_vector = (double *) malloc (nr * sizeof(double)); 00089 len = nr*nc; 00090 /* dcopy_(&len, x, &ione, input_vector, &ione); */ 00091 00092 for (i=0; i<len; i++) input_vector[i] = x[i]; 00093 00094 ifp_apply(precon, nr, nc, input_vector, nr, x, nr); 00095 free((void *) input_vector); 00096 }
1.4.7