|
IFPACK Development
|
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 void AZ_ifpack_prec_create(double *x, double *b, 00041 int *options, double *params, 00042 int *proc_config, 00043 AZ_MATRIX *Amat, AZ_PRECOND **Prec) 00044 { 00045 AZ_IFPACK *Prec_pass_data; 00046 void *precon, *bmat ; 00047 int nr, nc, *data_org; 00048 double rthresh, athresh; 00049 00050 Prec_pass_data = (AZ_IFPACK *) AZ_allocate(sizeof(AZ_IFPACK)); 00051 az2ifp_blockmatrix(&bmat, Amat); /* Create IFPACK encapsulation of Amat */ 00052 00053 /* set the preconditioning structure 'Prec'. */ 00054 00055 if (options[AZ_precond] == AZ_none) 00056 ifp_preconditioner(&precon, bmat, IFP_NONE, 00057 (double) options[AZ_graph_fill], 0.0, 00058 IFP_INVERSE, 0.0, 0.0); 00059 00060 else if (options[AZ_precond] == AZ_Jacobi) 00061 { 00062 rthresh = params[AZ_rthresh]; 00063 athresh = params[AZ_athresh]; 00064 ifp_preconditioner(&precon, bmat, IFP_BJACOBI, 0.0, 0.0, 00065 IFP_SVD, rthresh, athresh); 00066 /*IFP_INVERSE, 0.0, 0.0); */ 00067 } 00068 00069 else if (options[AZ_precond] == AZ_dom_decomp && 00070 options[AZ_subdomain_solve] == AZ_bilu_ifp) 00071 { 00072 rthresh = params[AZ_rthresh]; 00073 athresh = params[AZ_athresh]; 00074 ifp_preconditioner(&precon, bmat, 00075 IFP_BILUK, (double) options[AZ_graph_fill], 0.0, 00076 IFP_SVD, rthresh, athresh); 00077 /*IFP_INVERSE, 0.0, 0.0); */ 00078 00079 } 00080 else 00081 { 00082 printf("Not a supported preconditioner in az_ifpack_prec_create\n"); 00083 abort(); 00084 } 00085 00086 (*Prec) = AZ_precond_create(Amat,AZ_ifpack_precon,NULL); 00087 00088 00089 /* Store pointers to preconditioner and IFPACK encapsulation of Amat */ 00090 Prec_pass_data->precon = precon; 00091 Prec_pass_data->bmat = bmat; 00092 00093 /* Construct auxiliary vector for use with apply function. 00094 NOTE: We are assuming only one RHS at this time !!! */ 00095 00096 data_org = Amat->data_org; 00097 nr = data_org[AZ_N_internal] + data_org[AZ_N_border]; 00098 nc = 1; 00099 /*input_vector = (double *) malloc (nr * sizeof(double)); 00100 Prec_pass_data.input_vector = input_vector; */ 00101 Prec_pass_data->nr = nr; 00102 Prec_pass_data->nc = nc; 00103 (*Prec)->Pmat = Amat; 00104 Prec_pass_data->user_aux_ptr = (*Prec)->Pmat->aux_ptr; /* Save this to be able to restore*/ 00105 (*Prec)->Pmat->aux_ptr = (void *) Prec_pass_data; 00106 (*Prec)->prec_function = AZ_ifpack_precon; 00107 Prec_pass_data->user_precon = options[AZ_precond]; /* Save this to be able to restore*/ 00108 options[AZ_precond] = AZ_user_precond; 00109 }
1.7.4