您的位置:首页 > 其它

LibMesh::LinearSolver<T> & PetscLinearSolver<T> 类接口

2015-02-25 05:23 134 查看
This class provides a uniform interface for linear solvers, this base class is overloaded to provide linear solvers from different packages like PETSc / LASPACK

LinearSolver类继承关系:



共有成员函数:

LinearSovler(const libMesh::Communicator)

virtual ~LinearSolver()

clear(),

init(),

solver_type()

set_solver_type(),

Preconditioner_type(),

set_preconditioner_type(),

attach_preconditioner(),

1 {
2
if(this->_is_initialized)

3 libmesh_error_msg("Preconditioner must be attached before the s
olver is initialized");
4
5
_preconditioner_type = SHELL_PRECOND;
6
_preconditioner = preconditioner //function input;

7 }

virtual solver() 重载方法,一般给矩阵a,rhs列向量,求解列向量,pc矩阵可以给也可以有矩阵a计算。

static AutoPtr<LinearSolver<T> > build(), build a LinearSolver using linear solver package specified by solver_package

9 {

10 switch (solver_package)

11 {

12 #ifdef LIBMESH_HAVE_LASPACK

13
case LASPACK_SOLVERS:

14 {

15 AutoPtr<LinearSolver<T> > ap(new LaspackLinearSolver<T>(comm) );

16
return ap;

17 }

18 #endif

19

20 #ifdef LIBMESH_HAVE_PETSC

21
case PETSC_SOLVERS:

22 {

23 AutoPtr<LinearSolver<T> > ap(new PetscLinearSolver<T>(comm) );

24
return ap;

25 }

26 #endif

27

28 #ifdef LIBMESH_HAVE_TRILINOS

29
case TRILINOS_SOLVERS:

30 {

31 AutoPtr<LinearSolver<T> > ap(new AztecLinearSolver<T>(comm) );

32
return ap;

33 }

34 #endif

35

36 #ifdef LIBMESH_HAVE_EIGEN

37
case EIGEN_SOLVERS:

38 {

39 AutoPtr<LinearSolver<T> > ap(new EigenSparseLinearSolver<T>(comm) );

40
return ap;

41 }

42 #endif

43
default:

44 libmesh_error_msg("ERROR:Unrecognized solver package:" << solver_package);

45 }

46 AutoPtr<LinearSolver<T> > ap(NULL);

47 return ap;

48 }

PetscLinearSolver 重载 除构造/析构函数以外的 linear solver方法, 另外还有方法:

pc(),
ksp(), return PETSc ksp context pointer
get_residual_history()
get_initial_residual()
set_preconditioner_type(),
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: