19.06.2015 Views

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

A FEniCS Tutorial - FEniCS Project

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

# The diagonals can be right, left or crossed<br />

mesh = UnitSquare(6, 10, ’left’)<br />

mesh = UnitSquare(6, 10, ’crossed’)<br />

# Domain [0,3]x[0,2] with 6x10 divisions and left diagonals<br />

mesh = Rectangle(0, 0, 3, 2, 6, 10, ’left’)<br />

# 6x10x5 boxes in the unit cube, each box gets 6 tetrahedra:<br />

mesh = UnitCube(6, 10, 5)<br />

# Domain [-1,1]x[-1,0]x[-1,2] with 6x10x5 divisions<br />

mesh = Box(-1, -1, -1, 1, 0, 2, 6, 10, 5)<br />

# 10 divisions in radial directions<br />

mesh = UnitCircle(10)<br />

mesh = UnitSphere(10)<br />

4.2 Transforming Mesh Coordinates<br />

A mesh that is denser toward a boundary is often desired to increase accuracy in<br />

that region. Given a mesh with uniformly spaced coordinates x 0 ,...,x M−1 in<br />

[a,b], the coordinate transformation ξ = (x−a)/(b−a) maps x onto ξ ∈ [0,1]. A<br />

new mapping η = ξ s , for some s > 1, stretches the mesh toward ξ = 0 (x = a),<br />

while η = ξ 1/s makes a stretching toward ξ = 1 (x = b). Mapping the η ∈ [0,1]<br />

coordinates back to [a,b] gives new, stretched x coordinates,<br />

( ) s x−a<br />

¯x = a+(b−a)<br />

(86)<br />

b−a<br />

toward x = a, or<br />

¯x = a+(b−a)<br />

( ) 1/s x−a<br />

(87)<br />

b−a<br />

toward x = b<br />

One way of creating more complex geometries is to transform the vertex<br />

coordinates in a rectangular mesh according to some formula. Say we want to<br />

create a part of a hollow cylinder of Θ degrees, with inner radius a and outer<br />

radius b. A standard mapping from polar coordinates to Cartesian coordinates<br />

can be used to generate the hollow cylinder. Given a rectangle in (¯x,ȳ) space<br />

such that a ≤ ¯x ≤ b and 0 ≤ ȳ ≤ 1, the mapping<br />

ˆx = ¯xcos(Θȳ), ŷ = ¯xsin(Θȳ),<br />

takes a point in the rectangular (¯x,ȳ) geometry and maps it to a point (ˆx,ŷ) in<br />

a hollow cylinder.<br />

The corresponding Python code for first stretching the mesh and then mapping<br />

it onto a hollow cylinder looks as follows:<br />

72

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

Saved successfully!

Ooh no, something went wrong!