IFPACK
Development
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Friends
Pages
src
az_ifpack_precon.c
1
2
/*@HEADER
3
// ***********************************************************************
4
//
5
// Ifpack: Object-Oriented Algebraic Preconditioner Package
6
// Copyright (2002) Sandia Corporation
7
//
8
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9
// license for use of this work by or on behalf of the U.S. Government.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39
//
40
// ***********************************************************************
41
//@HEADER
42
*/
43
44
/*******************************************************************************
45
* MATRIX FREE matrix vector multiplication
46
******************************************************************************/
47
48
#include <stdio.h>
49
#include <stdlib.h>
50
#include <math.h>
51
#include "az_aztec.h"
52
#include "az_ifpack.h"
53
54
void
AZ_ifpack_precon(
double
x[],
int
options[],
55
int
proc_config[],
double
params[], AZ_MATRIX *Amat,
56
AZ_PRECOND *Prec)
57
58
59
/******************************************************************************/
60
/*
61
* A bogus preconditioning subroutine which simply smooths x[]
62
* in the interior of each local grid by taking averages with
63
* neighboring grid points.
64
*
65
* Parameters:
66
* =========
67
* x On input, a vector. On output, x[] is
68
* smoothed by taking averages with neighbors.
69
*
70
* prec On input, prec->Pmat->aux_ptr points to
71
* that data_structure 'pass_data' which contains
72
* the local grid size (nx,ny) on this processor.
73
*
74
* Amat, input_options, Not used.
75
* proc_config, Amat,
76
* input_params
77
*
78
*/
79
80
81
{
82
int
i, len;
83
void
*precon;
84
AZ_IFPACK
*Prec_pass_data;
85
int
nr, nc;
86
double
*input_vector;
87
/* Data passing structure. This user- */
88
/* defined data structure is used to pass */
89
/* information through Aztec and back into*/
90
/* the user's subroutines. */
91
92
/*-------------------------------------------------------------------------*/
93
/* Extract necessary data from pass_data */
94
95
Prec_pass_data = (
AZ_IFPACK
*) Prec->Pmat->aux_ptr;
96
precon = (
void
*) Prec_pass_data->precon;
97
nr = Prec_pass_data->nr;
98
nc = Prec_pass_data->nc;
99
if
(nc != 1) abort();
100
/* input_vector = (double *) Prec_pass_data->input_vector; */
101
input_vector = (
double
*) malloc (nr *
sizeof
(
double
));
102
len = nr*nc;
103
/* dcopy_(&len, x, &ione, input_vector, &ione); */
104
105
for
(i=0; i<len; i++) input_vector[i] = x[i];
106
107
ifp_apply(precon, nr, nc, input_vector, nr, x, nr);
108
free((
void
*) input_vector);
109
}
AZ_IFPACK_STRUCT
Definition:
az_ifpack.h:48
Generated on Thu Nov 21 2024 09:19:11 for IFPACK by
1.8.5