# High-Order Diffusion with MFEM + Ginkgo Solves $-\nabla \cdot (\kappa \nabla u) = 1$ with a spatially varying coefficient $\kappa(x) = 1 + x_0^2$ using quartic ($p=4$) finite elements. Shows two integration approaches: manual CSR wrapping and MFEM's built-in Ginkgo interface. ## Integration Overview High-order elements produce denser matrix rows (more non-zeros per row), making solver and preconditioner choice more impactful. This example demonstrates both integration paths: 1. **Manual CSR wrapping** — full control over Ginkgo's solver factory, preconditioner, and stopping criteria 2. **MFEM built-in** (requires `MFEM_USE_GINKGO=ON`) — simpler but less configurable ## Step-by-Step ### Variable Coefficient ```{literalinclude} high_order.cpp :language: cpp :start-after: [variable-coefficient] :end-before: [/variable-coefficient] ``` ### Assembly with High-Order Elements The only change from linear elements is `order = 4` in the `H1_FECollection`. The assembled matrix is larger and denser. ```{literalinclude} high_order.cpp :language: cpp :start-after: [assemble-high-order] :end-before: [/assemble-high-order] ``` ### Approach 1: Manual Ginkgo CSR Wrapping ```{literalinclude} high_order.cpp :language: cpp :start-after: [manual-ginkgo-solve] :end-before: [/manual-ginkgo-solve] ``` ### Approach 2: MFEM Built-in Ginkgo Interface ```{literalinclude} high_order.cpp :language: cpp :start-after: [builtin-ginkgo-solve] :end-before: [/builtin-ginkgo-solve] ``` ## Building ```bash cmake -S . -B build --preset default cmake --build build ./build/high_order -o 4 -r 3 ``` ## Expected Output ```text Options used: --order 4 --refine 2 Order: 4 Elements: 1024 DOFs: 16641 System: 16641 x 16641, nnz: 591361 (avg nnz/row: 35) Solving with manual Ginkgo CSR wrapping... Converged. Output written to solution.gf and mesh.mesh ```