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

Revision 999 - (show annotations)
Tue Feb 27 08:12:37 2007 UTC (13 years, 3 months ago) by gross
File MIME type: application/x-tex
File size: 48272 byte(s)
start to put some pycad documentation into the users guide

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

## Properties

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