← Back to team overview

dolfin team mailing list archive

Re: reset_tensor in assemble

 



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)


The problem I have with this is that it's completely meaningless without looking carefully at the where function assembler is declared. DOLFIN is strong in terms of code readability and the above breaks that. Python is nice because you can used named arguments (with the added advantage of the order of the arguments then being unimportant), but C++ is ugly.

Boost provides some support for named arguments

http://www.boost.org/doc/libs/1_39_0/libs/parameter/doc/html/index.html

It would be nice to have

  assembler(A, a);
  assembler(A, a, reset_sparsity_pattern=true);
  assembler(A, a, reset_sparsity_pattern=true, add_tensor=true);
  assembler(A, a, add_tensor=false, reset_sparsity_pattern=true);


I don't know how well it would play SWIG/Python.

Anyway, if it is ok, I update the assemble functions with both reset_tensor_sparsity and add_values.

Go ahead.

Garth

Kent

Kent








References