# Obtaining local sparsity pattern from form and/or *_integral

Registered by Garth Wells

Obtaining local sparsity pattern from form and/or *_integral. The sparsity pattern of a form can be the combined sparsity patterns of the integrals, i.e. a worst-case-scenario, while letting each integral have its own pattern may yield a more optimized pattern with multiple integrals over subdomains. Possible signatures to add in form and/or *_integral:

/// Return the number of nonzeros in an element tensor
virtual uint num_nonzeros() const;

/// Return the number of nonzeros in an element tensor
virtual void tabulate_sparsity_pattern(uint ** pattern) const

// Explanation: Either we define (pattern[0][i], pattern[1][i])
// to hold the row and col of nonzero number i,
// or (pattern[i][0], pattern[i][1]). We could also use a single
// pointer uint*pattern, the choice depends on how it will be
// natural to use.

## Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
Discussion
Series goal:
None
Implementation:
Unknown
Milestone target:
None

### Whiteboard

JH:
This Blueprint might be outdated, but I think the ideas presented here can be useful for a Blueprint on reducing the memory footprint in the

method in DOLFIN during assemble. See corresponding Blueprint in DOLFIN

The important here is to provide a way to know the dofs which are non zero in an integral.

/// Return the number of nonzeros in an element tensor for a given rank
virtual uint num_nonzeros(uint rank ) const;

/// Return the number of nonzeros in an element tensor for a given rank
virtual void tabulate_sparsity_pattern(uint rank, uint * pattern) const

These values can then be used to reduce the size of the tabulated tensor before