/[escript]/trunk/doc/user/escript.tex
ViewVC logotype

Annotation of /trunk/doc/user/escript.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 117 - (hide annotations)
Fri Apr 1 05:48:57 2005 UTC (14 years ago) by jgs
Original Path: trunk/esys2/doc/user/escript.tex
File MIME type: application/x-tex
File size: 41311 byte(s)
*** empty log message ***

1 jgs 107
2 jgs 82 % $Id$
3    
4     \chapter{The module \escript}
5    
6 jgs 102 \declaremodule{extension}{escript}
7     \modulesynopsis{Data manipulation}
8 jgs 82
9 jgs 102 \begin{figure}
10     \includegraphics[width=\textwidth]{EscriptDiagram1.eps}
11     \caption{\label{ESCRIPT DEP}Dependency of Function Spaces. An arrow indicates that a function in the
12     function space at the starting point can be interpreted as a function in the function space of the arrow target.}
13     \end{figure}
14 jgs 82
15 jgs 102 \escript is an extension of Python to handle functions represented by their values on
16 jgs 107 \DataSamplePoints for the geometrical region on which
17 jgs 102 the function is defined. The region as well as the method which is used
18     to interpolate value on the \DataSamplePoints is defined by
19     \Domain class objects. For instance when using
20     the finite element method (FEM) \index{finite element method}
21     \Domain object holds the information about the FEM mesh, eg.
22     a table of nodes and a table of elements. Although \Domain contains
23     the discretization method to be used \escript does not use this information directly.
24     \Domain objects are created from a module which want to make use
25     \escript, e.g. \finley.
26 jgs 82
27 jgs 102 The solution of a PDE is a function of its location in the domain of interest $\Omega$.
28     When solving a partial differential equation \index{partial differential equation} (PDE) using FEM
29     the solution is (piecewise) differentiable but, in general, its gradient
30     is discontinuous. To reflect these different degrees of smoothness different
31     representations of the functions are used. For instance; in FEM
32     the displacement field is represented by its values at the nodes of the mesh, while the
33     strain, which is the symmetric part of the gradient of the displacement field, is stored on the
34     element centers. To be able to classify functions with respect to their smoothness, \escript has the
35     concept of the "function space". A function space is described by a \FunctionSpace object.
36     The following statement generates the object \var{solution_space} which is
37     a \FunctionSpace object and provides access to the function space of
38     PDE solutions on the \Domain \var{mydomain}:
39     \begin{python}
40     solution_space=Solution(mydomain)
41     \end{python}
42 jgs 107 The following generators for function spaces on a \Domain \var{mydomain} are available:
43 jgs 102 \begin{itemize}
44     \item \var{Solution(mydomain)}: solutions of a PDE.
45     \item \var{ContinuousFunction(mydomain)}: continuous functions, eg. a temperature distribution.
46     \item \var{Function(mydomain)}: general functions which are not necessarily continuous, eg. a stress field.
47     \item \var{FunctionOnBoundary(mydomain)}: functions on the boundary of the domain, eg. a surface pressure.
48     \item \var{FunctionOnContact0(mydomain)}: functions on side $0$ of the discontinuity.
49     \item \var{FunctionOnContact1(mydomain)}: functions on side $1$ of the discontinuity.
50     \end{itemize}
51     A discontinuity \index{discontinuity} is a region within the domain across which functions may be discontinuous.
52     The location of discontinuity is defined in the \Domain object.
53     \fig{ESCRIPT DEP} shows the dependency between the types of function spaces.
54     The solution of a PDE is a continuous function. Any continuous function can be seen as a general function
55     on the domain and can be restricted to the boundary as well as to any side of the
56     discontinuity (the result will be different depending on
57     which side is chosen). Functions on any side of the
58     discontinuity can be seen as a function on the corresponding other side.
59     A function on the boundary or on one side of
60     the discontinuity cannot be seen as a general function on the domain as there are no values
61     defined for the interior. For most PDE solver libraries
62     the space of the solution and continuous functions is identical, however in some cases, eg.
63     when periodic boundary conditions are used in \finley, a solution
64     fulfils periodic boundary conditions while a continuous function does not have to be periodic.
65    
66     The concept of function spaces describes the properties of
67     functions and allows abstraction from the actual representation
68     of the function in the context of a particular application. For instance,
69     in the FEM context a
70     function in the \Function function space
71     is typically represented by its values at the element center,
72     but in a finite difference scheme the edge midpoint of cells is preferred.
73     Using the concept of function spaces
74     allows the user to run the same script on different
75     PDE solver libraries by just changing the creator of the \Domain object.
76     Changing the function space of a particular function
77     will typically lead to a change of its representation.
78     So, when seen as a general function,
79     a continuous function which is typically represented by its values
80     on the node of the FEM mesh or finite difference grid
81 jgs 107 must be interpolated to the element centers or the cell edges,
82 jgs 102 respectively.
83 jgs 82
84 jgs 102 \Data class objects store functions of the location in a domain.
85     The function is represented through its values on \DataSamplePoints where
86     the \DataSamplePoints are chosen according to the function space
87     of the function.
88     \Data class objects are used to define the coefficients
89     of the PDEs to be solved by a PDE solver library
90     and to store the returned solutions.
91 jgs 82
92 jgs 102 The values of the function have a rank which gives the
93 jgs 107 number of indices, and a \Shape defining the range of each index.
94 jgs 102 The rank in \escript is limited to the range $0$ through $4$ and
95     it is assumed that the rank and \Shape is the same for all \DataSamplePoints.
96     The \Shape of a \Data object is a tuple \var{s} of integers. The length
97     of \var{s} is the rank of the \Data object and \var{s[i]} is the maximum
98     value for the \var{i}-th index.
99     For instance, a stress field has rank $2$ and
100     \Shape $(d,d)$ where $d$ is the spatial dimension.
101     The following statement creates the \Data object
102     \var{mydat} representing a
103     continuous function with values
104     of \Shape $(2,3)$ and rank $2$:
105     \begin{python}
106     mydat=Data(value=1,what=ContinuousFunction(myDomain),shape=(2,3))
107     \end{python}
108     The initial value is the constant $1$ for all \DataSamplePoints and
109     all components.
110 jgs 82
111 jgs 102 \Data objects can also be created from any \numarray
112     array or any object, such as a list of floating point numbers,
113     that can be converted into a \numarray array \Ref{NUMARRAY}.
114     The following two statements
115     create objects which are equivalent to \var{mydat}:
116     \begin{python}
117     mydat1=Data(value=numarray.ones((2,3)),what=ContinuousFunction(myDomain))
118     mydat2=Data(value=[[1,1],[1,1],[1,1]],what=ContinuousFunction(myDomain))
119     \end{python}
120     In the first case the initial value is \var{numarray.ones((2,3))}
121     which generates a $2 \times 3$ matrix as a \numarray array
122     filled with ones. The \Shape of the created \Data object
123     it taken from the \Shape of the array. In the second
124     case, the creator converts the initial value, which is a list of lists,
125 jgs 107 and converts it into a \numarray array before creating the actual
126 jgs 102 \Data object.
127 jgs 82
128 jgs 102 For convenience \escript provides creators for the most common types
129     of \Data objects in the following forms (\var{d} defines the
130     spatial dimension):
131     \begin{itemize}
132     \item \var{Scalar(0,Function(mydomain))} is the same as \var{Data(0,Function(myDomain),(,))},
133     e.g a temperature field.
134     \item \var{Vector(0,Function(mydomain))}is the same as \var{Data(0,Function(myDomain),(d))}, e.g
135     a velocity field.
136     \item \var{Tensor(0,Function(mydomain))} is the same as \var{Data(0,Function(myDomain),(d,d))},
137     eg. a stress field.
138     \item \var{Tensor4(0,Function(mydomain))} is the same as \var{Data(0,Function(myDomain),(d,d,d,d))}
139     eg. a Hook tensor field.
140     \end{itemize}
141     Here the initial value is $0$ but any object that can be converted into a \numarray array and whose \Shape
142     is consistent with \Shape of the \Data object to be created can be used as the initial value.
143 jgs 82
144 jgs 102 \Data objects can be manipulated by applying unitary operations (eg. cos, sin, log)
145 jgs 107 and can be combined by applying binary operations (eg. +, - ,* , /).
146     It is to be emphasized that \escript itself does not handle any spatial dependencies as
147 jgs 102 it does not know how values are interpreted by the processing PDE solver library.
148     However \escript invokes interpolation if this is needed during data manipulations.
149     Typically, this occurs in binary operation when both arguments belong to different
150     function spaces or when data are handed over to a PDE solver library
151     which requires functions to be represented in a particular way.
152 jgs 82
153 jgs 102 The following example shows the usage of {\tt Data} objects: Assume we have a
154     displacement field $u$ and we want to calculate the corresponding stress field
155     $\sigma$ using the linear--elastic isotropic material model
156     \begin{eqnarray}\label{eq: linear elastic stress}
157     \sigma\hackscore {ij}=\lambda u\hackscore {k,k} \delta\hackscore {ij} + \mu ( u\hackscore {i,j} + u\hackscore {j,i})
158     \end{eqnarray}
159     where $\delta\hackscore {ij}$ is the Kronecker symbol and
160     $\lambda$ and $\mu$ are the Lame coefficients. The following function
161     takes the displacement {\tt u} and the Lame coefficients
162     \var{lam} and \var{mu} as arguments and returns the corresponding stress:
163     \begin{python}
164     import numarray
165     def getStress(u,lam,mu):
166     d=u.getDomain().getDim()
167     g=grad(u)
168     stress=lam*trace(g)*numarray.identity(d)+ \
169     mu*(g+transpose(g))
170     return stress
171     \end{python}
172     The variable
173     \var{d} gives the spatial dimension of the
174     domain on which the displacements are defined.
175     \var{identity} is a \numarray function which returns the Kronecker symbol with indexes
176     $i$ and $j$ running from $0$ to \var{d}-1. The call \var{grad(u)} requires
177     the displacement field \var{u} to be in the \var{Solution} or \ContinuousFunction
178     function space. The result \var{g} as well as the returned stress will be in the \Function function space.
179     If \var{u} is available, eg. by solving a PDE, \var{getStress} might be called
180     in the following way:
181     \begin{python}
182     s=getStress(u,1.,2.)
183     \end{python}
184     However \var{getStress} can also be called with \Data objects as values for
185     \var{lam} and \var{mu} which,
186     for instance in the case of a temperature dependency, are calculated by an expression.
187     The following call is equivalent to the previous example:
188     \begin{python}
189     lam=Scalar(1.,ContinuousFunction(mydomain))
190     mu=Scalar(2.,Function(mydomain))
191     s=getStress(u,lam,mu)
192     \end{python}
193     The function \var{lam} belongs to the \ContinuousFunction function space
194     but with \var{g} the function \var{trace(g)} is in the \Function function space.
195     Therefore the evaluation of the product \var{lam*trace(g)} in the stress calculation
196     produces a problem, as both functions are represented differently, eg. in FEM
197     \var{lam} by its values on the node, and in \var{trace(g)} by its values at the element centers.
198     In the case of inconsistent function spaces of arguments in a binary operation, \escript
199     interprets the arguments in the appropriate function space according to the inclusion
200     defined in Table~\ref{ESCRIPT DEP}. In this example that means
201     \escript sees \var{lam} as a function of the \Function function space.
202     In the context of FEM this means the nodal values of
203     \var{lam} are interpolated to the element centers. Behind the scenes
204     \escript calls the appropriate function from the PDE solver library.
205 jgs 82
206 jgs 102 \begin{figure}
207     \includegraphics[width=\textwidth]{EscriptDiagram2.eps}
208     \caption{\label{Figure: tag}Element Tagging. A rectangular mesh over a region with two rock types {\it white} and {\it gray}.
209     The number in each cell refers to the major rock type present in the cell ($1$ for {\it white} and $2$ for {\it gray}).
210     }
211     \end{figure}
212 jgs 82
213 jgs 102 Material parameters such as the Lame coefficients are typically dependent on rock types present in the
214     area of interest. A common technique to handle these kinds of material parameters is "tagging". \fig{Figure: tag}
215     shows an example. In this case two rock types {\it white} and {\it gray} can be found in the domain. The domain
216     is subdivided into rectangular shaped cells (which is not necessarily the best subdivision for this case). Each
217     cell has a tag indicating the rock type predominately found in this cell. Here $1$ is used to indicate
218     rock type {\it white} and $2$ for rock type {\it gray}. The tags are assigned at the time when the cells are generated
219     (\escript provides tools to manipulate tags at a later stage)
220     and stored in the \Domain class object. The following statements show how for the
221     example of \fig{Figure: tag} and the stress calculation discussed before tagged values are used for
222     \var{lam}:
223     \begin{python}
224     lam=Scalar(value=2.,what=Function(mydomain))
225     lam.setTaggedValue(1,30.)
226     lam.setTaggedValue(2,5000.)
227     s=getStress(u,lam,2.)
228     \end{python}
229     In this example \var{lam} is set to $30$ for those cells with tag $1$ and to $5000.$ for those cells
230     with tag $2$. The initial value $2$ of \var{lam} is used as a default value for the case when a tag
231     is encountered which has not been linked with a value. Note that the \var{getStress} method
232     is called without modification. \escript resolves the tags when \var{lam*trace(g)} is calculated.
233 jgs 82
234 jgs 102 The \Data class provides a transparent interface to various data representations and the
235     translations between them. As shown in the example of stress calculation, this allows the user to
236     develop and test algorithms for a simple case (for instance with the Lame coefficients as constants)
237     and then without further modifications of the program code to apply the algorithm in a
238     more complex application (for instance a definition of the Lame coefficients using tags).
239     As described here, there are three ways in which \Data objects are represented internally, constant, tagged, and expanded (other representions will become available in later versions of \escript):
240     In the constant case, if the same value is used at each sample point a single value is stored to save memory and compute time.
241     Any operation on this constant data will only be performed on the single value.
242     In the expanded case, each sample point has an individual value, eg. the solution of a PDE,
243     and the values are stored as a complete array. The tagged case has already been discussed above.
244    
245     Values are accessed through a sample reference number. Operations on expanded \Data
246     objects have to be performed for each sample point individually. If tagged values are used values are
247     held in a dictionary. Operations on tagged data require processing the set of tagged values only, rather than
248     processing the value for each individual sample point.
249     \escript allows use of constant, tagged and expanded data in a single expression.
250 jgs 82
251    
252 jgs 102
253     \section{\Domain class}
254    
255     \begin{classdesc}{Domain}{}
256 jgs 107 A \Domain object is used to describe a geometrical region together with
257 jgs 102 a way of representing functions over this region.
258     The \Domain class provides an abstract access to the domain of \FunctionSpace and \Data objects.
259     \Domain itself has no initialization but implementations of \Domain are
260     instantiated by numerical libraries making use of \Data objects.
261 jgs 82 \end{classdesc}
262    
263 jgs 102 \begin{methoddesc}[Domain]{getDim}{}
264     returns the spatial dimension of the \Domain.
265     \end{methoddesc}
266    
267     \begin{methoddesc}[Domain]{getX}{}
268     returns the locations in the \Domain. The \FunctionSpace of the returned
269     \Data object is chosen by the \Domain implementation. Typically it will be
270     in the \Function.
271     \end{methoddesc}
272    
273     \begin{methoddesc}[Domain]{setX}{newX}
274     assigns a new location to the \Domain. \var{newX} has to have \Shape $(d,)$
275     where $d$ is the spatial dimension of the domain. Typically \var{newX} must be
276     in the \ContinuousFunction but the space actually to be used depends on the \Domain implementation.
277     \end{methoddesc}
278    
279     \begin{methoddesc}[Domain]{getNormal}{}
280     returns the surface normals on the boundary of the \Domain as \Data object.
281     \end{methoddesc}
282    
283     \begin{methoddesc}[Domain]{getSize}{}
284     returns the local sample size, e.g. the element diameter, as \Data object.
285     \end{methoddesc}
286    
287     \begin{methoddesc}[Domain]{__eq__}{arg}
288     returns \True of the \Domain \var{arg} describes the same domain. Otherwise
289     \False is returned.
290     \end{methoddesc}
291    
292     \begin{methoddesc}[Domain]{__ne__}{arg}
293     returns \True of the \Domain \var{arg} does not describe the same domain.
294     Otherwise \False is returned.
295     \end{methoddesc}
296    
297     \section{\Domain class}
298     \begin{classdesc}{FunctionSpace}{}
299     \FunctionSpace objects are used to define properties of \Data objects, such as continuity. \FunctionSpace objects
300     are instantiated by generator functions. \Data objects in particular \FunctionSpace are
301     represented by their values at \DataSamplePoints which are defined by the type and the \Domain of the
302     \FunctionSpace.
303 jgs 82 \end{classdesc}
304    
305 jgs 102 \begin{methoddesc}[FunctionSpace]{getDim}{}
306     returns the spatial dimension of the \Domain of the \FunctionSpace.
307     \end{methoddesc}
308 jgs 82
309 jgs 102 \begin{methoddesc}[FunctionSpace]{getX}{}
310     returns the location of the \DataSamplePoints.
311     \end{methoddesc}
312 jgs 82
313 jgs 102 \begin{methoddesc}[FunctionSpace]{getNormal}{}
314     If the domain of functions in the \FunctionSpace
315     is a hypermanifold (e.g. the boundary of a domain)
316     the method returns the outer normal at each of the
317     \DataSamplePoints. Otherwise an exception is raised.
318     \end{methoddesc}
319 jgs 82
320 jgs 102 \begin{methoddesc}[FunctionSpace]{getSize}{}
321     returns a \Data objects measuring the spacing of the \DataSamplePoints.
322     The size may be zero.
323     \end{methoddesc}
324 jgs 82
325 jgs 102 \begin{methoddesc}[FunctionSpace]{getDomain}{}
326     returns the \Domain of the \FunctionSpace.
327     \end{methoddesc}
328 jgs 82
329 jgs 102 \begin{methoddesc}[FunctionSpace]{__eq__}{arg}
330     returns \True of the \Domain \var{arg} describes the same domain. Otherwise
331     \False is returned.
332     \end{methoddesc}
333 jgs 82
334 jgs 102 \begin{methoddesc}[FunctionSpace]{__ne__}{arg}
335     returns \True of the \Domain \var{arg} describes the note same domain.
336     Otherwise \False is returned.
337     \end{methoddesc}
338 jgs 82
339 jgs 102 The following function provide generators for \FunctionSpace objects:
340     \begin{funcdesc}{Function}{domain}
341     returns the \Function on the \Domain \var{domain}. \Data objects in this type of \Function
342     are defined over the whole geometrical region defined by \var{domain}.
343 jgs 82 \end{funcdesc}
344    
345 jgs 102 \begin{funcdesc}{ContinuousFunction}{domain}
346     returns the \ContinuousFunction on the \Domain domain. \Data objects in this type of \Function
347     are defined over the whole geometrical region defined by \var{domain} and assumed to represent
348     a continuous function.
349 jgs 82 \end{funcdesc}
350    
351 jgs 102 \begin{funcdesc}{FunctionOnBoundary}{domain}
352     returns the \ContinuousFunction on the \Domain domain. \Data objects in this type of \Function
353     are defined on the boundary of the geometrical region defined by \var{domain}.
354 jgs 82 \end{funcdesc}
355    
356 jgs 102 \begin{funcdesc}{FunctionOnContactZero}{domain}
357     returns the \FunctionOnContactZero the \Domain domain. \Data objects in this type of \Function
358     are defined on side 0 of a discontinutiy within the geometrical region defined by \var{domain}.
359     The discontinutiy is defined when \var{domain} is instantiated.
360 jgs 82 \end{funcdesc}
361    
362 jgs 102 \begin{funcdesc}{FunctionOnContactOne}{domain}
363     returns the \FunctionOnContactOne on the \Domain domain.
364     \Data objects in this type of \Function
365     are defined on side 1 of a discontinutiy within the geometrical region defined by \var{domain}.
366     The discontinutiy is defined when \var{domain} is instantiated.
367 jgs 82 \end{funcdesc}
368    
369 jgs 102 \begin{funcdesc}{Solution}{domain}
370     returns the \SolutionFS on the \Domain domain. \Data objects in this type of \Function
371     are defined on geometrical region defined by \var{domain} and are solutions of
372     partial differential equations \index{partial differential equation}.
373 jgs 82 \end{funcdesc}
374    
375 jgs 102 \begin{funcdesc}{ReducedSolution}{domain}
376     returns the \ReducedSolutionFS on the \Domain domain. \Data objects in this type of \Function
377     are defined on geometrical region defined by \var{domain} and are solutions of
378     partial differential equations \index{partial differential equation} with a reduced smoothness
379     for the solution approximation.
380 jgs 82 \end{funcdesc}
381    
382 jgs 102 \section{\Data Class}
383 jgs 107 \label{SEC ESCRIPT DATA}
384 jgs 82
385 jgs 102 The following table shows binary and unitary operations that can be applied to
386     \Data objects:
387     \begin{tableii}{l|l}{textrm}{expression}{Description}
388     \lineii{+\var{arg1}} {just \var{arg} \index{+}}
389     \lineii{-\var{arg1}} {swapping the sign\index{-}}
390     \lineii{\var{arg1}+\var{arg2}} {adds \var{arg1} and \var{arg2} \index{+}}
391     \lineii{\var{arg1}*\var{arg2}} {multiplies \var{arg1} and \var{arg2} \index{*}}
392     \lineii{\var{arg1}-\var{arg2}} {difference \var{arg2} from\var{arg2} \index{-}}
393     \lineii{\var{arg1}/\var{arg2}} {ratio \var{arg1} by \var{arg2} \index{/}}
394     \lineii{\var{arg1}**\var{arg2}} {raises \var{arg1} to the power of \var{arg2} \index{**}}
395     \end{tableii}
396 jgs 107 At least one of the arguments \var{arg1} or \var{arg2} must be a
397 jgs 102 \Data object. One of the arguments may be an object that can be
398     converted into a \Data object. If \var{arg1} or \var{arg2} are
399 jgs 107 defined on different \FunctionSpace an attempt is made to embed \var{arg1}
400 jgs 102 into the \FunctionSpace of \var{arg2} or to embed \var{arg2} into
401     the \FunctionSpace of \var{arg1}. Boths arguments must have the same
402     \Shape or one of the arguments my be of rank 0 or \Shape (1,). In the
403     latter case it is assumed that the particular argument is of the same
404 jgs 107 \Shape as the other argument but constant over all components.
405 jgs 82
406 jgs 102 The returned \Data object has the same \Shape and is defined on
407 jgs 107 the \DataSamplePoints as \var{arg1} or \var{arg2}.
408 jgs 82
409 jgs 102 The following table shows the update operations that can be applied to
410     \Data objects:
411     \begin{tableii}{l|l}{textrm}{expression}{Description}
412     \lineii{\var{arg1}+=\var{arg2}} {adds \var{arg1} to \var{arg2} \index{+}}
413     \lineii{\var{arg1}*=\var{arg2}} {multiplies \var{arg1} with \var{arg2} \index{*}}
414     \lineii{\var{arg1}-=\var{arg2}} {subtracts \var{arg2} from\var{arg2} \index{-}}
415     \lineii{\var{arg1}/=\var{arg2}} {divides \var{arg1} by \var{arg2} \index{/}}
416     \end{tableii}
417     \var{arg1} must be a \Data object. \var{arg1} must be a
418     \Data object or an object that can be converted into a
419     \Data object. \var{arg1} must have the same \Shape like
420     \var{arg1} or has rank 0 or \Shape (1,). In the latter case it is
421     assumed that the values of \var{arg1} are constant for all
422 jgs 107 components. \var{arg2} must be defined on the same \DataSamplePoints as
423 jgs 102 \var{arg1} or it must be possible to interpolate \var{arg2} onto the
424 jgs 107 \DataSamplePoints where \var{arg1} is held.
425 jgs 82
426 jgs 102 The \Data class supports getting slices as well as assigning new values to components in an existing
427 jgs 107 \Data object. \index{slicing}
428 jgs 102 The following expression for getting (expression on the right hand side of the
429     equal sign) and setting slices (expression on the left hand side of the
430     equal sign) are valid:
431     \begin{tableiii}{l|ll}{textrm}{rank of \var{arg}}{slicing expression}{\Shape of returned and assigned object}
432     \lineiii{0}{ no slicing } {-}
433     \lineiii{1}{\var{arg[l0:u0]}} {(\var{u0}-\var{l0},)}
434     \lineiii{2}{\var{arg[l0:u0,l1:u1]}} {(\var{u0}-\var{l0},\var{u1}-\var{l1})}
435     \lineiii{3}{\var{arg[l0:u0,l1:u1,l2:u2]} } {(\var{u0}-\var{l0},\var{u1}-\var{l1},\var{u2}-\var{l2})}
436     \lineiii{4}{\var{arg[l0:u0,l1:u1,l2:u2,l3:u3]}} {(\var{u0}-\var{l0},\var{u1}-\var{l1},\var{u2}-\var{l2},\var{u3}-\var{l3})}
437     \end{tableiii}
438     where
439     $0 \le \var{l0} \le \var{u0} \le \var{s[0]}$,
440     $0 \le \var{l1} \le \var{u1} \le \var{s[1]}$,
441     $0 \le \var{l2} \le \var{u2} \le \var{s[2]}$,
442     $0 \le \var{l3} \le \var{u3} \le \var{s[3]}$ and \var{s} the \Shape if \var{arg}.
443     Any of the lower indexes \var{l0}, \var{l1}, \var{l2} and \var{l3} may not be present in which case
444     $0$ is assumed.
445     Any of the upper indexes \var{u0}, \var{u1}, \var{u2} and \var{u3} may not be present in which case
446     \var{s} is assumed. The lower and upper index may be identical, in which case the column and the lower or upper
447     index may be dropped. In the returned or in the object assigned to a slice the corresponding component is dropped,
448     i.e. the rank is reduced by one in comparison to \var{arg}.
449 jgs 107 The following examples show slicing usage:
450 jgs 102 \begin{python}
451     t[1,1,1,0]=9.
452     s=t[:2,:,2:6,5] # s has rank 3
453     s[:,:,1]=1.
454     t[:2,:2,5,5]=s[2:4,1,:2]
455     \end{python}
456    
457    
458    
459     \begin{classdesc}{Data}{value=0,shape=(,),what=FunctionSpace(),expanded=\False}
460     creates a \Data object with \Shape \var{shape} in the \FunctionSpace \var{what}.
461     The values at all \DataSamplePoints are set to the double value \var{value}. If \var{expanded} is \True
462     the \Data object is represented in expanded from.
463 jgs 82 \end{classdesc}
464    
465 jgs 102 \begin{classdesc}{Data}{value,what=FunctionSpace(),expanded=\False}
466     creates a \Data object in the \FunctionSpace \var{what}.
467     The value for each \DataSamplePoints is set to \numarray object \var{value}.
468     The \Shape of the returned object is equal to the \Shape of \var{value}. If \var{expanded} is \True
469     the \Data object is represented in expanded from.
470     \end{classdesc}
471    
472     \begin{classdesc}{Data}{value,what=FunctionSpace()}
473     creates a \Data object in the \FunctionSpace \var{what} from the \Data object \var{value}.
474     The \Shape of the created \Data object is equal to the \Shape of \var{value}.
475     If the \FunctionSpace of \var{value} is equal to the \var{what}, a shallow copy, i.e.
476     a reference to the representation of \var{value} is greated. Otherwise,
477     \var{value} is interpolated into the \var{what}.
478     \end{classdesc}
479    
480     \begin{classdesc}{Data}{}
481     creates an \EmptyData object. The \EmptyData object is used to indicate that an argument is not present
482     where a \Data object is required.
483     \end{classdesc}
484    
485     \begin{methoddesc}[Data]{getFunctionSpace}{}
486     returns the \FunctionSpace of the object.
487 jgs 82 \end{methoddesc}
488    
489 jgs 102 \begin{methoddesc}[Data]{getFunctionSpace}{}
490     returns the \Domain of the object.
491     \end{methoddesc}
492    
493 jgs 82 \begin{methoddesc}[Data]{getShape}{}
494 jgs 102 returns the \Shape of the object as a \class{tuple} of
495     integers.
496 jgs 82 \end{methoddesc}
497    
498     \begin{methoddesc}[Data]{getRank}{}
499     returns the rank of the data on each data point. \index{rank}
500     \end{methoddesc}
501    
502 jgs 102 \begin{methoddesc}[Data]{isEmpty}{}
503     returns \True id the \Data object is the \EmptyData object.
504     Otherwise \False is returned.
505 jgs 82 \end{methoddesc}
506    
507 jgs 102 \begin{methoddesc}[Data]{setTaggedValue}{tag,value}
508     assigns the \var{value} to all \DataSamplePoints which have the tag
509     \var{tag}. \var{value} must be an object of class
510     \class{numarray.array} or must be convertable into a
511     \class{numarray.array} object. \var{value} (or the cooresponding
512     \class{numarray.array} object) must be of rank $0$ or must have the
513     same rank like the object.
514     If a value has already be defined for tag \var{tag} within the object
515     it is overwritten by the new \var{value}. If the object is expanded,
516     the value assigned to \DataSamplePoints with tag \var{tag} is replaced by
517     \var{value}.
518 jgs 82 \end{methoddesc}
519    
520 jgs 102 \begin{methoddesc}[Data]{wherePositive}{}
521     returns \Data object which has the same \Shape and is defined on
522     the same \FunctionSpace like the object. The returned values are $1$
523     where the object is positive and $0$ elsewhere.
524 jgs 82 \end{methoddesc}
525    
526 jgs 102 \begin{methoddesc}[Data]{wherePositive}{}
527     returns \Data object which has the same \Shape and is defined on
528     the same \FunctionSpace like the object. The returned values are $1$
529     where the object is non-positive and $0$ elsewhere.
530 jgs 82 \end{methoddesc}
531    
532 jgs 102 \begin{methoddesc}[Data]{whereNonnegative}{}
533     returns \Data object which has the same \Shape and is defined on
534     the same \FunctionSpace like the object. The returned values are $1$
535     where the object is non-negative and $0$ elsewhere.
536 jgs 82 \end{methoddesc}
537    
538 jgs 102 \begin{methoddesc}[Data]{whereNegative}{}
539     returns \Data object which has the same \Shape and is defined on
540     the same \FunctionSpace like the object. The returned values are $1$
541     where the object is negative and $0$ elsewhere.
542 jgs 82 \end{methoddesc}
543    
544 jgs 102 \begin{methoddesc}[Data]{whereZero}{tolerance=1.e-8}
545     returns \Data object which has the same \Shape and is defined on
546     the same \FunctionSpace like the object. The returned values are $1$
547     where the object is nearly zero, i.e. where the absolute value is less
548     than \var{tolerance}, and $0$ elsewhere.
549     \end{methoddesc}
550 jgs 82
551 jgs 102 \begin{methoddesc}[Data]{whereNonzero}{tolerance=1.e-8}
552     returns \Data object which has the same \Shape and is defined on
553     the same \FunctionSpace like the object. The returned values are $1$
554     where the object is nearly non-zero, i.e. where the absolute value is
555     greater or equal than \var{tolerance}, and $0$ elsewhere.
556 jgs 82 \end{methoddesc}
557    
558 jgs 102 \begin{methoddesc}[Data]{sign}{}
559     returns \Data object which has the same \Shape and is defined on
560     the same \FunctionSpace like the object. The returned values are $1$
561     where the object is positive, $-1$ where the value is negative and $0$ elsewhere.
562 jgs 82 \end{methoddesc}
563    
564 jgs 102 \begin{methoddesc}[Data]{copyWithMask}{arg,mask}
565     copies the \Data object \var{arg} into the object
566     where the \Data object \var{mask} is positive. \var{arg}
567     and \var{mask} must have the same \Shape
568     and must belong to same \FunctionSpace as
569     the object.
570 jgs 82 \end{methoddesc}
571    
572 jgs 102 \begin{methoddesc}[Data]{Lsup}{}
573     returns the $L^{sup}$-norm of the object. This is maximum absolute values over all components and all \DataSamplePoints. \index{$L^{sup}$-norm}.
574     \end{methoddesc}
575 jgs 117 \begin{methoddesc}[Data]{Linf}{}
576     returns the minimum absolute value over all components and all \DataSamplePoints. \index{$L^{inf}$-norm}.
577     \end{methoddesc}
578 jgs 102 \begin{methoddesc}[Data]{inf}{}
579     returns the minimum value (infimum) of the object. The minimum is
580     taken over all components and all \DataSamplePoints . \index{infimum}
581     \end{methoddesc}
582    
583     \begin{methoddesc}[Data]{sup}{}
584     returns the maximum value (supremum) of the object. The maximum is
585     taken over all components and all \DataSamplePoints . \index{supremum}
586     \end{methoddesc}
587    
588     \begin{methoddesc}[Data]{grad}{\optional{on}}
589     returns the gradient of the function represented by the object.
590     \Data object is in \FunctionSpace \var{on} and has rank r+1 where r is the rank of the object.
591     If \var{on} is not present, a suitbale \FunctionSpace is used.
592 jgs 82 \index{gradient}
593     \end{methoddesc}
594    
595     \begin{methoddesc}[Data]{integrate}{}
596 jgs 102 returns the integral of the function represented by the object. The method returns
597     a \class{numarray.array} object of the same \Shape like the object. A
598 jgs 82 component of the returned object is the integral of the corresponding
599 jgs 102 component of the object. \index{integral}
600 jgs 82 \end{methoddesc}
601    
602 jgs 102 \begin{methoddesc}[Data]{interpolate}{on}
603     interpolates
604     the function represented by the object
605     into the \FunctionSpace\var{on}.
606 jgs 82 \index{interpolation}
607     \end{methoddesc}
608    
609 jgs 102 \begin{methoddesc}[Data]{abs}{}
610     applies the absolute value function to the object. The
611     return \Data object has the same \Shape and is in the same
612     \FunctionSpace like the object. For all \DataSamplePoints and all
613     components the value is calculated by applying the exponential
614     function. \index{function!absolute value}
615 jgs 82 \end{methoddesc}
616    
617 jgs 102 \begin{methoddesc}[Data]{exp}{}
618     applies the exponential function to the object. The
619     return \Data object has the same \Shape and is in the same
620     \FunctionSpace like the object. For all \DataSamplePoints and all
621     components the value is calculated by applying the exponential
622     function. \index{function!exponential}
623 jgs 82 \end{methoddesc}
624    
625     \begin{methoddesc}[Data]{sqrt}{}
626 jgs 102 applies the square root function to the object. The
627     return \Data object has the same \Shape and is in the same
628     \FunctionSpace like the object. For all \DataSamplePoints and all
629     components the value is calculated by applying the square root function.
630     An exception is
631     raised if the value is negative. \index{function!square root}
632 jgs 82 \end{methoddesc}
633    
634     \begin{methoddesc}[Data]{sin}{}
635 jgs 102 applies the sine function to the object. The
636     return \Data object has the same \Shape and is in the same
637     \FunctionSpace like the object. For all \DataSamplePoints and all
638     components the value is calculated by applying the sine function. \index{function!sine}
639 jgs 82 \end{methoddesc}
640    
641     \begin{methoddesc}[Data]{cos}{}
642 jgs 102 applies the cosine function to the object. The
643     return \Data object has the same \Shape and is in the same
644     \FunctionSpace like the object. For all \DataSamplePoints and all
645     components the value is calculated by applying the cosine function. \index{function!cosine}
646 jgs 82 \end{methoddesc}
647    
648 jgs 102 \begin{methoddesc}[Data]{tan}{}
649     applies the tangent function to the object. The
650     return \Data object has the same \Shape and is in the same
651     \FunctionSpace like the object. For all \DataSamplePoints and all
652     components the value is calculated by applying the tangent function. \index{function!tangent}
653 jgs 82 \end{methoddesc}
654    
655 jgs 102 \begin{methoddesc}[Data]{log}{}
656     applies the logarithmic function to the object. The
657     return \Data object has the same \Shape and is in the same
658     \FunctionSpace like the object. For all \DataSamplePoints and all
659     components the value is calculated by applying the logarithmic function. An exception is
660     raised if the value is negative.\index{function!logarithmic}
661 jgs 82 \end{methoddesc}
662    
663 jgs 102 \begin{methoddesc}[Data]{maxval}{}
664     returns the maximum value over all components. The
665     return value is a \Data object of rank 0
666     and is in the same
667     \FunctionSpace like the object. For all \DataSamplePoints
668     the value is calculated as the maximum value over all components. \index{function!maximum}
669 jgs 82 \end{methoddesc}
670    
671 jgs 102 \begin{methoddesc}[Data]{minval}{}
672     returns the minimum value over all components. The
673     return value is a \Data object of rank 0
674     and is in the same
675     \FunctionSpace like the object. For all \DataSamplePoints
676     the value is calculated as the minimum value over all components. \index{function!minimum}
677 jgs 82 \end{methoddesc}
678    
679 jgs 102 \begin{methoddesc}[Data]{length}{}
680     returns the Euclidean length at all \DataSamplePoints. The
681     return value is a \Data object of rank 0
682     and is in the same
683     \FunctionSpace like the object. For all \DataSamplePoints
684     the value is calculated as the square root of the sum of the square over all over all components. \index{function!length}
685 jgs 82 \end{methoddesc}
686 jgs 102 \begin{methoddesc}[Data]{transpose}{axis}
687     returns the transpose of the object around \var{axis}. \var{axis} is a non-negative integer
688     which is less the rank $r$ of the object. Transpose swaps the indexes $0$ to \var{axis}
689     with the indexes \var{axis}+1 to $r$. If the \var{d} is \RankFour one has
690     \begin{python}
691     d[i,j,k,l]=d.transpose(0)[i,j,k,l]
692     d[i,j,k,l]=d.transpose(1)[j,k,l,i]
693     d[i,j,k,l]=d.transpose(2)[k,l,i,j]
694     d[i,j,k,l]=d.transpose(3)[l,i,j,k]
695     \end{python}
696     \index{function!transpose}
697 jgs 82 \end{methoddesc}
698    
699 jgs 102 \begin{methoddesc}[Data]{trace}{}
700     returns sum of the components with identical indexes.
701     The
702     return value is a \Data object of rank 0
703     and is in the same
704     \FunctionSpace like the object.
705     \index{function!trace}
706 jgs 82 \end{methoddesc}
707 jgs 102 \begin{methoddesc}[Data]{saveDX}{fileName}
708     saves the object to an openDX format file of name \var{fileName}, see
709     \ulink{www.opendx.org}{\url{www.opendx.org}}. \index{openDX}
710     \end{methoddesc}
711 jgs 82
712 jgs 102
713     For convenience the following factories are provided to created \Data object:
714    
715     \begin{funcdesc}{Scalar}{value=0.,what=escript::FunctionSpace(),expand=\False}
716     returns a \Data object of rank 0 in the \FunctionSpace \var{what}.
717     Values are initialed with the double \var{value}. If \var{expanded} is \True
718     the \Data object is represented in expanded from.
719     \end{funcdesc}
720    
721     \begin{funcdesc}{Vector}{value=0.,what=escript::FunctionSpace(),expand=\False}
722     returns a \Data object of \Shape \var{(d,)} in the \FunctionSpace \var{what}
723     where \var{d} is the spatial dimension of the \Domain of \var{what}.
724     Values are initialed with the double \var{value}. If \var{expanded} is \True
725     the \Data object is represented in expanded from.
726     \end{funcdesc}
727    
728     \begin{funcdesc}{Tensor}{value=0.,what=escript::FunctionSpace(),expand=\False}
729     returns a \Data object of \Shape \var{(d,d)} in the \FunctionSpace \var{what}
730     where \var{d} is the spatial dimension of the \Domain of \var{what}.
731     Values are initialed with the double \var{value}. If \var{expanded} is \True
732     the \Data object is represented in expanded from.
733     \end{funcdesc}
734    
735     \begin{funcdesc}{Tensor3}{value=0.,what=escript::FunctionSpace(),expand=\False}
736     returns a \Data object of \Shape \var{(d,d,d)} in the \FunctionSpace \var{what}
737     where \var{d} is the spatial dimension of the \Domain of \var{what}.
738     Values are initialed with the double \var{value}. If \var{expanded} is \True
739     the \Data object is re\var{arg}presented in expanded from.
740     \end{funcdesc}
741    
742     \begin{funcdesc}{Tensor4}{value=0.,what=escript::FunctionSpace(),expand=\False}
743     returns a \Data object of \Shape \var{(d,d,d,d)} in the \FunctionSpace \var{what}
744     where \var{d} is the spatial dimension of the \Domain of \var{what}.
745     Values are initialed with the double \var{value}. If \var{expanded} is \True
746     the \Data object is represented in expanded from.
747     \end{funcdesc}
748    
749     \begin{funcdesc}{abs}{arg}
750     returns the absolute value of \var{arg} where \var{arg}
751     can be double, a \Data object or an \numarray object.
752     \end{funcdesc}
753    
754     \begin{funcdesc}{sin}{arg}
755     returns the sine of \var{arg} where \var{arg}
756     can be double, a \Data object or an \numarray object.
757     \end{funcdesc}
758    
759     \begin{funcdesc}{cos}{arg}
760     returns the cosine of \var{arg} where \var{arg}
761     can be double, a \Data object or an \numarray object.
762     \end{funcdesc}
763    
764     \begin{funcdesc}{exp}{arg}
765     returns the value of the exponential function for \var{arg} where \var{arg}
766     can be double, a \Data object or an \numarray object.
767     \end{funcdesc}
768    
769     \begin{funcdesc}{sqrt}{arg}
770     returns the square root of \var{arg} where \var{arg}
771     can be double, a \Data object or an \numarray object.
772     \end{funcdesc}
773    
774     \begin{funcdesc}{maxval}{arg}
775     returns the maximum value over all component of \var{arg} where \var{arg}
776     can be double, a \Data object or an \numarray object.
777     \end{funcdesc}
778    
779     \begin{funcdesc}{minval}{arg}
780     returns the minumum value over all component of \var{arg} where \var{arg}
781     can be double, a \Data object or an \numarray object.
782     \end{funcdesc}
783    
784     \begin{funcdesc}{length}{arg}
785     returns the length of \var{arg} which is the
786     square root of the sum of the squares of all component of \var{arg}. \var{arg}
787     can be double, a \Data object or an \numarray object.
788     \end{funcdesc}
789    
790     \begin{funcdesc}{sign}{arg}
791     return the sign of \var{arg} where \var{arg}
792     can be double, a \Data object or an \numarray object.
793     \end{funcdesc}
794    
795     \begin{funcdesc}{transpose}{arg,\optional{axis}}
796     returns the transpose of \var{arg} around \var{axis}. \var{axis} is a non-negative integer
797     which is less the rank $r$ of the object. Transpose swaps the indexes $0$ to \var{axis}
798     with the indexes \var{axis}+1 to $r$. If \var{axis} is not present, \var{axis}=$r/2$ is assumed.
799     \var{arg}
800     may be a \Data object or an \numarray object.
801     \end{funcdesc}
802    
803     \begin{funcdesc}{transpose}{arg,\optional{axis}}
804     returns the trace the object of \var{arg}. The trace is the sum over those components
805     with identical indexed.
806     \var{arg}
807     may be a \Data object or a \numarray object.
808     \end{funcdesc}
809    
810     \begin{funcdesc}{sum}{arg}
811     returns the sum over all components and all
812     \DataSamplePoints of \var{arg}, where \var{arg}
813     is a \Data object.
814     \end{funcdesc}
815    
816     \begin{funcdesc}{sup}{arg}
817     returns the maximum over all components and all
818     \DataSamplePoints of \var{arg}, where \var{arg}
819     is a \Data object.
820     \end{funcdesc}
821    
822     \begin{funcdesc}{inf}{arg}
823     returns the mimumum over all components and all
824     \DataSamplePoints of \var{arg}, where \var{arg}
825     is a \Data object.
826     \end{funcdesc}
827    
828    
829     \begin{funcdesc}{L2}{arg}
830     returns the $L^2$ norm of \var{arg}. This is the square root
831     of the sum of the squared value over all components and all
832     \DataSamplePoints of \var{arg}, where \var{arg}
833     is a \Data object.
834     \end{funcdesc}
835    
836     \begin{funcdesc}{Lsup}{arg}
837     returns the $L^{sup}$ norm of \var{arg}. This is the maximum of the absolute values
838     over all components and all
839     \DataSamplePoints of \var{arg}, where \var{arg}
840     is a \Data object.
841     \end{funcdesc}
842    
843     \begin{funcdesc}{dot}{arg1,arg2}
844     returns the dot product of of \var{arg1} and \var{arg2}. This is sum
845     of the product of corresponding entries in \var{arg1} and \var{arg2} over all
846     components and and all
847     \DataSamplePoints. \var{arg1} and \var{arg2} are \Data objects of the
848     same \Shape and in the same \FunctionSpace.
849     \end{funcdesc}
850    
851     \begin{funcdesc}{grad}{arg,\optional{where}}
852     returns the gradient of \var{arg} as a function in the \FunctionSpace \var{where}.
853     If \var{where} is not present a reasonable \FunctionSpace is chosen.
854     \var{arg}
855     is a \Data object.
856     \end{funcdesc}
857    
858     \begin{funcdesc}{integrate}{arg}
859     returns the integral of \var{arg} as a \numarray object.
860     If \var{where} is not present a reasonable \FunctionSpace is chosen.
861     \var{arg}
862     is a \Data object.
863     \end{funcdesc}
864    
865     \begin{funcdesc}{interpolate}{arg,where}
866     interpolate \Data object \var{arg} into the \FunctionSpace \var{where}
867     \end{funcdesc}
868    
869    
870     \section{\Operator Class}
871    
872     The \Operator class provides an abstract access to operators build
873     within the \LinearPDE class. \Operator objects are created
874     when a PDE is handed over to a PDE solver library and handled
875     by the \LinearPDE class defining the PDE. The user can gain access
876     to the \Operator of a \LinearPDE object through the \var{getOperator}
877     method.
878    
879     \begin{classdesc}{Operator}{}
880     creates an empty \Operator object.
881     \end{classdesc}
882    
883     \begin{methoddesc}[Operator]{isEmpty}{fileName}
884     returns \True is the object is empty. Otherwise \True is returned.
885 jgs 82 \end{methoddesc}
886    
887 jgs 102 \begin{methoddesc}[Operator]{setValue}{value}
888     resets all entires in the obeject representation to \var{value}
889 jgs 82 \end{methoddesc}
890    
891 jgs 102 \begin{methoddesc}[Operator]{solves}{rhs}
892     solves the operator equation with right hand side \var{rhs}
893 jgs 82 \end{methoddesc}
894    
895 jgs 102 \begin{methoddesc}[Operator]{of}{u}
896     applies the operator to the \Data object \var{u}
897 jgs 82 \end{methoddesc}
898    
899 jgs 102 \begin{methoddesc}[Operator]{saveMM}{fileName}
900 jgs 82 saves the object to a matrix market format file of name
901     \var{fileName}, see
902     \ulink{maths.nist.gov/MatrixMarket}{\url{http://maths.nist.gov/MatrixMarket}}.
903     \index{Matrix Market}
904     \end{methoddesc}
905    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26