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

From ONELAB
Jump to: navigation, search
(Created page with "== The considered problem == In this problem, we consider a Laplace equation, as in that example, except...")
 
Line 1: Line 1:
 
== The considered problem ==
 
== The considered problem ==
  
In this problem, we consider a Laplace equation, as in [[Academic example: Laplace equation with Neumann boundary condition | that example]], except that the boundary condition is here of Dirichlet type. To model this in GetDP, we will introduce a "Constraint".
+
In this problem, we consider a Laplace equation, as in [[Academic example: Laplace equation with Neumann boundary condition | that example]], except that the boundary condition is here of Dirichlet type. To model this in GetDP, we will introduce a "Constraint". We assume that the reader has already study the previous example.
  
 
As in [[Academic example: Laplace equation with Neumann boundary condition | the example with a Neumann boundary condition]], we considered the unit square $\Omega = [0,1]\times[0,1]$ and the unknown function $u$ solves the following problem
 
As in [[Academic example: Laplace equation with Neumann boundary condition | the example with a Neumann boundary condition]], we considered the unit square $\Omega = [0,1]\times[0,1]$ and the unknown function $u$ solves the following problem
Line 26: Line 26:
 
\end{equation}
 
\end{equation}
 
where the functions $v$ are the ''test functions'' and $H^1_0(\Omega) = \left\{ v \in H^1(\Omega) \text{ such that } v|_{\Gamma} = 0\right\}$.
 
where the functions $v$ are the ''test functions'' and $H^1_0(\Omega) = \left\{ v \in H^1(\Omega) \text{ such that } v|_{\Gamma} = 0\right\}$.
 +
 +
== Outline of the program ==
 +
 +
The proposed solution is composed by 3 different files:
 +
; param.geo
 +
: this (auxiliary) file contains the index number associated with the geometry.
 +
; LaplacianNeumann.geo 
 +
: GMSH file, used to build both the square $\Omega$ and its boundary $\Gamma$. Except for the building of $\Gamma$, this file is the same as in [[Academic example: Laplace equation with Neumann boundary condition | the previous example]].
 +
; LaplacianNeumann.pro 
 +
: GetDP file, contains the weak formulation \eqref{eq:WeakFormulation} of the problem \eqref{eq:problemU}.

Revision as of 15:01, 22 September 2011

The considered problem

In this problem, we consider a Laplace equation, as in that example, except that the boundary condition is here of Dirichlet type. To model this in GetDP, we will introduce a "Constraint". We assume that the reader has already study the previous example.

As in the example with a Neumann boundary condition, we considered the unit square $\Omega = [0,1]\times[0,1]$ and the unknown function $u$ solves the following problem \begin{equation} \begin{cases}\label{eq:problemU} \Delta u + u = f & \text{in } \Omega,\\ \displaystyle{u = 0} & \text{on }\Gamma, \end{cases} \end{equation} where $\Gamma = \partial\Omega$ is the boundary of $\Omega$ and $\displaystyle{\Delta = \frac{\partial^2}{\partial x_1^2} + \frac{\partial^2}{\partial x_2^2} }$ is the Laplacian operator. To simplify, we suppose that 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). $$ As a consequence, the unique solution $u$ of the problem \eqref{eq:problemU} is clearly given by $$ \forall (x,y)\in [0,1]^2, \qquad u(x,y) = \cos(\pi x)\cos(\pi y). $$ In order to solve problem \eqref{eq:problemU} with the finite elements method, we write the weak formulation of problem \eqref{eq:problemU}: \begin{equation}\label{eq:WeakFormulation} \left\{\begin{array}{l} \text{Find } u\in H^1_0(\Omega) \text{ such that, }\\ \displaystyle{\forall v\in H^1_0(\Omega), \qquad \int_{\Omega} \nabla u\cdot\nabla v \;{\rm d}\Omega + \int_{\Omega}uv \;{\rm d}\Omega = 0}, \end{array}\right. \end{equation} where the functions $v$ are the test functions and $H^1_0(\Omega) = \left\{ v \in H^1(\Omega) \text{ such that } v|_{\Gamma} = 0\right\}$.

Outline of the program

The proposed solution is composed by 3 different files:

param.geo
this (auxiliary) file contains the index number associated with the geometry.
LaplacianNeumann.geo
GMSH file, used to build both the square $\Omega$ and its boundary $\Gamma$. Except for the building of $\Gamma$, this file is the same as in the previous example.
LaplacianNeumann.pro
GetDP file, contains the weak formulation \eqref{eq:WeakFormulation} of the problem \eqref{eq:problemU}.