20 
\item There must be no duplication of any geometric features whether they are 
\item There must be no duplication of any geometric features whether they are 
21 
points, lines, loops, surfaces or volumes. 
points, lines, loops, surfaces or volumes. 
22 
\item All objects with dimensions greater then a line have a normal defined by 
\item All objects with dimensions greater then a line have a normal defined by 
23 
the right hand rull (RHR). It is important to consider which direction a 
the right hand rule (RHR). It is important to consider which direction a 
24 
normal is oriented when combining primatives to form higher order shapes. 
normal is oriented when combining primitives to form higher order shapes. 
25 
\end{itemize} 
\end{itemize} 
26 


27 
The first step as always is to import the external modules. To build a 3D model 
The first step as always is to import the external modules. To build a 3D model 
28 
and mesh we will need pycad, some GMesh interfaces, the finley domain builder 
and mesh we will need pycad, some GMesh interfaces, the Finley domain builder 
29 
and some additional tools. 
and some additional tools. 
30 
\begin{python} 
\begin{python} 
31 
#######################################################EXTERNAL MODULES 
#######################################################EXTERNAL MODULES 
49 
intf=depth/2. #Depth of the interface. 
intf=depth/2. #Depth of the interface. 
50 
\end{python} 
\end{python} 
51 
We now start to specify the components of our model starting with the vertexes 
We now start to specify the components of our model starting with the vertexes 
52 
using the \verb!Point! primative. These are then joined by lines in a regular 
using the \verb!Point! primitive. These are then joined by lines in a regular 
53 
manner taking note of the right hand rule. Finally, the lines are turned into 
manner taking note of the right hand rule. Finally, the lines are turned into 
54 
loops and then planar surfaces. 
loops and then planar surfaces. 
55 
\footnote{Some code has been emmitted here for 
\footnote{Some code has been emmitted here for 
81 
linhe_ar.append(Line(ip3,ip0)) 
linhe_ar.append(Line(ip3,ip0)) 
82 
\end{python} 
\end{python} 
83 
Consider now the sides of the domain. One could specify the whole side using the 
Consider now the sides of the domain. One could specify the whole side using the 
84 
points first defined for the top and bottom layer. This would specify the whole 
points first defined for the top and bottom layer. This would define the whole 
85 
domain as one volume. However, there is an interface and we wish to define each 
domain as one volume. However, there is an interface and we wish to define each 
86 
layer individually. Therefore, there will be 8 surfaces on the sides of our 
layer individually. Therefore, there will be 8 surfaces on the sides of our 
87 
domain. We can do this operation quite simply using the points and lines that we 
domain. We can do this operation quite simply using the points and lines that we 
114 
#model=Volume(sloop) 
#model=Volume(sloop) 
115 
\end{python} 
\end{python} 
116 
The final steps are designing the mesh, tagging the volumes and the interface 
The final steps are designing the mesh, tagging the volumes and the interface 
117 
and outputting the data to file so it can be imported by an \esc sollution 
and outputting the data to file so it can be imported by an \esc solution 
118 
script. 
script. 
119 
\begin{python} 
\begin{python} 
120 
#############################################EXPORTING MESH FOR ESCRIPT 
#############################################EXPORTING MESH FOR ESCRIPT 
156 


157 
\section{Layer Cake Models} 
\section{Layer Cake Models} 
158 
Whilst this type of model seems simple enough to construct for two layers, 
Whilst this type of model seems simple enough to construct for two layers, 
159 
specifying multiple layers can become combersome. A function exists to generate 
specifying multiple layers can become cumbersome. A function exists to generate 
160 
layer cake models called \verb!layer_cake!. A detailed description of its 
layer cake models called \verb!layer_cake!. A detailed description of its 
161 
arguments and returns is available in the API and the function can be imported 
arguments and returns is available in the API and the function can be imported 
162 
from pycad. 
from the pycad.extras module. 
163 
\begin{python} 
\begin{python} 
164 
from esys.pycad import layer_cake 
from esys.pycad.extras import layer_cake 
165 
intfaces=[10,30,50,55,80,100,200,250,400,500] 
intfaces=[10,30,50,55,80,100,200,250,400,500] 
166 


167 
domaindes=Design(dim=3,element_size=element_size,order=2) 
domaindes=Design(dim=3,element_size=element_size,order=2) 
168 
cmplx_domain=layer_cake.LayerCake(domaindes,xwidth,ywidth,intfaces) 
cmplx_domain=layer_cake(domaindes,xwidth,ywidth,intfaces) 
169 
cmplx_domain.setScriptFileName(os.path.join(save_path,"example09lc.geo")) 
cmplx_domain.setScriptFileName(os.path.join(save_path,"example09lc.geo")) 
170 
cmplx_domain.setMeshFileName(os.path.join(save_path,"example09lc.msh")) 
cmplx_domain.setMeshFileName(os.path.join(save_path,"example09lc.msh")) 
171 
dcmplx=MakeDomain(cmplx_domain) 
dcmplx=MakeDomain(cmplx_domain) 
183 
\section{Troubleshooting Pycad} 
\section{Troubleshooting Pycad} 
184 
There are some techniques which can be useful when trying to troubleshoot 
There are some techniques which can be useful when trying to troubleshoot 
185 
problems with pycad. As mentioned earlier it is important to ensure the correct 
problems with pycad. As mentioned earlier it is important to ensure the correct 
186 
directionality of your primatives when constructing more complicated domains. If 
directionality of your primitives when constructing more complicated domains. If 
187 
one cannot establist the tangent of a line or curveloop, or the normal of a 
it remains too difficult to establish the tangent of a line or curveloop, or 
188 
surface. These values can be checked by importing the geometry to gmesh and 
the normal of a surface, these values can be checked by importing the geometry 
189 
applying the appropriate options. 
to gmesh and applying the appropriate visualisation options. 
190 


191 
\section{3D Seismic Wave Propagation} 
\section{3D Seismic Wave Propagation} 
192 
Adding an extra dimension to our wave equation solution script should be 
Adding an extra dimension to our wave equation solution script should be 
197 
\section{Applying a function to a domain tag} 
\section{Applying a function to a domain tag} 
198 
\sslist{example09b.py} 
\sslist{example09b.py} 
199 
To apply a function or data object to a domain requires a two step process. The 
To apply a function or data object to a domain requires a two step process. The 
200 
first step is to create a data object with a on/off mask based upon the tagged 
first step is to create a data object with an on/off mask based upon the tagged 
201 
value. This is quite simple and can be achieved by using a scalar data object 
value. This is quite simple and can be achieved by using a scalar data object 
202 
based upon the domain. In this case we are using the \verb!FunctionOnBoundary! 
based upon the domain. In this case we are using the \verb!FunctionOnBoundary! 
203 
function space because the tagged value \verb!'stop'! is effectively a specific 
function space because the tagged value \verb!'stop'! is effectively a specific 