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

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-

/// 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_

// 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

- Started by

- Completed by

### Related branches

### Related bugs

### Sprints

### 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

GenericTensor

method in DOLFIN during assemble. See corresponding Blueprint in DOLFIN

https:/

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_

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

GenericTensor

is called. The cost of copying the values from a tabulated tensor (and from the dofmap) to a reduced version is much less than the extra time it takes to shuffle zeros around to the underlying linear algebra backend. This is a fairly non invasive way (nothing done to dof_map, or tabulate_tensor) of reducing the time spent in GenericTensor::add.