GEOSX
SuperLU_Dist.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_SUPERLU_DIST_HPP_
20 #define GEOSX_LINEARALGEBRA_INTERFACES_SUPERLU_DIST_HPP_
21 
22 #include "common/DataTypes.hpp"
24 
25 #include <superlu_ddefs.h>
26 
27 namespace geosx
28 {
29 
35 inline int_t toSuperLU_intT( globalIndex const index )
36 {
37  return LvArray::integerConversion< int_t >( index );
38 }
39 
45 inline int_t * toSuperLU_intT( globalIndex * const index )
46 {
47  return reinterpret_cast< int_t * >( index );
48 }
49 
54 {
55 
56 public:
57 
61  SuperLU_Dist();
62 
67  SuperLU_Dist( LinearSolverParameters const & params );
68 
72  ~SuperLU_Dist();
73 
78  void create( LinearSolverParameters const & params );
79 
84  int setup();
85 
92  int solve( real64 const * b, real64 * x );
93 
98  real64 condEst();
99 
105 
109  void destroy();
110 
115  void setNumGlobalRows( int_t const numGlobalRows );
116 
121  int_t numGlobalRows() const;
122 
127  void setNumGlobalCols( int_t const numGlobalCols );
128 
133  int_t numGlobalCols() const;
134 
139  void setNumLocalRows( int_t const numLocalRows );
140 
145  int_t numLocalRows() const;
146 
151  void setComm( MPI_Comm const comm );
152 
157  MPI_Comm getComm() const;
158 
164  void resize( localIndex const numLocalRows, localIndex const numLocalNonzeros );
165 
170  void createSuperMatrix( globalIndex const ilower );
171 
176  int_t * rowPtr();
177 
182  int_t * colIndices();
183 
188  real64 * values();
189 
194  real64 setupTime() const;
195 
200  real64 solveTime() const;
201 
207 
212  real64 precisionTolerance() const;
213 
214 private:
215 
217  int_t m_numGlobalRows;
218 
220  int_t m_numGlobalCols;
221 
223  int_t m_numLocalRows;
224 
226  int_t m_numLocalNonzeros;
227 
229  int_t * m_rowPtr;
230 
232  int_t * m_colIndices;
233 
235  real64 * m_values;
236 
238  SuperMatrix m_mat;
239 
241  dScalePermstruct_t m_ScalePermstruct;
242 
244  dLUstruct_t m_LUstruct;
245 
247  SuperLUStat_t m_stat;
248 
250  gridinfo_t m_grid;
251 
253  dSOLVEstruct_t m_SOLVEstruct;
254 
256  superlu_dist_options_t m_options;
257 
259  MPI_Comm m_comm;
260 
262  real64 m_condEst;
263 
265  real64 m_setupTime;
266 
268  real64 m_solveTime;
269 
271  LinearSolverParameters m_params;
272 
274  real64 const m_precisionTolerance = 100.0 * std::numeric_limits< real64 >::epsilon();
275 };
276 
277 }
278 
279 #endif /*GEOSX_LINEARALGEBRA_INTERFACES_SUPERLU_DIST_HPP_*/
void setNumGlobalRows(int_t const numGlobalRows)
Sets the global number of rows.
void setNumLocalRows(int_t const numLocalRows)
Sets the local number of rows.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
void destroy()
Deallocates a SuperLU_Dist data structure.
real64 precisionTolerance() const
Returns the precision tolerance used in SuperLU_Dist class.
real64 setupTime() const
Provides the setup time.
int_t * colIndices()
Returns the array with the column indices.
Set of parameters for a linear solver or preconditioner.
void createSuperMatrix(globalIndex const ilower)
Create the matrix in SuperLU_Dist format (SuperMatrix)
real64 relativeTolerance()
Estimates the relative tolerance for the matrix.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
void resize(localIndex const numLocalRows, localIndex const numLocalNonzeros)
Allocate the internal memory.
int_t numGlobalRows() const
Returns the global number of rows.
int_t * rowPtr()
Returns the array with the row pointers.
LinearSolverParameters getParameters() const
Returns the parameters used to initialize this object.
int_t numLocalRows() const
Returns the local number of rows.
void setNumGlobalCols(int_t const numGlobalCols)
Sets the global number of columns.
SuperLU_Dist()
Constructor.
void create(LinearSolverParameters const &params)
Creates the SuperLU_Dist data structure.
real64 * values()
Returns the array with the values.
int_t toSuperLU_intT(globalIndex const index)
Convert GEOSX globalIndex value to SuperLU_Dist int_t.
void setComm(MPI_Comm const comm)
Sets the communicator.
real64 condEst()
Estimates the condition number of the matrix.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
int setup()
Factorizes a linear system with SuperLU_Dist.
int_t numGlobalCols() const
Returns the global number of columns.
~SuperLU_Dist()
Destructor.
real64 solveTime() const
Provides the solve time.
MPI_Comm getComm() const
Returns the communicator.
int solve(real64 const *b, real64 *x)
Solves a linear system with SuperLU_Dist (matrix has already been factorized)