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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26