22
edits
(→Mixed Formulation for Poisson Equation: Adapt the example to the ufl paradigm) |
|||
Line 162: | Line 162: | ||
=== Mixed Formulation for Poisson Equation === | === Mixed Formulation for Poisson Equation === | ||
In this example the Poisson equation is solved with a '''mixed approach''': the stable FE space obtained using Brezzi-Douglas-Marini polynomial of order 1 and | In this example the Poisson equation is solved with a '''mixed approach''': the stable FE space obtained using Brezzi-Douglas-Marini polynomial of order 1 and Dicontinuos element of order 0 is used. | ||
<math>-\mathrm{div}\ ( \mathbf{\sigma} (x, y) ) ) = f (x, y) \qquad \mbox{ in } \Omega</math> | <math>-\mathrm{div}\ ( \mathbf{\sigma} (x, y) ) ) = f (x, y) \qquad \mbox{ in } \Omega</math> | ||
Line 172: | Line 172: | ||
<math>(\sigma (x, y) ) \cdot \mathbf{n} = \sin (5x) \qquad \mbox{ on } \Gamma_N</math> | <math>(\sigma (x, y) ) \cdot \mathbf{n} = \sin (5x) \qquad \mbox{ on } \Gamma_N</math> | ||
A complete description of the problem is | A complete description of the problem is avilable on the [http://fenicsproject.org/documentation/dolfin/1.2.0/python/demo/pde/mixed-poisson/python/documentation.html Fenics website.] | ||
<div style="width: 100%;"> | <div style="width: 100%;"> | ||
<div style="float:left; width: 48%"> | <div style="float:left; width: 48%"> | ||
{{Code|Define MixedPoisson problem with fem-fenics|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Define MixedPoisson problem with fem-fenics|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
pkg load fem-fenics msh | pkg load fem-fenics msh | ||
import_ufl_Problem ('MixedPoisson') | |||
# Create mesh | # Create mesh | ||
Line 199: | Line 183: | ||
mesh = Mesh(msh2m_structured_mesh (x, y, 1, 1:4)); | mesh = Mesh(msh2m_structured_mesh (x, y, 1, 1:4)); | ||
# ufl | # File MixedPoisson.ufl | ||
# BDM = FiniteElement("BDM", triangle, 1) | # BDM = FiniteElement("BDM", triangle, 1) | ||
# DG = FiniteElement("DG", triangle, 0) | # DG = FiniteElement("DG", triangle, 0) | ||
Line 206: | Line 190: | ||
# Define trial and test function | # Define trial and test function | ||
# ufl | # File MixedPoisson.ufl | ||
# (sigma, u) = TrialFunctions(W) | # (sigma, u) = TrialFunctions(W) | ||
# (tau, v) = TestFunctions(W) | # (tau, v) = TestFunctions(W) | ||
Line 215: | Line 199: | ||
# Define variational form | # Define variational form | ||
# ufl | # File MixedPoisson.ufl | ||
# a = (dot(sigma, tau) + div(tau)*u + div(sigma)*v)*dx | # a = (dot(sigma, tau) + div(tau)*u + div(sigma)*v)*dx | ||
# L = - f*v*dx | # L = - f*v*dx | ||
Line 261: | Line 245: | ||
{{Code|Define MixedPoisson problem with fenics python|<syntaxhighlight lang="python" style="font-size:13px"> | {{Code|Define MixedPoisson problem with fenics python|<syntaxhighlight lang="python" style="font-size:13px"> | ||
from dolfin import * | from dolfin import * | ||
# Create mesh | # Create mesh | ||
mesh = UnitSquareMesh(32, 32) | mesh = UnitSquareMesh(32, 32) | ||
Line 293: | Line 260: | ||
(sigma, u) = TrialFunctions(W) | (sigma, u) = TrialFunctions(W) | ||
(tau, v) = TestFunctions(W) | (tau, v) = TestFunctions(W) | ||
edits