> On Aug 28, 2015, at 7:29 PM, Gideon Simpson <[email protected]> wrote: > > That was a mistake on my part. But I did want to ask, what should be the > behavior with a grid sequence if the SNES fails during one of the > intermediate steps?
You'll have to look at the code. So I just did, unless you set the option -snes_error_if_not_converged it will blinding go on. But the final SNESConvergedReason() will hopefully be negative indicating that SNES has not converged. Barry > > -gideon > >> On Aug 28, 2015, at 6:03 PM, Barry Smith <[email protected]> wrote: >> >> >>> On Aug 28, 2015, at 4:35 PM, Gideon Simpson <[email protected]> >>> wrote: >>> >>> Hi Barry, >>> >>> Ok, I tried that and it works as intended, but there’s something I noticed. >>> If i use that, and do a SNESGetConvergedReason on the snesrefine, it >>> always seems to return 0. Is there a reason for that? >> >> Should never do that; are you sure that SNESSolve() has actually been >> called on it. What does -snes_monitor and -snes_converged_reason show. >> >> Barry >> >> >> >>> >>> -gideon >>> >>>> On Aug 28, 2015, at 4:21 PM, Barry Smith <[email protected]> wrote: >>>> >>>>> >>>>> On Aug 28, 2015, at 3:04 PM, Gideon Simpson <[email protected]> >>>>> wrote: >>>>> >>>>> Yes, if i continue in this parameter on the coarse mesh, I can generally >>>>> solve at all values. I do find that I need to do some amount of >>>>> continuation to solve near the endpoint. The problem is that on the >>>>> coarse mesh, things are not fully resolved at all the values along the >>>>> continuation parameter, and I would like to do refinement. >>>>> >>>>> One subtlety is that I actually want the intermediate continuation >>>>> solutions too. Currently, without doing any grid sequence, I compute >>>>> each, write it to disk, and then go on to the next one. So I now need to >>>>> go back an refine them. I was thinking that perhaps I could refine them >>>>> on the fly, dump them to disk, and use the coarse solution as the >>>>> starting guess at the next iteration, but that would seem to require >>>>> resetting the snes back to the coarse grid. >>>>> >>>>> The alternative would be to just script the mesh refinement in a post >>>>> processing stage, where each value of the continuation is parameter is >>>>> loaded on the coarse mesh, and refined. Perhaps that’s the most >>>>> practical thing to do. >>>> >>>> I would do the following. Create your DM and create a SNES that will do >>>> the continuation >>>> >>>> loop over continuation parameter >>>> >>>> SNESSolve(snes,NULL,Ucoarse); >>>> >>>> if (you decide you want to see the refined solution at this >>>> continuation point) { >>>> SNESCreate(comm,&snesrefine); >>>> SNESSetDM() >>>> etc >>>> SNESSetGridSequence(snesrefine,) >>>> SNESSolve(snesrefine,0,Ucoarse); >>>> SNESGetSolution(snesrefine,&Ufine); >>>> VecView(Ufine or do whatever you want to do with the Ufine at >>>> that continuation point >>>> SNESDestroy(snesrefine); >>>> end if >>>> >>>> end loop over continuation parameter. >>>> >>>> Barry >>>> >>>>> >>>>> -gideon >>>>> >>>>>> On Aug 28, 2015, at 3:55 PM, Barry Smith <[email protected]> wrote: >>>>>> >>>>>>> >>>>>>> >>>>>>> 3. This problem is actually part of a continuation problem that >>>>>>> roughly looks like this >>>>>>> >>>>>>> for( continuation parameter p = 0 to 1){ >>>>>>> >>>>>>> solve with parameter p_i using solution from p_{i-1}, >>>>>>> } >>>>>>> >>>>>>> What I would like to do is to start the solver, for each value of >>>>>>> parameter p_i on the coarse mesh, and then do grid sequencing on that. >>>>>>> But it appears that after doing grid sequencing on the initial p_0 = 0, >>>>>>> the SNES is set to use the finer mesh. >>>>>> >>>>>> So you are using continuation to give you a good enough initial guess on >>>>>> the coarse level to even get convergence on the coarse level? First I >>>>>> would check if you even need the continuation (or can you not even solve >>>>>> the coarse problem without it). >>>>>> >>>>>> If you do need the continuation then you will need to tweak how you do >>>>>> the grid sequencing. I think this will work: >>>>>> >>>>>> Do not use -snes_grid_sequencing >>>>>> >>>>>> Run SNESSolve() as many times as you want with your continuation >>>>>> parameter. This will all happen on the coarse mesh. >>>>>> >>>>>> Call SNESSetGridSequence() >>>>>> >>>>>> Then call SNESSolve() again and it will do one solve on the coarse level >>>>>> and then interpolate to the next level etc. >>> >> >
