← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] merge

 

On Thu, Jul 02, 2009 at 04:26:04PM +0200, Johan Hake wrote:
> [snip]
> 
> > > I think we should add new parameter set by reference and not by value.
> > > Then we should be able to populate the childs default parameters with the
> > > parameters of the parents. Something like this:
> > >
> > >   p.add(NewtonSolver::parameters);
> > >   p.add(LUSolver::parameters);
> > >   p.add(KrylovSolver::parameters);
> > >
> > > (Is this the correct syntax?)
> > >
> > > The add by reference also makes it possible for a user to collect all
> > > parameters used in an application into a single parameter set. This set
> > > can then be used to update all parameters in the application.
> >
> > I began doing this, but I got into difficulties. Consider the
> > following example. A user writes:
> >
> >  VariationalProblem problem(a, L, bc);
> >  problem.parameters["newton_solver"]("relative_tolerance") = 1e-16;
> >
> > For this to work the nested parameter set for the Newton solver must e
> > created already in the constructor of VariationalProblem. But at this
> > time, the NewtonSolver has not been created. It gets created later
> > when the user calls solve().
> >
> > I didn't see an easy way around this.
> 
> One could add a construtor taking a parameter set and using this as the 
> default parameter instead? Might be more messy.
> 
> I was more thinking about inherited classes for example:
> 
> class Base
> {
>   Base(){
>     parameters = default_parameters();
>   }
>   ...
> };
> 
> class Derived : public Base
> {
>   derived():base(){Base
>     parameters = default_parameters();
>     paramerers.add(Base::parameters)
>   }
>   ...
> };
> 
> I suppose it would work if we pass the parameter set to add() by reference. 

I don't think we have this case anywhere in the code. What we have is
nested parameter sets for completely unrelated classes, except that
one of them is using the other.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


References