This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Defining a Domain

0 votes

Hello
I ran the simple code related to Poisson equation. In this code, the domain has been defined between 0 and 1 for both x and y.

from dolfin import *
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, "Lagrange", 1)
u = Function(V)
v = TestFunction(V)
f = Constant(-6.0)
g = Expression("1 + x[0]x[0] + 2x[1]x[1]")
bc = DirichletBC(V, g, DomainBoundary())
F = inner(grad(u), grad(v))
dx - fvdx
solve(F == 0, u, bc)
plot(u, interactive=True)

The question is how I can define a different domain? For example x=[0,3] and y=[0,5]. Thanks in advance for your help.

asked Oct 22, 2015 by jafar FEniCS Novice (670 points)

1 Answer

0 votes
 
Best answer

Use e.g. RectangleMesh(Point(0,0), Point(3,5), 20, 20)

In general, you might want to generate your own mesh using, for example, gmsh.

answered Oct 22, 2015 by chris_richardson FEniCS Expert (31,740 points)
selected Oct 23, 2015 by chris_richardson

Chris
Thank you. It worked.

...