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