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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1045 - (show annotations)
Tue Mar 20 01:30:58 2007 UTC (13 years, 2 months ago) by gross
File MIME type: application/x-tex
File size: 49210 byte(s)
some modifications on the pycad implementation to make it easier to build
interfaces for other mesh generators. The script statement generation is now
done by the Design and not the Primitive classes.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26