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.
x, flux_x_exact, ’b-’,<br />
legend=(’numerical (projected) flux’, ’exact flux’),<br />
title=’Flux in x-direction (at y=%g)’ % y_fixed,<br />
savefig=’flux.eps’)<br />
AsseenfromFigure1.12b, thenumericalfluxisaccurateexceptintheboundary<br />
elements.<br />
Thevisualizationconstructionsshownaboveandusedtogeneratethefigures<br />
are found in the program vcp2D.py in the stationary/poisson directory.<br />
It should be easy with the information above to transform a finite element<br />
field over a uniform rectangular or box-shaped mesh to the corresponding<br />
BoxField object and perform MATLAB-style visualizations of the whole field<br />
or the field over planes or along lines through the domain. By the transformation<br />
to a regular grid we have some more flexibility than what Viper offers.<br />
However, we remark that comprehensive tools like VisIt, MayaVi2, or ParaView<br />
also have the possibility for plotting fields along lines and extracting planes in<br />
3D geometries, though usually with less degree of control compared to Gnuplot,<br />
MATLAB, and Matplotlib. For example, in investigations of numerical<br />
accuracy or numerical artifacts one is often interested in studying curve plots<br />
where only the nodal values sampled. This is straightforward with a structured<br />
mesh data structure, but more difficult in visualization packages utilizing unstructured<br />
grids, as hitting exactly then nodes when sampling a function along<br />
a line through the grid might be non-trivial.<br />
1.13 Combining Dirichlet and Neumann Conditions<br />
Let us make a slight extension of our two-dimensional Poisson problem from<br />
Section 1.1 and add a Neumann boundary condition. The domain is still the<br />
unit square, but now we set the Dirichlet condition u = u 0 at the left and right<br />
sides, x = 0 and x = 1, while the Neumann condition<br />
− ∂u<br />
∂n = g<br />
is applied to the remaining sides y = 0 and y = 1. The Neumann condition is<br />
alsoknownasanatural boundary condition (incontrasttoanessentialboundary<br />
condition).<br />
Let Γ D and Γ N denote the parts of ∂Ω where the Dirichlet and Neumann<br />
conditions apply, respectively. The complete boundary-value problem can be<br />
written as<br />
−∇ 2 u = f in Ω, (30)<br />
u = u 0 on Γ D , (31)<br />
− ∂u<br />
∂n = g on Γ N . (32)<br />
Again we choose u = 1+x 2 +2y 2 as the exact solution and adjust f, g, and u 0<br />
38