  In this work we formally derive and prove the correctness of the algorithms
and data structures in a parallel, distributed-memory, generic finite element
framework that supports h-adaptivity on computational domains represented as
forest-of-trees. The framework is grounded on a rich representation of the
adaptive mesh suitable for generic finite elements that is built on top of a
low-level, light-weight forest-of-trees data structure handled by a
specialized, highly parallel adaptive meshing engine, for which we have
identified the requirements it must fulfill to be coupled into our framework.
Atop this two-layered mesh representation, we build the rest of data structures
required for the numerical integration and assembly of the discrete system of
linear equations. We consider algorithms that are suitable for both
subassembled and fully-assembled distributed data layouts of linear system
matrices. The proposed framework has been implemented within the FEMPAR
scientific software library, using p4est as a practical forest-of-octrees
demonstrator. A strong scaling study of this implementation when applied to
Poisson and Maxwell problems reveals remarkable scalability up to 32.2K CPU
cores and 482.2M degrees of freedom. Besides, a comparative performance study
of FEMPAR and the state-of-the-art deal.ii finite element software shows at
least comparative performance, and at most factor 2-3 improvements in the
h-adaptive approximation of a Poisson problem with first- and second-order
Lagrangian finite elements, respectively.
