| 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 | #ifndef HYPRE_STRUCT_MV_HEADER
|
|---|
| 16 | #define HYPRE_STRUCT_MV_HEADER
|
|---|
| 17 |
|
|---|
| 18 | #include "HYPRE_utilities.h"
|
|---|
| 19 |
|
|---|
| 20 | #ifdef __cplusplus
|
|---|
| 21 | extern "C" {
|
|---|
| 22 | #endif
|
|---|
| 23 |
|
|---|
| 24 | /*--------------------------------------------------------------------------
|
|---|
| 25 | *--------------------------------------------------------------------------*/
|
|---|
| 26 |
|
|---|
| 27 | /**
|
|---|
| 28 | * @name Struct System Interface
|
|---|
| 29 | *
|
|---|
| 30 | * This interface represents a structured-grid conceptual view of a linear
|
|---|
| 31 | * system.
|
|---|
| 32 | *
|
|---|
| 33 | * @memo A structured-grid conceptual interface
|
|---|
| 34 | **/
|
|---|
| 35 | /*@{*/
|
|---|
| 36 |
|
|---|
| 37 | /*--------------------------------------------------------------------------
|
|---|
| 38 | *--------------------------------------------------------------------------*/
|
|---|
| 39 |
|
|---|
| 40 | /**
|
|---|
| 41 | * @name Struct Grids
|
|---|
| 42 | **/
|
|---|
| 43 | /*@{*/
|
|---|
| 44 |
|
|---|
| 45 | struct hypre_StructGrid_struct;
|
|---|
| 46 | /**
|
|---|
| 47 | * A grid object is constructed out of several ``boxes'', defined on a global
|
|---|
| 48 | * abstract index space.
|
|---|
| 49 | **/
|
|---|
| 50 | typedef struct hypre_StructGrid_struct *HYPRE_StructGrid;
|
|---|
| 51 |
|
|---|
| 52 | /**
|
|---|
| 53 | * Create an {\tt ndim}-dimensional grid object.
|
|---|
| 54 | **/
|
|---|
| 55 | int HYPRE_StructGridCreate(MPI_Comm comm,
|
|---|
| 56 | int ndim,
|
|---|
| 57 | HYPRE_StructGrid *grid);
|
|---|
| 58 |
|
|---|
| 59 | /**
|
|---|
| 60 | * Destroy a grid object. An object should be explicitly destroyed using this
|
|---|
| 61 | * destructor when the user's code no longer needs direct access to it. Once
|
|---|
| 62 | * destroyed, the object must not be referenced again. Note that the object may
|
|---|
| 63 | * not be deallocated at the completion of this call, since there may be
|
|---|
| 64 | * internal package references to the object. The object will then be destroyed
|
|---|
| 65 | * when all internal reference counts go to zero.
|
|---|
| 66 | **/
|
|---|
| 67 | int HYPRE_StructGridDestroy(HYPRE_StructGrid grid);
|
|---|
| 68 |
|
|---|
| 69 | /**
|
|---|
| 70 | * Set the extents for a box on the grid.
|
|---|
| 71 | **/
|
|---|
| 72 | int HYPRE_StructGridSetExtents(HYPRE_StructGrid grid,
|
|---|
| 73 | int *ilower,
|
|---|
| 74 | int *iupper);
|
|---|
| 75 |
|
|---|
| 76 | /**
|
|---|
| 77 | * Finalize the construction of the grid before using.
|
|---|
| 78 | **/
|
|---|
| 79 | int HYPRE_StructGridAssemble(HYPRE_StructGrid grid);
|
|---|
| 80 |
|
|---|
| 81 | /**
|
|---|
| 82 | * Set periodic.
|
|---|
| 83 | **/
|
|---|
| 84 | int HYPRE_StructGridSetPeriodic(HYPRE_StructGrid grid,
|
|---|
| 85 | int *periodic);
|
|---|
| 86 |
|
|---|
| 87 | /**
|
|---|
| 88 | * Set the ghost layer in the grid object
|
|---|
| 89 | **/
|
|---|
| 90 | int HYPRE_StructGridSetNumGhost(HYPRE_StructGrid grid,
|
|---|
| 91 | int *num_ghost);
|
|---|
| 92 |
|
|---|
| 93 | /*@}*/
|
|---|
| 94 |
|
|---|
| 95 | /*--------------------------------------------------------------------------
|
|---|
| 96 | *--------------------------------------------------------------------------*/
|
|---|
| 97 |
|
|---|
| 98 | /**
|
|---|
| 99 | * @name Struct Stencils
|
|---|
| 100 | **/
|
|---|
| 101 | /*@{*/
|
|---|
| 102 |
|
|---|
| 103 | struct hypre_StructStencil_struct;
|
|---|
| 104 | /**
|
|---|
| 105 | * The stencil object.
|
|---|
| 106 | **/
|
|---|
| 107 | typedef struct hypre_StructStencil_struct *HYPRE_StructStencil;
|
|---|
| 108 |
|
|---|
| 109 | /**
|
|---|
| 110 | * Create a stencil object for the specified number of spatial dimensions and
|
|---|
| 111 | * stencil entries.
|
|---|
| 112 | **/
|
|---|
| 113 | int HYPRE_StructStencilCreate(int ndim,
|
|---|
| 114 | int size,
|
|---|
| 115 | HYPRE_StructStencil *stencil);
|
|---|
| 116 |
|
|---|
| 117 | /**
|
|---|
| 118 | * Destroy a stencil object.
|
|---|
| 119 | **/
|
|---|
| 120 | int HYPRE_StructStencilDestroy(HYPRE_StructStencil stencil);
|
|---|
| 121 |
|
|---|
| 122 | /**
|
|---|
| 123 | * Set a stencil entry.
|
|---|
| 124 | *
|
|---|
| 125 | * NOTE: The name of this routine will eventually be changed to {\tt
|
|---|
| 126 | * HYPRE\_StructStencilSetEntry}.
|
|---|
| 127 | **/
|
|---|
| 128 | int HYPRE_StructStencilSetElement(HYPRE_StructStencil stencil,
|
|---|
| 129 | int entry,
|
|---|
| 130 | int *offset);
|
|---|
| 131 |
|
|---|
| 132 | /*@}*/
|
|---|
| 133 |
|
|---|
| 134 | /*--------------------------------------------------------------------------
|
|---|
| 135 | *--------------------------------------------------------------------------*/
|
|---|
| 136 |
|
|---|
| 137 | /**
|
|---|
| 138 | * @name Struct Matrices
|
|---|
| 139 | **/
|
|---|
| 140 | /*@{*/
|
|---|
| 141 |
|
|---|
| 142 | struct hypre_StructMatrix_struct;
|
|---|
| 143 | /**
|
|---|
| 144 | * The matrix object.
|
|---|
| 145 | **/
|
|---|
| 146 | typedef struct hypre_StructMatrix_struct *HYPRE_StructMatrix;
|
|---|
| 147 |
|
|---|
| 148 | /**
|
|---|
| 149 | * Create a matrix object.
|
|---|
| 150 | **/
|
|---|
| 151 | int HYPRE_StructMatrixCreate(MPI_Comm comm,
|
|---|
| 152 | HYPRE_StructGrid grid,
|
|---|
| 153 | HYPRE_StructStencil stencil,
|
|---|
| 154 | HYPRE_StructMatrix *matrix);
|
|---|
| 155 |
|
|---|
| 156 | /**
|
|---|
| 157 | * Destroy a matrix object.
|
|---|
| 158 | **/
|
|---|
| 159 | int HYPRE_StructMatrixDestroy(HYPRE_StructMatrix matrix);
|
|---|
| 160 |
|
|---|
| 161 | /**
|
|---|
| 162 | * Prepare a matrix object for setting coefficient values.
|
|---|
| 163 | **/
|
|---|
| 164 | int HYPRE_StructMatrixInitialize(HYPRE_StructMatrix matrix);
|
|---|
| 165 |
|
|---|
| 166 | /**
|
|---|
| 167 | * Set matrix coefficients index by index. The {\tt values} array is of length
|
|---|
| 168 | * {\tt nentries}.
|
|---|
| 169 | *
|
|---|
| 170 | * NOTE: For better efficiency, use \Ref{HYPRE_StructMatrixSetBoxValues} to set
|
|---|
| 171 | * coefficients a box at a time.
|
|---|
| 172 | **/
|
|---|
| 173 | int HYPRE_StructMatrixSetValues(HYPRE_StructMatrix matrix,
|
|---|
| 174 | int *index,
|
|---|
| 175 | int nentries,
|
|---|
| 176 | int *entries,
|
|---|
| 177 | double *values);
|
|---|
| 178 |
|
|---|
| 179 | /**
|
|---|
| 180 | * Add to matrix coefficients index by index. The {\tt values} array is of
|
|---|
| 181 | * length {\tt nentries}.
|
|---|
| 182 | *
|
|---|
| 183 | * NOTE: For better efficiency, use \Ref{HYPRE_StructMatrixAddToBoxValues} to
|
|---|
| 184 | * set coefficients a box at a time.
|
|---|
| 185 | **/
|
|---|
| 186 | int HYPRE_StructMatrixAddToValues(HYPRE_StructMatrix matrix,
|
|---|
| 187 | int *index,
|
|---|
| 188 | int nentries,
|
|---|
| 189 | int *entries,
|
|---|
| 190 | double *values);
|
|---|
| 191 |
|
|---|
| 192 | /**
|
|---|
| 193 | * Set matrix coefficients which are constant over the grid. The {\tt values}
|
|---|
| 194 | * array is of length {\tt nentries}.
|
|---|
| 195 | **/
|
|---|
| 196 | int HYPRE_StructMatrixSetConstantValues(HYPRE_StructMatrix matrix,
|
|---|
| 197 | int nentries,
|
|---|
| 198 | int *entries,
|
|---|
| 199 | double *values);
|
|---|
| 200 | /**
|
|---|
| 201 | * Add to matrix coefficients which are constant over the grid. The {\tt
|
|---|
| 202 | * values} array is of length {\tt nentries}.
|
|---|
| 203 | **/
|
|---|
| 204 | int HYPRE_StructMatrixAddToConstantValues(HYPRE_StructMatrix matrix,
|
|---|
| 205 | int nentries,
|
|---|
| 206 | int *entries,
|
|---|
| 207 | double *values);
|
|---|
| 208 |
|
|---|
| 209 | /**
|
|---|
| 210 | * Set matrix coefficients a box at a time. The data in {\tt values} is ordered
|
|---|
| 211 | * as follows:
|
|---|
| 212 | *
|
|---|
| 213 | \begin{verbatim}
|
|---|
| 214 | m = 0;
|
|---|
| 215 | for (k = ilower[2]; k <= iupper[2]; k++)
|
|---|
| 216 | for (j = ilower[1]; j <= iupper[1]; j++)
|
|---|
| 217 | for (i = ilower[0]; i <= iupper[0]; i++)
|
|---|
| 218 | for (entry = 0; entry < nentries; entry++)
|
|---|
| 219 | {
|
|---|
| 220 | values[m] = ...;
|
|---|
| 221 | m++;
|
|---|
| 222 | }
|
|---|
| 223 | \end{verbatim}
|
|---|
| 224 | **/
|
|---|
| 225 | int HYPRE_StructMatrixSetBoxValues(HYPRE_StructMatrix matrix,
|
|---|
| 226 | int *ilower,
|
|---|
| 227 | int *iupper,
|
|---|
| 228 | int nentries,
|
|---|
| 229 | int *entries,
|
|---|
| 230 | double *values);
|
|---|
| 231 | /**
|
|---|
| 232 | * Add to matrix coefficients a box at a time. The data in {\tt values} is
|
|---|
| 233 | * ordered as in \Ref{HYPRE_StructMatrixSetBoxValues}.
|
|---|
| 234 | **/
|
|---|
| 235 | int HYPRE_StructMatrixAddToBoxValues(HYPRE_StructMatrix matrix,
|
|---|
| 236 | int *ilower,
|
|---|
| 237 | int *iupper,
|
|---|
| 238 | int nentries,
|
|---|
| 239 | int *entries,
|
|---|
| 240 | double *values);
|
|---|
| 241 |
|
|---|
| 242 | /**
|
|---|
| 243 | * Finalize the construction of the matrix before using.
|
|---|
| 244 | **/
|
|---|
| 245 | int HYPRE_StructMatrixAssemble(HYPRE_StructMatrix matrix);
|
|---|
| 246 |
|
|---|
| 247 | /**
|
|---|
| 248 | * Define symmetry properties of the matrix. By default, matrices are assumed
|
|---|
| 249 | * to be nonsymmetric. Significant storage savings can be made if the matrix is
|
|---|
| 250 | * symmetric.
|
|---|
| 251 | **/
|
|---|
| 252 | int HYPRE_StructMatrixSetSymmetric(HYPRE_StructMatrix matrix,
|
|---|
| 253 | int symmetric);
|
|---|
| 254 |
|
|---|
| 255 | /**
|
|---|
| 256 | * Specify which stencil entries are constant over the grid. Declaring entries
|
|---|
| 257 | * to be ``constant over the grid'' yields significant memory savings because
|
|---|
| 258 | * the value for each declared entry will only be stored once. However, not all
|
|---|
| 259 | * solvers are able to utilize this feature.
|
|---|
| 260 | *
|
|---|
| 261 | * Presently supported:
|
|---|
| 262 | * \begin{itemize}
|
|---|
| 263 | * \item no entries constant (this function need not be called)
|
|---|
| 264 | * \item all entries constant
|
|---|
| 265 | * \item all but the diagonal entry constant
|
|---|
| 266 | * \end{itemize}
|
|---|
| 267 | **/
|
|---|
| 268 | int HYPRE_StructMatrixSetConstantEntries( HYPRE_StructMatrix matrix,
|
|---|
| 269 | int nentries,
|
|---|
| 270 | int *entries );
|
|---|
| 271 |
|
|---|
| 272 | /**
|
|---|
| 273 | * Set the ghost layer in the matrix
|
|---|
| 274 | **/
|
|---|
| 275 | int HYPRE_StructMatrixSetNumGhost(HYPRE_StructMatrix matrix,
|
|---|
| 276 | int *num_ghost);
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | /**
|
|---|
| 280 | * Print the matrix to file. This is mainly for debugging purposes.
|
|---|
| 281 | **/
|
|---|
| 282 | int HYPRE_StructMatrixPrint(const char *filename,
|
|---|
| 283 | HYPRE_StructMatrix matrix,
|
|---|
| 284 | int all);
|
|---|
| 285 |
|
|---|
| 286 | /*@}*/
|
|---|
| 287 |
|
|---|
| 288 | /*--------------------------------------------------------------------------
|
|---|
| 289 | *--------------------------------------------------------------------------*/
|
|---|
| 290 |
|
|---|
| 291 | /**
|
|---|
| 292 | * @name Struct Vectors
|
|---|
| 293 | **/
|
|---|
| 294 | /*@{*/
|
|---|
| 295 |
|
|---|
| 296 | struct hypre_StructVector_struct;
|
|---|
| 297 | /**
|
|---|
| 298 | * The vector object.
|
|---|
| 299 | **/
|
|---|
| 300 | typedef struct hypre_StructVector_struct *HYPRE_StructVector;
|
|---|
| 301 |
|
|---|
| 302 | /**
|
|---|
| 303 | * Create a vector object.
|
|---|
| 304 | **/
|
|---|
| 305 | int HYPRE_StructVectorCreate(MPI_Comm comm,
|
|---|
| 306 | HYPRE_StructGrid grid,
|
|---|
| 307 | HYPRE_StructVector *vector);
|
|---|
| 308 |
|
|---|
| 309 | /**
|
|---|
| 310 | * Destroy a vector object.
|
|---|
| 311 | **/
|
|---|
| 312 | int HYPRE_StructVectorDestroy(HYPRE_StructVector vector);
|
|---|
| 313 |
|
|---|
| 314 | /**
|
|---|
| 315 | * Prepare a vector object for setting coefficient values.
|
|---|
| 316 | **/
|
|---|
| 317 | int HYPRE_StructVectorInitialize(HYPRE_StructVector vector);
|
|---|
| 318 |
|
|---|
| 319 | /**
|
|---|
| 320 | * Clears the ghostvalues of vector object. Beneficial to users that re-assemble
|
|---|
| 321 | * a vector object (e.g., in time-stepping).
|
|---|
| 322 | **/
|
|---|
| 323 | int HYPRE_StructVectorClearGhostValues(HYPRE_StructVector vector);
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 | /**
|
|---|
| 327 | * Set vector coefficients index by index.
|
|---|
| 328 | *
|
|---|
| 329 | * NOTE: For better efficiency, use \Ref{HYPRE_StructVectorSetBoxValues} to set
|
|---|
| 330 | * coefficients a box at a time.
|
|---|
| 331 | **/
|
|---|
| 332 | int HYPRE_StructVectorSetValues(HYPRE_StructVector vector,
|
|---|
| 333 | int *index,
|
|---|
| 334 | double value);
|
|---|
| 335 |
|
|---|
| 336 | /**
|
|---|
| 337 | * Add to vector coefficients index by index.
|
|---|
| 338 | *
|
|---|
| 339 | * NOTE: For better efficiency, use \Ref{HYPRE_StructVectorAddToBoxValues} to
|
|---|
| 340 | * set coefficients a box at a time.
|
|---|
| 341 | **/
|
|---|
| 342 | int HYPRE_StructVectorAddToValues(HYPRE_StructVector vector,
|
|---|
| 343 | int *index,
|
|---|
| 344 | double value);
|
|---|
| 345 |
|
|---|
| 346 | /**
|
|---|
| 347 | * Set vector coefficients a box at a time. The data in {\tt values} is ordered
|
|---|
| 348 | * as follows:
|
|---|
| 349 | *
|
|---|
| 350 | \begin{verbatim}
|
|---|
| 351 | m = 0;
|
|---|
| 352 | for (k = ilower[2]; k <= iupper[2]; k++)
|
|---|
| 353 | for (j = ilower[1]; j <= iupper[1]; j++)
|
|---|
| 354 | for (i = ilower[0]; i <= iupper[0]; i++)
|
|---|
| 355 | {
|
|---|
| 356 | values[m] = ...;
|
|---|
| 357 | m++;
|
|---|
| 358 | }
|
|---|
| 359 | \end{verbatim}
|
|---|
| 360 | **/
|
|---|
| 361 | int HYPRE_StructVectorSetBoxValues(HYPRE_StructVector vector,
|
|---|
| 362 | int *ilower,
|
|---|
| 363 | int *iupper,
|
|---|
| 364 | double *values);
|
|---|
| 365 | /**
|
|---|
| 366 | * Add to vector coefficients a box at a time. The data in {\tt values} is
|
|---|
| 367 | * ordered as in \Ref{HYPRE_StructVectorSetBoxValues}.
|
|---|
| 368 | **/
|
|---|
| 369 | int HYPRE_StructVectorAddToBoxValues(HYPRE_StructVector vector,
|
|---|
| 370 | int *ilower,
|
|---|
| 371 | int *iupper,
|
|---|
| 372 | double *values);
|
|---|
| 373 |
|
|---|
| 374 | /**
|
|---|
| 375 | * Finalize the construction of the vector before using.
|
|---|
| 376 | **/
|
|---|
| 377 | int HYPRE_StructVectorAssemble(HYPRE_StructVector vector);
|
|---|
| 378 |
|
|---|
| 379 | /**
|
|---|
| 380 | * Get vector coefficients index by index.
|
|---|
| 381 | *
|
|---|
| 382 | * NOTE: For better efficiency, use \Ref{HYPRE_StructVectorGetBoxValues} to get
|
|---|
| 383 | * coefficients a box at a time.
|
|---|
| 384 | **/
|
|---|
| 385 | int HYPRE_StructVectorGetValues(HYPRE_StructVector vector,
|
|---|
| 386 | int *index,
|
|---|
| 387 | double *value);
|
|---|
| 388 |
|
|---|
| 389 | /**
|
|---|
| 390 | * Get vector coefficients a box at a time. The data in {\tt values} is ordered
|
|---|
| 391 | * as in \Ref{HYPRE_StructVectorSetBoxValues}.
|
|---|
| 392 | **/
|
|---|
| 393 | int HYPRE_StructVectorGetBoxValues(HYPRE_StructVector vector,
|
|---|
| 394 | int *ilower,
|
|---|
| 395 | int *iupper,
|
|---|
| 396 | double *values);
|
|---|
| 397 |
|
|---|
| 398 | /**
|
|---|
| 399 | * Print the vector to file. This is mainly for debugging purposes.
|
|---|
| 400 | **/
|
|---|
| 401 | int HYPRE_StructVectorPrint(const char *filename,
|
|---|
| 402 | HYPRE_StructVector vector,
|
|---|
| 403 | int all);
|
|---|
| 404 |
|
|---|
| 405 | /*@}*/
|
|---|
| 406 | /*@}*/
|
|---|
| 407 |
|
|---|
| 408 | /*--------------------------------------------------------------------------
|
|---|
| 409 | * Miscellaneous: These probably do not belong in the interface.
|
|---|
| 410 | *--------------------------------------------------------------------------*/
|
|---|
| 411 |
|
|---|
| 412 | int HYPRE_StructMatrixGetGrid(HYPRE_StructMatrix matrix,
|
|---|
| 413 | HYPRE_StructGrid *grid);
|
|---|
| 414 |
|
|---|
| 415 | struct hypre_CommPkg_struct;
|
|---|
| 416 | typedef struct hypre_CommPkg_struct *HYPRE_CommPkg;
|
|---|
| 417 |
|
|---|
| 418 | int HYPRE_StructVectorSetNumGhost(HYPRE_StructVector vector,
|
|---|
| 419 | int *num_ghost);
|
|---|
| 420 |
|
|---|
| 421 | int HYPRE_StructVectorSetConstantValues(HYPRE_StructVector vector,
|
|---|
| 422 | double values);
|
|---|
| 423 |
|
|---|
| 424 | int HYPRE_StructVectorGetMigrateCommPkg(HYPRE_StructVector from_vector,
|
|---|
| 425 | HYPRE_StructVector to_vector,
|
|---|
| 426 | HYPRE_CommPkg *comm_pkg);
|
|---|
| 427 |
|
|---|
| 428 | int HYPRE_StructVectorMigrate(HYPRE_CommPkg comm_pkg,
|
|---|
| 429 | HYPRE_StructVector from_vector,
|
|---|
| 430 | HYPRE_StructVector to_vector);
|
|---|
| 431 |
|
|---|
| 432 | int HYPRE_CommPkgDestroy(HYPRE_CommPkg comm_pkg);
|
|---|
| 433 |
|
|---|
| 434 | /*--------------------------------------------------------------------------
|
|---|
| 435 | *--------------------------------------------------------------------------*/
|
|---|
| 436 |
|
|---|
| 437 | #ifdef __cplusplus
|
|---|
| 438 | }
|
|---|
| 439 | #endif
|
|---|
| 440 |
|
|---|
| 441 | #endif
|
|---|
| 442 |
|
|---|