// @HEADER // ***************************************************************************** // Amesos2: Templated Direct Sparse Solver Package // // Copyright 2011 NTESS and the Amesos2 contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER /** \file Amesos2_NewSolver_def.hpp \author John Doe \date Thu Jul 8 16:08:10 2010 \brief Definitions for the Amesos2 NewSolver interface. */ #ifndef AMESOS2_NEWSOLVER_DEF_HPP #define AMESOS2_NEWSOLVER_DEF_HPP #include "Amesos2_SolverCore_def.hpp" #include "Amesos2_NewSolver_decl.hpp" namespace Amesos2 { template NewSolver::NewSolver( Teuchos::RCP A, Teuchos::RCP X, Teuchos::RCP B) : SolverCore(A, X, B) // instantiate superclass , nzvals_() , colind_() , rowptr_() { /* Assign private variables necessary for interfacing with the NewSolver TPL. * * Also set default solver options and paramters. */ } template NewSolver::~NewSolver( ) { /* * Free any memory allocated by the NewSolver library functions */ } template int NewSolver::preOrdering_impl() { /* * TODO: implement for the NewSolver library * * Can assume that the internal matrix data is current */ return(0); } template int NewSolver::symbolicFactorization_impl() { /* TODO: implement for the NewSolver library * * Can assume that the internal matrix data is current */ return(0); } template int NewSolver::numericFactorization_impl() { /* TODO: implement for NewSolver TPL * * Use function_map to link to the appropriate NewSolver library * functions in the case that the TPL functions are not overloaded * by type. * * Can assume that the internal matrix data is current */ return( 0 ); } template int NewSolver::solve_impl(const Teuchos::Ptr > X, const Teuchos::Ptr > B) const { /* TODO: implement for the NewSolver library * * Use function_map to link to the appropriate TPL functions in * the case that the TPL functions are not overloaded by type. * * Multivector data should be extracted from B and solution placed * in X before return. Can use utilities * Amesos2::Util::get_1d_copy_helper and * Amesos2::Util::put_1d_data_helper if the solver manipulates * RHS's as 1D arrays. */ return( 0 ); } template bool NewSolver::matrixShapeOK_impl() const { /* * Test shape of Matrix and return appropriate boolean */ return( true ); } template void NewSolver::setParameters_impl(const Teuchos::RCP & parameterList ) { /* * Set solver-specific parameters * * Say, for example, the solver supports the options * * - Equilibrate * - PivotThreshold * - Transpose */ if( parameterList->isParameter("Equilibrate") ){ bool equil = parameterList->template get("Equil"); if( equil ){ // Set flag for solver to do equilibration } else { // Set flag for solver *not* to do equilibration } } if( parameterList->isParameter("DiagPivotThresh") ){ double threshold = parameterList->template get("DiagPivotThresh"); // Set solver threshold parameter } if ( parameterList->isParameter("Trans") ){ std::string fact = parameterList->template get("Trans"); if( fact == "Tranpose" ){ // Set flag for solver to use transpose } else if ( fact == "NoTranspose" ){ // Set flag for solver to *not* use transpose } else if ( fact == "Conjugate" ) { // Set flag for solver to use the conjugate transpose } } else { // Set default value (if not set in constructor) } } template Teuchos::RCP NewSolver::getValidParameters_impl() const { using Teuchos::ParameterList; ParameterList valid_params; // valid_params.set("Parameter", default_value, doc_string); return Teuchos::rcpFromRef( valid_params ); } template bool NewSolver::loadA_impl(EPhase current_phase) { #ifdef HAVE_AMESOS2_TIMERS Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_); #endif // resize storage arrays if necessary // use Amesos2::Util::get_crs_helper or // Amesos2::Util::get_ccs_helper to get a CRS or CCS // representation of the matrix, if appropriate. Otherwise do // whatever conversion is necessary to get the matrix data ready // for the other library functions. return( true ); } template const char* NewSolver::name = "NewSolver"; } // end namespace Amesos2 #endif // AMESOS2_NEWSOLVER_DEF_HPP