MFEM  v4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
hypre_parcsr.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_HYPRE_PARCSR_HPP
13 #define MFEM_HYPRE_PARCSR_HPP
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 // Enable internal hypre timing routines
20 #define HYPRE_TIMING
21 
22 #include "_hypre_parcsr_mv.h"
23 
24 namespace mfem
25 {
26 
27 // This module contains functions that are logically part of HYPRE, and might
28 // become part of HYPRE at some point. In the meantime the module can be
29 // thought of as an extension of HYPRE.
30 
31 namespace internal
32 {
33 
34 /** Parallel essential BC elimination from the system A*X = B.
35  (Adapted from hypre_ParCSRMatrixEliminateRowsCols.) */
36 void hypre_ParCSRMatrixEliminateAXB(hypre_ParCSRMatrix *A,
37  HYPRE_Int num_rowscols_to_elim,
38  HYPRE_Int *rowscols_to_elim,
39  hypre_ParVector *X,
40  hypre_ParVector *B);
41 
42 /** Parallel essential BC elimination from matrix A only. The eliminated
43  elements are stored in a new matrix Ae, so that (A + Ae) equals the original
44  matrix A. */
45 void hypre_ParCSRMatrixEliminateAAe(hypre_ParCSRMatrix *A,
46  hypre_ParCSRMatrix **Ae,
47  HYPRE_Int num_rowscols_to_elim,
48  HYPRE_Int *rowscols_to_elim);
49 
50 /** Split matrix 'A' into nr x nc blocks, return nr x nc pointers to
51  new parallel matrices. The array 'blocks' needs to be preallocated to hold
52  nr x nc pointers. If 'interleaved' == 0 the matrix is split into contiguous
53  blocks (AAABBBCCC) otherwise the blocks are interleaved (ABCABCABC).
54  The local number of rows of A must be divisible by nr. The local number of
55  columns of A must be divisible by nc. */
56 void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
57  HYPRE_Int nr, HYPRE_Int nc,
58  hypre_ParCSRMatrix **blocks,
59  int interleaved_rows, int interleaved_cols);
60 
61 typedef int HYPRE_Bool;
62 #define HYPRE_MPI_BOOL MPI_INT
63 
64 /** The "Boolean" analog of y = alpha * A * x + beta * y, where elements in the
65  sparsity pattern of the CSR matrix A are treated as "true". */
66 void hypre_CSRMatrixBooleanMatvec(hypre_CSRMatrix *A,
67  HYPRE_Bool alpha,
68  HYPRE_Bool *x,
69  HYPRE_Bool beta,
70  HYPRE_Bool *y);
71 
72 /** The "Boolean" analog of y = alpha * A^T * x + beta * y, where elements in
73  the sparsity pattern of the CSR matrix A are treated as "true". */
74 void hypre_CSRMatrixBooleanMatvecT(hypre_CSRMatrix *A,
75  HYPRE_Bool alpha,
76  HYPRE_Bool *x,
77  HYPRE_Bool beta,
78  HYPRE_Bool *y);
79 
80 hypre_ParCSRCommHandle *
81 hypre_ParCSRCommHandleCreate_bool(HYPRE_Int job,
82  hypre_ParCSRCommPkg *comm_pkg,
83  HYPRE_Bool *send_data,
84  HYPRE_Bool *recv_data);
85 
86 /** The "Boolean" analog of y = alpha * A * x + beta * y, where elements in the
87  sparsity pattern of the ParCSR matrix A are treated as "true". */
88 void hypre_ParCSRMatrixBooleanMatvec(hypre_ParCSRMatrix *A,
89  HYPRE_Bool alpha,
90  HYPRE_Bool *x,
91  HYPRE_Bool beta,
92  HYPRE_Bool *y);
93 
94 /** The "Boolean" analog of y = alpha * A^T * x + beta * y, where elements in
95  the sparsity pattern of the ParCSR matrix A are treated as "true". */
96 void hypre_ParCSRMatrixBooleanMatvecT(hypre_ParCSRMatrix *A,
97  HYPRE_Bool alpha,
98  HYPRE_Bool *x,
99  HYPRE_Bool beta,
100  HYPRE_Bool *y);
101 
102 /** Perform the operation A += beta*B, assuming that the sparsity pattern of A
103  contains that of B. */
104 HYPRE_Int
105 hypre_CSRMatrixSum(hypre_CSRMatrix *A,
106  HYPRE_Complex beta,
107  hypre_CSRMatrix *B);
108 
109 /** Return a new matrix containing the sum of A and B, assuming that both
110  matrices use the same row and column partitions. The col_map_offd do not
111  need to be the same, but a more efficient algorithm is used if that's the
112  case. */
113 hypre_ParCSRMatrix *
114 hypre_ParCSRMatrixAdd(hypre_ParCSRMatrix *A,
115  hypre_ParCSRMatrix *B);
116 
117 /** Perform the operation A += beta*B, assuming that both matrices use the same
118  row and column partitions and the same col_map_offd arrays, or B has an empty
119  off-diagonal block. We also assume that the sparsity pattern of A contains
120  that of B. */
121 HYPRE_Int
122 hypre_ParCSRMatrixSum(hypre_ParCSRMatrix *A,
123  HYPRE_Complex beta,
124  hypre_ParCSRMatrix *B);
125 
126 /** Initialize all entries of A with value. */
127 HYPRE_Int
128 hypre_CSRMatrixSetConstantValues(hypre_CSRMatrix *A,
129  HYPRE_Complex value);
130 
131 /** Initialize all entries of A with value. */
132 HYPRE_Int
133 hypre_ParCSRMatrixSetConstantValues(hypre_ParCSRMatrix *A,
134  HYPRE_Complex value);
135 
136 } // namespace mfem::internal
137 
138 } // namespace mfem
139 
140 #endif // MFEM_USE_MPI
141 
142 #endif
const double alpha
Definition: ex15.cpp:339