Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP (Do Not Merge!!): Belos Small Dense Matrix Abstraction #11837

Draft
wants to merge 110 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
f353a3d
Added DenseMatrix template param to Belos::MultiVecTraits.
jennloe Dec 30, 2022
4558b2c
Add Dense template paramter to solver manager base class and solver f…
jennloe Dec 30, 2022
aa21a51
Remove Serial Dense from ICGSOrthoMgr
jennloe Mar 1, 2023
4cac21f
Removed Serial Dense from MatOrthoMgr.
jennloe Mar 1, 2023
ecf4297
Removed SerialDense from OrthoMgr.
jennloe Mar 1, 2023
fb75baa
Added Dense param to blockGMRESIter.
jennloe Mar 1, 2023
a2f69ec
Added template param to Gmres iterations.
jennloe Mar 1, 2023
69a98fc
Add dense param to GMRES sol mgr and base class.
jennloe Mar 1, 2023
2ee9622
Added template param to FGmres iter and OrthoMgrFactory.
jennloe Mar 1, 2023
0833975
First attempt at outlining a few Dense Matrix Traits.
jennloe Mar 2, 2023
04f69b7
Add header file to Belos src needed for Thyra to compile.
jennloe Mar 8, 2023
a83a9c1
Updated DenseMatrixAdapter functions. Wrote a partial Teuchos Serial …
jennloe Mar 8, 2023
e182901
Expanded MultiVec Traits and corresponding Teuchos adapter, which pas…
jennloe Mar 14, 2023
0475c9c
BlockGmres solver partially running through dense mat traits
jennloe Mar 16, 2023
58f8e97
Add default constructor to dense mat taits.
jennloe Mar 18, 2023
932b663
Update reshape traits fct to have init to zero option.
jennloe Mar 18, 2023
e271c5e
Added more functions for GMRES transition.
jennloe Mar 20, 2023
aa4fe14
Converted BlockGmresIter outer layer to use abstract dense.
jennloe Mar 20, 2023
549d065
Added Frobenius norm to dense traits.
jennloe Mar 21, 2023
18efc6e
Converted ICGS to dense abstract interface.
jennloe Mar 21, 2023
d983f9d
First attempt at Kokkos adapter.
jennloe Mar 27, 2023
ae30039
Minor adjustment of comments.
jennloe Mar 28, 2023
b7e055c
Kokkos Dense adapter now passes dense unit test.
jennloe Mar 28, 2023
7bd92e1
Reorganized Tpetra MV traits to allow future specialization for Kokko…
jennloe Apr 25, 2023
0b671a6
We now have a working Kokkos::View Dense adapter that is passing basic
jennloe May 2, 2023
476023f
Converted IMGS OrthoMgr to new Dense interface.
jennloe May 3, 2023
b9454d3
Fixed build error in ICGS.
jennloe May 3, 2023
24f3e8b
Incorporated Dense Abstract interface into status tests.
jennloe May 4, 2023
31b9f4c
GMRES spaces experiment.
jennloe May 8, 2023
bcbaaff
Converted BelosLSQR and added ValueConst function explicitly in the n…
jennloe Jun 26, 2023
a1de42c
Finally got the Kokkos Dense + Tpetra Block GMRES test building and p…
jennloe Jul 7, 2023
51d111a
Got DenseMat template param added to all needed solvers at the top le…
jennloe Jul 24, 2023
24e6ef6
Test many dense scalar types with SerialDenseMat Teuchos traits, via …
jennloe Jul 31, 2023
12b62c9
Remove requirement to mark rawptr data modified. Fix two instances of…
jennloe Jul 31, 2023
8c3c0be
Added SyncHostToDevice function for DenseMatTraits.
jennloe Jul 31, 2023
9dd9ff2
Added syncs around TRSM. No change in failing test.
jennloe Jul 31, 2023
62522c8
Added syncs to LS problem solve. No change in failing test.
jennloe Jul 31, 2023
7c27f57
Added extra syncs. Encountering deep copy error. Added debug statemen…
jennloe Aug 14, 2023
c26148e
Converted Minres to abstract layer; works with Teuchos dense backend.
jennloe Jul 26, 2023
2074957
Minres solver converted and runs with KK dense on CPU.
jennloe Jul 31, 2023
e26c8ce
Fixed a deep copy issue for strided matrices. Also added some couts f…
jennloe Sep 18, 2023
97828e6
Fix Kokkos stride method for dense matrix traits and small code cleanup
hkthorn Oct 10, 2023
825edca
Improve integration of dense matrix traits into LSQR
hkthorn Oct 17, 2023
203698d
Converts BiCGStab and TFQMR solver to use dense matrix template
hkthorn Oct 17, 2023
7c45b55
Removes unused implicit residual norm status test
hkthorn Oct 17, 2023
f8e6cad
Remove unused Teuchos_SerialDenseMatrix.hpp header file
hkthorn Oct 17, 2023
fae528f
Removes default argument for dense matrix template argument
hkthorn Oct 17, 2023
8e8542f
Minor change to binary name for Kokkos::DualView MINRES test
hkthorn Oct 17, 2023
acf65f3
Converts PCPG solver to use dense matrix traits
hkthorn Oct 17, 2023
0400b92
Removes unused typedef
hkthorn Oct 19, 2023
5dc9cd4
Fixes GCRODR template to include dense matrix argument
hkthorn Oct 19, 2023
1bdf4ad
Removes duplicate definition of MINRES directory
hkthorn Oct 19, 2023
52412e4
Fixes MINRES test so it will compile.
hkthorn Oct 19, 2023
53261ae
Fixes MVOPTester code for Kokkos. Now this test passes on ascicgpu030.
hkthorn Oct 23, 2023
3a364f7
Fixes MINRES solver for Kokkos. Now the MINRES test passes on ascicg…
hkthorn Oct 23, 2023
03f7c22
Finishes integration of dense matrix traits into PCPG
hkthorn Oct 24, 2023
de4501b
Fixes all orthogonalization classes and testers to work with dense ma…
hkthorn Oct 25, 2023
8f7277a
Removes debugging statements
hkthorn Oct 26, 2023
e6be018
Changes diagonal updating to use Subview/PutScalar methods
hkthorn Oct 26, 2023
73af96a
Adds Teuchos::SerialDenseMatrix test for DenseMatrixTester
hkthorn Oct 26, 2023
a1eba92
Converts over TSQR classes in Belos to use dense matrix template argu…
hkthorn Oct 26, 2023
e0da7ad
Converts flexible GMRES to use dense matrix traits and adds test
hkthorn Oct 26, 2023
0556c35
Converts fixed-point solver to use dense matrix template
hkthorn Oct 26, 2023
c05e6f0
Adds missing override to address build warning
hkthorn Nov 2, 2023
756e3fd
Removed unnecessary Teuchos SDM header
hkthorn Nov 2, 2023
1444b58
Moves pseudo-block GMRES data structures to iteration header
hkthorn Nov 3, 2023
a245a93
Adds override statment to address compiler warning
hkthorn Nov 10, 2023
1af8602
Converts single-vector CG, pseudo-block CG, and stochastic CG to DMT
hkthorn Nov 10, 2023
b8ca6e6
Removes unused serial dense matrix objects
hkthorn Nov 15, 2023
c4a9ac0
Adds DenseSolver interface for block CG solver
hkthorn Dec 13, 2023
c83718d
Fixes dense solver for Kokkos interface, clean up CG solvers
hkthorn Dec 13, 2023
64a97b9
Finished converting GMRES-variants to dense matrix traits
hkthorn Dec 15, 2023
e33bf99
Adds GMRES resolve test for Kokkos DualView, fixes templates in other…
hkthorn Dec 18, 2023
9ce63cc
Fixes compile error for CommandLineProcessor
hkthorn Jun 13, 2024
9bdf513
Fixes OrthoFactory to use dense matrix traits in template argument
hkthorn Jun 14, 2024
2996a26
Inserts missing device to host synchronization
hkthorn Jun 14, 2024
b6d6b3a
Fixing const correctness in arguments
hkthorn Jul 31, 2024
64b021f
Fixes CreateCopy and GetRawHostPtr, updates test
hkthorn Jul 31, 2024
bd5fd96
Update GCRODR solver to use dense matrix traits
hkthorn Jul 31, 2024
ce62ed8
Adds tests for GCRODR and CG solver using Kokkos::DualView dense matrix
hkthorn Aug 2, 2024
1a81440
Fix headers to be consistent with recent changes
hkthorn Aug 5, 2024
9ee594a
Add complex-valued tests for minres, bicgstab, and gcrodr
hkthorn Aug 7, 2024
aaeb288
Consolidates Teuchos::ScalarTraits typedefs
hkthorn Aug 23, 2024
23612ad
Corrects use of DMT::Value to DMT::ValueConst.
hkthorn Aug 23, 2024
95ea9c6
Comments out failing BiCGStab test
hkthorn Aug 23, 2024
806fb9d
Adding new tests to exercise orthogonalization options with GCRODR
hkthorn Aug 26, 2024
f49a0e6
Adding method to debugging output to enable better understanding of p…
hkthorn Aug 26, 2024
2b92f8f
Completes integration of DenseMatrixTraits
hkthorn Aug 26, 2024
a007d5a
Changes scalar values from SerialDenseMatrix to std::vector<>
hkthorn Aug 27, 2024
ac5c515
Moves several dense matrix objects to std::vector objects
hkthorn Aug 28, 2024
fe52229
Remove unnecessary header
hkthorn Aug 29, 2024
956ba09
Code cleanup to remove unnecessary dense matrix views
hkthorn Aug 30, 2024
51a5995
Final clean up before dense matrix traits transformation of RCG
hkthorn Aug 30, 2024
cd1e46c
Convert SerialDenseMatrix objects to dense matrix traits.
hkthorn Sep 4, 2024
f42c362
Cleans up use of MvAddMv to use Assign when more appropriate
hkthorn Sep 9, 2024
8c73b96
Finishes migration of GEMM calls to use Teuchos::BLAS class
hkthorn Sep 9, 2024
6df1683
Removes unused one/zero definitions after MvAddMv -> Assign changes
hkthorn Sep 17, 2024
2524f9c
Fixes RCG solver to be correct with Kokkos::DualView
hkthorn Sep 18, 2024
f1979c8
Removes unused zero and one definitions
hkthorn Sep 18, 2024
4513c02
Fix deprecated std::random_shuffle call
hkthorn Sep 25, 2024
d92bbf6
Update pseudo-block solvers for dense matrix abstraction
hkthorn Sep 25, 2024
ae03ed8
Fixes block GCRODR to compile with updated dense matrix traits
hkthorn Sep 25, 2024
c4b8a32
Cleaning up unnecessary examples, per Jennifer's note, before final c…
hkthorn Sep 25, 2024
d584a2c
Removes dependence of GmresIteration on Teuchos::SerialDenseMatrix
hkthorn Sep 30, 2024
23d2aa8
Adds Teuchos_SerialDenseMatrix and Teuchos_SerialDenseVector headers
hkthorn Sep 30, 2024
ba03404
Adds some checks to avoid compiler errors on unused variables.
hkthorn Sep 30, 2024
4507058
Adds Teuchos::SerialDenseMatrix as default dense matrix in template
hkthorn Oct 2, 2024
c97b897
Adds dense matrix traits to the partial specialization of GenResSubNorm
hkthorn Oct 2, 2024
f30e1f9
Removes template argument with default value since default value is b…
hkthorn Oct 2, 2024
cc025aa
Remove unused local variables
hkthorn Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ void registerSolverFactory() {
typedef double ST;
typedef Epetra_MultiVector MV;
typedef Epetra_Operator OP;
typedef Teuchos::SerialDenseMatrix<int,ST> DM;

Impl::registerSolverSubclassForTypes<BiCGStabSolMgr<ST,MV,OP>, ST, MV, OP> ("BICGSTAB");
Impl::registerSolverSubclassForTypes<BlockCGSolMgr<ST,MV,OP>, ST, MV, OP> ("BLOCK CG");
Impl::registerSolverSubclassForTypes<BlockGmresSolMgr<ST,MV,OP>, ST, MV, OP> ("BLOCK GMRES");
Impl::registerSolverSubclassForTypes<BlockCGSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("BLOCK CG");
Impl::registerSolverSubclassForTypes<BlockGmresSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("BLOCK GMRES");
Impl::registerSolverSubclassForTypes<FixedPointSolMgr<ST,MV,OP>, ST, MV, OP> ("FIXED POINT");
Impl::registerSolverSubclassForTypes<GCRODRSolMgr<ST,MV,OP>, ST, MV, OP> ("GCRODR");
Impl::registerSolverSubclassForTypes<GmresPolySolMgr<ST,MV,OP>, ST, MV, OP> ("HYBRID BLOCK GMRES");
Impl::registerSolverSubclassForTypes<LSQRSolMgr<ST,MV,OP>, ST, MV, OP> ("LSQR");
Impl::registerSolverSubclassForTypes<MinresSolMgr<ST,MV,OP>, ST, MV, OP> ("MINRES");
Impl::registerSolverSubclassForTypes<PCPGSolMgr<ST,MV,OP>, ST, MV, OP> ("PCPG");
Impl::registerSolverSubclassForTypes<PseudoBlockCGSolMgr<ST,MV,OP>, ST, MV, OP> ("PSEUDOBLOCK CG");
Impl::registerSolverSubclassForTypes<PseudoBlockGmresSolMgr<ST,MV,OP>, ST, MV, OP> ("PSEUDOBLOCK GMRES");
Impl::registerSolverSubclassForTypes<GCRODRSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("GCRODR");
Impl::registerSolverSubclassForTypes<GmresPolySolMgr<ST,MV,OP,DM>, ST, MV, OP> ("HYBRID BLOCK GMRES");
Impl::registerSolverSubclassForTypes<LSQRSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("LSQR");
Impl::registerSolverSubclassForTypes<MinresSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("MINRES");
Impl::registerSolverSubclassForTypes<PCPGSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("PCPG");
Impl::registerSolverSubclassForTypes<PseudoBlockCGSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("PSEUDOBLOCK CG");
Impl::registerSolverSubclassForTypes<PseudoBlockGmresSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("PSEUDOBLOCK GMRES");
Impl::registerSolverSubclassForTypes<PseudoBlockTFQMRSolMgr<ST,MV,OP>, ST, MV, OP> ("PSEUDOBLOCK TFQMR");
Impl::registerSolverSubclassForTypes<RCGSolMgr<ST,MV,OP>, ST, MV, OP> ("RCG");
Impl::registerSolverSubclassForTypes<RCGSolMgr<ST,MV,OP,DM>, ST, MV, OP> ("RCG");
Impl::registerSolverSubclassForTypes<TFQMRSolMgr<ST,MV,OP>, ST, MV, OP> ("TFQMR");
}

