← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] merge

 

[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. 

Johan


Follow ups

References