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.

dt = period/20 # 20 time steps per period<br />

theta = 1<br />

T = TrialFunction(V)<br />

v = TestFunction(V)<br />

f = Constant(0)<br />

a = rho*c*T*v*dx + theta*dt*kappa*\<br />

inner(nabla_grad(T), nabla_grad(v))*dx<br />

L = (rho*c*T_prev*v + dt*f*v -<br />

(1-theta)*dt*kappa*inner(nabla_grad(T), nabla_grad(v)))*dx<br />

A = assemble(a)<br />

b = None # variable used for memory savings in assemble calls<br />

T = Function(V) # unknown at the current time level<br />

We could, alternatively, breakaandLup in subexpressions and assemble a mass<br />

matrix and stiffness matrix, as exemplified in Section 3.3, to avoid assembly of b<br />

at every time level. This modification is straightforward and left as an exercise.<br />

The speed-up can be significant in 3D problems.<br />

The time loop is very similar to what we have displayed in Section 3.2:<br />

T = Function(V) # unknown at the current time level<br />

t = dt<br />

while t

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

Saved successfully!

Ooh no, something went wrong!