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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26