Expand Down
5 changes: 3 additions & 2 deletions packages/belos/epetra/test/MVOPTester/cxx_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "BelosMVOPTester.hpp"
#include "BelosEpetraAdapter.hpp"
#include "BelosOutputManager.hpp"
#include "BelosTeuchosDenseAdapter.hpp"

#include "Teuchos_StandardCatchMacros.hpp"

Expand Down Expand Up @@ -121,7 +122,7 @@ int main(int argc, char *argv[])

// Issue several useful typedefs;
typedef Belos::MultiVec<double> EMV;
//typedef Belos::Operator<double> EOP; // unused
typedef Teuchos::SerialDenseMatrix<int, double> TDM;

// Create an Epetra_MultiVector for an initial std::vector to start the solver.
// Note that this needs to have the same number of columns as the blocksize.
Expand All @@ -135,7 +136,7 @@ int main(int argc, char *argv[])
}

// test the Epetra adapter multivector
ierr = Belos::TestMultiVecTraits<double,EMV>(MyOM,ivec);
ierr = Belos::TestMultiVecTraits<double,EMV,TDM>(MyOM,ivec);
gerr &= ierr;
if (ierr) {
MyOM->print(Belos::Warnings,"*** EpetraAdapter PASSED TestMultiVecTraits()\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ main (int argc, char *argv[])
// subclass, given a name for the subclass. The name is not the
// same as the class' syntactic name: e.g., "DKGS" is the name of
// DkgsOrthoManager.
Belos::OrthoManagerFactory< scalar_type, MV, OP > factory;
Belos::OrthoManagerFactory< scalar_type, MV, OP, serial_matrix_type > factory;
// The name of the (Mat)OrthoManager subclass to instantiate.
std::string ortho (factory.defaultName());

Expand Down Expand Up @@ -528,7 +528,7 @@ main (int argc, char *argv[])
// should return zero).
int numFailed = 0;
{
typedef Belos::Test::OrthoManagerTester<scalar_type, MV> tester_type;
typedef Belos::Test::OrthoManagerTester<scalar_type, MV, serial_matrix_type> tester_type;
debugOut << "Running OrthoManager tests..." << endl;
numFailed = tester_type::runTests (OM, isRankRevealing, S,
sizeX1, sizeX2, outMan);
Expand Down
14 changes: 8 additions & 6 deletions packages/belos/kokkos/example/GCRODRComplexKokkosExFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "BelosGCRODRSolMgr.hpp"
#include "BelosOutputManager.hpp"

#include "Teuchos_SerialDenseMatrix.hpp"
#include "Teuchos_CommandLineProcessor.hpp"
#include "Teuchos_ParameterList.hpp"
#include "Teuchos_StandardCatchMacros.hpp"
Expand All @@ -41,11 +42,12 @@ bool success = true;
typedef Kokkos::complex<double> ST;
typedef int OT;
typedef Kokkos::DefaultExecutionSpace EXSP;
typedef Teuchos::ScalarTraits<ST> SCT;
typedef Teuchos::ScalarTraits<ST> SCT;
typedef Teuchos::SerialDenseMatrix<int,ST>DM;
typedef SCT::magnitudeType MT;
typedef Belos::KokkosMultiVec<ST, EXSP> MV;
typedef Belos::MultiVec<ST> KMV;
typedef Belos::Operator<ST> KOP;
typedef Belos::KokkosMultiVec<ST, EXSP> MV;
typedef Belos::MultiVec<ST> KMV;
typedef Belos::Operator<ST> KOP;
typedef Belos::MultiVecTraits<ST,KMV> MVT;
typedef Belos::OperatorTraits<ST,KMV,KOP> OPT;

Expand Down Expand Up @@ -136,8 +138,8 @@ try {
// *******************************************************************
//
// Create an iterative solver manager.
RCP< Belos::SolverManager<ST,KMV,KOP> > newSolver
= rcp( new Belos::GCRODRSolMgr<ST,KMV,KOP,true>(rcpFromRef(problem), rcpFromRef(belosList)) );
RCP< Belos::SolverManager<ST,KMV,KOP,DM> > newSolver
= rcp( new Belos::GCRODRSolMgr<ST,KMV,KOP,DM,true>(rcpFromRef(problem), rcpFromRef(belosList)) );

//
// **********Print out information about problem*******************
Expand Down
2 changes: 1 addition & 1 deletion packages/belos/kokkos/example/GCRODRKokkosExFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ try {
//
// Create an iterative solver manager.
RCP< Belos::SolverManager<ST,KMV,KOP> > newSolver
= rcp( new Belos::GCRODRSolMgr<ST,KMV,KOP,true>(rcpFromRef(problem), rcpFromRef(belosList)) );
= rcp( new Belos::GCRODRSolMgr<ST,KMV,KOP>(rcpFromRef(problem), rcpFromRef(belosList)) );

//
// **********Print out information about problem*******************
Expand Down
30 changes: 14 additions & 16 deletions packages/belos/src/BelosBiCGStabIter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "BelosOperatorTraits.hpp"
#include "BelosMultiVecTraits.hpp"

#include "Teuchos_SerialDenseMatrix.hpp"
#include "Teuchos_SerialDenseVector.hpp"
#include "Teuchos_ScalarTraits.hpp"
#include "Teuchos_ParameterList.hpp"
#include "Teuchos_TimeMonitor.hpp"
Expand Down Expand Up @@ -77,15 +75,15 @@ namespace Belos {
}
};

template<class ScalarType, class MV, class OP>
class BiCGStabIter : virtual public Iteration<ScalarType,MV,OP> {
template<class ScalarType, class MV, class OP, class DM>
class BiCGStabIter : virtual public Iteration<ScalarType,MV,OP,DM> {

public:

//
// Convenience typedefs
//
typedef MultiVecTraits<ScalarType,MV> MVT;
typedef MultiVecTraits<ScalarType,MV,DM> MVT;
typedef OperatorTraits<ScalarType,MV,OP> OPT;
typedef Teuchos::ScalarTraits<ScalarType> SCT;
typedef typename SCT::magnitudeType MagnitudeType;
Expand All @@ -101,7 +99,7 @@ namespace Belos {
*/
BiCGStabIter( const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem,
const Teuchos::RCP<OutputManager<ScalarType> > &printer,
const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > &tester,
Teuchos::ParameterList &params );

//! Destructor.
Expand Down Expand Up @@ -235,7 +233,7 @@ namespace Belos {
//
const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > lp_;
const Teuchos::RCP<OutputManager<ScalarType> > om_;
const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > stest_;
const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > stest_;

//
// Algorithmic parameters
Expand Down Expand Up @@ -277,10 +275,10 @@ namespace Belos {

//////////////////////////////////////////////////////////////////////////////////////////////////
// Constructor.
template<class ScalarType, class MV, class OP>
BiCGStabIter<ScalarType,MV,OP>::BiCGStabIter(const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem,
template<class ScalarType, class MV, class OP, class DM>
BiCGStabIter<ScalarType,MV,OP,DM>::BiCGStabIter(const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem,
const Teuchos::RCP<OutputManager<ScalarType> > &printer,
const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > &tester,
Teuchos::ParameterList &/* params */ ):
lp_(problem),
om_(printer),
Expand All @@ -295,8 +293,8 @@ namespace Belos {

//////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize this iteration object
template <class ScalarType, class MV, class OP>
void BiCGStabIter<ScalarType,MV,OP>::initializeBiCGStab(BiCGStabIterationState<ScalarType,MV>& newstate)
template<class ScalarType, class MV, class OP, class DM>
void BiCGStabIter<ScalarType,MV,OP,DM>::initializeBiCGStab(BiCGStabIterationState<ScalarType,MV>& newstate)
{
// Check if there is any multivector to clone from.
Teuchos::RCP<const MV> lhsMV = lp_->getCurrLHSVec();
Expand Down Expand Up @@ -425,8 +423,8 @@ namespace Belos {

//////////////////////////////////////////////////////////////////////////////////////////////////
// Iterate until the status test informs us we should stop.
template <class ScalarType, class MV, class OP>
void BiCGStabIter<ScalarType,MV,OP>::iterate()
template<class ScalarType, class MV, class OP, class DM>
void BiCGStabIter<ScalarType,MV,OP,DM>::iterate()
{
using Teuchos::RCP;

Expand Down Expand Up @@ -588,8 +586,8 @@ namespace Belos {

//////////////////////////////////////////////////////////////////////////////////////////////////
// Iterate until the status test informs us we should stop.
template <class ScalarType, class MV, class OP>
void BiCGStabIter<ScalarType,MV,OP>::axpy(const ScalarType alpha, const MV & A,
template<class ScalarType, class MV, class OP, class DM>
void BiCGStabIter<ScalarType,MV,OP,DM>::axpy(const ScalarType alpha, const MV & A,
const std::vector<ScalarType> beta, const MV& B, MV& mv, bool minus)
{
Teuchos::RCP<const MV> A1, B1;
Expand Down
58 changes: 30 additions & 28 deletions packages/belos/src/BelosBiCGStabSolMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "BelosStatusTestCombo.hpp"
#include "BelosStatusTestOutputFactory.hpp"
#include "BelosOutputManager.hpp"

#include "BelosTeuchosDenseAdapter.hpp"
#ifdef BELOS_TEUCHOS_TIME_MONITOR
#include "Teuchos_TimeMonitor.hpp"
#endif
Expand Down Expand Up @@ -61,11 +63,11 @@ namespace Belos {
BiCGStabSolMgrLinearProblemFailure(const std::string& what_arg) : BelosError(what_arg)
{}};

template<class ScalarType, class MV, class OP>
class BiCGStabSolMgr : public SolverManager<ScalarType,MV,OP> {
template<class ScalarType, class MV, class OP, class DM = Teuchos::SerialDenseMatrix<int, ScalarType>>
class BiCGStabSolMgr : public SolverManager<ScalarType,MV,OP,DM> {

private:
typedef MultiVecTraits<ScalarType,MV> MVT;
typedef MultiVecTraits<ScalarType,MV,DM> MVT;
typedef OperatorTraits<ScalarType,MV,OP> OPT;
typedef Teuchos::ScalarTraits<ScalarType> SCT;
typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
Expand Down Expand Up @@ -99,8 +101,8 @@ namespace Belos {
virtual ~BiCGStabSolMgr() {};

//! clone for Inverted Injection (DII)
Teuchos::RCP<SolverManager<ScalarType, MV, OP> > clone () const override {
return Teuchos::rcp(new BiCGStabSolMgr<ScalarType,MV,OP>);
Teuchos::RCP<SolverManager<ScalarType, MV, OP, DM> > clone () const override {
return Teuchos::rcp(new BiCGStabSolMgr<ScalarType,MV,OP,DM>);
}
//@}

Expand Down Expand Up @@ -216,10 +218,10 @@ namespace Belos {
Teuchos::RCP<std::ostream> outputStream_;

// Status test.
Teuchos::RCP<StatusTest<ScalarType,MV,OP> > sTest_;
Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> > maxIterTest_;
Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> > convTest_;
Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> > outputTest_;
Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > sTest_;
Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP,DM> > maxIterTest_;
Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP,DM> > convTest_;
Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP,DM> > outputTest_;

// Current parameter list.
Teuchos::RCP<Teuchos::ParameterList> params_;
Expand Down Expand Up @@ -257,8 +259,8 @@ namespace Belos {
};

// Empty Constructor
template<class ScalarType, class MV, class OP>
BiCGStabSolMgr<ScalarType,MV,OP>::BiCGStabSolMgr() :
template<class ScalarType, class MV, class OP, class DM>
BiCGStabSolMgr<ScalarType,MV,OP,DM>::BiCGStabSolMgr() :
outputStream_(Teuchos::rcpFromRef(std::cout)),
convtol_(DefaultSolverParameters::convTol),
maxIters_(maxIters_default_),
Expand All @@ -274,8 +276,8 @@ BiCGStabSolMgr<ScalarType,MV,OP>::BiCGStabSolMgr() :
{}

// Basic Constructor
template<class ScalarType, class MV, class OP>
BiCGStabSolMgr<ScalarType,MV,OP>::
template<class ScalarType, class MV, class OP, class DM>
BiCGStabSolMgr<ScalarType,MV,OP,DM>::
BiCGStabSolMgr (const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem,
const Teuchos::RCP<Teuchos::ParameterList> &pl ) :
problem_(problem),
Expand Down Expand Up @@ -304,8 +306,8 @@ BiCGStabSolMgr (const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem,
}
}

template<class ScalarType, class MV, class OP>
void BiCGStabSolMgr<ScalarType,MV,OP>::setParameters( const Teuchos::RCP<Teuchos::ParameterList> &params )
template<class ScalarType, class MV, class OP, class DM>
void BiCGStabSolMgr<ScalarType,MV,OP,DM>::setParameters( const Teuchos::RCP<Teuchos::ParameterList> &params )
{
using Teuchos::ParameterList;
using Teuchos::parameterList;
Expand Down Expand Up @@ -400,8 +402,8 @@ void BiCGStabSolMgr<ScalarType,MV,OP>::setParameters( const Teuchos::RCP<Teuchos
}

// Convergence
typedef Belos::StatusTestCombo<ScalarType,MV,OP> StatusTestCombo_t;
typedef Belos::StatusTestGenResNorm<ScalarType,MV,OP> StatusTestResNorm_t;
typedef Belos::StatusTestCombo<ScalarType,MV,OP,DM> StatusTestCombo_t;
typedef Belos::StatusTestGenResNorm<ScalarType,MV,OP,DM> StatusTestResNorm_t;

// Check for convergence tolerance
if (params->isParameter("Convergence Tolerance")) {
Expand Down Expand Up @@ -482,7 +484,7 @@ void BiCGStabSolMgr<ScalarType,MV,OP>::setParameters( const Teuchos::RCP<Teuchos

// Basic test checks maximum iterations and native residual.
if (maxIterTest_ == Teuchos::null)
maxIterTest_ = Teuchos::rcp( new StatusTestMaxIters<ScalarType,MV,OP>( maxIters_ ) );
maxIterTest_ = Teuchos::rcp( new StatusTestMaxIters<ScalarType,MV,OP,DM>( maxIters_ ) );

// Implicit residual test, using the native residual to determine if convergence was achieved.
if (convTest_ == Teuchos::null || newResTest) {
Expand All @@ -497,7 +499,7 @@ void BiCGStabSolMgr<ScalarType,MV,OP>::setParameters( const Teuchos::RCP<Teuchos

// Create the status test output class.
// This class manages and formats the output from the status test.
StatusTestOutputFactory<ScalarType,MV,OP> stoFactory( outputStyle_ );
StatusTestOutputFactory<ScalarType,MV,OP,DM> stoFactory( outputStyle_ );
outputTest_ = stoFactory.create( printer_, sTest_, outputFreq_, Passed+Failed+Undefined );

// Set the solver string for the output test
Expand All @@ -519,9 +521,9 @@ void BiCGStabSolMgr<ScalarType,MV,OP>::setParameters( const Teuchos::RCP<Teuchos
}


template<class ScalarType, class MV, class OP>
template<class ScalarType, class MV, class OP, class DM>
Teuchos::RCP<const Teuchos::ParameterList>
BiCGStabSolMgr<ScalarType,MV,OP>::getValidParameters() const
BiCGStabSolMgr<ScalarType,MV,OP,DM>::getValidParameters() const
{
using Teuchos::ParameterList;
using Teuchos::parameterList;
Expand Down Expand Up @@ -575,8 +577,8 @@ BiCGStabSolMgr<ScalarType,MV,OP>::getValidParameters() const
}


template<class ScalarType, class MV, class OP>
ReturnType BiCGStabSolMgr<ScalarType,MV,OP>::solve ()
template<class ScalarType, class MV, class OP, class DM>
ReturnType BiCGStabSolMgr<ScalarType,MV,OP,DM>::solve ()
{
// Set the current parameters if they were not set before.
// NOTE: This may occur if the user generated the solver manager with the default constructor and
Expand Down Expand Up @@ -624,8 +626,8 @@ ReturnType BiCGStabSolMgr<ScalarType,MV,OP>::solve ()
//////////////////////////////////////////////////////////////////////////////////////
// Pseudo-Block BiCGStab solver

Teuchos::RCP<BiCGStabIter<ScalarType,MV,OP> > bicgstab_iter
= Teuchos::rcp( new BiCGStabIter<ScalarType,MV,OP>(problem_,printer_,outputTest_,plist) );
Teuchos::RCP<BiCGStabIter<ScalarType,MV,OP,DM> > bicgstab_iter
= Teuchos::rcp( new BiCGStabIter<ScalarType,MV,OP,DM>(problem_,printer_,outputTest_,plist) );

// Enter solve() iterations
{
Expand Down Expand Up @@ -669,7 +671,7 @@ ReturnType BiCGStabSolMgr<ScalarType,MV,OP>::solve ()
if ( convTest_->getStatus() == Passed ) {

// Figure out which linear systems converged.
std::vector<int> convIdx = Teuchos::rcp_dynamic_cast<StatusTestGenResNorm<ScalarType,MV,OP> >(convTest_)->convIndices();
std::vector<int> convIdx = Teuchos::rcp_dynamic_cast<StatusTestGenResNorm<ScalarType,MV,OP,DM> >(convTest_)->convIndices();

// If the number of converged linear systems is equal to the
// number of current linear systems, then we are done with this block.
Expand Down Expand Up @@ -823,8 +825,8 @@ ReturnType BiCGStabSolMgr<ScalarType,MV,OP>::solve ()
}

// This method requires the solver manager to return a std::string that describes itself.
template<class ScalarType, class MV, class OP>
std::string BiCGStabSolMgr<ScalarType,MV,OP>::description() const
template<class ScalarType, class MV, class OP, class DM>
std::string BiCGStabSolMgr<ScalarType,MV,OP,DM>::description() const
{
std::ostringstream oss;
oss << "Belos::BiCGStabSolMgr<...,"<<Teuchos::ScalarTraits<ScalarType>::name()<<">";
Expand Down
Loading