[petsc-users] What is the difference between these two approaches?
Barry Smith
bsmith at mcs.anl.gov
Mon Feb 8 15:26:46 CST 2010
If both on converging then there is something wrong with your
function evaluation code for one or both of the two approaches. Or
perhaps Newton is not actually converging and so you are getting an
unconverged (wrong) solution. Make sure you always call
SNESGetConvergedReason() to insure the nonlinear equations are
actually be solved.
Barry
On Feb 8, 2010, at 3:24 PM, (Rebecca) Xuefei YUAN wrote:
> That is also confusing me when running this bad example. The good
> examples have matched solutions, but this bad one does not. I do not
> know what is wrong and where is the difference coming from?
>
>
>
>
> Quoting Matthew Knepley <knepley at gmail.com>:
>
>> I am confused by b). If they both converge, how can the answers be
>> different?
>>
>> Matt
>>
>> On Mon, Feb 8, 2010 at 3:13 PM, (Rebecca) Xuefei YUAN
>> <xy2102 at columbia.edu>wrote:
>>
>>> Dear all,
>>>
>>> I do have an PDE-constrained optimization problem:
>>>
>>> F1(phi(x,y),c) = L(phi(x,y)) + rho(s1(x,y),s2(x,y)) = 0 (1)
>>> F2(phi(x,y),c) = int_{domain}(c*rho(s1(x,y),s2(x,y)) - 1.0)dxdy =
>>> 0 (2)
>>>
>>> where phi(x,y) is defined at each grid point and c is a scalar
>>> parameter
>>> that satisfying the equation (2).
>>>
>>> I have two pieces of codes to solve them by different approaches.
>>>
>>> The first approach is to use DMComposite() to manage unknowns and
>>> solve
>>> F1&F2 at the same time, and it calls DMMGSolve() once.
>>>
>>> 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,
>>>
>>> if (cres<1e-10){CONTINUE=PETSC_FALSE;} // update on c
>>> if (functionNorm<1e-10){CONTINUE=PETSC_FALSE;}//residual function
>>> norm
>>> if (reason>0){CONTINUE=PETSC_FALSE;}//snes_converged_reason
>>> if (totalNumberOfNonlinearIterations>50){CONTINUE=PETSC_FALSE;}
>>>
>>> In this approach, DMMGSolve() was called more than once.
>>>
>>> Although these two approaches convergence, the results are quite
>>> different.
>>>
>>> My understanding is that
>>> a) approach one updates c in each linear iteration, but approach two
>>> updates c
>>> only after several (i.e. 1) nonlinear iterations.
>>>
>>> ierr = DMMGSolve(dmmg);CHKERRQ(ierr);
>>> parameters->c = parameters->integration/area;
>>>
>>> b) the results from two approaches should be the same or very
>>> close to each
>>> other but due to some reasons, they are not.
>>>
>>> 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.
>>>
>>> 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.
>>>
>>> Any thoughts about how to debug or compare these two approaches is
>>> appreciate!~
>>>
>>>
>>> Thanks a ton!
>>>
>>> Rebecca
>>>
>>>
>>>
>>>
>>>
>>> --
>>> (Rebecca) Xuefei YUAN
>>> Department of Applied Physics and Applied Mathematics
>>> Columbia University
>>> Tel:917-399-8032
>>> www.columbia.edu/~xy2102 <http://www.columbia.edu/%7Exy2102>
>>>
>>>
>>
>>
>> --
>> What most experimenters take for granted before they begin their
>> experiments
>> is infinitely more interesting than any results to which their
>> experiments
>> lead.
>> -- Norbert Wiener
>>
>
>
>
> --
> (Rebecca) Xuefei YUAN
> Department of Applied Physics and Applied Mathematics
> Columbia University
> Tel:917-399-8032
> www.columbia.edu/~xy2102
>
More information about the petsc-users
mailing list