⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quickstart.tex

📁 finite element library for mathematic majored research
💻 TEX
字号:
\chapter{Quickstart}\index{quickstart}This chapter demonstrates how to get started with \ffc{}, includingdownloading and installing the latest version of \ffc{}, and compilingPoisson's equation. These topics are discussed in more detailelsewhere in this manual. In particular, seeAppendix~\ref{app:installation} for detailed installation instructionsand Chapter~\ref{sec:formlanguage} for a detailed discussion of theform language.%------------------------------------------------------------------------------\section{Downloading and installing \ffc{}}\index{downloading}\index{installation}The latest version of \ffc{} can be found on the \fenics{} web page:\begin{code}http://www.fenics.org/\end{code}The following commands illustrate the installation process, assumingthat you have downloaded release \texttt{x.y.z} of \ffc{}:\begin{code}# tar zxfv ffc-x.y.z.tar.gz# cd ffc-x.y.z# sudo python setup.py install\end{code}Make sure that you download the latest release.You may also need to install the Python packages \fiat{} andNumPy. (See Appendix~\ref{app:installation} for detailed instructions.)\index{FIAT}\index{Numeric}%------------------------------------------------------------------------------\section{Compiling Poisson's equation with \ffc{}}\index{Poisson's equation}The discrete variational (finite element) formulation of Poisson'sequation, $-\Delta u = f$, reads: Find $u_h \in V_h$ such that\begin{equation} \label{eq:varform}  a(v, u_h) = L(v) \quad \forall v\in \hat{V}_h, \end{equation}with $(\hat{V}_h, V_h)$ a pair of suitable function spaces (the test andtrial spaces). The bilinear form $a : \hat{V}_h \times V_h \rightarrow\R$ is given by\begin{equation}  a(v, u_h) = \int_{\Omega} \nabla v \cdot \nabla u_h \dx\end{equation}and the linear form $L : \hat{V}_h \rightarrow \R$ is given by\begin{equation}  L(v) = \int_{\Omega} v \, f \dx.\end{equation}To compile the pair of forms $(a, L)$ into code that can called toassemble the linear system $A x = b$ corresponding to the variationalproblem (\ref{eq:varform}) for a pair of discrete function spaces,specify the forms in a text file with extension \texttt{.form},e.g. \texttt{Poisson.form}, as follows:\begin{code}element = FiniteElement("Lagrange", "triangle", 1)v = TestFunction(element)u = TrialFunction(element)f = Function(element)  a = dot(grad(v), grad(u))*dxL = v*f*dx\end{code}The example is given for piecewise linear finite elements in twodimensions, but other choices are available, including arbitrary orderLagrange elements in two and three dimensions.To compile the pair of forms implemented in the file\texttt{Poisson.form}, call the compiler on the command-line asfollows:\begin{code}# ffc Poisson.form\end{code}This will generate the file \texttt{Poisson.h} containing low levelC++ code in the UFC (Unified Form-assembly Code)format~\cite{www:ufc,ufcmanual}. The generated code can be used byany UFC-based assembler such as \dolfin{}~\cite{www:dolfin} toassemble the discrete representations (the matrix~$A$ and vector~$b$)of the bilinear form $a$ and linear form~$L$ of Poisson's equation.Note that by adding the flag \texttt{-l dolfin}, additional\dolfin{}-specific wrappers are added to the generated code whichsimplifies the use of the generated code with \dolfin{}. Inparticular, the handling of forms depending on coefficients like $f$in Poisson's equation is simplified.For further help on the \texttt{ffc} command and availablecommand-line options, refer to the \ffc{} man page:\begin{code}# man ffc\end{code}\index{ffc}\index{man page}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -