Hi,
I have some question about petsc_nonlinear_solver in libmesh0.62.
Look at the code as follow: (petsc_nonlinear_solver.C)
> template <typename T>
> std::pair<unsigned int, Real>
> PetscNonlinearSolver<T>::solve (SparseMatrix<T>& jac_in, // System
> Jacobian Matrix
> NumericVector<T>& x_in, // Solution vector
> NumericVector<T>& r_in, // Residual vector
> const double, // Stopping tolerance
> const unsigned int)
> {
> this->init ();
>
> PetscMatrix<T>* jac = dynamic_cast<PetscMatrix<T>*>(&jac_in);
> PetscVector<T>* x = dynamic_cast<PetscVector<T>*>(&x_in);
> PetscVector<T>* r = dynamic_cast<PetscVector<T>*>(&r_in);
>
> // We cast to pointers so we can be sure that they succeeded
> // by comparing the result against NULL.
> assert(jac != NULL); assert(jac->mat() != NULL);
> assert(x != NULL); assert(x->vec() != NULL);
> assert(r != NULL); assert(r->vec() != NULL);
>
> int ierr=0;
> int n_iterations =0;
>
> ierr = SNESSetFunction (_snes, r->vec(),
> __libmesh_petsc_snes_residual, this);
> CHKERRABORT(libMesh::COMM_WORLD,ierr);
>
> ierr = SNESSetJacobian (_snes, jac->mat(), jac->mat(),
> __libmesh_petsc_snes_jacobian, this);
> CHKERRABORT(libMesh::COMM_WORLD,ierr);
>
> // Older versions (at least up to 2.1.5) of SNESSolve took 3 arguments,
> // the last one being a pointer to an int to hold the number of
> iterations required.
> # if PETSC_VERSION_LESS_THAN(2,2,0)
>
> ierr = SNESSolve (_snes, x->vec(), &n_iterations);
> CHKERRABORT(libMesh::COMM_WORLD,ierr);
>
> // 2.2.x style
> #elif PETSC_VERSION_LESS_THAN(2,3,0)
>
> ierr = SNESSolve (_snes, x->vec());
> CHKERRABORT(libMesh::COMM_WORLD,ierr);
>
> // 2.3.x & newer style
> #else
>
> ierr = SNESSolve (_snes, PETSC_NULL, x->vec());
> CHKERRABORT(libMesh::COMM_WORLD,ierr);
>
> #endif
>
> this->clear();
>
> // return the # of its. and the final residual norm. Note that
> // n_iterations may be zero for PETSc versions 2.2.x and greater.
> return std::make_pair(n_iterations, 0.);
> }
it seems that stopping tolerance and maxiter are not used here when
the PETSc vision >2.3.0 , why?
Because no SNESSETFormOptions(snes) here, so I can't set the ksp type,
precondition type, at one time I don't know what is the default setting?
Maybe GMRES and Block jacobian with ILU(0) for parallel calculations?
Thank you for your help!
Luyi
2008-3-19
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users