<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19019">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>./pgfem -pc_type none does not work either, leading to
negative jacobian of element.</FONT></DIV>
<DIV><FONT size=2>The SNES solve is soling a meshfree method.</FONT></DIV>
<DIV><FONT size=2>I attached the segment of code.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>What is the output for -mat_view, are all the output the
jacobian, or do they inlcude preconditioning matrix?</FONT></DIV>
<DIV><FONT size=2>I found the output matrices do not have the same nonzero
structure.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>PetscErrorCode FormFunction(SNES snes,Vec u, Vec r, void
*ctx)<BR>{<BR> Log::Send(Log::Info, " Form Function ...");<BR>
ApplicationCtx *user = (ApplicationCtx*) ctx;<BR> //NOTE: r is the
nonlinea function, NOT the r.h.s term<BR> //the r.h.s is '-r'<BR>
//u is the solution during the current Newton-Raphson iteration<BR> //not
an increment </FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //VecSet(u,0.001);<BR>
//user->pDomain->pPhyDomain->GetMesh(0)->GetEBoundary()->Treatment(NULL,&u);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //printf("solutoin
vector.................\n");<BR>
//VecView(u,PETSC_VIEWER_STDOUT_WORLD);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //dof = du<BR> VecAYPX(user->oldu, -1,
u);<BR>
user->pDomain->pPhyDomain->UpdateDofs(user->oldu);<BR>
VecCopy(u,user->oldu);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //x = x + du<BR>
user->pDomain->pPhyDomain->UpdateConfiguration(user->oldu);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //QPoint's gradients in current config, new jacobian,
new locations etc.<BR>
user->pDomain->pPhyDomain->UpdateQPoints();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //mfree connectivity in the new configuration<BR>
user->pDomain->pPhyDomain->MFreeConnectivity();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //F = (dX/dx)^-1<BR>
user->pDomain->pPhyDomain->DeformGradients();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //stress<BR>
user->pDomain->pPhyDomain->UpdateStress();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //f(x) of J(x) dx = f(x)<BR>
FormInitialGuess(r);<BR>
user->pDomain->pPhyDomain->InternalForce(r);<BR>
VecAssemblyBegin(r);<BR> VecAssemblyEnd(r);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>
user->pDomain->pPhyDomain->Loads(user->pDomain->contrl.loadContlType,
-1.0*user->lambda, &u, &r);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> //printf("residual
force.................\n");<BR>
//VecView(r,PETSC_VIEWER_STDOUT_WORLD);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> PetscFunctionReturn(0);<BR>}</FONT></DIV>
<DIV> </DIV><FONT size=2>
<DIV><BR>PetscErrorCode FormJacobian(SNES snes, Vec x, Mat *jac/*jacobian*/, Mat
*B/*precon*/,MatStructure*flag,void *ctx)<BR>{<BR> Log::Send(Log::Info, "
Form Jacobian ...");<BR> ApplicationCtx *user = (ApplicationCtx*)
ctx;<BR> <BR> //initialize jacobian matrix<BR>
MatZeroEntries(*B);</DIV>
<DIV> </DIV>
<DIV> //assemble<BR>
user->pDomain->pPhyDomain->TangentMatrix(*B);<BR>
MatAssemblyBegin(*B,MAT_FINAL_ASSEMBLY);<BR>
MatAssemblyEnd(*B,MAT_FINAL_ASSEMBLY);</DIV>
<DIV> </DIV>
<DIV> //boundary treatment, mainly MatZeroRows()<BR>
user->pDomain->pPhyDomain->Constraints(user->pDomain->contrl.loadContlType,
B);</DIV>
<DIV> </DIV>
<DIV> //printf("Global matrix........\n");<BR>
//MatView(*B,PETSC_VIEWER_STDOUT_WORLD);</DIV>
<DIV> </DIV>
<DIV> if (*jac != *B){<BR>
MatAssemblyBegin(*jac,MAT_FINAL_ASSEMBLY);<BR>
MatAssemblyEnd(*jac,MAT_FINAL_ASSEMBLY);<BR> }</DIV>
<DIV> </DIV>
<DIV> ::DumpMatrixToDisk(*B);</DIV>
<DIV> </DIV>
<DIV> *flag = SAME_NONZERO_PATTERN;</DIV>
<DIV> </DIV>
<DIV> PetscFunctionReturn(0);<BR>}<BR></DIV>
<DIV> </DIV></FONT>
<DIV> </DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px"
dir=ltr>
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=jed@59A2.org href="mailto:jed@59A2.org">Jed Brown</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=petsc-users@mcs.anl.gov
href="mailto:petsc-users@mcs.anl.gov">PETSc users list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, May 16, 2011 9:04 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [petsc-users] SNES
convergence issue</DIV>
<DIV><BR></DIV>
<DIV class=gmail_quote>On Mon, May 16, 2011 at 14:54, Tian(ICT) <SPAN
dir=ltr><<A
href="mailto:rongtian@ncic.ac.cn">rongtian@ncic.ac.cn</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote>
<DIV> 12 KSP preconditioned resid norm 5.794625326821e+000 true resid
norm 5.490686672936e+006 ||Ae||/||Ax|| 7.765003561961e+004<BR> 13 KSP
preconditioned resid norm 7.239823936251e-001 true resid norm
4.262009749173e+005 ||Ae||/||Ax|| 6.027391992073e+003<BR> 14 KSP
preconditioned resid norm 6.718858761053e-001 true resid norm
7.089916382344e+005 ||Ae||/||Ax|| 1.002665590704e+004<BR> 15 KSP
preconditioned resid norm 6.284315560280e-001 true resid norm
4.441924320726e+005 ||Ae||/||Ax|| 6.281829619309e+003<BR> 16 KSP
preconditioned resid norm 6.861179511523e-011 true resid norm
1.032548577293e+006 ||Ae||/||Ax||
1.460244202260e+004</DIV></BLOCKQUOTE></DIV><BR>
<DIV>Notice how the true residual is blowing up while the GMRES estimate
converges. (The language here is not correct, "preconditioned resid norm" in
this case is actually the unpreconditioned norm as estimated by FGMRES.) This
indicates that the preconditioner is singular which could be due to lack of
pivoting. If you run with -pc_type none, it should converge correctly. Do that
and see if SNES is converging properly. Also try -pc_type lu
-pc_factor_mat_solver_package superlu (or mumps or umfpack) if you have any of
these packages installed.</DIV>
<DIV><BR></DIV>
<DIV>What equations are you solving and with what
discretization?</DIV></BLOCKQUOTE></BODY></HTML>