A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
A FEniCS Tutorial - FEniCS Project
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
weak form has<br />
∫<br />
a(T,v) =<br />
∫<br />
L(v) =<br />
Ω<br />
Ω<br />
(̺cTv +θ∆tκ∇T ·∇v) dx, (84)<br />
(̺cT k−1 v −(1−θ)∆tκ∇T k−1 ·∇v ) dx. (85)<br />
Observe that boundary integrals vanish because of the Neumann boundary conditions.<br />
The size of a 3D box is taken as W × W × D, where D is the depth and<br />
W = D/2isthewidth. Wegivethedegreeofthebasisfunctionsatthecommand<br />
line, then D, and then the divisions of the domain in the various directions. To<br />
make a box, rectangle, or interval of arbitrary (not unit) size, we have the<br />
DOLFIN classes Box, Rectangle, and Interval at our disposal. The mesh and<br />
the function space can be created by the following code:<br />
degree = int(sys.argv[1])<br />
D = float(sys.argv[2])<br />
W = D/2.0<br />
divisions = [int(arg) for arg in sys.argv[3:]]<br />
d = len(divisions) # no of space dimensions<br />
if d == 1:<br />
mesh = Interval(divisions[0], -D, 0)<br />
elif d == 2:<br />
mesh = Rectangle(-W/2, -D, W/2, 0, divisions[0], divisions[1])<br />
elif d == 3:<br />
mesh = Box(-W/2, -W/2, -D, W/2, W/2, 0,<br />
divisions[0], divisions[1], divisions[2])<br />
V = FunctionSpace(mesh, ’Lagrange’, degree)<br />
The Rectangle and Box objects are defined by the coordinates of the ”minimum”<br />
and ”maximum” corners.<br />
Setting Dirichlet conditions at the upper boundary can be done by<br />
T_R = 0; T_A = 1.0; omega = 2*pi<br />
T_0 = Expression(’T_R + T_A*sin(omega*t)’,<br />
T_R=T_R, T_A=T_A, omega=omega, t=0.0)<br />
def surface(x, on_boundary):<br />
return on_boundary and abs(x[d-1]) < 1E-14<br />
bc = DirichletBC(V, T_0, surface)<br />
The κ function can be defined as a constant κ 1 inside the particular rectangular<br />
area with a special soil composition, as indicated in Figure 7. Outside<br />
this area κ is a constant κ 0 . The domain of the rectangular area is taken as<br />
[−W/4,W/4]×[−W/4,W/4]×[−D/2,−D/2+D/4]<br />
in 3D, with [−W/4,W/4]×[−D/2,−D/2+D/4] in 2D and [−D/2,−D/2+D/4]<br />
in 1D. Since we need some testing in the definition of the κ(x) function, the most<br />
68