source: CIVL/examples/mpi-omp/AMG2013/parcsr_ls/pcg_par.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 7.8 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13
14
15
16/******************************************************************************
17 *
18 * Struct matrix-vector implementation of PCG interface routines.
19 *
20 *****************************************************************************/
21
22#include "headers.h"
23
24/*--------------------------------------------------------------------------
25 * hypre_ParKrylovCAlloc
26 *--------------------------------------------------------------------------*/
27
28char *
29hypre_ParKrylovCAlloc( int count,
30 int elt_size )
31{
32 return( hypre_CAlloc( count, elt_size ) );
33}
34
35/*--------------------------------------------------------------------------
36 * hypre_ParKrylovFree
37 *--------------------------------------------------------------------------*/
38
39int
40hypre_ParKrylovFree( char *ptr )
41{
42 int ierr = 0;
43
44 hypre_Free( ptr );
45
46 return ierr;
47}
48
49/*--------------------------------------------------------------------------
50 * hypre_ParKrylovCreateVector
51 *--------------------------------------------------------------------------*/
52
53void *
54hypre_ParKrylovCreateVector( void *vvector )
55{
56 hypre_ParVector *vector = vvector;
57 hypre_ParVector *new_vector;
58
59 new_vector = hypre_ParVectorCreate( hypre_ParVectorComm(vector),
60 hypre_ParVectorGlobalSize(vector),
61 hypre_ParVectorPartitioning(vector) );
62 hypre_ParVectorSetPartitioningOwner(new_vector,0);
63 hypre_ParVectorInitialize(new_vector);
64
65 return ( (void *) new_vector );
66}
67
68/*--------------------------------------------------------------------------
69 * hypre_ParKrylovCreateVectorArray
70 *--------------------------------------------------------------------------*/
71
72void *
73hypre_ParKrylovCreateVectorArray(int n, void *vvector )
74{
75 hypre_ParVector *vector = vvector;
76 hypre_ParVector **new_vector;
77 int i;
78
79 new_vector = hypre_CTAlloc(hypre_ParVector*,n);
80 for (i=0; i < n; i++)
81 {
82 new_vector[i] = hypre_ParVectorCreate( hypre_ParVectorComm(vector),
83 hypre_ParVectorGlobalSize(vector),
84 hypre_ParVectorPartitioning(vector) );
85 hypre_ParVectorSetPartitioningOwner(new_vector[i],0);
86 hypre_ParVectorInitialize(new_vector[i]);
87 }
88
89 return ( (void *) new_vector );
90}
91
92/*--------------------------------------------------------------------------
93 * hypre_ParKrylovDestroyVector
94 *--------------------------------------------------------------------------*/
95
96int
97hypre_ParKrylovDestroyVector( void *vvector )
98{
99 hypre_ParVector *vector = vvector;
100
101 return( hypre_ParVectorDestroy( vector ) );
102}
103
104/*--------------------------------------------------------------------------
105 * hypre_ParKrylovMatvecCreate
106 *--------------------------------------------------------------------------*/
107
108void *
109hypre_ParKrylovMatvecCreate( void *A,
110 void *x )
111{
112 void *matvec_data;
113
114 matvec_data = NULL;
115
116 return ( matvec_data );
117}
118
119/*--------------------------------------------------------------------------
120 * hypre_ParKrylovMatvec
121 *--------------------------------------------------------------------------*/
122
123int
124hypre_ParKrylovMatvec( void *matvec_data,
125 double alpha,
126 void *A,
127 void *x,
128 double beta,
129 void *y )
130{
131 return ( hypre_ParCSRMatrixMatvec ( alpha,
132 (hypre_ParCSRMatrix *) A,
133 (hypre_ParVector *) x,
134 beta,
135 (hypre_ParVector *) y ) );
136}
137
138/*--------------------------------------------------------------------------
139 * hypre_ParKrylovMatvecT
140 *--------------------------------------------------------------------------*/
141
142int
143hypre_ParKrylovMatvecT(void *matvec_data,
144 double alpha,
145 void *A,
146 void *x,
147 double beta,
148 void *y )
149{
150 return ( hypre_ParCSRMatrixMatvecT( alpha,
151 (hypre_ParCSRMatrix *) A,
152 (hypre_ParVector *) x,
153 beta,
154 (hypre_ParVector *) y ) );
155}
156
157/*--------------------------------------------------------------------------
158 * hypre_ParKrylovMatvecDestroy
159 *--------------------------------------------------------------------------*/
160
161int
162hypre_ParKrylovMatvecDestroy( void *matvec_data )
163{
164 return 0;
165}
166
167/*--------------------------------------------------------------------------
168 * hypre_ParKrylovInnerProd
169 *--------------------------------------------------------------------------*/
170
171double
172hypre_ParKrylovInnerProd( void *x,
173 void *y )
174{
175 return ( hypre_ParVectorInnerProd( (hypre_ParVector *) x,
176 (hypre_ParVector *) y ) );
177}
178
179
180/*--------------------------------------------------------------------------
181 * hypre_ParKrylovCopyVector
182 *--------------------------------------------------------------------------*/
183
184int
185hypre_ParKrylovCopyVector( void *x,
186 void *y )
187{
188 return ( hypre_ParVectorCopy( (hypre_ParVector *) x,
189 (hypre_ParVector *) y ) );
190}
191
192/*--------------------------------------------------------------------------
193 * hypre_ParKrylovClearVector
194 *--------------------------------------------------------------------------*/
195
196int
197hypre_ParKrylovClearVector( void *x )
198{
199 return ( hypre_ParVectorSetConstantValues( (hypre_ParVector *) x, 0.0 ) );
200}
201
202/*--------------------------------------------------------------------------
203 * hypre_ParKrylovScaleVector
204 *--------------------------------------------------------------------------*/
205
206int
207hypre_ParKrylovScaleVector( double alpha,
208 void *x )
209{
210 return ( hypre_ParVectorScale( alpha, (hypre_ParVector *) x ) );
211}
212
213/*--------------------------------------------------------------------------
214 * hypre_ParKrylovAxpy
215 *--------------------------------------------------------------------------*/
216
217int
218hypre_ParKrylovAxpy( double alpha,
219 void *x,
220 void *y )
221{
222 return ( hypre_ParVectorAxpy( alpha, (hypre_ParVector *) x,
223 (hypre_ParVector *) y ) );
224}
225
226/*--------------------------------------------------------------------------
227 * hypre_ParKrylovCommInfo
228 *--------------------------------------------------------------------------*/
229
230int
231hypre_ParKrylovCommInfo( void *A, int *my_id, int *num_procs)
232{
233 MPI_Comm comm = hypre_ParCSRMatrixComm ( (hypre_ParCSRMatrix *) A);
234 MPI_Comm_size(comm,num_procs);
235 MPI_Comm_rank(comm,my_id);
236 return 0;
237}
238
239/*--------------------------------------------------------------------------
240 * hypre_ParKrylovIdentitySetup
241 *--------------------------------------------------------------------------*/
242
243int
244hypre_ParKrylovIdentitySetup( void *vdata,
245 void *A,
246 void *b,
247 void *x )
248
249{
250 return 0;
251}
252
253/*--------------------------------------------------------------------------
254 * hypre_ParKrylovIdentity
255 *--------------------------------------------------------------------------*/
256
257int
258hypre_ParKrylovIdentity( void *vdata,
259 void *A,
260 void *b,
261 void *x )
262
263{
264 return( hypre_ParKrylovCopyVector( b, x ) );
265}
266
Note: See TracBrowser for help on using the repository browser.