22
edits
m (→Known issues: Added 14.04 as tested Ubuntu version.) |
(→Poisson Equation: Edited to show the ufl.m usage) |
||
Line 33: | Line 33: | ||
{{Code|Define Poisson problem with fem-fenics|<syntaxhighlight lang="octave" style="font-size:13px"> | {{Code|Define Poisson problem with fem-fenics|<syntaxhighlight lang="octave" style="font-size:13px"> | ||
pkg load fem-fenics msh | pkg load fem-fenics msh | ||
ufl start Poisson | |||
ufl element = FiniteElement("Lagrange", triangle, 1) | |||
ufl | |||
ufl u = TrialFunction(element) | |||
ufl v = TestFunction(element) | |||
ufl f = Coefficient(element) | |||
ufl g = Coefficient(element) | |||
ufl | |||
ufl a = inner(grad(u), grad(v))*dx | |||
ufl L = f*v*dx + g*v*ds | |||
ufl end | |||
# Create mesh and define function space | # Create mesh and define function space | ||
Line 39: | Line 50: | ||
mesh = Mesh(msh2m_structured_mesh (x, y, 1, 1:4)); | mesh = Mesh(msh2m_structured_mesh (x, y, 1, 1:4)); | ||
V = FunctionSpace('Poisson', mesh); | V = FunctionSpace('Poisson', mesh); | ||
Line 52: | Line 61: | ||
# Define variational problem | # Define variational problem | ||
# | # Operation performed in the ufl snippet above | ||
# u = TrialFunction(element) | # u = TrialFunction(element) | ||
# v = TestFunction(element) | # v = TestFunction(element) | ||
Line 62: | Line 71: | ||
g = Expression ('g', @(x,y) sin (5.0 * x)); | g = Expression ('g', @(x,y) sin (5.0 * x)); | ||
# | # As in the ufl snippet above | ||
# a = inner(grad(u), grad(v))*dx | # a = inner(grad(u), grad(v))*dx | ||
# L = f*v*dx + g*v*ds | # L = f*v*dx + g*v*ds | ||
Line 88: | Line 97: | ||
{{Code|Define Poisson problem with fenics python|<syntaxhighlight lang="python" style="font-size:13px"> | {{Code|Define Poisson problem with fenics python|<syntaxhighlight lang="python" style="font-size:13px"> | ||
from dolfin import * | from dolfin import * | ||
Line 93: | Line 113: | ||
mesh = UnitSquareMesh(32, 32) | mesh = UnitSquareMesh(32, 32) | ||
V = FunctionSpace(mesh, "Lagrange", 1) | V = FunctionSpace(mesh, "Lagrange", 1) |
edits