MFEM  v4.1.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-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
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  int ignore_rows = 0);
50 
51 /** Eliminate rows from a hypre ParCSRMatrix, setting all entries in the listed
52  rows of the matrix to zero. */
53 void hypre_ParCSRMatrixEliminateRows(hypre_ParCSRMatrix *A,
54  HYPRE_Int num_rows_to_elim,
55  const HYPRE_Int *rows_to_elim);
56 
57 /** Split matrix 'A' into nr x nc blocks, return nr x nc pointers to
58  new parallel matrices. The array 'blocks' needs to be preallocated to hold
59  nr x nc pointers. If 'interleaved' == 0 the matrix is split into contiguous
60  blocks (AAABBBCCC) otherwise the blocks are interleaved (ABCABCABC).
61  The local number of rows of A must be divisible by nr. The local number of
62  columns of A must be divisible by nc. */
63 void hypre_ParCSRMatrixSplit(hypre_ParCSRMatrix *A,
64  HYPRE_Int nr, HYPRE_Int nc,
65  hypre_ParCSRMatrix **blocks,
66  int interleaved_rows, int interleaved_cols);
67 
68 typedef int HYPRE_Bool;
69 #define HYPRE_MPI_BOOL MPI_INT
70 
71 /** The "Boolean" analog of y = alpha * A * x + beta * y, where elements in the
72  sparsity pattern of the CSR matrix A are treated as "true". */
73 void hypre_CSRMatrixBooleanMatvec(hypre_CSRMatrix *A,
74  HYPRE_Bool alpha,
75  HYPRE_Bool *x,
76  HYPRE_Bool beta,
77  HYPRE_Bool *y);
78 
79 /** The "Boolean" analog of y = alpha * A^T * x + beta * y, where elements in
80  the sparsity pattern of the CSR matrix A are treated as "true". */
81 void hypre_CSRMatrixBooleanMatvecT(hypre_CSRMatrix *A,
82  HYPRE_Bool alpha,
83  HYPRE_Bool *x,
84  HYPRE_Bool beta,
85  HYPRE_Bool *y);
86 
87 hypre_ParCSRCommHandle *
88 hypre_ParCSRCommHandleCreate_bool(HYPRE_Int job,
89  hypre_ParCSRCommPkg *comm_pkg,
90  HYPRE_Bool *send_data,
91  HYPRE_Bool *recv_data);
92 
93 /** The "Boolean" analog of y = alpha * A * x + beta * y, where elements in the
94  sparsity pattern of the ParCSR matrix A are treated as "true". */
95 void hypre_ParCSRMatrixBooleanMatvec(hypre_ParCSRMatrix *A,
96  HYPRE_Bool alpha,
97  HYPRE_Bool *x,
98  HYPRE_Bool beta,
99  HYPRE_Bool *y);
100 
101 /** The "Boolean" analog of y = alpha * A^T * x + beta * y, where elements in
102  the sparsity pattern of the ParCSR matrix A are treated as "true". */
103 void hypre_ParCSRMatrixBooleanMatvecT(hypre_ParCSRMatrix *A,
104  HYPRE_Bool alpha,
105  HYPRE_Bool *x,
106  HYPRE_Bool beta,
107  HYPRE_Bool *y);
108 
109 /** Perform the operation A += beta*B, assuming that the sparsity pattern of A
110  contains that of B. */
111 HYPRE_Int
112 hypre_CSRMatrixSum(hypre_CSRMatrix *A,
113  HYPRE_Complex beta,
114  hypre_CSRMatrix *B);
115 
116 /** Return a new matrix containing the sum of A and B, assuming that both
117  matrices use the same row and column partitions. The col_map_offd do not
118  need to be the same, but a more efficient algorithm is used if that's the
119  case. */
120 hypre_ParCSRMatrix *
121 hypre_ParCSRMatrixAdd(hypre_ParCSRMatrix *A,
122  hypre_ParCSRMatrix *B);
123 
124 /** Perform the operation A += beta*B, assuming that both matrices use the same
125  row and column partitions and the same col_map_offd arrays, or B has an empty
126  off-diagonal block. We also assume that the sparsity pattern of A contains
127  that of B. */
128 HYPRE_Int
129 hypre_ParCSRMatrixSum(hypre_ParCSRMatrix *A,
130  HYPRE_Complex beta,
131  hypre_ParCSRMatrix *B);
132 
133 /** Initialize all entries of A with value. */
134 HYPRE_Int
135 hypre_CSRMatrixSetConstantValues(hypre_CSRMatrix *A,
136  HYPRE_Complex value);
137 
138 /** Initialize all entries of A with value. */
139 HYPRE_Int
140 hypre_ParCSRMatrixSetConstantValues(hypre_ParCSRMatrix *A,
141  HYPRE_Complex value);
142 
143 } // namespace mfem::internal
144 
145 } // namespace mfem
146 
147 #endif // MFEM_USE_MPI
148 
149 #endif
const double alpha
Definition: ex15.cpp:336