| 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 | * HYPRE_ParVector interface
|
|---|
| 18 | *
|
|---|
| 19 | *****************************************************************************/
|
|---|
| 20 |
|
|---|
| 21 | #include "headers.h"
|
|---|
| 22 |
|
|---|
| 23 | /*--------------------------------------------------------------------------
|
|---|
| 24 | * HYPRE_ParVectorCreate
|
|---|
| 25 | *--------------------------------------------------------------------------*/
|
|---|
| 26 |
|
|---|
| 27 | int
|
|---|
| 28 | HYPRE_ParVectorCreate( MPI_Comm comm,
|
|---|
| 29 | HYPRE_BigInt global_size,
|
|---|
| 30 | HYPRE_BigInt *partitioning,
|
|---|
| 31 | HYPRE_ParVector *vector )
|
|---|
| 32 | {
|
|---|
| 33 | *vector = (HYPRE_ParVector) hypre_ParVectorCreate(comm, global_size,
|
|---|
| 34 | partitioning) ;
|
|---|
| 35 | if (!vector) hypre_error_in_arg(4);
|
|---|
| 36 |
|
|---|
| 37 | return hypre_error_flag;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | /*--------------------------------------------------------------------------
|
|---|
| 41 | * HYPRE_ParMultiVectorCreate
|
|---|
| 42 | *--------------------------------------------------------------------------*/
|
|---|
| 43 |
|
|---|
| 44 | /*int
|
|---|
| 45 | HYPRE_ParMultiVectorCreate( MPI_Comm comm,
|
|---|
| 46 | int global_size,
|
|---|
| 47 | int *partitioning,
|
|---|
| 48 | int number_vectors,
|
|---|
| 49 | HYPRE_ParVector *vector )
|
|---|
| 50 | {
|
|---|
| 51 | *vector = (HYPRE_ParVector) hypre_ParMultiVectorCreate
|
|---|
| 52 | (comm, global_size, partitioning, number_vectors );
|
|---|
| 53 |
|
|---|
| 54 | if (!vector) hypre_error_in_arg(5);
|
|---|
| 55 |
|
|---|
| 56 | return hypre_error_flag;
|
|---|
| 57 | }*/
|
|---|
| 58 |
|
|---|
| 59 | /*--------------------------------------------------------------------------
|
|---|
| 60 | * HYPRE_ParVectorDestroy
|
|---|
| 61 | *--------------------------------------------------------------------------*/
|
|---|
| 62 |
|
|---|
| 63 | int
|
|---|
| 64 | HYPRE_ParVectorDestroy( HYPRE_ParVector vector )
|
|---|
| 65 | {
|
|---|
| 66 | return ( hypre_ParVectorDestroy( (hypre_ParVector *) vector ) );
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | /*--------------------------------------------------------------------------
|
|---|
| 70 | * HYPRE_ParVectorInitialize
|
|---|
| 71 | *--------------------------------------------------------------------------*/
|
|---|
| 72 |
|
|---|
| 73 | int
|
|---|
| 74 | HYPRE_ParVectorInitialize( HYPRE_ParVector vector )
|
|---|
| 75 | {
|
|---|
| 76 | return ( hypre_ParVectorInitialize( (hypre_ParVector *) vector ) );
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | /*--------------------------------------------------------------------------
|
|---|
| 80 | * HYPRE_ParVectorRead
|
|---|
| 81 | *--------------------------------------------------------------------------*/
|
|---|
| 82 |
|
|---|
| 83 | int
|
|---|
| 84 | HYPRE_ParVectorRead( MPI_Comm comm,
|
|---|
| 85 | const char *file_name,
|
|---|
| 86 | HYPRE_ParVector *vector)
|
|---|
| 87 | {
|
|---|
| 88 | *vector = (HYPRE_ParVector) hypre_ParVectorRead( comm, file_name ) ;
|
|---|
| 89 | if (!vector) hypre_error_in_arg(3);
|
|---|
| 90 | return hypre_error_flag;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /*--------------------------------------------------------------------------
|
|---|
| 94 | * HYPRE_ParVectorPrint
|
|---|
| 95 | *--------------------------------------------------------------------------*/
|
|---|
| 96 |
|
|---|
| 97 | int
|
|---|
| 98 | HYPRE_ParVectorPrint( HYPRE_ParVector vector,
|
|---|
| 99 | const char *file_name )
|
|---|
| 100 | {
|
|---|
| 101 | return ( hypre_ParVectorPrint( (hypre_ParVector *) vector,
|
|---|
| 102 | file_name ) );
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | /*--------------------------------------------------------------------------
|
|---|
| 106 | * HYPRE_ParVectorPrintIJ
|
|---|
| 107 | *--------------------------------------------------------------------------*/
|
|---|
| 108 |
|
|---|
| 109 | int
|
|---|
| 110 | HYPRE_ParVectorPrintIJ( HYPRE_ParVector vector,
|
|---|
| 111 | int base_i, const char *file_name )
|
|---|
| 112 | {
|
|---|
| 113 | return ( hypre_ParVectorPrintIJ( (hypre_ParVector *) vector, base_i,
|
|---|
| 114 | file_name ) );
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /*--------------------------------------------------------------------------
|
|---|
| 118 | * HYPRE_ParVectorSetConstantValues
|
|---|
| 119 | *--------------------------------------------------------------------------*/
|
|---|
| 120 |
|
|---|
| 121 | int
|
|---|
| 122 | HYPRE_ParVectorSetConstantValues( HYPRE_ParVector vector,
|
|---|
| 123 | double value )
|
|---|
| 124 | {
|
|---|
| 125 | return ( hypre_ParVectorSetConstantValues( (hypre_ParVector *) vector,
|
|---|
| 126 | value ) );
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | /*--------------------------------------------------------------------------
|
|---|
| 130 | * HYPRE_ParVectorSetRandomValues
|
|---|
| 131 | *--------------------------------------------------------------------------*/
|
|---|
| 132 |
|
|---|
| 133 | int
|
|---|
| 134 | HYPRE_ParVectorSetRandomValues( HYPRE_ParVector vector,
|
|---|
| 135 | int seed )
|
|---|
| 136 | {
|
|---|
| 137 | return ( hypre_ParVectorSetRandomValues( (hypre_ParVector *) vector,
|
|---|
| 138 | seed ) );
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | /*--------------------------------------------------------------------------
|
|---|
| 142 | * HYPRE_ParVectorCopy
|
|---|
| 143 | *--------------------------------------------------------------------------*/
|
|---|
| 144 |
|
|---|
| 145 | int
|
|---|
| 146 | HYPRE_ParVectorCopy( HYPRE_ParVector x, HYPRE_ParVector y)
|
|---|
| 147 | {
|
|---|
| 148 | return ( hypre_ParVectorCopy( (hypre_ParVector *) x,
|
|---|
| 149 | (hypre_ParVector *) y ) );
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | /*--------------------------------------------------------------------------
|
|---|
| 153 | * HYPRE_ParVectorCloneShallow
|
|---|
| 154 | *--------------------------------------------------------------------------*/
|
|---|
| 155 |
|
|---|
| 156 | HYPRE_ParVector
|
|---|
| 157 | HYPRE_ParVectorCloneShallow( HYPRE_ParVector x )
|
|---|
| 158 | {
|
|---|
| 159 | return ( (HYPRE_ParVector) hypre_ParVectorCloneShallow( (hypre_ParVector *) x ) );
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | /*--------------------------------------------------------------------------
|
|---|
| 163 | * HYPRE_ParVectorScale
|
|---|
| 164 | *--------------------------------------------------------------------------*/
|
|---|
| 165 |
|
|---|
| 166 | int
|
|---|
| 167 | HYPRE_ParVectorScale( double value, HYPRE_ParVector x)
|
|---|
| 168 | {
|
|---|
| 169 | return ( hypre_ParVectorScale( value, (hypre_ParVector *) x) );
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | /*--------------------------------------------------------------------------
|
|---|
| 173 | * HYPRE_ParVectorAxpy
|
|---|
| 174 | *--------------------------------------------------------------------------*/
|
|---|
| 175 | int
|
|---|
| 176 | HYPRE_ParVectorAxpy( double alpha,
|
|---|
| 177 | HYPRE_ParVector x,
|
|---|
| 178 | HYPRE_ParVector y )
|
|---|
| 179 | {
|
|---|
| 180 | return hypre_ParVectorAxpy( alpha, (hypre_ParVector *)x, (hypre_ParVector *)y );
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | /*--------------------------------------------------------------------------
|
|---|
| 184 | * HYPRE_ParVectorInnerProd
|
|---|
| 185 | *--------------------------------------------------------------------------*/
|
|---|
| 186 |
|
|---|
| 187 | int
|
|---|
| 188 | HYPRE_ParVectorInnerProd( HYPRE_ParVector x, HYPRE_ParVector y, double *prod)
|
|---|
| 189 | {
|
|---|
| 190 | if (!x)
|
|---|
| 191 | {
|
|---|
| 192 | hypre_error_in_arg(1);
|
|---|
| 193 | return hypre_error_flag;
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | if (!y)
|
|---|
| 197 | {
|
|---|
| 198 | hypre_error_in_arg(2);
|
|---|
| 199 | return hypre_error_flag;
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | *prod = hypre_ParVectorInnerProd( (hypre_ParVector *) x,
|
|---|
| 203 | (hypre_ParVector *) y) ;
|
|---|
| 204 | return hypre_error_flag;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | /*--------------------------------------------------------------------------
|
|---|
| 208 | * HYPRE_VectorToParVector
|
|---|
| 209 | *--------------------------------------------------------------------------*/
|
|---|
| 210 |
|
|---|
| 211 | /*int
|
|---|
| 212 | HYPRE_VectorToParVector( MPI_Comm comm, HYPRE_Vector b, int *partitioning,
|
|---|
| 213 | HYPRE_ParVector *vector)
|
|---|
| 214 | {
|
|---|
| 215 | *vector = (HYPRE_ParVector) hypre_VectorToParVector (comm,
|
|---|
| 216 | (hypre_Vector *) b, partitioning );
|
|---|
| 217 | if (!vector) hypre_error_in_arg(4);
|
|---|
| 218 | return hypre_error_flag;
|
|---|
| 219 | }*/
|
|---|