| 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 | * HYPRE_StructVector interface
|
|---|
| 17 | *
|
|---|
| 18 | *****************************************************************************/
|
|---|
| 19 |
|
|---|
| 20 | #include "headers.h"
|
|---|
| 21 |
|
|---|
| 22 | /*--------------------------------------------------------------------------
|
|---|
| 23 | * HYPRE_StructVectorCreate
|
|---|
| 24 | *--------------------------------------------------------------------------*/
|
|---|
| 25 |
|
|---|
| 26 | int
|
|---|
| 27 | HYPRE_StructVectorCreate( MPI_Comm comm,
|
|---|
| 28 | HYPRE_StructGrid grid,
|
|---|
| 29 | HYPRE_StructVector *vector )
|
|---|
| 30 | {
|
|---|
| 31 | int ierr = 0;
|
|---|
| 32 |
|
|---|
| 33 | *vector = hypre_StructVectorCreate(comm, grid);
|
|---|
| 34 |
|
|---|
| 35 | return ierr;
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | /*--------------------------------------------------------------------------
|
|---|
| 39 | * HYPRE_StructVectorDestroy
|
|---|
| 40 | *--------------------------------------------------------------------------*/
|
|---|
| 41 |
|
|---|
| 42 | int
|
|---|
| 43 | HYPRE_StructVectorDestroy( HYPRE_StructVector struct_vector )
|
|---|
| 44 | {
|
|---|
| 45 | return( hypre_StructVectorDestroy(struct_vector) );
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | /*--------------------------------------------------------------------------
|
|---|
| 49 | * HYPRE_StructVectorInitialize
|
|---|
| 50 | *--------------------------------------------------------------------------*/
|
|---|
| 51 |
|
|---|
| 52 | int
|
|---|
| 53 | HYPRE_StructVectorInitialize( HYPRE_StructVector vector )
|
|---|
| 54 | {
|
|---|
| 55 | return ( hypre_StructVectorInitialize(vector) );
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | /*--------------------------------------------------------------------------
|
|---|
| 59 | * HYPRE_StructVectorClearGhostValues
|
|---|
| 60 | *--------------------------------------------------------------------------*/
|
|---|
| 61 |
|
|---|
| 62 | int
|
|---|
| 63 | HYPRE_StructVectorClearGhostValues( HYPRE_StructVector vector )
|
|---|
| 64 | {
|
|---|
| 65 | return ( hypre_StructVectorClearGhostValues(vector) );
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | /*--------------------------------------------------------------------------
|
|---|
| 69 | * HYPRE_StructVectorSetValues
|
|---|
| 70 | *--------------------------------------------------------------------------*/
|
|---|
| 71 |
|
|---|
| 72 | int
|
|---|
| 73 | HYPRE_StructVectorSetValues( HYPRE_StructVector vector,
|
|---|
| 74 | int *grid_index,
|
|---|
| 75 | double values )
|
|---|
| 76 | {
|
|---|
| 77 | hypre_Index new_grid_index;
|
|---|
| 78 |
|
|---|
| 79 | int d;
|
|---|
| 80 | int ierr = 0;
|
|---|
| 81 |
|
|---|
| 82 | hypre_ClearIndex(new_grid_index);
|
|---|
| 83 | for (d = 0; d < hypre_StructGridDim(hypre_StructVectorGrid(vector)); d++)
|
|---|
| 84 | {
|
|---|
| 85 | hypre_IndexD(new_grid_index, d) = grid_index[d];
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | ierr = hypre_StructVectorSetValues(vector, new_grid_index, values, 0);
|
|---|
| 89 |
|
|---|
| 90 | return ierr;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /*--------------------------------------------------------------------------
|
|---|
| 94 | * HYPRE_StructVectorSetBoxValues
|
|---|
| 95 | *--------------------------------------------------------------------------*/
|
|---|
| 96 |
|
|---|
| 97 | int
|
|---|
| 98 | HYPRE_StructVectorSetBoxValues( HYPRE_StructVector vector,
|
|---|
| 99 | int *ilower,
|
|---|
| 100 | int *iupper,
|
|---|
| 101 | double *values )
|
|---|
| 102 | {
|
|---|
| 103 | hypre_Index new_ilower;
|
|---|
| 104 | hypre_Index new_iupper;
|
|---|
| 105 | hypre_Box *new_value_box;
|
|---|
| 106 |
|
|---|
| 107 | int d;
|
|---|
| 108 | int ierr = 0;
|
|---|
| 109 |
|
|---|
| 110 | hypre_ClearIndex(new_ilower);
|
|---|
| 111 | hypre_ClearIndex(new_iupper);
|
|---|
| 112 | for (d = 0; d < hypre_StructGridDim(hypre_StructVectorGrid(vector)); d++)
|
|---|
| 113 | {
|
|---|
| 114 | hypre_IndexD(new_ilower, d) = ilower[d];
|
|---|
| 115 | hypre_IndexD(new_iupper, d) = iupper[d];
|
|---|
| 116 | }
|
|---|
| 117 | new_value_box = hypre_BoxCreate();
|
|---|
| 118 | hypre_BoxSetExtents(new_value_box, new_ilower, new_iupper);
|
|---|
| 119 |
|
|---|
| 120 | ierr = hypre_StructVectorSetBoxValues(vector, new_value_box, values, 0 );
|
|---|
| 121 |
|
|---|
| 122 | hypre_BoxDestroy(new_value_box);
|
|---|
| 123 |
|
|---|
| 124 | return ierr;
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | /*--------------------------------------------------------------------------
|
|---|
| 128 | * HYPRE_StructVectorAddToValues
|
|---|
| 129 | *--------------------------------------------------------------------------*/
|
|---|
| 130 |
|
|---|
| 131 | int
|
|---|
| 132 | HYPRE_StructVectorAddToValues( HYPRE_StructVector vector,
|
|---|
| 133 | int *grid_index,
|
|---|
| 134 | double values )
|
|---|
| 135 | {
|
|---|
| 136 | hypre_Index new_grid_index;
|
|---|
| 137 |
|
|---|
| 138 | int d;
|
|---|
| 139 | int ierr = 0;
|
|---|
| 140 |
|
|---|
| 141 | hypre_ClearIndex(new_grid_index);
|
|---|
| 142 | for (d = 0; d < hypre_StructGridDim(hypre_StructVectorGrid(vector)); d++)
|
|---|
| 143 | {
|
|---|
| 144 | hypre_IndexD(new_grid_index, d) = grid_index[d];
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | ierr = hypre_StructVectorSetValues(vector, new_grid_index, values, 1);
|
|---|
| 148 |
|
|---|
| 149 | return ierr;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | /*--------------------------------------------------------------------------
|
|---|
| 153 | * HYPRE_StructVectorAddToBoxValues
|
|---|
| 154 | *--------------------------------------------------------------------------*/
|
|---|
| 155 |
|
|---|
| 156 | int
|
|---|
| 157 | HYPRE_StructVectorAddToBoxValues( HYPRE_StructVector vector,
|
|---|
| 158 | int *ilower,
|
|---|
| 159 | int *iupper,
|
|---|
| 160 | double *values )
|
|---|
| 161 | {
|
|---|
| 162 | hypre_Index new_ilower;
|
|---|
| 163 | hypre_Index new_iupper;
|
|---|
| 164 | hypre_Box *new_value_box;
|
|---|
| 165 |
|
|---|
| 166 | int d;
|
|---|
| 167 | int ierr = 0;
|
|---|
| 168 |
|
|---|
| 169 | hypre_ClearIndex(new_ilower);
|
|---|
| 170 | hypre_ClearIndex(new_iupper);
|
|---|
| 171 | for (d = 0; d < hypre_StructGridDim(hypre_StructVectorGrid(vector)); d++)
|
|---|
| 172 | {
|
|---|
| 173 | hypre_IndexD(new_ilower, d) = ilower[d];
|
|---|
| 174 | hypre_IndexD(new_iupper, d) = iupper[d];
|
|---|
| 175 | }
|
|---|
| 176 | new_value_box = hypre_BoxCreate();
|
|---|
| 177 | hypre_BoxSetExtents(new_value_box, new_ilower, new_iupper);
|
|---|
| 178 |
|
|---|
| 179 | ierr = hypre_StructVectorSetBoxValues(vector, new_value_box, values, 1);
|
|---|
| 180 |
|
|---|
| 181 | hypre_BoxDestroy(new_value_box);
|
|---|
| 182 |
|
|---|
| 183 | return ierr;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | /*--------------------------------------------------------------------------
|
|---|
| 187 | * HYPRE_StructVectorScaleValues
|
|---|
| 188 | *--------------------------------------------------------------------------*/
|
|---|
| 189 |
|
|---|
| 190 | int
|
|---|
| 191 | HYPRE_StructVectorScaleValues( HYPRE_StructVector vector,
|
|---|
| 192 | double factor )
|
|---|
| 193 | {
|
|---|
| 194 | return hypre_StructVectorScaleValues( vector, factor );
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | /*--------------------------------------------------------------------------
|
|---|
| 198 | * HYPRE_StructVectorGetValues
|
|---|
| 199 | *--------------------------------------------------------------------------*/
|
|---|
| 200 |
|
|---|
| 201 | int
|
|---|
| 202 | HYPRE_StructVectorGetValues( HYPRE_StructVector vector,
|
|---|
| 203 | int *grid_index,
|
|---|
| 204 | double *values_ptr )
|
|---|
| 205 | {
|
|---|
| 206 | hypre_Index new_grid_index;
|
|---|
| 207 |
|
|---|
| 208 | int d;
|
|---|
| 209 | int ierr = 0;
|
|---|
| 210 |
|
|---|
| 211 | hypre_ClearIndex(new_grid_index);
|
|---|
| 212 | for (d = 0; d < hypre_StructGridDim(hypre_StructVectorGrid(vector)); d++)
|
|---|
| 213 | {
|
|---|
| 214 | hypre_IndexD(new_grid_index, d) = grid_index[d];
|
|---|
| 215 | }
|
|---|
| 216 |
|
|---|
| 217 | ierr = hypre_StructVectorGetValues(vector, new_grid_index, values_ptr);
|
|---|
| 218 |
|
|---|
| 219 | return ierr;
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | /*--------------------------------------------------------------------------
|
|---|
| 223 | * HYPRE_StructVectorGetBoxValues
|
|---|
| 224 | *--------------------------------------------------------------------------*/
|
|---|
| 225 |
|
|---|
| 226 | int
|
|---|
| 227 | HYPRE_StructVectorGetBoxValues( HYPRE_StructVector vector,
|
|---|
| 228 | int *ilower,
|
|---|
| 229 | int *iupper,
|
|---|
| 230 | double *values )
|
|---|
| 231 | {
|
|---|
| 232 | hypre_Index new_ilower;
|
|---|
| 233 | hypre_Index new_iupper;
|
|---|
| 234 | hypre_Box *new_value_box;
|
|---|
| 235 |
|
|---|
| 236 | int d;
|
|---|
| 237 | int ierr = 0;
|
|---|
| 238 |
|
|---|
| 239 | hypre_ClearIndex(new_ilower);
|
|---|
| 240 | hypre_ClearIndex(new_iupper);
|
|---|
| 241 | for (d = 0; d < hypre_StructGridDim(hypre_StructVectorGrid(vector)); d++)
|
|---|
| 242 | {
|
|---|
| 243 | hypre_IndexD(new_ilower, d) = ilower[d];
|
|---|
| 244 | hypre_IndexD(new_iupper, d) = iupper[d];
|
|---|
| 245 | }
|
|---|
| 246 | new_value_box = hypre_BoxCreate();
|
|---|
| 247 | hypre_BoxSetExtents(new_value_box, new_ilower, new_iupper);
|
|---|
| 248 |
|
|---|
| 249 | ierr = hypre_StructVectorGetBoxValues(vector, new_value_box, values);
|
|---|
| 250 |
|
|---|
| 251 | hypre_BoxDestroy(new_value_box);
|
|---|
| 252 |
|
|---|
| 253 | return ierr;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | /*--------------------------------------------------------------------------
|
|---|
| 257 | * HYPRE_StructVectorAssemble
|
|---|
| 258 | *--------------------------------------------------------------------------*/
|
|---|
| 259 |
|
|---|
| 260 | int
|
|---|
| 261 | HYPRE_StructVectorAssemble( HYPRE_StructVector vector )
|
|---|
| 262 | {
|
|---|
| 263 | return( hypre_StructVectorAssemble(vector) );
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | /*--------------------------------------------------------------------------
|
|---|
| 267 | * HYPRE_StructVectorPrint
|
|---|
| 268 | *--------------------------------------------------------------------------*/
|
|---|
| 269 |
|
|---|
| 270 | int
|
|---|
| 271 | HYPRE_StructVectorPrint( const char *filename,
|
|---|
| 272 | HYPRE_StructVector vector,
|
|---|
| 273 | int all )
|
|---|
| 274 | {
|
|---|
| 275 | return ( hypre_StructVectorPrint(filename, vector, all) );
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | /*--------------------------------------------------------------------------
|
|---|
| 279 | * HYPRE_StructVectorSetNumGhost
|
|---|
| 280 | *--------------------------------------------------------------------------*/
|
|---|
| 281 |
|
|---|
| 282 | int
|
|---|
| 283 | HYPRE_StructVectorSetNumGhost( HYPRE_StructVector vector,
|
|---|
| 284 | int *num_ghost )
|
|---|
| 285 | {
|
|---|
| 286 | return ( hypre_StructVectorSetNumGhost(vector, num_ghost) );
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | /*--------------------------------------------------------------------------
|
|---|
| 290 | * HYPRE_StructVectorCopy
|
|---|
| 291 | * copies data from x to y
|
|---|
| 292 | * y has its own data array, so this is a deep copy in that sense.
|
|---|
| 293 | * The grid and other size information are not copied - they are
|
|---|
| 294 | * assumed to be consistent already.
|
|---|
| 295 | *--------------------------------------------------------------------------*/
|
|---|
| 296 | int
|
|---|
| 297 | HYPRE_StructVectorCopy( HYPRE_StructVector x, HYPRE_StructVector y )
|
|---|
| 298 | {
|
|---|
| 299 | return( hypre_StructVectorCopy( x, y ) );
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | /*--------------------------------------------------------------------------
|
|---|
| 303 | * HYPRE_StructVectorSetConstantValues
|
|---|
| 304 | *--------------------------------------------------------------------------*/
|
|---|
| 305 |
|
|---|
| 306 | int
|
|---|
| 307 | HYPRE_StructVectorSetConstantValues( HYPRE_StructVector vector,
|
|---|
| 308 | double values )
|
|---|
| 309 | {
|
|---|
| 310 | return( hypre_StructVectorSetConstantValues(vector, values) );
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | /*--------------------------------------------------------------------------
|
|---|
| 314 | * HYPRE_StructVectorGetMigrateCommPkg
|
|---|
| 315 | *--------------------------------------------------------------------------*/
|
|---|
| 316 |
|
|---|
| 317 | int
|
|---|
| 318 | HYPRE_StructVectorGetMigrateCommPkg( HYPRE_StructVector from_vector,
|
|---|
| 319 | HYPRE_StructVector to_vector,
|
|---|
| 320 | HYPRE_CommPkg *comm_pkg )
|
|---|
| 321 | {
|
|---|
| 322 | int ierr = 0;
|
|---|
| 323 |
|
|---|
| 324 | *comm_pkg = hypre_StructVectorGetMigrateCommPkg(from_vector, to_vector);
|
|---|
| 325 |
|
|---|
| 326 | return ierr;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | /*--------------------------------------------------------------------------
|
|---|
| 330 | * HYPRE_StructVectorMigrate
|
|---|
| 331 | *--------------------------------------------------------------------------*/
|
|---|
| 332 |
|
|---|
| 333 | int
|
|---|
| 334 | HYPRE_StructVectorMigrate( HYPRE_CommPkg comm_pkg,
|
|---|
| 335 | HYPRE_StructVector from_vector,
|
|---|
| 336 | HYPRE_StructVector to_vector )
|
|---|
| 337 | {
|
|---|
| 338 | return( hypre_StructVectorMigrate( comm_pkg, from_vector, to_vector) );
|
|---|
| 339 | }
|
|---|
| 340 |
|
|---|
| 341 | /*--------------------------------------------------------------------------
|
|---|
| 342 | * HYPRE_CommPkgDestroy
|
|---|
| 343 | *--------------------------------------------------------------------------*/
|
|---|
| 344 |
|
|---|
| 345 | int
|
|---|
| 346 | HYPRE_CommPkgDestroy( HYPRE_CommPkg comm_pkg )
|
|---|
| 347 | {
|
|---|
| 348 | return ( hypre_CommPkgDestroy(comm_pkg) );
|
|---|
| 349 | }
|
|---|
| 350 |
|
|---|
| 351 |
|
|---|