Here's a somewhat radical proposal: move all calls to PetscOptionsGetXXX() to XXXSetUp(). At the time of XXXSetUp() all of the nested objects are create or can be create, if they are not. XXXSetFromOptions() will only set a flag for XXX to look in the options database at setup time. This should help PCFieldSplit, for example. What is the need for having the intermediate state where the object is "set-from-options" but "not-yet-setup"? So that XXXView() can report the options before the data structures are built?
On Fri, Nov 22, 2013 at 5:36 PM, Jed Brown <[email protected]> wrote: > Barry Smith <[email protected]> writes: > > >> Indeed, but I thought we wanted to avoid this because it can lead to > >> options being checked on each iteration > > > > No, no, and no. Look in mg.c > > > > if (!pc->setupcalled) { > > for (i=0; i<n; i++) { > > ierr = KSPSetFromOptions(mglevels[i]->smoothd);CHKERRQ(ierr); > > In gamg.c: > > PetscBool redo_mesh_setup = (PetscBool)(!pc_gamg->reuse_prol); > > if (redo_mesh_setup) { > /* reset everything */ > ierr = PCReset_MG(pc);CHKERRQ(ierr); > pc->setupcalled = 0; > > The number of levels can change because the strength of connection and > thus thresholding changes. > > > You are correct that currently there are other unprotected calls in > > fieldsplit.c but I think they can be easily fixed so that the inner > > SetFromOptions() is called only when setup called is zero. Having > > non-nested XXXSetFromOptions() has nothing to do with things being > > check every iteration stuff. > > Fair enough, the case above is a different issue and I agree that your > other points are at the very least, pragmatic. > -- Dmitry Karpeev Mathematics and Computer Science Argonne National Laboratory Argonne, Illinois, USA and Computation Institute University of Chicago 5735 S. Ellis Avenue Chicago, IL 60637 ----------------------- Phone: 630-252-1229 Fax: 630-252-5986
