Anders Logg wrote:
> On Thu, Sep 25, 2008 at 05:20:53PM +0200, Anders Logg wrote:
>> On Thu, Sep 25, 2008 at 04:18:23PM +0100, Garth N. Wells wrote:
>>>
>>> Anders Logg wrote:
>>>> On Thu, Sep 25, 2008 at 03:53:01PM +0100, Garth N. Wells wrote:
>>>>> Anders Logg wrote:
>>>>>> On Thu, Sep 25, 2008 at 03:11:27PM +0100, Garth N. Wells wrote:
>>>>>>> Anders Logg wrote:
>>>>>>>> On Thu, Sep 25, 2008 at 12:41:33PM +0100, Garth N. Wells wrote:
>>>>>>>>> Nuno David Lopes wrote:
>>>>>>>>>> Is there a simple way of setting an initial guess for an Iterative 
>>>>>>>>>> LinearSolver? 
>>>>>>>>>> In Umfpack and PETSc the default initial guess is the zero vector 
>>>>>>>>>> right?
>>>>>>>>> At the moment, yes (note the UMFPACK is an LU solver, so an initial 
>>>>>>>>> guess doesn't do anything).
>>>>>>>>>
>>>>>>>>> It's very simple, and I've been meaning to add an option for using an 
>>>>>>>>> initial guess. It's also useful for Newton solvers. I'll add 
>>>>>>>>> something 
>>>>>>>>> in the next few days.
>>>>>>>>>
>>>>>>>>> Garth
>>>>>>>> It would be natural to let the x argument always be the initial
>>>>>>>> guess. I thought we already did this.
>>>>>>>>
>>>>>>>> Would it be enough to make sure that Vector::init() does not reset the
>>>>>>>> values to zero?
>>>>>>>>
>>>>>>> Yes.
>>>>>>>
>>>>>>> The danger is if someone sends an uninitialised vector to the solver.
>>>>>>>
>>>>>>> Garth
>>>>>> We can just put something like this in the init() functions:
>>>>>>
>>>>>>   if (x && size() == N)
>>>>>>     return;
>>>>>>
>>>>>> I think we had this a while back but at some point VecZeroEntries was
>>>>>> inserted.
>>>>>>
>>>>> I think that we should have an option whether or not to use an initial 
>>>>> guess. The default can be to use the guess (as in your above code 
>>>>> extract).
>>>>>
>>>>> Garth
>>>> I think it would work nicely if the solver calls x.init() and that
>>>> will initialize x to a zero vector only if it has not already been
>>>> initialized. 
>>> Sounds a bit dangerous to me that Vector::init() sometimes zeroes a the 
>>> vector, and sometimes it doesn't. Should we get rid of Vector::init() 
>>> and use Vector::resize() and Vector::zero() instead? No ambiguity then.
>>>
>>> Garth
>> That sounds good.
> 
> On second thought, we shouldn't mess with the init() functions unless
> we want to change the meaning of init() for all the classes deriving
> from GenericTensor, including also matrices for all backends. Also,
> resize() sometimes means that existing values will be preserved when
> the size is increased.
>

I've already started on it. There are a lot of places in the code where 
we only need to resize and not zero, so I like using resize() and 
zero(). We even had places with

    x.init(N);
    x.zero();

There is no ambiguity now with resize and zero.


> So the best solution is to do something like
> 
>   if (x.size() != N)
>     x.init();
> 

This is what I've done.

Garth

> in the Krylov solvers instead of just init().
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> DOLFIN-dev mailing list
> [email protected]
> http://www.fenics.org/mailman/listinfo/dolfin-dev


_______________________________________________
DOLFIN-dev mailing list
[email protected]
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to