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.
y<br />
✻<br />
u = 1<br />
Ω 1<br />
∂u<br />
∂n = 0<br />
∂u<br />
∂n = 0<br />
Ω 0<br />
u = 0<br />
✲<br />
x<br />
Figure9: SketchofaPoissonproblemwithavariablecoefficientthatisconstant<br />
in each of the two subdomains Ω 0 and Ω 1 .<br />
interpretation is flow in porous media with two geological layers, where the<br />
layers’ ability to transport the fluid differs by a factor of 10.<br />
5.2 Implementation<br />
The new functionality in this subsection regards how to define the subdomains<br />
Ω 0 and Ω 1 . For this purpose we need to use subclasses of class SubDomain, not<br />
only plain functions as we have used so far for specifying boundaries. Consider<br />
the boundary function<br />
def boundary(x, on_boundary):<br />
tol = 1E-14<br />
return on_boundary and abs(x[0]) < tol<br />
fordefiningtheboundaryx = 0. Insteadofusingsuchastand-alonefunction,we<br />
can create an instance (or object) of a subclass of SubDomain, which implements<br />
the inside method as an alternative to the boundary function:<br />
class Boundary(SubDomain):<br />
def inside(self, x, on_boundary):<br />
tol = 1E-14<br />
return on_boundary and abs(x[0]) < tol<br />
boundary = Boundary()<br />
bc = DirichletBC(V, Constant(0), boundary)<br />
A word about computer science terminology may be used here: The term instance<br />
meansaPythonobjectofaparticulartype(suchasSubDomain,Function<br />
75