← Back to team overview

dolfin team mailing list archive

Re: uBLASKrylovMatrix and Python callbacks: now the fun begins

 

On Tue, Apr 14, 2009 at 03:34:08PM +0200, Johan Hake wrote:
> On Tuesday 14 April 2009 04:38:15 Robert Kirby wrote:
> > Trilinos does this via the ParameterList class in Teuchos.  They have an
> > XML format that can be parsed.
> > Sundance uses this feature extensively to define solvers from the various
> > Trilinos packages.
> 
> I havn't worked with the ParameterList, but I have worked with a similare type 
> in Python, called ParameterDict, which is based on the python dict. The 
> ParameterList actually works more or less as a dict in PyTrilinos. 
> 
> A nice feature with both of these is that you can define nested parameters, 
> which would be nice to have for the next iteration of DolfinParameters.

What is nested parameters? Is it similar to what we already have
(hierarchical parametrization) or is it something different?

> I have also found it instructive to let my solvers, or applications "have" a 
> ParameterList instead of "beeing", i.e, by inheritance. All my applications 
> and/or solvers objects also have a default_params() function, which returns a 
> predefined set of parameters. This object knows what parameters it have and 
> complains if one tries to set parameters which are not predefined. It can do 
> all sorts of type and range checking too, the first not so usefull in c++, 
> but in Python. 
> 
> An application often consist of many objects which all defines their own 
> parameters. With the nested feature mentioned above we can collect all these 
> into a nested parameter dict for all of the included objects.
> 
> The built in parameters in dolfin could be defined either as a nested 
> ParameterList type of object:
> 
>   ParameterList ODE_params("fixed time step",false,
>                            "ODE solve dual problem", false,...);
>   ParameterList Krylov_params(...);
>   ParameterList Newton_params(...);
>   
>   ParameterList dolfin_params("ODE",ODE_params,
>                               "Krylov",Krylov_params,
>                               "Newton",Newton_params);
> 
> then one can:
> 
>   dolfin_params["ODE"]["fixed time step"]
> 
> or just:
> 
>   ODE_params["fixed time step"]
> 
> This is quite straight forward to do in Python but not _so_ easy to do in c++. 
> It is probably not worth the effort of making it possible to state such a 
> ParameterList in the constructor, especially not from c++, but it is quite 
> convinient.

So it's something like having namespaces for parameters? 

That would be useful. We have this already in some way, but it's done
manually:

  "ODE fixed time step"
  "Krylov relative tolerance"

One simple option could be to add an optional argument to the
constructor of Parametrized which can be used to set a
prefix/namespace.

For example, the ODE class could send in "ODE" to the constructor and
"ODE " would be prepended to all its parameters:

  dolfin_set("ODE tolerance", 0.1);

  ode.set("tolerance", 0.1);

Would that be enough?

-- 
Anders

Attachment: signature.asc
Description: Digital signature


References