I am confused by b). If they both converge, how can the answers be different?<br><br>  Matt<br><br><div class="gmail_quote">On Mon, Feb 8, 2010 at 3:13 PM, (Rebecca) Xuefei YUAN <span dir="ltr">&lt;<a href="mailto:xy2102@columbia.edu">xy2102@columbia.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Dear all,<br>
<br>
I do have an PDE-constrained optimization problem:<br>
<br>
F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1)<br>
F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy = 0 (2)<br>
<br>
where phi(x,y) is defined at each grid point and c is a scalar parameter that satisfying the equation (2).<br>
<br>
I have two pieces of codes to solve them by different approaches.<br>
<br>
The first approach is to use DMComposite() to manage unknowns and solve F1&amp;F2 at the same time, and it calls DMMGSolve() once.<br>
<br>
The second approach is to solve F1 with a guess c for some number(i.e. 1) times of nonlinear and linear iteration, and then update c from F2. Solve F1 again with updated c till some conditions satisfied, for example,<br>

<br>
if (cres&lt;1e-10){CONTINUE=PETSC_FALSE;} // update on c<br>
if (functionNorm&lt;1e-10){CONTINUE=PETSC_FALSE;}//residual function norm<br>
if (reason&gt;0){CONTINUE=PETSC_FALSE;}//snes_converged_reason<br>
if (totalNumberOfNonlinearIterations&gt;50){CONTINUE=PETSC_FALSE;}<br>
<br>
In this approach, DMMGSolve() was called more than once.<br>
<br>
Although these two approaches convergence, the results are quite different.<br>
<br>
My understanding is that<br>
a) approach one updates c in each linear iteration, but approach two updates c<br>
only after several (i.e. 1) nonlinear iterations.<br>
<br>
ierr = DMMGSolve(dmmg);CHKERRQ(ierr);<br>
parameters-&gt;c = parameters-&gt;integration/area;<br>
<br>
b) the results from two approaches should be the same or very close to each other but due to some reasons, they are not.<br>
<br>
c) three different examples are tested by these two approaches, two are good, but one is bad. The bad one is different from the other two because the solution has large gradient at some points.<br>
<br>
d) the shortcoming of approach one is PETSc has not ready for assemble a Jacobian for object DMComposite, so the second approach is able to write an analytic Jacobian.<br>
<br>
Any thoughts about how to debug or compare these two approaches is appreciate!~<br>
<br>
<br>
Thanks a ton!<br>
<br>
Rebecca<br><font color="#888888">
<br>
<br>
<br>
<br>
<br>
-- <br>
(Rebecca) Xuefei YUAN<br>
Department of Applied Physics and Applied Mathematics<br>
Columbia University<br>
Tel:917-399-8032<br>
<a href="http://www.columbia.edu/%7Exy2102" target="_blank">www.columbia.edu/~xy2102</a><br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>