19.06.2015 Views

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

def T_exact(x):<br />

a = sqrt(omega*rho*c/(2*kappa_0))<br />

return T_R + T_A*numpy.exp(a*x)*numpy.sin(omega*t + a*x)<br />

The reader is encouraged to play around with the code and test out various<br />

parameter sets:<br />

1. T R = 0, T A = 1, κ 0 = κ 1 = 0.2, ̺ = c = 1, ω = 2π<br />

2. T R = 0, T A = 1, κ 0 = 0.2, κ 1 = 0.01, ̺ = c = 1, ω = 2π<br />

3. T R = 0, T A = 1, κ 0 = 0.2, κ 1 = 0.001, ̺ = c = 1, ω = 2π<br />

4. T R = 10 C, T A = 10 C, κ 0 = 2.3 K −1 Ns −1 , κ 1 = 100 K −1 Ns −1 , ̺ =<br />

1500 kg/m 3 , c = 1480 Nmkg −1 K −1 , ω = 2π/24 1/h = 7.27 · 10 −5 1/s,<br />

D = 1.5 m<br />

5. As above, but κ 0 = 12.3 K −1 Ns −1 and κ 1 = 10 4 K −1 Ns −1<br />

Data set number 4 is relevant for real temperature variations in the ground<br />

(not necessarily the large value of κ 1 ), while data set number 5 exaggerates the<br />

effect of a large heat conduction contrast so that it becomes clearly visible in<br />

an animation.<br />

4 Creating More Complex Domains<br />

Up to now we have been very fond of the unit square as domain, which is an<br />

appropriate choice for initial versions of a PDE solver. The strength of the finite<br />

element method, however, is its ease of handling domains with complex shapes.<br />

This section shows some methods that can be used to create different types of<br />

domains and meshes.<br />

Domains of complex shape must normally be constructed in separate preprocessor<br />

programs. Two relevant preprocessors are Triangle for 2D domains<br />

and NETGEN for 3D domains.<br />

4.1 Built-In Mesh Generation Tools<br />

DOLFIN has a few tools for creating various types of meshes over domains with<br />

simple shape: UnitInterval, UnitSquare, UnitCube, Interval, Rectangle,<br />

Box, UnitCircle, and UnitSphere. Some of these names have been briefly<br />

met in previous sections. The hopefully self-explanatory code snippet below<br />

summarizes typical constructions of meshes with the aid of these tools:<br />

# 1D domains<br />

mesh = UnitInterval(20) # 20 cells, 21 vertices<br />

mesh = Interval(20, -1, 1) # domain [-1,1]<br />

# 2D domains (6x10 divisions, 120 cells, 77 vertices)<br />

mesh = UnitSquare(6, 10) # ’right’ diagonal is default<br />

71

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!