The assembler converts the PDE problem into a linear algebraic system by evaluating all the integrals of test/ansatz functions multiplied with the derivatives of \( f \) and \( g \) and scattering the results into a large sparse matrix.
The class VariationalFunctionalAssembler implements this, and is parametrized with the variational functional class defining the PDE and the involved FE spaces.
using Assembler = VariationalFunctionalAssembler<LinearizationAt<Functional>>;
Assembler assembler(spaces);
For assembly, we may choose between any combination of functional value (d0), right hand side (d1), and stiffness matrix (d2) to be assembled - value of course only if the problem is a variational functional and not a weak formulation.
assembler.assemble(linearization(F,u),
Assembler::MATRIX|Assembler::RHS|Assembler::VALUE);
After assembly, the right hand side and stiffness matrix can be extracted as a sparse matrix, or the assembler directly provided for the construction of a more abstract wrapper class such as a DirectInverseOperator.
auto M = assembler.get<SparseMatrix>();
AssembledGalerkinOperator<Assembler> A(assembler);
auto Ainv = directInverseOperator(A);
To access single subblocks on a certain position of the stiffness matrix, use
auto M = assembler.get<row,col>();
for obtaining the subblock at position row,col as sparse matrix (e.g. NumaBCRSMatrix). For access to subblocks in a certain half-open range [rbegin,rend), [cbegin,cend), use
auto M = assembler.get<SparseMatrix>(bool,rbegin,rend,cbegin,cend);
where bool=true extracts only the lower triangular part and can be used if the matrix is symmetric.
For parabolic equations, the mass matrix has to be assembled in addition to the stiffness matrix. This is done in b2 cache and processed with help of the ParabolicEquation interface. Assembly then follows the same procedures as for the elliptic equations and the combined mass and stiffness matrix can be accessed in the same ways.