← Back to team overview

dolfin team mailing list archive

Re: reset_tensor in assemble

 

On on., 2009-09-02 at 10:40 +0200, Anders Logg wrote:
> On Wed, Sep 02, 2009 at 10:18:10AM +0200, Kent Andre wrote:
> > On on., 2009-09-02 at 08:58 +0200, Anders Logg wrote:
> > > On Wed, Sep 02, 2009 at 08:45:55AM +0200, Kent Andre wrote:
> > > > On ti., 2009-09-01 at 17:59 +0100, Garth N. Wells wrote:
> > > > >
> > > > > Kent Andre wrote:
> > > > > > On ti., 2009-09-01 at 17:16 +0100, Garth N. Wells wrote:
> > > > > >> Kent Andre wrote:
> > > > > >>> Hi,
> > > > > >>> A.zero() is called both when reset_tensor is true and false
> > > > > >>> in Assembler::init_global_tensor.
> > > > > >>>
> > > > > >>> The code is as follows:
> > > > > >>>
> > > > > >>> void Assembler::init_global_tensor(GenericTensor& A,
> > > > > >>>                                    const Form& a,
> > > > > >>>                                    UFC& ufc, bool reset_tensor)
> > > > > >>> {
> > > > > >>>   if (reset_tensor)
> > > > > >>>   {
> > > > > >>>     ...
> > > > > >>>   }
> > > > > >>>   else
> > > > > >>>     A.zero();
> > > > > >>> }
> > > > > >>>
> > > > > >>> Is this on purpose or is it a bug ?
> > > > > >> The code is correct. 'A.zero()' zeroes the entries but preserves the
> > > > > >> non-zero structure of the matrix.
> > > > > >>
> > > > > >> Garth
> > > > > >>
> > > > > >
> > > > > > Then maybe reset_sparsity_pattern is a better name ?
> > > > > >
> > > > >
> > > > > We could extend the assembler interface to
> > > > >
> > > > >    assemble(GenericTensor& A, const Form& a,
> > > > >             bool reset_tensor_sparsity=true, bool add_values=false);
> > > > >
> > > > > I'm not a big fan of booleans though because they make no sense to the
> > > > > reader in the calling code, e,g. what does
> > > > >
> > > > >    assemble(A, a, true, true);
> > > > >
> > > > > mean? We could use the parameter system instead.
> > > > >
> > > > > Garth
> > > > >
> > > >
> > > >
> > > > Does it matter if it is booleans ?
> > > >
> > > > Calling the assemble function, the way I want would be:
> > > >
> > > > E = assemble(mass, D, None, None, None, None, None, True, False)
> > > 
> > > If you're doing this in Python, then you could drop all the Nones and
> > > just do
> > > 
> > >   E = assemble(mass, D, add_values=False)
> > > 
> > > But what is D?
> > 
> > Yes, sorry about the mix of C++ and Python. D is a tensor. 
> > 
> > > 
> > > Also, does it make sense to reset the sparsity pattern when not
> > > zeroing the matrix? Resetting the sparsity pattern requires erasing
> > > the values.
> > 
> > I guess the matrix must be zeroed if the sparsity pattern is earased. 
> 
> Yes, there needs to be a check for this and a warning if the options
> are set in a conflicting way.
> 

OK, so the old parameter 'reset_tensor' is renamed to
'reset_tensor_sparsity' and a new parameter 'add_values' is introduced. 

An error is raised if the user wants to remove the sparsity pattern 
and add the values. 

Kent





Follow ups

References