\chapter{Complete UFC code for Poisson's equation}
\index{Poisson's equation}
\index{example code}

In this section, a simple example is given of UFC code generated by
the form compilers
FFC~\cite{www:ffc,logg:article:07,logg:article:09,logg:article:10,logg:article:11}
and SyFi~\cite{www:syfi} for Poisson's equation. The code presented
below is generated for the bilinear form of Poisson's equation for
standard continuous piecewise linear Lagrange finite elements on a
two-dimensional domain $\Omega$,
\begin{equation}
  a(v, u) = \int_{\Omega} \nabla v \cdot \nabla u \dx.
\end{equation}

Although FFC and SyFi are two different form compilers, with very
different approaches to code generation, both generate code that
conforms to the UFC specification and may thus be used interchangeably
within any UFC-based system.

In the generated code, we have omitted the two functions
\texttt{evaluate\_basis} and
\texttt{evaluate\_basis\_derivatives}\footnotemark{} to save space.

\footnotetext{For FFC, this may be done by using the compiler flags
  \texttt{-fno-evaluate\_basis} and
  \texttt{-fno-evaluate\_basis\_derivatives}.}

\section{Code generated by FFC}
\index{FFC}

\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/poisson_ffc.h}
\normalsize

\section{Code generated by SyFi}
\index{SyFi}

In the following we list the complete code for the finite element,
the dofmap and the variational form for computing a stiffness matrix
based on linear Lagrangian elements in 2D.

The code below is generated for the assembler in PyCC and it therefore
includes some PyCC files, since the option \texttt{SFC.options.include\_from = "pycc"} was used during the code generation. If PyCC is not present, the option \texttt{SFC.options.include\_from = "syfi"} can be used, and this will result in some additional files that define the numbering scheme.

\subsection{Header file for linear Lagrange element in 2D}

\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/stiffness_syfi/fe_Lagrange_1_2D.h}
\normalsize

\subsection{Source file for linear Lagrange element in 2D}
\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/stiffness_syfi/fe_Lagrange_1_2D.cpp}
\normalsize

\subsection{Header file for the dofmap}
\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/stiffness_syfi/dof_map_Lagrange_1_2D.h}
\normalsize

\subsection{Source file for the dofmap}
\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/stiffness_syfi/dof_map_Lagrange_1_2D.cpp}
\normalsize

\subsection{Header file for the stiffness matrix form}
\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/stiffness_syfi/form__stiffness_form__Lagrange_1_2D.h}
\normalsize


\subsection{Source file for the stiffness matrix form}
\scriptsize
\VerbatimInput[frame=single,rulecolor=\color{blue}]{code/stiffness_syfi/form__stiffness_form__Lagrange_1_2D.cpp}
\normalsize
