Difference between revisions of "Tutorial/Laplace equation with Neumann boundary condition"

From ONELAB
Jump to: navigation, search
(The problem)
(The considered problem)
Line 8: Line 8:
 
\end{cases}
 
\end{cases}
 
\end{equation}
 
\end{equation}
where $\Omega$ is the unit square, $\partial\Omega$ its boundary and $f$ the two-variables function defined by
+
where the function $f$ is defined by
 
$$
 
$$
\forall x,y\in [0,1]^2,\qquad f(x,y) = (1+2\pi^2)\cos(\pi x)\cos(\pi y)
+
\forall x,y\in [0,1]^2,\qquad f(x,y) = (1+2\pi^2)\cos(\pi x)\cos(\pi y).
 
$$
 
$$
Then, the unique solution of problem \eqref{eq:problemU} is
+
One can easily shows that the unique solution of the problem \eqref{eq:problemU} is
 
$$
 
$$
 
\forall x,y\in[0,1]^2, \qquad u(x,y) = \cos(\pi x)\cos(\pi y).
 
\forall x,y\in[0,1]^2, \qquad u(x,y) = \cos(\pi x)\cos(\pi y).
 
$$
 
$$
If $H^1(\Omega)$ denotes the usual Sobolev space, then the variationnal formulation of problem \eqref{eq:problemU} reads
+
To solve problem \eqref{eq:problemU} using a the finite elements method, we write the weak formulation of the probleme \eqref{eq:problemU}, which reads as
 
\begin{equation}\label{eq:WeakFormulation}
 
\begin{equation}\label{eq:WeakFormulation}
 
\left\{\begin{array}{l}
 
\left\{\begin{array}{l}
 
\text{Find } u\in H^1(\Omega) \text{ such that, }\\
 
\text{Find } u\in H^1(\Omega) \text{ such that, }\\
\displaystyle{\forall v\in H^1(\Omega), \qquad \int_{\Omega} \nabla u\cdot\nabla v \;{\rm d}\Omega + \int_{\Omega}uv \;{\rm d}\Omega - \int_{\Omega}fv\;{\rm d}\Omega = 0}.
+
\displaystyle{\forall v\in H^1(\Omega), \qquad \int_{\Omega} \nabla u\cdot\nabla v \;{\rm d}\Omega + \int_{\Omega}uv \;{\rm d}\Omega - \int_{\Omega}fv\;{\rm d}\Omega = 0},
 
\end{array}\right.
 
\end{array}\right.
 
\end{equation}
 
\end{equation}
 +
where $H^1(\Omega)$ is the classical Sobolev space.
  
 
== Outline of the program ==
 
== Outline of the program ==

Revision as of 11:24, 1 September 2011

The considered problem

We propose here to solve a first very simple academic example with GMSH and GetDP. We considered the unit square $\Omega$ with boundary $\Gamma$ and unit outward normal $\mathbf{n}$. We seek $u$, solution of the following problem \begin{equation} \begin{cases}\label{eq:problemU} \Delta u + u = f & \text{in } \Omega\\ \displaystyle{\frac{\partial u}{\partial \mathbf{n}} = 0} & \text{on }\Gamma, \end{cases} \end{equation} where the function $f$ is defined by $$ \forall x,y\in [0,1]^2,\qquad f(x,y) = (1+2\pi^2)\cos(\pi x)\cos(\pi y). $$ One can easily shows that the unique solution of the problem \eqref{eq:problemU} is $$ \forall x,y\in[0,1]^2, \qquad u(x,y) = \cos(\pi x)\cos(\pi y). $$ To solve problem \eqref{eq:problemU} using a the finite elements method, we write the weak formulation of the probleme \eqref{eq:problemU}, which reads as \begin{equation}\label{eq:WeakFormulation} \left\{\begin{array}{l} \text{Find } u\in H^1(\Omega) \text{ such that, }\\ \displaystyle{\forall v\in H^1(\Omega), \qquad \int_{\Omega} \nabla u\cdot\nabla v \;{\rm d}\Omega + \int_{\Omega}uv \;{\rm d}\Omega - \int_{\Omega}fv\;{\rm d}\Omega = 0}, \end{array}\right. \end{equation} where $H^1(\Omega)$ is the classical Sobolev space.

Outline of the program

We give here a (very) detailled solution. We proposed to construct 3 different files. The two principles are : - LaplacianSquare.geo : GMSH file, used to build the domain (the square). The extension ".geo" is mainly used to design a GMSH file - LaplacianSquare.pro : GetDP file, contains the weak formulation \eqref{eq:WeakFormulation} of the problem \eqref{eq:problemU}. The extension ".pro" is associated with GetDP files.

The last file, "data.geo", contains the index number associated with the geometry. It can be usefull to be sure that GMSH and GetDP have the same numbering of the domains.


param.geo: the auxiliary file

LaplacianSquare.geo: creation of the geometry with GMSH

LaplacianSquare.pro: weak formulation