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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26