19 #ifndef AMESOS2_SOLVERCORE_DEF_HPP
20 #define AMESOS2_SOLVERCORE_DEF_HPP
22 #if KOKKOS_VERSION >= 40799
23 #include "KokkosKernels_ArithTraits.hpp"
25 #include "Kokkos_ArithTraits.hpp"
28 #include "Amesos2_MatrixAdapter_def.hpp"
29 #include "Amesos2_MultiVecAdapter_def.hpp"
33 #include "KokkosSparse_spmv.hpp"
34 #include "KokkosBlas.hpp"
39 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
41 Teuchos::RCP<const Matrix> A,
42 Teuchos::RCP<Vector> X,
43 Teuchos::RCP<const Vector> B )
44 : matrixA_(createConstMatrixAdapter<Matrix>(A))
47 , globalNumRows_(matrixA_->getGlobalNumRows())
48 , globalNumCols_(matrixA_->getGlobalNumCols())
49 , globalNumNonZeros_(matrixA_->getGlobalNNZ())
50 , rowIndexBase_(matrixA_->getRowIndexBase())
51 , columnIndexBase_(matrixA_->getColumnIndexBase())
52 , rank_(Teuchos::rank(*this->getComm()))
54 , nprocs_(Teuchos::
size(*this->getComm()))
56 TEUCHOS_TEST_FOR_EXCEPTION(
58 std::invalid_argument,
59 "Matrix shape inappropriate for this solver");
64 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
71 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
75 #ifdef HAVE_AMESOS2_TIMERS
76 Teuchos::TimeMonitor LocalTimer1(timers_.totalTime_);
81 int error_code =
static_cast<solver_type*
>(
this)->preOrdering_impl();
82 if (error_code == EXIT_SUCCESS){
83 ++status_.numPreOrder_;
84 status_.last_phase_ = PREORDERING;
91 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
95 #ifdef HAVE_AMESOS2_TIMERS
96 Teuchos::TimeMonitor LocalTimer1(timers_.totalTime_);
100 #ifdef HAVE_AMESOS2_TIMERS
101 Teuchos::TimeMonitor LocalTimer2(timers_.coreSymFactTime_);
103 if( !status_.preOrderingDone() ){
105 if( !matrix_loaded_ ) loadA(SYMBFACT);
110 int error_code =
static_cast<solver_type*
>(
this)->symbolicFactorization_impl();
111 if (error_code == EXIT_SUCCESS){
112 ++status_.numSymbolicFact_;
113 status_.last_phase_ = SYMBFACT;
120 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
124 #ifdef HAVE_AMESOS2_TIMERS
125 Teuchos::TimeMonitor LocalTimer1(timers_.totalTime_);
128 #ifdef HAVE_AMESOS2_TIMERS
129 Teuchos::TimeMonitor LocalTimer2(timers_.coreNumFactTime_);
131 if( !status_.symbolicFactorizationDone() ){
132 symbolicFactorization();
133 if( !matrix_loaded_ ) loadA(NUMFACT);
138 int error_code =
static_cast<solver_type*
>(
this)->numericFactorization_impl();
139 if (error_code == EXIT_SUCCESS){
140 ++status_.numNumericFact_;
141 status_.last_phase_ = NUMFACT;
149 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
153 solve(multiVecX_.ptr(), multiVecB_.ptr());
156 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
159 const Teuchos::Ptr<const Vector> B)
const
161 #ifdef HAVE_AMESOS2_TIMERS
162 Teuchos::TimeMonitor LocalTimer1(timers_.totalTime_);
168 if (control_.useIterRefine_) {
169 solve_ir(X, B, control_.maxNumIterRefines_, control_.verboseIterRefine_);
173 const Teuchos::RCP<MultiVecAdapter<Vector> > x =
174 createMultiVecAdapter<Vector>(Teuchos::rcpFromPtr(X));
175 const Teuchos::RCP<const MultiVecAdapter<Vector> > b =
176 createConstMultiVecAdapter<Vector>(Teuchos::rcpFromPtr(B));
178 #ifdef HAVE_AMESOS2_DEBUG
180 TEUCHOS_TEST_FOR_EXCEPTION
181 (x->getGlobalLength() != matrixA_->getGlobalNumCols(),
182 std::invalid_argument,
183 "MultiVector X must have length equal to the number of "
184 "global columns in A. X->getGlobalLength() = "
185 << x->getGlobalLength() <<
" != A->getGlobalNumCols() = "
186 << matrixA_->getGlobalNumCols() <<
".");
188 TEUCHOS_TEST_FOR_EXCEPTION(b->getGlobalLength() != matrixA_->getGlobalNumRows(),
189 std::invalid_argument,
190 "MultiVector B must have length equal to the number of "
193 TEUCHOS_TEST_FOR_EXCEPTION(x->getGlobalNumVectors() != b->getGlobalNumVectors(),
194 std::invalid_argument,
195 "X and B MultiVectors must have the same number of vectors");
196 #endif // HAVE_AMESOS2_DEBUG
198 if( !status_.numericFactorizationDone() ){
205 #ifdef HAVE_AMESOS2_TIMERS
206 Teuchos::TimeMonitor LocalTimer2(timers_.coreSolveTime_);
208 int error_code =
static_cast<const solver_type*
>(
this)->solve_impl(Teuchos::outArg(*x), Teuchos::ptrInArg(*b));
209 if (error_code == EXIT_SUCCESS){
211 status_.last_phase_ = SOLVE;
216 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
220 solve(Teuchos::ptr(X), Teuchos::ptr(B));
224 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
228 return solve_ir(multiVecX_.ptr(), multiVecB_.ptr(), maxNumIters, verbose);
231 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
233 SolverCore<ConcreteSolver,Matrix,Vector>::solve_ir(Vector* X,
const Vector* B,
const int maxNumIters,
const bool verbose)
const
235 return solve_ir(Teuchos::ptr(X), Teuchos::ptr(B), maxNumIters, verbose);
238 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
240 SolverCore<ConcreteSolver,Matrix,Vector>::solve_ir(
const Teuchos::Ptr< Vector> x,
241 const Teuchos::Ptr<const Vector> b,
242 const int maxNumIters,
243 const bool verbose)
const
245 #if KOKKOS_VERSION >= 40799
246 using KAT = KokkosKernels::ArithTraits<scalar_type>;
248 using KAT = Kokkos::ArithTraits<scalar_type>;
250 using impl_scalar_type =
typename KAT::val_type;
251 using magni_type =
typename KAT::mag_type;
252 using host_execution_space = Kokkos::DefaultHostExecutionSpace;
253 using host_crsmat_t = KokkosSparse::CrsMatrix<impl_scalar_type, int, host_execution_space, void, int>;
254 using host_graph_t =
typename host_crsmat_t::StaticCrsGraphType;
255 using host_values_t =
typename host_crsmat_t::values_type::non_const_type;
256 using host_row_map_t =
typename host_graph_t::row_map_type::non_const_type;
257 using host_colinds_t =
typename host_graph_t::entries_type::non_const_type;
258 using host_mvector_t = Kokkos::View<impl_scalar_type **, Kokkos::LayoutLeft, host_execution_space>;
259 using host_vector_t = Kokkos::View<impl_scalar_type *, Kokkos::LayoutLeft, host_execution_space>;
260 using host_magni_view = Kokkos::View<magni_type *, Kokkos::LayoutLeft, host_execution_space>;
262 const impl_scalar_type one(1.0);
263 const impl_scalar_type mone = impl_scalar_type(-one);
264 const magni_type eps = KAT::eps ();
267 using MVAdapter = MultiVecAdapter<Vector>;
268 Teuchos::RCP< MVAdapter> X = createMultiVecAdapter<Vector>(Teuchos::rcpFromPtr(x));
269 Teuchos::RCP<const MVAdapter> B = createConstMultiVecAdapter<Vector>(Teuchos::rcpFromPtr(b));
271 auto r_ = B->clone();
272 auto e_ = X->clone();
275 Teuchos::RCP< MVAdapter> R = createMultiVecAdapter<Vector>(Teuchos::rcpFromPtr(r));
276 Teuchos::RCP< MVAdapter> E = createMultiVecAdapter<Vector>(Teuchos::rcpFromPtr(e));
278 const size_t nrhs = X->getGlobalNumVectors();
279 const int nnz = this->matrixA_->getGlobalNNZ();
280 const int nrows = this->matrixA_->getGlobalNumRows();
283 host_crsmat_t crsmat;
284 host_graph_t static_graph;
285 host_row_map_t rowmap_view;
286 host_colinds_t colind_view;
287 host_values_t values_view;
289 Kokkos::resize(rowmap_view, 1+nrows);
290 Kokkos::resize(colind_view, nnz);
291 Kokkos::resize(values_view, nnz);
293 Kokkos::resize(rowmap_view, 1);
294 Kokkos::resize(colind_view, 0);
295 Kokkos::resize(values_view, 0);
299 Util::get_crs_helper_kokkos_view<
300 MatrixAdapter<Matrix>, host_values_t, host_colinds_t, host_row_map_t>::do_get(
301 this->matrixA_.ptr(),
302 values_view, colind_view, rowmap_view,
303 nnz_ret, ROOTED, ARBITRARY, this->rowIndexBase_);
306 static_graph = host_graph_t(colind_view, rowmap_view);
307 crsmat = host_crsmat_t(
"CrsMatrix", nrows, values_view, static_graph);
312 static_cast<const solver_type*
>(
this)->solve_impl(Teuchos::outArg(*X), Teuchos::ptrInArg(*B));
316 const int ldx = (this->root_ ? X->getGlobalLength() : 0);
317 const int ldb = (this->root_ ? B->getGlobalLength() : 0);
318 const int ldr = (this->root_ ? R->getGlobalLength() : 0);
319 const int lde = (this->root_ ? E->getGlobalLength() : 0);
320 const bool initialize_data =
true;
321 const bool not_initialize_data =
true;
322 host_mvector_t X_view;
323 host_mvector_t B_view;
324 host_mvector_t R_view;
325 host_mvector_t E_view;
327 global_size_type rowIndexBase = this->rowIndexBase_;
328 auto Xptr = Teuchos::Ptr< MVAdapter>(X.ptr());
329 auto Bptr = Teuchos::Ptr<const MVAdapter>(B.ptr());
330 auto Rptr = Teuchos::Ptr< MVAdapter>(R.ptr());
331 auto Eptr = Teuchos::Ptr< MVAdapter>(E.ptr());
332 Util::get_1d_copy_helper_kokkos_view<MVAdapter, host_mvector_t>::
333 do_get( initialize_data, Xptr, X_view, ldx, CONTIGUOUS_AND_ROOTED, rowIndexBase);
334 Util::get_1d_copy_helper_kokkos_view<MVAdapter, host_mvector_t>::
335 do_get( initialize_data, Bptr, B_view, ldb, CONTIGUOUS_AND_ROOTED, rowIndexBase);
336 Util::get_1d_copy_helper_kokkos_view<MVAdapter, host_mvector_t>::
337 do_get(not_initialize_data, Rptr, R_view, ldr, CONTIGUOUS_AND_ROOTED, rowIndexBase);
338 Util::get_1d_copy_helper_kokkos_view<MVAdapter, host_mvector_t>::
339 do_get(not_initialize_data, Eptr, E_view, lde, CONTIGUOUS_AND_ROOTED, rowIndexBase);
342 host_magni_view x0norms(
"x0norms", nrhs);
343 host_magni_view bnorms(
"bnorms", nrhs);
344 host_magni_view enorms(
"enorms", nrhs);
347 for (
size_t j = 0; j < nrhs; j++) {
348 auto x_subview = Kokkos::subview(X_view, Kokkos::ALL(), j);
349 host_vector_t x_1d (const_cast<impl_scalar_type*>(x_subview.data()), x_subview.extent(0));
350 x0norms(j) = KokkosBlas::nrm2(x_1d);
353 std::cout << std::endl
354 <<
" SolverCore :: solve_ir (maxNumIters = " << maxNumIters
355 <<
", tol = " << x0norms(0) <<
" * " << eps <<
" = " << x0norms(0)*eps
361 std::cout <<
" bnorm = ";
362 for (
size_t j = 0; j < nrhs; j++) {
363 auto b_subview = Kokkos::subview(B_view, Kokkos::ALL(), j);
364 host_vector_t b_1d (const_cast<impl_scalar_type*>(b_subview.data()), b_subview.extent(0));
365 bnorms(j) = KokkosBlas::nrm2(b_1d);
366 std::cout << bnorms(j) <<
", ";
368 std::cout << std::endl;
377 for (numIters = 0; numIters < maxNumIters && converged == 0; ++numIters) {
380 Kokkos::deep_copy(R_view, B_view);
381 KokkosSparse::spmv(
"N", mone, crsmat, X_view, one, R_view);
386 std::cout <<
" > " << numIters <<
" : norm(r,x,e) = ";
387 for (
size_t j = 0; j < nrhs; j++) {
388 auto r_subview = Kokkos::subview(R_view, Kokkos::ALL(), j);
389 auto x_subview = Kokkos::subview(X_view, Kokkos::ALL(), j);
390 host_vector_t r_1d (const_cast<impl_scalar_type*>(r_subview.data()), r_subview.extent(0));
391 host_vector_t x_1d (const_cast<impl_scalar_type*>(x_subview.data()), x_subview.extent(0));
392 impl_scalar_type rnorm = KokkosBlas::nrm2(r_1d);
393 impl_scalar_type xnorm = KokkosBlas::nrm2(x_1d);
394 std::cout << rnorm <<
" -> " << rnorm/bnorms(j) <<
" " << xnorm <<
" " << enorms(j) <<
", ";
396 std::cout << std::endl;
401 Util::put_1d_data_helper_kokkos_view<MVAdapter, host_mvector_t>::
402 do_put(Rptr, R_view, ldr, CONTIGUOUS_AND_ROOTED, rowIndexBase);
403 static_cast<const solver_type*
>(
this)->solve_impl(Teuchos::outArg(*E), Teuchos::ptrInArg(*R));
404 Util::get_1d_copy_helper_kokkos_view<MVAdapter, host_mvector_t>::
405 do_get(initialize_data, Eptr, E_view, lde, CONTIGUOUS_AND_ROOTED, rowIndexBase);
409 KokkosBlas::axpy(one, E_view, X_view);
411 if (numIters < maxNumIters-1) {
414 for (
size_t j = 0; j < nrhs; j++) {
415 auto e_subview = Kokkos::subview(E_view, Kokkos::ALL(), j);
416 host_vector_t e_1d (const_cast<impl_scalar_type*>(e_subview.data()), e_subview.extent(0));
417 enorms(j) = KokkosBlas::nrm2(e_1d);
418 if (enorms(j) > eps * x0norms(j)) {
422 if (verbose && converged) {
423 std::cout <<
" converged " << std::endl;
429 Teuchos::broadcast(*(this->matrixA_->getComm()), 0, &converged);
432 if (verbose && this->root_) {
434 Kokkos::deep_copy(R_view, B_view);
435 KokkosSparse::spmv(
"N", mone, crsmat, X_view, one, R_view);
437 std::cout <<
" > final residual norm = ";
438 for (
size_t j = 0; j < nrhs; j++) {
439 auto r_subview = Kokkos::subview(R_view, Kokkos::ALL(), j);
440 host_vector_t r_1d (const_cast<impl_scalar_type*>(r_subview.data()), r_subview.extent(0));
441 scalar_type rnorm = KokkosBlas::nrm2(r_1d);
442 std::cout << rnorm <<
" -> " << rnorm/bnorms(j) <<
", ";
444 std::cout << std::endl << std::endl;
448 Util::put_1d_data_helper_kokkos_view<MVAdapter, host_mvector_t>::
449 do_put(Xptr, X_view, ldx, CONTIGUOUS_AND_ROOTED, rowIndexBase);
454 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
458 #ifdef HAVE_AMESOS2_TIMERS
459 Teuchos::TimeMonitor LocalTimer1(timers_.totalTime_);
462 return( static_cast<solver_type*>(
this)->matrixShapeOK_impl() );
468 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
473 matrixA_ = createConstMatrixAdapter(a);
475 #ifdef HAVE_AMESOS2_DEBUG
476 TEUCHOS_TEST_FOR_EXCEPTION( (keep_phase != CLEAN) &&
477 (globalNumRows_ != matrixA_->getGlobalNumRows() ||
478 globalNumCols_ != matrixA_->getGlobalNumCols()),
479 std::invalid_argument,
480 "Dimensions of new matrix be the same as the old matrix if "
481 "keeping any solver phase" );
484 status_.last_phase_ = keep_phase;
487 switch( status_.last_phase_ ){
489 status_.numPreOrder_ = 0;
492 status_.numSymbolicFact_ = 0;
495 status_.numNumericFact_ = 0;
498 status_.numSolve_ = 0;
505 globalNumNonZeros_ = matrixA_->getGlobalNNZ();
506 globalNumCols_ = matrixA_->getGlobalNumCols();
507 globalNumRows_ = matrixA_->getGlobalNumRows();
511 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
514 const Teuchos::RCP<Teuchos::ParameterList> & parameterList )
516 #ifdef HAVE_AMESOS2_TIMERS
517 Teuchos::TimeMonitor LocalTimer1(timers_.totalTime_);
520 if( parameterList->name() ==
"Amesos2" ){
522 Teuchos::RCP<const Teuchos::ParameterList> valid_params = getValidParameters();
523 parameterList->validateParameters(*valid_params);
526 control_.setControlParameters(parameterList);
530 if( parameterList->isSublist(name()) ){
533 control_.setControlParameters(Teuchos::sublist(parameterList, name()));
535 static_cast<solver_type*
>(
this)->setParameters_impl(Teuchos::sublist(parameterList, name()));
543 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
544 Teuchos::RCP<const Teuchos::ParameterList>
547 #ifdef HAVE_AMESOS2_TIMERS
548 Teuchos::TimeMonitor LocalTimer1( timers_.totalTime_ );
551 using Teuchos::ParameterList;
556 RCP<ParameterList> control_params = rcp(
new ParameterList(
"Amesos2"));
557 control_params->set(
"Transpose",
false,
"Whether to solve with the matrix transpose");
558 control_params->set(
"Iterative refinement",
false,
"Whether to solve with iterative refinement");
559 control_params->set(
"Number of iterative refinements", 2,
"Number of iterative refinements");
560 control_params->set(
"Verboes for iterative refinement",
false,
"Verbosity for iterative refinements");
566 RCP<const ParameterList>
567 solver_params =
static_cast<const solver_type*
>(
this)->getValidParameters_impl();
569 Teuchos::rcp_const_cast<ParameterList>(solver_params)->set(
"Transpose",
false,
570 "Whether to solve with the "
573 RCP<ParameterList> amesos2_params = rcp(
new ParameterList(
"Amesos2"));
574 amesos2_params->setParameters(*control_params);
575 amesos2_params->set(name(), *solver_params);
577 return amesos2_params;
581 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
585 std::ostringstream oss;
586 oss << name() <<
" solver interface";
591 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
594 Teuchos::FancyOStream &out,
595 const Teuchos::EVerbosityLevel verbLevel)
const
597 if( matrixA_.is_null() || (rank_ != 0) ){
return; }
600 using Teuchos::VERB_DEFAULT;
601 using Teuchos::VERB_NONE;
602 using Teuchos::VERB_LOW;
603 using Teuchos::VERB_MEDIUM;
604 using Teuchos::VERB_HIGH;
605 using Teuchos::VERB_EXTREME;
606 Teuchos::EVerbosityLevel vl = verbLevel;
607 if (vl == VERB_DEFAULT) vl = VERB_LOW;
608 Teuchos::RCP<const Teuchos::Comm<int> > comm = this->getComm();
610 for(
size_t dec = 10; dec < globalNumRows_; dec *= 10 ) {
613 width = std::max<size_t>(width,size_t(11)) + 2;
614 Teuchos::OSTab tab(out);
622 if( vl != VERB_NONE ) {
623 std::string p = name();
625 out << this->description() << std::endl << std::endl;
627 out << p <<
"Matrix has " << globalNumRows_ <<
" rows"
628 <<
" and " << globalNumNonZeros_ <<
" nonzeros"
630 if( vl == VERB_MEDIUM || vl == VERB_HIGH || vl == VERB_EXTREME ){
631 out << p <<
"Nonzero elements per row = "
632 << globalNumNonZeros_ / globalNumRows_
634 out << p <<
"Percentage of nonzero elements = "
635 << 100.0 * globalNumNonZeros_ / (globalNumRows_ * globalNumCols_)
638 if( vl == VERB_HIGH || vl == VERB_EXTREME ){
639 out << p <<
"Use transpose = " << control_.useTranspose_
641 out << p <<
"Use iterative refinement = " << control_.useIterRefine_
644 if ( vl == VERB_EXTREME ){
652 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
655 Teuchos::FancyOStream &out,
656 const Teuchos::EVerbosityLevel verbLevel)
const
658 if( matrixA_.is_null() || (rank_ != 0) ){
return; }
660 double preTime = timers_.preOrderTime_.totalElapsedTime();
661 double symTime = timers_.symFactTime_.totalElapsedTime();
662 double numTime = timers_.numFactTime_.totalElapsedTime();
663 double solTime = timers_.solveTime_.totalElapsedTime();
664 double totTime = timers_.totalTime_.totalElapsedTime();
665 double overhead = totTime - (preTime + symTime + numTime + solTime);
667 std::string p = name() +
" : ";
670 if(verbLevel != Teuchos::VERB_NONE)
672 out << p <<
"Time to convert matrix to implementation format = "
673 << timers_.mtxConvTime_.totalElapsedTime() <<
" (s)"
675 out << p <<
"Time to redistribute matrix = "
676 << timers_.mtxRedistTime_.totalElapsedTime() <<
" (s)"
679 out << p <<
"Time to convert vectors to implementation format = "
680 << timers_.vecConvTime_.totalElapsedTime() <<
" (s)"
682 out << p <<
"Time to redistribute vectors = "
683 << timers_.vecRedistTime_.totalElapsedTime() <<
" (s)"
686 out << p <<
"Number of pre-orderings = "
687 << status_.getNumPreOrder()
689 out << p <<
"Time for pre-ordering = "
690 << preTime <<
" (s), avg = "
691 << preTime / status_.getNumPreOrder() <<
" (s)"
694 out << p <<
"Number of symbolic factorizations = "
695 << status_.getNumSymbolicFact()
697 out << p <<
"Time for sym fact = "
698 << symTime <<
" (s), avg = "
699 << symTime / status_.getNumSymbolicFact() <<
" (s)"
702 out << p <<
"Number of numeric factorizations = "
703 << status_.getNumNumericFact()
705 out << p <<
"Time for num fact = "
706 << numTime <<
" (s), avg = "
707 << numTime / status_.getNumNumericFact() <<
" (s)"
710 out << p <<
"Number of solve phases = "
711 << status_.getNumSolve()
713 out << p <<
"Time for solve = "
714 << solTime <<
" (s), avg = "
715 << solTime / status_.getNumSolve() <<
" (s)"
718 out << p <<
"Total time spent in Amesos2 = "
721 out << p <<
"Total time spent in the Amesos2 interface = "
722 << overhead <<
" (s)"
724 out << p <<
" (the above time does not include solver time)"
726 out << p <<
"Amesos2 interface time / total time = "
727 << overhead / totTime
734 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
737 Teuchos::ParameterList& timingParameterList)
const
739 Teuchos::ParameterList temp;
740 timingParameterList = temp.setName(
"NULL");
744 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
748 std::string solverName = solver_type::name;
752 template <
template <
class,
class>
class ConcreteSolver,
class Matrix,
class Vector >
756 matrix_loaded_ =
static_cast<solver_type*
>(
this)->loadA_impl(current_phase);
762 #endif // AMESOS2_SOLVERCORE_DEF_HPP
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Return a const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
Definition: Amesos2_SolverCore_def.hpp:545
void solve() override
Solves (or )
Definition: Amesos2_SolverCore_def.hpp:151
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:71
~SolverCore()
Destructor.
Definition: Amesos2_SolverCore_def.hpp:65
const int size
Definition: klu2_simple.cpp:50
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:31
super_type & setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList) override
Set/update internal variables and solver options.
Definition: Amesos2_SolverCore_def.hpp:513
std::string description() const override
Returns a short description of this Solver.
Definition: Amesos2_SolverCore_def.hpp:583
void setA(const Teuchos::RCP< const Matrix > a, EPhase keep_phase=CLEAN) override
Sets the matrix A of this solver.
Definition: Amesos2_SolverCore_def.hpp:470
Utility functions for Amesos2.
super_type & preOrdering() override
Pre-orders the matrix A for minimal fill-in.
Definition: Amesos2_SolverCore_def.hpp:73
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const override
Definition: Amesos2_SolverCore_def.hpp:593
void printTiming(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
Prints timing information about the current solver.
Definition: Amesos2_SolverCore_def.hpp:654
SolverCore(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize a Solver instance.
Definition: Amesos2_SolverCore_def.hpp:40
virtual type & numericFactorization(void)=0
Performs numeric factorization on the matrix.
bool matrixShapeOK() override
Returns true if the solver can handle this matrix shape.
Definition: Amesos2_SolverCore_def.hpp:456
void printLine(Teuchos::FancyOStream &out)
Prints a line of 70 "-"s on std::cout.
Definition: Amesos2_Util.cpp:85
super_type & symbolicFactorization() override
Performs symbolic factorization on the matrix A.
Definition: Amesos2_SolverCore_def.hpp:93
void loadA(EPhase current_phase)
Refresh this solver's internal data about A.
Definition: Amesos2_SolverCore_def.hpp:754
std::string name() const override
Return the name of this solver.
Definition: Amesos2_SolverCore_def.hpp:746
Interface to Amesos2 solver objects.
Definition: Amesos2_Solver_decl.hpp:44
void getTiming(Teuchos::ParameterList &timingParameterList) const override
Extracts timing information from the current solver.
Definition: Amesos2_SolverCore_def.hpp:736
super_type & numericFactorization() override
Performs numeric factorization on the matrix A.
Definition: Amesos2_SolverCore_def.hpp:122