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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26