Skip to content

Commit

Permalink
* fixed a issue on BinarySolver, FunctorBase and KSPSolver, - removed…
Browse files Browse the repository at this point in the history
… Multiply
  • Loading branch information
canercandan committed Feb 14, 2011
1 parent f4967c8 commit 56756cd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/petsc_cxx/BinarySolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace petsc_cxx
{

/* here's the solver base class */
template < A1, A2, R >
template < typename A1, typename A2, typename R >
class BinarySolver : public ConstBF< A1, A2, R > {};

}
Expand Down
2 changes: 2 additions & 0 deletions src/petsc_cxx/FunctorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ namespace petsc_cxx
struct unary_function_tag {};
/// tag to identify a binary function in compile time function selection @see functor_category
struct binary_function_tag {};
/// tag to identify a tertiary function in compile time function selection @see functor_category
struct tertiary_function_tag {};
};
/** @example t-Functor.cpp
*/
Expand Down
14 changes: 7 additions & 7 deletions src/petsc_cxx/KSPSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@ namespace petsc_cxx
{

template < typename Atom >
class KSPSolver : public BinarySolver< Matrix< Atom >, Vector< Atom >, Vector< Atom >, public Printable
class KSPSolver : public BO< Matrix< Atom >, Vector< Atom >, Vector< Atom > >, public Printable
{
public:
KSPSolver( MPI_Comm comm = PETSC_COMM_WORLD, MatStructure flag = DIFFERENT_NONZERO_PATTERN )
: _flag( flag )
{
KSPCreate( comm, &_solver );
KSPSetTolerences( _solver, 1.e-7, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT );
//KSPSetTolerences( _solver, 1.e-7, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT );
KSPSetFromOptions( _solver );
}

~KSPSolver() { KSPDestroy( _solver ); }

virtual Vector< Atom > operator( const Matrix< Atom >& A, const Vector< Atom >& b )() const
virtual void operator()( const Matrix< Atom >& A, const Vector< Atom >& x, Vector< Atom >& b )
{
KSPSetOperators( _solver, A, A, flag );
Vector< Atom > x;
KSPSolve( _solver, b, x );
return x;
KSPSetOperators( _solver, A, A, _flag );
KSPSolve( _solver, x, b );
}

void printOn(std::ostream& os) const
Expand All @@ -57,6 +56,7 @@ namespace petsc_cxx

private:
KSP _solver;
MatStructure _flag;
};

}
Expand Down
File renamed without changes.
10 changes: 9 additions & 1 deletion src/petsc_cxx/petsc_cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,19 @@
#include "F.h"
#include "UF.h"
#include "BF.h"
#include "TF.h"
#include "ConstF.h"
#include "ConstUF.h"
#include "ConstBF.h"
#include "ConstTF.h"

#include "Multiply.h"
#include "BO.h"
#include "MultiplyMatVec.h"
#include "AdditionMatrix.h"
#include "Dot.h"

#include "BinarySolver.h"
#include "KSPSolver.h"

#endif // !_petsc_cxx_

Expand Down

0 comments on commit 56756cd

Please sign in to comment.