next up previous contents index
Next: Alternative File Formats Up: The Module esys.pycad Previous: Holes   Contents   Index

A 3D example

In this section we discuss the definition of 3D geometries. The example is the unit cube, see Figure 5.3. First we generate the vertices of the cube:
\begin{python}
from esys.pycad import *
p0=Point(0.,0.,0.)
p1=Point(1.,0.,0.)
p2...
...(0.,0.,1.)
p5=Point(1.,0.,1.)
p6=Point(0.,1.,1.)
p7=Point(1.,1.,1.)
\end{python}
We connect the points to form the bottom and top surfaces of the cube:
\begin{python}
l01=Line(p0,p1)
l13=Line(p1,p3)
l32=Line(p3,p2)
l20=Line(p2,p0)
bottom=PlaneSurface(CurveLoop(l01,l13,l32,l20))
\end{python}
and
\begin{python}
l45=Line(p4,p5)
l57=Line(p5,p7)
l76=Line(p7,p6)
l64=Line(p6,p4)
top=PlaneSurface(CurveLoop(l45,l57,l76,l64))
\end{python}
To form the front face we introduce the two additional lines connecting the left and right front points of the the top and bottom face:
\begin{python}
l15=Line(p1,p5)
l40=Line(p4,p0)
\end{python}
To form the front face we encounter the problem as the line l45 used to define the top face is pointing the wrong direction. In esys.pycad you can reversing direction of an object by changing its sign. So we write -l45 to indicate that the direction is to be reversed. With this notation we can write
\begin{python}
front=PlaneSurface(CurveLoop(l01,l15,-l45,l40))
\end{python}
Keep in mind that if you use Line(p4,p5) instead -l45 both objects are treated as different although the connecting the same points with a straight line in the same direction. The resulting geometry would include an opening along the p4-p5 connection. This will lead to an inconsistent mesh and may result in a failure of the volumetric mesh generator. Similarly we can define the other sides of the cube:
\begin{python}
l37=Line(p3,p7)
l62=Line(p6,p2)
back=PlaneSurface(CurveLoop(l32,-...
...l40,-l64,l62,l20))
right=PlaneSurface(CurveLoop(-l15,l13,l37,-l57))
\end{python}
We can now put the six surfaces together to form a SurfaceLoop defining the boundary of the volume of the cube:
\begin{python}
sl=SurfaceLoop(top,-bottom,front,back,left,right)
v=Volume(sl)
\end{python}
Similar to the definition of a CurvedLoop the orientation of the surfaces SurfaceLoop is relevant. In fact the surface normal direction defined by the the right hand rule needs to point outwards as indicated by the surface normals in Figure 5.3. As the bottom face is directed upwards it is inserted with the minus sign into the SurfaceLoop in order to adjust the orientation of the surface.

As in the 2D case, the Design class is used to define the geometry:
\begin{python}
from esys.pycad.gmsh import Design
from esys.finley import MakeDo...
...nt, left , right)
\par
dom=MakeDomain(des)
dom.write(''brick.fly'')
\end{python}
Note that the esys.finley mesh file brick.fly will contain the triangles used to define the surfaces as they are added to the Design. The example script of the cube is included with the software in brick.py in the example directory.


next up previous contents index
Next: Alternative File Formats Up: The Module esys.pycad Previous: Holes   Contents   Index
esys@esscc.uq.edu.au