GEOSX
SuiteSparse.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_LINEARALGEBRA_INTERFACES_SUITESPARSE_HPP_
20 #define GEOSX_LINEARALGEBRA_INTERFACES_SUITESPARSE_HPP_
21 
22 #include "common/DataTypes.hpp"
24 
25 #include <umfpack.h>
26 
27 namespace geosx
28 {
29 
33 using SSInt = SuiteSparse_long;
34 
40 inline SSInt toSuiteSparse_Int( globalIndex const index )
41 {
42  return LvArray::integerConversion< SSInt >( index );
43 }
44 
51 {
52 
53 public:
54 
58  SuiteSparse();
59 
64  SuiteSparse( LinearSolverParameters const & params );
65 
69  ~SuiteSparse();
70 
75  void create( LinearSolverParameters const & params );
76 
81  int setup();
82 
90  int solveWorkingRank( real64 * b, real64 * x, bool transpose = false );
91 
95  void syncTimes();
96 
101  real64 condEst() const;
102 
107  real64 relativeTolerance() const;
108 
112  void destroy();
113 
118  void setWorkingRank( int const workingRank );
119 
124  int workingRank() const;
125 
130  void setSubCommWorkingRank( int const subCommWorkingRank );
131 
136  int subCommWorkingRank() const;
137 
142  void setComm( MPI_Comm const comm );
143 
148  MPI_Comm getComm() const;
149 
154  void setSubComm( MPI_Comm const subComm );
155 
160  MPI_Comm getSubComm() const;
161 
166  SSInt numRows() const;
167 
172  SSInt numCols() const;
173 
178  SSInt nonZeros() const;
179 
186  void resize( SSInt const numRows, SSInt const numCols, SSInt const nonZeros );
187 
193 
199 
205 
210  real64 setupTime() const;
211 
216  real64 solveTime() const;
217 
222  real64 precisionTolerance() const;
223 
224 private:
225 
227  integer m_logLevel;
228 
230  SSInt m_numRows;
231 
233  SSInt m_numCols;
234 
236  SSInt m_nonZeros;
237 
239  array1d< SSInt > m_rowPtr;
240 
242  array1d< SSInt > m_colIndices;
243 
245  array1d< real64 > m_values;
246 
248  real64 m_Info[UMFPACK_INFO];
249 
251  real64 m_Control[UMFPACK_CONTROL];
252 
254  void * m_Symbolic;
255 
257  void * m_Numeric;
258 
260  MPI_Comm m_comm;
261 
263  MPI_Comm m_subComm;
264 
266  bool m_usingSubComm;
267 
269  int m_workingRank;
270 
272  int m_subCommWorkingRank;
273 
275  real64 m_condEst;
276 
278  real64 m_setupTime;
279 
281  real64 m_solveTime;
282 
284  real64 const m_precisionTolerance = 100.0 * std::numeric_limits< real64 >::epsilon();
285 
286 };
287 
288 }
289 
290 #endif /*GEOSX_LINEARALGEBRA_INTERFACES_SUITESPARSE_HPP_*/
void setWorkingRank(int const workingRank)
Sets the working rank.
void resize(SSInt const numRows, SSInt const numCols, SSInt const nonZeros)
Allocate the internal data storage arrays.
real64 precisionTolerance() const
Returns the precision tolarance used in SuiteSparse class.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
constexpr void transpose(DST_MATRIX &&LVARRAY_RESTRICT_REF dstMatrix, SRC_MATRIX const &LVARRAY_RESTRICT_REF srcMatrix)
Store the transpose of the NxM matrix srcMatrix in dstMatrix.
SSInt toSuiteSparse_Int(globalIndex const index)
Convert GEOSX globalIndex value to SuiteSparse int.
Definition: SuiteSparse.hpp:40
void setSubComm(MPI_Comm const subComm)
Sets the subcommunicator.
real64 solveTime() const
Provides the solve time.
SuiteSparse()
Constructor.
Set of parameters for a linear solver or preconditioner.
arrayView1d< real64 > values()
Returns the array with the matrix values.
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
void create(LinearSolverParameters const &params)
Creates the SuiteSparse data structure.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
real64 condEst() const
Estimates the condition number of the matrix.
This class provides an interface for UMFPACK direct solver from SuiteSparse linear algebra package...
Definition: SuiteSparse.hpp:50
SSInt numRows() const
Returns the number of rows.
arrayView1d< SSInt > colIndices()
Returns the array with the column indices.
int solveWorkingRank(real64 *b, real64 *x, bool transpose=false)
Solves a linear system with SuiteSparse (matrix has already been factorized)
int workingRank() const
Returns the working rank.
int subCommWorkingRank() const
Returns the working rank in the sub-communicator.
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
MPI_Comm getComm() const
Returns the communicator.
SuiteSparse_long SSInt
Definition: SuiteSparse.hpp:33
int setup()
Factorizes a linear system with SuiteSparse.
void setComm(MPI_Comm const comm)
Sets the communicator.
void setSubCommWorkingRank(int const subCommWorkingRank)
Sets the working rank in the sub-communicator.
SSInt numCols() const
Returns the number of columns.
arrayView1d< SSInt > rowPtr()
Returns the array with the row pointers.
real64 setupTime() const
Provides the setup time.
~SuiteSparse()
Destructor.
void syncTimes()
Sycronizes times across ranks.
real64 relativeTolerance() const
Estimates the relative tolerance for the matrix.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
SSInt nonZeros() const
Returns the number of non zeros.
MPI_Comm getSubComm() const
Returns the subcommunicator.
void destroy()
Deallocates a SuiteSparse data structure.