|
Amesos2 - Direct Sparse Solver Interfaces
Version of the Day
|
00001 // @HEADER 00002 // 00003 // *********************************************************************** 00004 // 00005 // Amesos2: Templated Direct Sparse Solver Package 00006 // Copyright 2011 Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government retains certain rights in this software. 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00039 // 00040 // *********************************************************************** 00041 // 00042 // @HEADER 00043 00053 #ifndef AMESOS2_SUPERLUMT_DECL_HPP 00054 #define AMESOS2_SUPERLUMT_DECL_HPP 00055 00056 #include "Amesos2_SolverTraits.hpp" 00057 #include "Amesos2_SolverCore_decl.hpp" 00058 #include "Amesos2_Superlumt_FunctionMap.hpp" 00059 00060 00061 namespace Amesos2 { 00062 00063 00075 template <class Matrix, 00076 class Vector> 00077 class Superlumt : public SolverCore<Amesos2::Superlumt, Matrix, Vector> 00078 { 00079 friend class SolverCore<Amesos2::Superlumt,Matrix,Vector>; // Give our base access 00080 // to our private 00081 // implementation funcs 00082 public: 00083 00085 static const char* name; // declaration. Initialization outside. 00086 00087 typedef Superlumt<Matrix,Vector> type; 00088 typedef SolverCore<Amesos2::Superlumt,Matrix,Vector> super_type; 00089 00090 // Since typedef's are not inheritted, go grab them 00091 typedef typename super_type::scalar_type scalar_type; 00092 typedef typename super_type::local_ordinal_type local_ordinal_type; 00093 typedef typename super_type::global_ordinal_type global_ordinal_type; 00094 typedef typename super_type::global_size_type global_size_type; 00095 00096 typedef TypeMap<Amesos2::Superlumt,scalar_type> type_map; 00097 00098 typedef typename type_map::type slu_type; 00099 typedef typename type_map::magnitude_type magnitude_type; 00100 00101 typedef FunctionMap<Amesos2::Superlumt,slu_type> function_map; 00102 00103 00105 00106 00113 Superlumt(Teuchos::RCP<const Matrix> A, 00114 Teuchos::RCP<Vector> X, 00115 Teuchos::RCP<const Vector> B); 00116 00117 00119 ~Superlumt( ); 00120 00122 00123 private: 00124 00131 int preOrdering_impl(); 00132 00133 00141 int symbolicFactorization_impl(); 00142 00143 00153 int numericFactorization_impl(); 00154 00155 00167 int solve_impl(const Teuchos::Ptr<MultiVecAdapter<Vector> > X, 00168 const Teuchos::Ptr<const MultiVecAdapter<Vector> > B) const; 00169 00170 00176 bool matrixShapeOK_impl() const; 00177 00178 00216 void setParameters_impl( 00217 const Teuchos::RCP<Teuchos::ParameterList> & parameterList ); 00218 /* Parameters to support in the future: 00219 * 00220 * <li> \c "IterRefine" : { \c "NO" | \c "SINGLE" | \c "DOUBLE" | \c "EXTRA" 00221 * }. Specifies whether to perform iterative refinement, and in 00222 * what precision to compute the residual. (Not currently supported)</li> 00223 */ 00224 00231 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters_impl() const; 00232 00233 00242 bool loadA_impl(EPhase current_phase); 00243 00244 00245 // struct holds all data necessary to make a superlu factorization or solve call 00246 mutable struct SLUData { 00247 SLUMT::SuperMatrix A, BX, L, U; 00248 SLUMT::SuperMatrix AC; 00249 00250 SLUMT::superlumt_options_t options; 00251 SLUMT::superlu_memusage_t mem_usage; 00252 SLUMT::Gstat_t stat; 00253 00254 Teuchos::Array<magnitude_type> berr; 00255 Teuchos::Array<magnitude_type> ferr; 00256 Teuchos::Array<int> perm_r; 00257 Teuchos::Array<int> perm_c; 00258 Teuchos::Array<magnitude_type> R; 00259 Teuchos::Array<magnitude_type> C; 00260 00261 // in contrast to SuperLU, memory for etree will be allocated by 00262 // pxgssvx and the pointer will be stored in `options' 00263 00264 SLUMT::equed_t equed; 00265 bool rowequ, colequ; 00266 } data_; 00267 00268 // The following Arrays are persisting storage arrays for A, X, and B 00270 Teuchos::Array<typename TypeMap<Amesos2::Superlumt,scalar_type>::type> nzvals_; 00272 Teuchos::Array<int> rowind_; 00274 Teuchos::Array<int> colptr_; 00275 00276 /* Note: In the above, must use "Amesos2::Superlumt" rather than 00277 * "Superlumt" because otherwise the compiler references the 00278 * specialized type of the class, and not the templated type that is 00279 * required for Amesos2::TypeMap 00280 */ 00281 00282 /* SuperLU can accept input in either compressed-row or 00283 * compressed-column storage. We will store and pass matrices in 00284 * *compressed-row* format because that is the format Amesos used. 00285 */ 00286 00287 }; // End class Superlumt 00288 00289 00290 // Specialize the solver_traits struct for SuperLU_MT 00291 template <> 00292 struct solver_traits<Superlumt> { 00293 #ifdef HAVE_TEUCHOS_COMPLEX 00294 typedef Meta::make_list6<float, 00295 double, 00296 std::complex<float>, 00297 std::complex<double>, 00298 SLUMT::C::complex, 00299 SLUMT::Z::doublecomplex> supported_scalars; 00300 #else 00301 typedef Meta::make_list2<float, double> supported_scalars; 00302 #endif 00303 }; 00304 00305 } // end namespace Amesos2 00306 00307 #endif // AMESOS2_SUPERLUMT_DECL_HPP
1.7.6.1