← Back to team overview

dolfin team mailing list archive

Re: [HG] Remove add("solver", "direct") from the constructors of PDE.

 

On Fri, Feb 17, 2006 at 08:03:14PM +0100, Garth N. Wells wrote:
> On Fri, 2006-02-17 at 12:48 -0600, Anders Logg wrote:
> > Alternatively, the solver type can be set by
> > 
> >     pde.set("solver", "direct");
> > 
> > That way, only the solver type for the PDE in question will be
> > affected (not the global choice).
> > 
> 
> Sure, this would be better I wasn't thinking straight when I did this
> and had some spurious idea in my head why this wasn't possible. 
> 
> Also, I think that I'm suffering from some amnesia wrt the parameter
> system - is the parameter "solver", set by
> 
> 	pde.set("solver", "direct");
> 
> local to pde, and
> 
> 	set("solver", "direct");
> 
> global?
> 
> Garth

:-)

Yes, if you set the value of a parameter on some object (which must be
of a subclass of Parametrized, which is the case for PDE objects)
using the member function ::set(), then that value will override the
global value, but only locally for the object.

So it's hierarchical: first the local value, then the global value.

You can also build more complicated hierarchies (trees). For example,
if a PDE object is used internally in a solver (like PoissonSolver),
one can do

    PoissonSolver solver(...);
    solver.set("key", value);

to set the parameters for any objects below solver in the hierarchy 
(if solver is a parent to these objects in the hierarchy).

To build a hierarchy, do

     Foo foo;
     Bar bar;

     bar.set("parent", foo);

This means that bar will look for parameters in foo if they are not
defined locally in bar. foo will consults its local database and if
the parameter is not set locally there, it will ask its parent and so
on back to the global database.

Check in src/test/main.cpp for a demo.

/Anders



References