Suppose we have the scalar advection equation with compressible velocity $\vec{v}$:
$$ \frac{du}{dt} + \nabla \cdot( \vec{v} u ) = 0 $$
in some domain $\Omega$.
Using the group finite element formulation with $\phi$ representing the basis functions such that
$$ u = \sum_j u_j \phi_j $$
and
$$ (\vec{v} u)_h = \sum_j u_j ( \vec{v}_j \cdot \nabla \phi_j ) $$
we can write the semi-discrete form of the advection equation as follows:
$$\sum_j \left( \int_{\Omega} \phi_i \phi_j dx \right) \frac{du_j}{dt} = - \sum_j \vec{v}_j \cdot \left( \int_{\Omega}\phi_i \nabla \phi_j dx \right) u_j $$
My question is this: is there a way to construct the discrete gradient defined by
$$ \vec{c}_{ij} = \left( \int_{\Omega}\phi_i \nabla \phi_j dx \right) $$
as a set of PETScMatrices (for each spatial variable) to be used for computing the discrete transport operator in the PDE above? This is to avoid reassembly of the gradient mainly since the velocity will be changing in time in my problem.